[Fai-commit] r4769 - in people/michael/features/setup_harddisks_2/implementation: . lib

michael-guest at alioth.debian.org michael-guest at alioth.debian.org
Sun Nov 18 16:22:07 UTC 2007


Author: michael-guest
Date: 2007-11-18 16:22:06 +0000 (Sun, 18 Nov 2007)
New Revision: 4769

Modified:
   people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
   people/michael/features/setup_harddisks_2/implementation/lib/exec.pm
   people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
   people/michael/features/setup_harddisks_2/implementation/storage-magic
Log:
minor fixes according to the suggestions of Thomas and Henning


Modified: people/michael/features/setup_harddisks_2/implementation/lib/commands.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/commands.pm	2007-11-18 13:50:13 UTC (rev 4768)
+++ people/michael/features/setup_harddisks_2/implementation/lib/commands.pm	2007-11-18 16:22:06 UTC (rev 4769)
@@ -54,8 +54,8 @@
 
   return if ( $fs eq "-" );
 
-  my ($create_options) = $partition->{fs_options}=~m/.*createopts="([^"]+)".*/;
-  my ($tune_options) = $partition->{fs_options}=~m/.*tuneopts="([^"]+)".*/;
+  my ( $create_options ) = $partition->{fs_options} =~ m/createopts="([^"]+)"/;
+  my ( $tune_options )   = $partition->{fs_options} =~ m/tuneopts="([^"]+)"/;
   $create_options = $partition->{fs_options} unless $create_options;
   print STDERR "create_options: $create_options tune_options: $tune_options\n" if $FAI::debug;
 
