[Fai-commit] r4978 - trunk/lib/setup-storage
lange at alioth.debian.org
lange at alioth.debian.org
Fri Jun 13 10:28:34 UTC 2008
Author: lange
Date: 2008-06-13 10:28:34 +0000 (Fri, 13 Jun 2008)
New Revision: 4978
Modified:
trunk/lib/setup-storage/Commands.pm
trunk/lib/setup-storage/Exec.pm
trunk/lib/setup-storage/Fstab.pm
trunk/lib/setup-storage/Init.pm
trunk/lib/setup-storage/Parser.pm
trunk/lib/setup-storage/Sizes.pm
trunk/lib/setup-storage/Volumes.pm
Log:
replace empty lines containing white spaces with empty lines without
white spaces
Modified: trunk/lib/setup-storage/Commands.pm
===================================================================
--- trunk/lib/setup-storage/Commands.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Commands.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -59,7 +59,7 @@
$create_options = $partition->{fs_options} unless $create_options;
print "create_options: $create_options\n" if ($FAI::debug && $create_options);
print "tune_options: $tune_options\n" if ($FAI::debug && $tune_options);
-
+
# check for encryption requests
$device = &FAI::encrypt_device($device, $partition);
@@ -71,7 +71,7 @@
$pre_encrypt = "encrypt_$device" if ($partition->{encrypt});
&FAI::push_command( "$create_tool $create_options $device", $pre_encrypt,
"has_fs_$device" );
-
+
# possibly tune the file system - this depends on whether the file system
# supports tuning at all
return unless $tune_options;
@@ -96,7 +96,7 @@
#
################################################################################
sub encrypt_device {
-
+
my ($device, $partition) = @_;
return $device unless $partition->{encrypt};
@@ -169,7 +169,7 @@
my $vol = (\%FAI::configs)->{$config}->{volumes}->{$id};
# the desired RAID level
my $level = $vol->{mode};
-
+
warn "RAID implementation is incomplete - preserve is not supported\n" if
($vol->{preserve});
@@ -203,7 +203,7 @@
# wait for udev to set up all devices
&FAI::push_command( "udevsettle --timeout=10", $pre_req_no_comma,
"settle_for_mdadm_create$id" );
-
+
# create the command
if (0 == $id) {
$pre_req = "settle_for_mdadm_create$id$pre_req";
@@ -406,7 +406,7 @@
# loop through all configs
foreach my $config (keys %FAI::configs) {
-
+
# no physical devices or RAID here
next if ($config =~ /^PHY_./ || $config eq "RAID");
($config =~ /^VG_(.+)$/) or &FAI::internal_error("Invalid config $config");
@@ -441,11 +441,11 @@
#
################################################################################
sub get_preserved_partitions {
-
+
my ($config) = @_;
($config =~ /^PHY_(.+)$/) or &FAI::internal_error("Invalid config $config");
my $disk = $1; # the device to be configured
-
+
# the list of partitions that must be preserved
my @to_preserve = ();
@@ -558,11 +558,11 @@
#
################################################################################
sub rebuild_preserved_partitions {
-
+
my ($config, $to_preserve) = @_;
($config =~ /^PHY_(.+)$/) or &FAI::internal_error("Invalid config $config");
my $disk = $1; # the device to be configured
-
+
# once we rebuild partitions, their ids are likely to change; this counter
# helps keeping track of this
my $part_nr = 0;
@@ -591,7 +591,7 @@
$part_nr = 4 if ( $part_nr < 4 );
}
}
-
+
# restore the partition type, if any
my $fs =
$FAI::current_config{$disk}{partitions}{$mapped_id}{filesystem};
@@ -626,7 +626,7 @@
my ($config) = @_;
($config =~ /^PHY_(.+)$/) or &FAI::internal_error("Invalid config $config");
my $disk = $1; # the device to be configured
-
+
# the list of partitions that must be preserved
my @to_preserve = &FAI::get_preserved_partitions($config);
@@ -703,11 +703,11 @@
$deps .= ",resized_" . &FAI::make_device_name($disk, $p_other);
}
}
-
+
# get the new starts and ends
my $start = $part->{start_byte};
my $end = $part->{end_byte};
-
+
# build an appropriate command
# ntfs requires specific care
if ($FAI::current_config{$disk}{partitions}{$mapped_id}{filesystem} eq
@@ -736,7 +736,7 @@
"rebuilt_" . &FAI::make_device_name($disk, $p), "resized_" .
&FAI::make_device_name($disk, $p) );
}
-
+
}
# write the disklabel again to drop the partition table and create a new one
@@ -768,7 +768,7 @@
$part_type = "logical";
}
}
-
+
my $fs = $part->{filesystem};
$fs = "" unless defined($fs);
$fs = "linux-swap" if ($fs eq "swap");
@@ -806,7 +806,7 @@
#
################################################################################
sub build_disk_commands {
-
+
# loop through all configs
foreach my $config ( keys %FAI::configs ) {
# no RAID or LVM devices here
@@ -816,7 +816,7 @@
# create partitions on non-virtual configs
&FAI::setup_partitions($config) unless ($FAI::configs{$config}{virtual});
-
+
# generate the commands for creating all filesystems
foreach my $part_id (&numsort(keys %{ $FAI::configs{$config}{partitions} })) {
# reference to the current partition
@@ -866,7 +866,7 @@
$part_type = "logical";
}
}
-
+
# restore the partition type, if any
my $fs = $curr_part->{filesystem};
Modified: trunk/lib/setup-storage/Exec.pm
===================================================================
--- trunk/lib/setup-storage/Exec.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Exec.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -198,7 +198,7 @@
my ($command, $stdout, $stderr) = @_;
my $err = &execute_command_internal($command, $stdout, $stderr);
-
+
if ($err ne "") {
my $response = &get_error($err, "response");
my $message = &get_error($err, "message");
@@ -216,7 +216,7 @@
sub execute_ro_command {
my ($command, $stdout, $stderr) = @_;
-
+
# backup value of $FAI::no_dry_run
my $no_dry_run = $FAI::no_dry_run;
@@ -224,10 +224,10 @@
$FAI::no_dry_run = 1;
my $err = &execute_command_internal($command, $stdout, $stderr);
-
+
# reset no_dry_run
$FAI::no_dry_run = $no_dry_run;
-
+
if ($err ne "") {
my $response = &get_error($err, "response");
my $message = &get_error($err, "message");
Modified: trunk/lib/setup-storage/Fstab.pm
===================================================================
--- trunk/lib/setup-storage/Fstab.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Fstab.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -118,8 +118,8 @@
return $device_name;
}
}
-
+
################################################################################
#
# @brief this function generates the fstab file from our representation of the
@@ -138,7 +138,7 @@
# the file to be returned, a list of lines
my @fstab = ();
-
+
# walk through all configured parts
# the order of entries is most likely wrong, it is fixed at the end
foreach my $c (keys %$config) {
@@ -159,14 +159,14 @@
# skip extended partitions and entries without a mountpoint
next if ($p_ref->{size}->{extended} || $p_ref->{mountpoint} eq "-");
-
+
my $device_name = &FAI::make_device_name($device, $p_ref->{number});
if ($p_ref->{encrypt}) {
# encryption requested, rewrite the device name
$device_name =~ "s#/#_#g";
$device_name = "/dev/mapper/crypt$device_name";
}
-
+
# if the mount point is / or /boot, the variables should be set, unless
# they are already
if ($p_ref->{mountpoint} eq "/boot" || ($p_ref->{mountpoint} eq "/" &&
@@ -177,14 +177,14 @@
defined ($FAI::disk_var{BOOT_DEVICE}) and ($FAI::disk_var{BOOT_DEVICE} ne "") or
$FAI::disk_var{BOOT_DEVICE} = $1;
}
-
+
push @fstab, &FAI::create_fstab_line($p_ref,
&FAI::get_fstab_key($device_name, $config->{$c}->{fstabkey}), $device_name);
}
} elsif ($c =~ /^VG_(.+)$/) {
next if ($1 eq "--ANY--");
-
+
my $device = $1;
# create a line in the output file for each logical volume
@@ -202,14 +202,14 @@
# resolve the symlink to the real device
# and write it as the first entry
&FAI::execute_ro_command("readlink -f /dev/$device/$l", \@fstab_key, 0);
-
+
# remove the newline
chomp ($fstab_key[0]);
# make sure we got back a real device
($FAI::no_dry_run == 0 || -b $fstab_key[0])
or die "Failed to resolve /dev/$device/$l\n";
-
+
my $device_name = "/dev/$device/$l";
if ($l_ref->{encrypt}) {
# encryption requested, rewrite the device name
@@ -218,7 +218,7 @@
} else {
$device_name = $fstab_key[0];
}
-
+
# according to http://grub.enbug.org/LVMandRAID, this should work...
# if the mount point is / or /boot, the variables should be set, unless
# they are already
@@ -243,7 +243,7 @@
# skip entries without a mountpoint
next if ($r_ref->{mountpoint} eq "-");
-
+
my $device_name = "/dev/md$r";
if ($r_ref->{encrypt}) {
# encryption requested, rewrite the device name
@@ -273,7 +273,7 @@
# cleanup the swaplist (remove leading space and add quotes)
$FAI::disk_var{SWAPLIST} =~ s/^\s*/"/;
$FAI::disk_var{SWAPLIST} =~ s/\s*$/"/;
-
+
# cleanup the list of boot devices (remove leading space and add quotes)
$FAI::disk_var{BOOT_DEVICE} =~ s/^\s*/"/;
$FAI::disk_var{BOOT_DEVICE} =~ s/\s*$/"/;
Modified: trunk/lib/setup-storage/Init.pm
===================================================================
--- trunk/lib/setup-storage/Init.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Init.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -133,7 +133,7 @@
################################################################################
sub push_command {
my ($cmd, $pre, $post) = @_;
-
+
$FAI::commands{$FAI::n_c_i} = {
cmd => $cmd,
pre => $pre,
Modified: trunk/lib/setup-storage/Parser.pm
===================================================================
--- trunk/lib/setup-storage/Parser.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Parser.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -351,7 +351,7 @@
&FAI::init_disk_config($item[ 1 ]);
}
option(s?)
-
+
raid_option: /^preserve_always:(\d+(,\d+)*)/
{
# set the preserve flag for all ids in all cases
@@ -559,7 +559,7 @@
# range has no upper limit, assume the whole disk
$range = "${range}100%";
}
-
+
# convert the units, if necessary
my ($min, $max) = split (/-/, $range);
$min = &FAI::convert_unit($min);
Modified: trunk/lib/setup-storage/Sizes.pm
===================================================================
--- trunk/lib/setup-storage/Sizes.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Sizes.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -263,7 +263,7 @@
}
}
}
-
+
################################################################################
#
# @brief Handle preserved partitions while computing the size of partitions
@@ -280,7 +280,7 @@
sub do_partition_preserve {
my ($part_id, $config, $current_disk, $next_start, $min_req_total_space) = @_;
-
+
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
@@ -353,7 +353,7 @@
sub do_partition_extended {
my ($part_id, $config, $current_disk) = @_;
-
+
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
@@ -405,10 +405,10 @@
my ($part_id, $config, $current_disk, $next_start, $min_req_total_space,
$worklist) = @_;
-
+
# reference to the current partition
my $part = (\%FAI::configs)->{$config}->{partitions}->{$part_id};
-
+
my ($start, $end) = &FAI::make_range($part->{size}->{range},
$current_disk->{size} . "B");
Modified: trunk/lib/setup-storage/Volumes.pm
===================================================================
--- trunk/lib/setup-storage/Volumes.pm 2008-06-13 10:19:43 UTC (rev 4977)
+++ trunk/lib/setup-storage/Volumes.pm 2008-06-13 10:28:34 UTC (rev 4978)
@@ -85,7 +85,7 @@
$error =
&FAI::execute_ro_command("parted -s $disk unit TiB print", \@parted_print, 0);
}
-
+
($error eq "") or die "Failed to read the partition table from $disk\n";
# the following code parses the output of parted print, using various units
@@ -289,7 +289,7 @@
#
################################################################################
sub get_current_lvm {
-
+
use Linux::LVM;
# get the existing volume groups
@@ -297,13 +297,13 @@
# initialise the hash entry
$FAI::current_lvm_config{$vg}{physical_volumes} = ();
&FAI::push_command( "true", "", "vg_created_$vg" );
-
+
# store the vg size in MB
my %vg_info = get_volume_group_information($vg);
$FAI::current_lvm_config{$vg}{size} =
&FAI::convert_unit( $vg_info{alloc_pe_size} .
$vg_info{alloc_pe_size_unit} );
-
+
# store the logical volumes and their sizes
my %lv_info = get_logical_volume_information($vg);
foreach my $lv_name (sort keys %lv_info) {
@@ -314,7 +314,7 @@
$lv_info{$lv_name}->{lv_size_unit});
&FAI::push_command( "true", "", "exist_/dev/$vg/$short_name" );
}
-
+
# store the physical volumes
my %pv_info = get_physical_volume_information($vg);
@{ $FAI::current_lvm_config{$vg}{physical_volumes} } =
@@ -406,10 +406,10 @@
# loop through all configs
foreach my $config (keys %FAI::configs) {
-
+
# no physical devices here
next if ($config =~ /^PHY_./);
-
+
if ($config =~ /^VG_(.+)$/) {
next if ($1 eq "--ANY--");
# check for logical volumes that need to be preserved and preserve the
More information about the Fai-commit
mailing list