- vars['ROOT_MOUNTED']= 0
-
- if not utils.sysexec_noerr( "vgextend planetlab %s" %
- string.join(new_devices," "), log ):
- log.write( "Failed to add physical volumes %s to " \
- "volume group, continuing.\n" % string.join(new_devices," "))
- return 1
+ vars['ROOT_MOUNTED'] = 0
+
+ while True:
+ cmd = "vgextend planetlab {}".format(" ".join(new_devices))
+ if not utils.sysexec_noerr(cmd, log):
+ log.write("Failed to add physical volumes {} to "\
+ "volume group, continuing.\n".format(" ".join(new_devices)))
+ res = 1
+ break
+
+ # now, get the number of unused extents, and extend the vserver
+ # logical volume by that much.
+ remaining_extents = \
+ InstallPartitionDisks.get_remaining_extents_on_vg(vars, log)
+
+ log.write("Extending vservers logical volume.\n")
+ utils.sysexec("vgchange -ay", log)
+ cmd = "lvextend -l +{} {}".format(remaining_extents, PARTITIONS["vservers"])
+ if not utils.sysexec_noerr(cmd, log):
+ log.write("Failed to extend vservers logical volume, continuing\n")
+ res = 1
+ break
+
+ log.write("making the ext filesystem match new logical volume size.\n")
+
+ vars['ROOT_MOUNTED'] = 1
+ cmd = "mount {} {}".format(PARTITIONS["root"], SYSIMG_PATH)
+ utils.sysexec_noerr(cmd, log)
+ cmd = "mount {} {}/vservers".format(PARTITIONS["vservers"], SYSIMG_PATH)
+ utils.sysexec_noerr(cmd, log)
+ cmd = "resize2fs {}".format(PARTITIONS["vservers"])
+ resize = utils.sysexec_noerr(cmd,log)
+ utils.sysexec_noerr("umount {}/vservers".format(SYSIMG_PATH), log)
+ utils.sysexec_noerr("umount {}".format(SYSIMG_PATH), log)
+ vars['ROOT_MOUNTED'] = 0
+
+ utils.sysexec("vgchange -an", log)
+
+ if not resize:
+ log.write("Failed to resize vservers partition, continuing.\n")
+ res = 1
+ break
+ else:
+ log.write("Extended vservers partition by {:4.2f} Gb\n"\
+ .format(extended_gb_size))
+ res = 1
+ break