[Fai-commit] r3619 -
people/michael/features/setup_harddisks_2/implementation
fai-commit at lists.alioth.debian.org
fai-commit at lists.alioth.debian.org
Sat Jul 22 20:35:48 UTC 2006
Author: michael-guest
Date: 2006-07-22 20:35:47 +0000 (Sat, 22 Jul 2006)
New Revision: 3619
Modified:
people/michael/features/setup_harddisks_2/implementation/shdd2-commands
people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
people/michael/features/setup_harddisks_2/implementation/shdd2-lib
people/michael/features/setup_harddisks_2/implementation/shdd2-parser
people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
Log:
added commands
Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-commands
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-commands 2006-07-22 17:13:33 UTC (rev 3618)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-commands 2006-07-22 20:35:47 UTC (rev 3619)
@@ -4,6 +4,10 @@
package FAI;
+ at FAI::commands = ();
+
+$FAI::parted_binary = "/sbin/parted -s";
+
foreach my $config ( keys %FAI::configs )
{
if ( $config eq "RAID" || $config =~ /^VG_/ )
@@ -14,9 +18,88 @@
}
elsif ( $config =~ /^PHY_(.*)$/ )
{
+ my $disk = $1;
+ my @to_preserve = ();
+ my $extended = -1;
+
+ my $target_label = $FAI::configs{$config}{'disklabel'};
+ my $source_label = $FAI::current_config{$disk}{'disklabel'};
+
+ foreach
+ my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } )
+ {
+ if ( $FAI::current_config{$disk}{"disklabel"} eq "msdos"
+ && $FAI::current_config{$disk}{$part_id}{"is_extended"} == 1 )
+ {
+ $extended = $part_id;
+ }
+ }
+
foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
{
+
+ if (
+ $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"preserve"} == 1
+ || $FAI::configs{$config}{"partitions"}{$part_id}{"size"}{"resize"} ==
+ 1 )
+ {
+ if ( !defined( $FAI::current_config{$disk}{"partitions"}{$part_id} ) )
+ {
+ warn "$part_id can't be preserved, it does not exist.\n";
+ }
+ else
+ {
+ push @to_preserve, $part_id;
+ if ( $extended > -1
+ && $part_id > 4
+ && $FAI::current_config{$disk}{"disklabel"} eq "msdos" )
+ {
+ push @to_preserve, $extended;
+ $extended = -1;
+ }
+ }
+ }
+
}
+ @to_preserve = sort { $a <=> $b } @to_preserve;
+
+ if ( $target_label ne $source_label )
+ {
+ if ( scalar(@to_preserve) > 0 )
+ {
+ warn "Can't change disklabel, partitions are to be preserved!\n";
+ }
+ else
+ {
+ push @FAI::commands, "$FAI::parted_binary $disk mklabel $target_label";
+ }
+ }
+ else
+ {
+ foreach
+ my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } )
+ {
+ if ( $to_preserve[0] == $part_id )
+ {
+ shift @to_preserve;
+ next;
+ }
+ push @FAI::commands, "$FAI::parted_binary $disk rm $part_id";
+ }
+ }
+
+ foreach my $cmd (@FAI::commands)
+ {
+ print $cmd . "\n";
+ }
+
+ foreach
+ my $part_id ( sort keys %{ $FAI::current_config{$disk}{"partitions"} } )
+ {
+ }
+ foreach my $part_id ( sort keys %{ $FAI::configs{$config}{"partitions"} } )
+ {
+ }
}
}
Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-fstab
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-fstab 2006-07-22 17:13:33 UTC (rev 3618)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-fstab 2006-07-22 20:35:47 UTC (rev 3619)
@@ -74,5 +74,11 @@
}
}
+my @fstab = &FAI::generate_fstab( \%FAI::configs );
+foreach my $line (@fstab)
+{
+ printf $line. "\n";
+}
+
1;
Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-lib
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-lib 2006-07-22 17:13:33 UTC (rev 3618)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-lib 2006-07-22 20:35:47 UTC (rev 3619)
@@ -20,5 +20,24 @@
return 0;
}
+sub print_hash
+{
+ my ( $hash_ref, $k ) = @_;
+ $k = $k . ">";
+ foreach my $key ( keys %$hash_ref )
+ {
+ if ( ref( $hash_ref->{$key} ) )
+ {
+ print "$k Schluessel: " . $key . " Wert: " . "Hash" . "\n";
+ &print_hash( $hash_ref->{$key}, $k );
+ }
+ else
+ {
+ print "$k Schluessel: " . $key . " Wert: " . $hash_ref->{$key} . "\n";
+ }
+
+ }
+}
+
1;
Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-parser
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-parser 2006-07-22 17:13:33 UTC (rev 3618)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-parser 2006-07-22 20:35:47 UTC (rev 3619)
@@ -350,25 +350,6 @@
}
);
-sub print_hash
-{
- my ( $hash_ref, $k ) = @_;
- $k = $k . ">";
- foreach my $key ( keys %$hash_ref )
- {
- if ( ref( $hash_ref->{$key} ) )
- {
- print "$k Schluessel: " . $key . " Wert: " . "Hash" . "\n";
- &print_hash( $hash_ref->{$key}, $k );
- }
- else
- {
- print "$k Schluessel: " . $key . " Wert: " . $hash_ref->{$key} . "\n";
- }
-
- }
-}
-
my $ifs = $/;
undef $/;
my $input = <STDIN>;
@@ -378,11 +359,5 @@
defined $Parser->file($input) or die "Syntax error\n";
-my @fstab = &FAI::generate_fstab( \%FAI::configs );
-foreach my $line (@fstab)
-{
- printf $line. "\n";
-}
-
1;
Modified: people/michael/features/setup_harddisks_2/implementation/shdd2-sizes
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/shdd2-sizes 2006-07-22 17:13:33 UTC (rev 3618)
+++ people/michael/features/setup_harddisks_2/implementation/shdd2-sizes 2006-07-22 20:35:47 UTC (rev 3619)
@@ -65,14 +65,37 @@
{
foreach my $line (@parted_print)
{
- if ( $line =~ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B/i )
+ if ( $FAI::current_config{$disk}{"disklabel"} eq "msdos" )
{
+ if ( $line =~
+ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B\s+(primary|logical|extended)/i )
+ {
- $FAI::current_config{$disk}{"partitions"}{$1}{"begin_byte"} = $2;
- $FAI::current_config{$disk}{"partitions"}{$1}{"end_byte"} = $3;
- $FAI::current_config{$disk}{"partitions"}{$1}{"count_byte"} = $4;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"begin_byte"} = $2;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"end_byte"} = $3;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"count_byte"} = $4;
+ if ( $5 eq "extended" )
+ {
+ $FAI::current_config{$disk}{"partitions"}{$1}{"is_extended"} = 1;
+ }
+ else
+ {
+ $FAI::current_config{$disk}{"partitions"}{$1}{"is_extended"} = 0;
+ }
+ }
}
+ else
+ {
+ if ( $line =~ /^(\d+)*\s+(\d+)B\s+(\d+)B\s+(\d+)B/i )
+ {
+ $FAI::current_config{$disk}{"partitions"}{$1}{"begin_byte"} = $2;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"end_byte"} = $3;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"count_byte"} = $4;
+ $FAI::current_config{$disk}{"partitions"}{$1}{"is_extended"} = 0;
+ }
+ }
+
if ( $line =~ /^Disk geometry for.*(\d+)B - (\d+)B/i )
{
$FAI::current_config{$disk}{"begin_byte"} = $1;
More information about the Fai-commit
mailing list