def __init__(self): logger = logging.getLogger(_functions.PRODUCT_SHORT) logger.propagate = False OVIRT_VARS = _functions.parse_defaults() self.overcommit = 0.5 self.BOOT_SIZE = 512 self.ROOT_SIZE = 512 self.CONFIG_SIZE = 5 self.LOGGING_SIZE = 2048 self.EFI_SIZE = 256 self.SWAP_SIZE = 0 self.MIN_SWAP_SIZE = 5 self.MIN_LOGGING_SIZE = 5 self.SWAP2_SIZE = 0 self.DATA2_SIZE = 0 self.BOOTDRIVE = "" self.HOSTVGDRIVE = "" self.APPVGDRIVE = [] self.ISCSIDRIVE = "" # -1 indicates data partition should use remaining disk self.DATA_SIZE = -1 # gpt or msdos partition table type self.LABEL_TYPE = "gpt" if "OVIRT_INIT" in OVIRT_VARS: _functions.OVIRT_VARS["OVIRT_INIT"] = \ _functions.OVIRT_VARS["OVIRT_INIT"].strip(",") if "," in _functions.OVIRT_VARS["OVIRT_INIT"]: disk_count = 0 init = _functions.OVIRT_VARS["OVIRT_INIT"].strip(",").split(",") for disk in init: skip = False translated_disk = _functions.translate_multipath_device(disk) if disk_count < 1: self.ROOTDRIVE = translated_disk if len(init) == 1: self.HOSTVGDRIVE = translated_disk disk_count = disk_count + 1 else: for hostvg in self.HOSTVGDRIVE.split(","): if hostvg == translated_disk: skip = True break if not skip: self.HOSTVGDRIVE += ("%s," % translated_disk) \ if translated_disk else "" else: self.ROOTDRIVE = _functions.translate_multipath_device( _functions.OVIRT_VARS["OVIRT_INIT"]) self.HOSTVGDRIVE = _functions.translate_multipath_device( _functions.OVIRT_VARS["OVIRT_INIT"]) if _functions.is_iscsi_install(): logger.info(self.BOOTDRIVE) logger.info(self.ROOTDRIVE) self.BOOTDRIVE = _functions.translate_multipath_device( \ self.ROOTDRIVE) if "OVIRT_OVERCOMMIT" in OVIRT_VARS: self.overcommit = OVIRT_VARS["OVIRT_OVERCOMMIT"] if "OVIRT_VOL_SWAP_SIZE" in OVIRT_VARS: if int(OVIRT_VARS["OVIRT_VOL_SWAP_SIZE"]) < self.MIN_SWAP_SIZE: logger.error("Swap size is smaller than minimum required + " "size of: %s" % self.MIN_SWAP_SIZE) print ("\n\nSwap size is smaller than minimum required " + "size of: %s" % self.MIN_SWAP_SIZE) #return False sys.exit(1) else: self.SWAP_SIZE = _functions.OVIRT_VARS["OVIRT_VOL_SWAP_SIZE"] else: self.SWAP_SIZE = _functions.calculate_swap_size( \ float(self.overcommit)) for i in ['OVIRT_VOL_BOOT_SIZE', 'OVIRT_VOL_ROOT_SIZE', 'OVIRT_VOL_CONFIG_SIZE', 'OVIRT_VOL_LOGGING_SIZE', 'OVIRT_VOL_DATA_SIZE', 'OVIRT_VOL_SWAP2_SIZE', 'OVIRT_VOL_DATA2_SIZE', 'OVIRT_VOL_EFI_SIZE']: i_short = i.replace("OVIRT_VOL_", "MIN_") if not i_short in self.__dict__: i_short = i_short.replace("MIN_", "") if i in OVIRT_VARS: if int(OVIRT_VARS[i]) < int(self.__dict__[i_short]): logger.error(("%s is smaller than minimum required size " + "of: %s") % (i, self.__dict__[i_short])) print (("\n%s is smaller than minimum required size of: " + "%s") % (i, self.__dict__[i_short])) #return False logger.info(("Setting value for %s to %s " % (self.__dict__[i_short], _functions.OVIRT_VARS[i]))) i_short = i_short.replace("MIN_", "") self.__dict__[i_short] = int(OVIRT_VARS[i]) else: logger.info("Using default value for: %s" % i_short) self.RootBackup_end = self.ROOT_SIZE * 2 + self.EFI_SIZE self.Root_end = self.EFI_SIZE + self.ROOT_SIZE if "OVIRT_INIT_APP" in OVIRT_VARS: if self.SWAP2_SIZE != 0 or self.DATA2_SIZE != 0: for drv in _functions.OVIRT_VARS["OVIRT_INIT_APP"].split(","): DRIVE = _functions.translate_multipath_device(drv) self.APPVGDRIVE.append(DRIVE) else: if self.SWAP2_SIZE != 0 or self.DATA2_SIZE != 0: logger.error("Missing device parameter for AppVG: " + "unable to partition any disk")
def calculcate_default_size(self, overcommit): from ovirtnode.ovirtfunctions import calculate_swap_size return calculate_swap_size(overcommit)