From ac33037abb3b028c7e57010d1e85216fe11ea6c1 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Wed, 17 Dec 2008 16:42:41 +0000 Subject: [PATCH] Add support for a rawdisk model option, to let a slice use the drives which aren't required for the node/slices to function. --- source/ModelOptions.py | 4 +++- source/configuration | 5 +++++ source/steps/CheckForNewDisks.py | 15 ++++++++++--- source/steps/InstallPartitionDisks.py | 32 ++++++++++++++++++++------- 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/source/ModelOptions.py b/source/ModelOptions.py index 08912a0..8c8e979 100644 --- a/source/ModelOptions.py +++ b/source/ModelOptions.py @@ -18,6 +18,7 @@ NUMA = 0x020 GEODE = 0x040 BADHD = 0x080 LAST = 0x100 +RAWDISK = 0x200 modeloptions = {'smp':SMP, 'x64':X86_64, @@ -28,7 +29,8 @@ modeloptions = {'smp':SMP, 'numa':NUMA, 'geode':GEODE, 'badhd':BADHD, - 'minhw':MINHW} + 'minhw':MINHW, + 'rawdisk':RAWDISK} def Get(model): modelinfo = string.split(model,'/') diff --git a/source/configuration b/source/configuration index 5d98812..152cc75 100644 --- a/source/configuration +++ b/source/configuration @@ -51,6 +51,11 @@ ROOT_SIZE=7G SWAP_SIZE=1G +# in raw disk mode, the size of /vservers +# if unset or -1, use the entire first disk +VSERVERS_SIZE=-1 + + # whether or not to skip hardware requirement check SKIP_HARDWARE_REQUIREMENT_CHECK=0 diff --git a/source/steps/CheckForNewDisks.py b/source/steps/CheckForNewDisks.py index 1e368d5..44489e8 100644 --- a/source/steps/CheckForNewDisks.py +++ b/source/steps/CheckForNewDisks.py @@ -14,6 +14,8 @@ import systeminfo import utils import os +import ModelOptions + def Run( vars, log ): """ @@ -22,6 +24,7 @@ def Run( vars, log ): Expect the following variables to be set: SYSIMG_PATH the path where the system image will be mounted MINIMUM_DISK_SIZE any disks smaller than this size, in GB, are not used + NODE_MODEL_OPTIONS the node's model options Set the following variables upon successfully running: ROOT_MOUNTED the node root file system is mounted @@ -41,6 +44,7 @@ def Run( vars, log ): if PARTITIONS == None: raise ValueError, "PARTITIONS" + NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"] except KeyError, var: raise BootManagerException, "Missing variable in vars: %s\n" % var except ValueError, var: @@ -96,16 +100,21 @@ def Run( vars, log ): log.write("To paranoid to add %s to vservers lvm.\n" % device) continue - log.write( "Attempting to add %s to the volume group\n" % device ) - if not InstallPartitionDisks.single_partition_device( device, vars, log ): log.write( "Unable to partition %s, not using it.\n" % device ) continue - log.write( "Successfully initialized %s\n" % device ) + log.write( "Successfully partitioned %s\n" % device ) + + if NODE_MODEL_OPTIONS & ModelOptions.RAWDISK: + log.write( "Running on a raw disk node, not using it.\n" ) + continue part_path= InstallPartitionDisks.get_partition_path_from_device( device, vars, log ) + + log.write( "Attempting to add %s to the volume group\n" % device ) + if not InstallPartitionDisks.create_lvm_physical_volume( part_path, vars, log ): log.write( "Unable to create lvm physical volume %s, not using it.\n" % diff --git a/source/steps/InstallPartitionDisks.py b/source/steps/InstallPartitionDisks.py index 77bc9d4..6ebe27e 100644 --- a/source/steps/InstallPartitionDisks.py +++ b/source/steps/InstallPartitionDisks.py @@ -55,6 +55,13 @@ def Run( vars, log ): if PARTITIONS == None: raise ValueError, "PARTITIONS" + if NODE_MODEL_OPTIONS & ModelOptions.RAWDISK: + VSERVERS_SIZE= "-1" + if "VSERVER_SIZE" in vars: + VSERVERS_SIZE= vars["VSERVERS_SIZE"] + if VSERVERS_SIZE == "" or VSERVERS_SIZE == 0: + raise ValueError, "VSERVERS_SIZE" + except KeyError, var: raise BootManagerException, "Missing variable in vars: %s\n" % var except ValueError, var: @@ -80,11 +87,15 @@ def Run( vars, log ): used_devices= [] - for device in INSTALL_BLOCK_DEVICES: + for device in sorted(INSTALL_BLOCK_DEVICES): if single_partition_device( device, vars, log ): - used_devices.append( device ) - log.write( "Successfully initialized %s\n" % device ) + if (len(used_devices) > 0 and + (vars['NODE_MODEL_OPTIONS'] & ModelOptions.RAWDISK)): + log.write( "Running in raw disk mode, not using %s.\n" % device ) + else: + used_devices.append( device ) + log.write( "Successfully initialized %s\n" % device ) else: log.write( "Unable to partition %s, not using it.\n" % device ) continue @@ -112,11 +123,16 @@ def Run( vars, log ): # create root logical volume utils.sysexec( "lvcreate -L%s -nroot planetlab" % ROOT_SIZE, log ) - # create vservers logical volume with all remaining space - # first, we need to get the number of remaining extents we can use - remaining_extents= get_remaining_extents_on_vg( vars, log ) - - utils.sysexec( "lvcreate -l%s -nvservers planetlab" % remaining_extents, log ) + if vars['NODE_MODEL_OPTIONS'] & ModelOptions.RAWDISK and VSERVERS_SIZE != "-1": + utils.sysexec( "lvcreate -L%s -nvservers planetlab" % VSERVERS_SIZE, log ) + remaining_extents= get_remaining_extents_on_vg( vars, log ) + utils.sysexec( "lvcreate -l%s -nrawdisk planetlab" % remaining_extents, log ) + else: + # create vservers logical volume with all remaining space + # first, we need to get the number of remaining extents we can use + remaining_extents= get_remaining_extents_on_vg( vars, log ) + + utils.sysexec( "lvcreate -l%s -nvservers planetlab" % remaining_extents, log ) # activate volume group (should already be active) #utils.sysexec( TEMP_PATH + "vgchange -ay planetlab", log ) -- 2.43.0