@@ -102,20 +102,20 @@
     foreach my $id ( sort keys %{ $FAI::configs{$config}{volumes} } ) {
 
       # keep a reference to the current volume
-      my $vol_ref = ( \%FAI::configs )->{$config}->{volumes}->{$id};
+      my $vol = ( \%FAI::configs )->{$config}->{volumes}->{$id};
       # the desired RAID level
-      my $level = $vol_ref->{mode};
+      my $level = $vol->{mode};
 
       # prepend "raid", if the mode is numeric-only
       $level = "raid" . $level if ( $level =~ /^\d+$/ );
 
       # the list of RAID devices
-      my @devs = keys %{ $vol_ref->{devices} };
+      my @devs = keys %{ $vol->{devices} };
 
       # set proper partition types for RAID
       foreach my $d (@devs) {
         # skip devices marked missing
-        next if( 1 == $vol_ref->{devices}{$d}{missing} );
+        next if( 1 == $vol->{devices}{$d}{missing} );
         # only match physical partitions (this string of matchings is hopefully complete)
         next unless( $d =~
           m{^/dev/(cciss/c\dd\dp|ida/c\dd\dp|rd/c\dd\dp|ataraid/d\dp|sd[a-t]|hd[a-t])(\d+)$} );
@@ -199,8 +199,8 @@
     # already exist
     foreach my $lv ( keys %{ $FAI::configs{$config}{volumes} } ) {
       # reference to the size of the current logical volume
-      my $lv_ref_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
-      next unless ( $lv_ref_size->{preserve} == 1 || $lv_ref_size->{resize} == 1 );
+      my $lv_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
+      next unless ( $lv_size->{preserve} == 1 || $lv_size->{resize} == 1 );
 
       # preserved or resized volumes must exist already
       defined( $FAI::current_lvm_config{$vg}{volumes}{$lv} )
@@ -287,28 +287,28 @@
     # now create or resize the configured logical volumes
     foreach my $lv ( keys %{ $FAI::configs{$config}{volumes} } ) {
       # reference to the size of the current logical volume
-      my $lv_ref_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
+      my $lv_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
       # skip preserved partitions, but ensure that they exist
-      if ( $lv_ref_size->{preserve} == 1 ) {
+      if ( $lv_size->{preserve} == 1 ) {
         defined( $FAI::current_lvm_config{$vg}{volumes}{$lv} )
           or die "Preserved volume $vg/$lv does not exist\n";
         next;
       }
 
       # resize the volume
-      if ( $lv_ref_size->{resize} == 1 ) {
+      if ( $lv_size->{resize} == 1 ) {
         defined( $FAI::current_lvm_config{$vg}{volumes}{$lv} )
           or die "Resized volume $vg/$lv does not exist\n";
 
         # note that resizing a volume destroys the data on it
         push @FAI::commands,
-          "lvresize -L " . $lv_ref_size->{eff_size} . " $vg/$lv";
+          "lvresize -L " . $lv_size->{eff_size} . " $vg/$lv";
       }
 
       # create a new volume
       else {
         push @FAI::commands,
-          "lvcreate -n $lv -L " . $lv_ref_size->{eff_size} . " $vg";
+          "lvcreate -n $lv -L " . $lv_size->{eff_size} . " $vg";
 
         # create the filesystem on the volume
         &FAI::build_mkfs_commands( "/dev/$vg/$lv",
@@ -350,9 +350,9 @@
       # find partitions that should be preserved or resized
       foreach my $part_id ( sort keys %{ $FAI::configs{$config}{partitions} } ) {
         # reference to the current partition
-        my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+        my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
         next unless (
-          $part_ref->{size}->{preserve} == 1 || $part_ref->{size}->{resize} == 1 );
+          $part->{size}->{preserve} == 1 || $part->{size}->{resize} == 1 );
 
         # preserved or resized partitions must exist already
         defined( $FAI::current_config{$disk}{partitions}{$part_id} )
@@ -360,7 +360,7 @@
 
         # add a mapping from the configured partition to the existing one
         # (identical here, may change for extended partitions below)
-        $part_ref->{maps_to_existing} = $part_id;
+        $part->{maps_to_existing} = $part_id;
 
         # add $part_id to the list of preserved partitions
         push @to_preserve, $part_id;
@@ -412,17 +412,17 @@
             # find the configured extended partition to set the mapping
             foreach my $p ( sort keys %{ $FAI::configs{$config}{partitions} } ) {
               # reference to the current partition
-              my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$p};
-              next unless ( $part_ref->{size}->{extended} == 1 );
+              my $part = ( \%FAI::configs )->{$config}->{partitions}->{$p};
+              next unless ( $part->{size}->{extended} == 1 );
 
               # make sure resize is set
-              $part_ref->{size}->{resize} = 1;
+              $part->{size}->{resize} = 1;
 
               # store the id for further checks
               $extended = $p;
 
               # add a mapping entry to the existing extended partition
-              $part_ref->{maps_to_existing} = $part_id;
+              $part->{maps_to_existing} = $part_id;
 
               # add it to the preserved partitions
               push @to_preserve, $p;
@@ -502,15 +502,15 @@
       # iterate over the worklists
       foreach my $part_id (@shrink_list) {
         # reference to the current partition
-        my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+        my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
         # anything to be done?
-        next unless ( $part_ref->{size}->{resize} == 1 );
+        next unless ( $part->{size}->{resize} == 1 );
 
         # get the existing id
-        my $mapped_id = $part_ref->{maps_to_existing};
+        my $mapped_id = $part->{maps_to_existing};
 
         # if partition is to be grown, move it to then grow_list
-        if ( $part_ref->{size}->{eff_size} >
+        if ( $part->{size}->{eff_size} >
           $FAI::current_config{$disk}{partitions}{$mapped_id}{count_byte} ) {
           unshift @grow_list, $part_id;
           next;
@@ -520,8 +520,8 @@
         my $p = $FAI::current_config{$disk}{partitions}{$mapped_id}{new_id};
 
         # get the new starts and ends
-        my $start = $part_ref->{start_byte};
-        my $end = $part_ref->{end_byte};
+        my $start = $part->{start_byte};
+        my $end = $part->{end_byte};
 
         # build an appropriate command
         push @FAI::commands, "parted -s $disk resize $p ${start}B ${end}B";
@@ -530,17 +530,17 @@
       # grow the remaining partitions
       foreach my $part_id (@grow_list) {
         # reference to the current partition
-        my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+        my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
 
         # get the existing id
-        my $mapped_id = $part_ref->{maps_to_existing};
+        my $mapped_id = $part->{maps_to_existing};
 
         # get the new partition id
         my $p = $FAI::current_config{$disk}{partitions}{$mapped_id}{new_id};
 
         # get the new starts and ends
-        my $start = $part_ref->{start_byte};
-        my $end = $part_ref->{end_byte};
+        my $start = $part->{start_byte};
+        my $end = $part->{end_byte};
 
         # build an appropriate command
         push @FAI::commands, "parted -s $disk resize $p ${start}B ${end}B";
@@ -552,18 +552,18 @@
       # generate the commands for creating all partitions
       foreach my $part_id ( sort keys %{ $FAI::configs{$config}{partitions} } ) {
         # reference to the current partition
-        my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+        my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
 
         # get the new starts and ends
-        my $start = $part_ref->{start_byte};
-        my $end = $part_ref->{end_byte};
+        my $start = $part->{start_byte};
+        my $end = $part->{end_byte};
 
         # the type of the partition defaults to primary
         my $part_type = "primary";
         if ( $FAI::configs{$config}{disklabel} eq "msdos" ) {
 
           # change the partition type to extended or logical as appropriate
-          if ( $part_ref->{size}->{extended} == 1 ) {
+          if ( $part->{size}->{extended} == 1 ) {
             $part_type = "extended";
           } elsif ( $part_id > 4 ) {
             $part_type = "logical";
@@ -588,14 +588,14 @@
     # generate the commands for creating all filesystems
     foreach my $part_id ( sort keys %{ $FAI::configs{$config}{partitions} } ) {
       # reference to the current partition
-      my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+      my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
 
       # skip preserved/resized/extended partitions
-      next if ( $part_ref->{size}->{preserve} == 1
-        || $part_ref->{size}->{resize} == 1 || $part_ref->{size}->{extended} == 1 );
+      next if ( $part->{size}->{preserve} == 1
+        || $part->{size}->{resize} == 1 || $part->{size}->{extended} == 1 );
 
       # create the filesystem on $disk$part_id
-      &FAI::build_mkfs_commands( $disk . $part_id, $part_ref );
+      &FAI::build_mkfs_commands( $disk . $part_id, $part );
     }
   }
 }
@@ -617,18 +617,18 @@
     # generate the commands for creating all partitions
     foreach my $part_id ( sort keys %{ $FAI::current_config{$disk}{partitions} } ) {
       # reference to the current partition
-      my $curr_part_ref = ( \%FAI::current_config )->{$disk}->{partitions}->{$part_id};
+      my $curr_part = ( \%FAI::current_config )->{$disk}->{partitions}->{$part_id};
 
       # get the starts and ends
-      my $start = $curr_part_ref->{begin_byte};
-      my $end = $curr_part_ref->{end_byte};
+      my $start = $curr_part->{begin_byte};
+      my $end = $curr_part->{end_byte};
 
       # the type of the partition defaults to primary
       my $part_type = "primary";
       if ( $FAI::current_config{$disk}{disklabel} eq "msdos" ) {
 
         # change the partition type to extended or logical as appropriate
-        if ( $curr_part_ref->{is_extended} == 1 ) {
+        if ( $curr_part->{is_extended} == 1 ) {
           $part_type = "extended";
         } elsif ( $part_id > 4 ) {
           $part_type = "logical";

Modified: people/michael/features/setup_harddisks_2/implementation/lib/exec.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/exec.pm	2007-11-18 13:50:13 UTC (rev 4768)
+++ people/michael/features/setup_harddisks_2/implementation/lib/exec.pm	2007-11-18 16:22:06 UTC (rev 4769)
@@ -147,18 +147,18 @@
 # defined action, when an error occurs.
 #
 # @param command bash command to be executed as string
-# @reference stdout_ref reference to a list, that should contain the standard
+# @reference stdout reference to a list, that should contain the standard
 # output of the bash command
 #
-# @reference stderr_ref reference to a list, that should contain the standard
+# @reference stderr reference to a list, that should contain the standard
 # errer output of the bash command
 #
 # @return the identifier of the error
 #
 ################################################################################
 sub execute_command_std {
-  my ( $command, $stdout_ref, $stderr_ref ) = @_;
-  my $err = &execute_command( $command, $stdout_ref, $stderr_ref );
+  my ( $command, $stdout, $stderr ) = @_;
+  my $err = &execute_command( $command, $stdout, $stderr );
   if ( $err ne "" ) {
     my $response = &get_error( $err, "response" );
     my $message  = &get_error( $err, "message" );

Modified: people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm	2007-11-18 13:50:13 UTC (rev 4768)
+++ people/michael/features/setup_harddisks_2/implementation/lib/sizes.pm	2007-11-18 16:22:06 UTC (rev 4769)
@@ -179,11 +179,11 @@
     # set effective sizes where available
     foreach my $lv ( keys %{ $FAI::configs{$config}{volumes} } ) {
       # reference to the size of the current logical volume
-      my $lv_ref_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
+      my $lv_size = ( \%FAI::configs )->{$config}->{volumes}->{$lv}->{size};
 
       # make sure the size specification is a range (even though it might be
       # something like x-x) and store the dimensions
-      ( $lv_ref_size->{range} =~ /^(\d+%?)-(\d+%?)$/ )
+      ( $lv_size->{range} =~ /^(\d+%?)-(\d+%?)$/ )
         or die "INTERNAL ERROR: Invalid range\n";
       my $start = $1;
       my $end   = $2;
@@ -202,12 +202,12 @@
       $max_space += $end;
 
       # write back the range in MB
-      $lv_ref_size->{range} = "$start-$end";
+      $lv_size->{range} = "$start-$end";
 
       # the size is fixed
       if ( $start == $end ) { 
         # write the size back to the configuration
-        $lv_ref_size->{eff_size} = $start;
+        $lv_size->{eff_size} = $start;
       } else {
 
         # add this volume to the redistribution list
@@ -323,10 +323,10 @@
       # work on the first entry of the list
       my $part_id = $worklist[0];
       # reference to the current partition
-      my $part_ref = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
+      my $part = ( \%FAI::configs )->{$config}->{partitions}->{$part_id};
 
       # the partition $part_id must be preserved
-      if ( $part_ref->{size}->{preserve} == 1 ) {
+      if ( $part->{size}->{preserve} == 1 ) {
 
         # a partition that should be preserved must exist already
         defined( $current_disk->{partitions}->{$part_id} )
@@ -336,17 +336,17 @@
           and die "Previous partitions overflow begin of preserved partition $part_id\n";
 
         # set the effective size to the value known already
-        $part_ref->{size}->{eff_size} = $current_disk->{partitions}->{$part_id}->{count_byte};
+        $part->{size}->{eff_size} = $current_disk->{partitions}->{$part_id}->{count_byte};
 
         # copy the start_byte and end_byte information
-        $part_ref->{start_byte} = $current_disk->{partitions}->{$part_id}->{begin_byte};
-        $part_ref->{end_byte} = $current_disk->{partitions}->{$part_id}->{end_byte};
+        $part->{start_byte} = $current_disk->{partitions}->{$part_id}->{begin_byte};
+        $part->{end_byte} = $current_disk->{partitions}->{$part_id}->{end_byte};
 
         # and add it to the total disk space required by this config
-        $min_req_total_space += $part_ref->{size}->{eff_size};
+        $min_req_total_space += $part->{size}->{eff_size};
 
         # set the next start
-        $next_start = $part_ref->{end_byte} + 1;
+        $next_start = $part->{end_byte} + 1;
 
         # several msdos specific parts
         if ( $FAI::configs{$config}{disklabel} eq "msdos" ) {
@@ -364,13 +364,13 @@
             $current_disk->{sector_size} if ( $part_id > 4 );
 
           # extended partitions consume no space
-          if ( $part_ref->{size}->{extended} == 1 ) {
+          if ( $part->{size}->{extended} == 1 ) {
 
             # revert the addition of the size
-            $min_req_total_space -= $part_ref->{size}->{eff_size};
+            $min_req_total_space -= $part->{size}->{eff_size};
 
             # set the next start to the start of the extended partition
-            $next_start = $part_ref->{start_byte};
+            $next_start = $part->{start_byte};
           }
 
         }
@@ -387,7 +387,7 @@
       }
 
       # msdos specific: deal with extended partitions
-      elsif ( $part_ref->{size}->{extended} == 1 ) {
+      elsif ( $part->{size}->{extended} == 1 ) {
         ( $FAI::configs{$config}{disklabel} eq "msdos" )
           or die "found an extended partition on a non-msdos disklabel\n";
 
@@ -416,28 +416,28 @@
             $current_disk->{sector_size};
 
           # initialise the size and the start byte
-          $part_ref->{size}->{eff_size} = 0;
-          $part_ref->{start_byte} = -1;
+          $part->{size}->{eff_size} = 0;
+          $part->{start_byte} = -1;
 
           foreach my $p ( sort keys %{ $FAI::configs{$config}{partitions} } )
           {
             next if ( $p < 5 );
 
-            if ( -1 == $part_ref->{start_byte} )
+            if ( -1 == $part->{start_byte} )
             {
-              $part_ref->{start_byte} =
+              $part->{start_byte} =
                 $FAI::configs{$config}{partitions}{$p}{start_byte} -
                 $epbr_size;
             }
 
-            $part_ref->{size}->{eff_size} +=
+            $part->{size}->{eff_size} +=
               $FAI::configs{$config}{partitions}{$p}{size}{eff_size} +
               $epbr_size;
 
-            $part_ref->{end_byte} = $FAI::configs{$config}{partitions}{$p}{end_byte};
+            $part->{end_byte} = $FAI::configs{$config}{partitions}{$p}{end_byte};
           }
 
-          ( $part_ref->{size}->{eff_size} > 0 )
+          ( $part->{size}->{eff_size} > 0 )
             or die "Extended partition has a size of 0\n";
 
           # partition done
@@ -447,7 +447,7 @@
 
         # make sure the size specification is a range (even though it might be
         # something like x-x) and store the dimensions
-        ( $part_ref->{size}->{range} =~
+        ( $part->{size}->{range} =~
             /^(\d+%?)-(\d+%?)$/ ) or die "INTERNAL ERROR: Invalid range\n";
         my $start = $1;
         my $end   = $2;
@@ -623,19 +623,19 @@
         $end   = $start;
 
         # write back the size spec in bytes
-        $part_ref->{size}->{range} = $start . "-" . $end;
+        $part->{size}->{range} = $start . "-" . $end;
 
         # then set eff_size to a proper value
-        $part_ref->{size}->{eff_size} = $start;
+        $part->{size}->{eff_size} = $start;
 
         # write the end byte to the configuration
-        $part_ref->{end_byte} = $end_byte;
+        $part->{end_byte} = $end_byte;
 
         # and add it to the total disk space required by this config
-        $min_req_total_space += $part_ref->{size}->{eff_size};
+        $min_req_total_space += $part->{size}->{eff_size};
 
         # set the next start
-        $next_start = $part_ref->{end_byte} + 1;
+        $next_start = $part->{end_byte} + 1;
 
         # partition done
         shift @worklist;

Modified: people/michael/features/setup_harddisks_2/implementation/storage-magic
===================================================================
--- people/michael/features/setup_harddisks_2/implementation/storage-magic	2007-11-18 13:50:13 UTC (rev 4768)
+++ people/michael/features/setup_harddisks_2/implementation/storage-magic	2007-11-18 16:22:06 UTC (rev 4769)
@@ -71,7 +71,8 @@
 ($opt_X) or warn "shdd2 is running in test-only mode!\n";
 
 # include all subparts
-unshift @INC, "/usr/share/fai/storage-magic/";
+unshift @INC, "/var/lib/fai/sm/lib/";
+# unshift @INC, "/usr/share/fai/storage-magic/";
 require "init.pm";
 require "volumes.pm";
 require "parser.pm";




More information about the Fai-commit mailing list