# simply creating an instance of this class and listing the system
# block devices will make them show up so vgscan can find the planetlab
# volume group
- systeminfo.get_block_device_list(vars, log)
+ systeminfo.get_block_devices_dict(vars, log)
utils.sysexec("vgscan", log)
utils.sysexec("vgchange -ay planetlab", log)
except ValueError as var:
raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
- all_devices = systeminfo.get_block_device_list(vars, log)
+ devices_dict = systeminfo.get_block_devices_dict(vars, log)
# will contain the new devices to add to the volume group
new_devices = []
# total amount of new space in gb
extended_gb_size = 0
- for device in all_devices.keys():
+ for device, details in devices_dict.items():
- (major, minor, blocks, gb_size, readonly) = all_devices[device]
+ (major, minor, blocks, gb_size, readonly) = details
if device[:14] == "/dev/planetlab":
log.write("Skipping device {} in volume group.\n".format(device))
# get a list of block devices to attempt to install on
# (may include cdrom devices)
- install_devices = systeminfo.get_block_device_list(vars, log)
+ install_devices = systeminfo.get_block_devices_dict(vars, log)
# save the list of block devices in the log
log.write("Detected block devices:\n")
# also, keep track of the total size for all devices that appear usable
total_size = 0
- for device in install_devices.keys():
+ # do not modify subject of current loop
+ ignored_devices = []
+ for device, details in install_devices.items():
- major, minor, blocks, gb_size, readonly = install_devices[device]
+ major, minor, blocks, gb_size, readonly = details
# if the device string starts with
# planetlab or dm- (device mapper), ignore it (could be old lvm setup)
if device[:14] == "/dev/planetlab" or device[:8] == "/dev/dm-":
- del install_devices[device]
+ ignored_devices.append(device)
continue
if gb_size < MINIMUM_DISK_SIZE:
log.write("Device is too small to use: {} \n"
"(appears to be {:4.2f} Gb)\n".format(device, gb_size))
- try:
- del install_devices[device]
- except KeyError as e:
- pass
+ ignored_devices.append(device)
continue
if readonly:
log.write("Device is readonly, not using: {}\n".format(device))
- try:
- del install_devices[device]
- except KeyError as e:
- pass
+ ignored_devices.append(device)
continue
# add this sector count to the total count of usable
# sectors we've found.
total_size = total_size + gb_size
+ # delayed erasure
+ for device in ignored_devices:
+ try:
+ del install_devices[device]
+ except KeyError as e:
+ pass
if len(install_devices) == 0:
log.write("No suitable block devices found for install.\n")
bs_request = BootServerRequest.BootServerRequest(vars)
+ # in upgrade mode, since we skip InstallPartitionDisks
+ # we need to run this
+ if upgrade:
+ log.write("Running vgscan for devices (upgrade mode)\n")
+ systeminfo.get_block_devices_dict(vars, log)
+ utils.sysexec_noerr("vgscan", log)
+
log.write("turning on swap space\n")
utils.sysexec("swapon {}".format(PARTITIONS["swap"]), log)
# simply creating an instance of this class and listing the system
# block devices will make them show up so vgscan can find the planetlab
# volume group
- systeminfo.get_block_device_list(vars, log)
+ systeminfo.get_block_devices_dict(vars, log)
try:
utils.sysexec("vgscan", log)
meminfo_file.close()
return total_memory
-def get_block_device_list(vars = {}, log = sys.stderr):
+def get_block_devices_dict(vars = {}, log = sys.stderr):
"""
get a list of block devices from this system.
return an associative array, where the device name
if __name__ == "__main__":
- devices = get_block_device_list()
+ devices = get_block_devices_dict()
print("block devices detected:")
if not devices:
print("no devices found!")