Exemple #1
0
 def initiator_name(self, initiator_name=None):
     try:
         import ovirtnode.iscsi as oiscsi
         if initiator_name:
             oiscsi.set_iscsi_initiator(initiator_name)
         return oiscsi.get_current_iscsi_initiator_name()
     except ImportError as e:
         self.logger.warning("Failed on import: %s" % e)
Exemple #2
0
 def initiator_name(self, initiator_name=None):
     try:
         import ovirtnode.iscsi as oiscsi
         if initiator_name:
             oiscsi.set_iscsi_initiator(initiator_name)
         return oiscsi.get_current_iscsi_initiator_name()
     except ImportError as e:
         self.logger.warning("Failed on import: %s" % e)
    def perform_partitioning(self):
        if self.HOSTVGDRIVE is None and not _functions.is_iscsi_install():
            logger.error("\nNo storage device selected.")
            return False

        if self.BOOTDRIVE is None and _functions.is_iscsi_install():
            logger.error("No storage device selected.")
            return False

        if not self.cross_check_host_app():
            logger.error("Skip disk partitioning, AppVG overlaps with HostVG")
            return False

        if _functions.has_fakeraid(self.HOSTVGDRIVE):
            if not handle_fakeraid(self.HOSTVGDRIVE):
                return False
        if _functions.has_fakeraid(self.ROOTDRIVE):
            if not handle_fakeraid(self.ROOTDRIVE):
                return False

        logger.info("Saving parameters")
        _functions.unmount_config("/etc/default/ovirt")
        if not self.check_partition_sizes():
            return False

        # Check for still remaining HostVGs this can be the case when
        # Node was installed on a disk not given in storage_init
        # rhbz#872114
        existing_vgs = str(_functions.passthrough("vgs"))
        for vg in existing_vgs.split("\n"):
            vg = vg.strip()
            if "HostVG" in str(vg):
                logger.error("An existing installation was found or not " +
                     "all VGs could be removed.  " +
                     "Please manually cleanup the storage using " +
                     "standard disk tools.")
                return False

        logger.info("Removing old LVM partitions")
        # HostVG must not exist at this point
        # we wipe only foreign LVM here
        logger.info("Wiping LVM on HOSTVGDRIVE %s" % self.HOSTVGDRIVE)
        if not self.wipe_lvm_on_disk(self.HOSTVGDRIVE):
            logger.error("Wiping LVM on %s Failed" % self.HOSTVGDRIVE)
            return False
        logger.info("Wiping LVM on ROOTDRIVE %s" % self.ROOTDRIVE)
        if not self.wipe_lvm_on_disk(self.ROOTDRIVE):
            logger.error("Wiping LVM on %s Failed" % self.ROOTDRIVE)
            return False
        logger.info("Wiping LVM on BOOTDRIVE %s" % self.BOOTDRIVE)
        if not self.wipe_lvm_on_disk(self.BOOTDRIVE):
            logger.error("Wiping LVM on %s Failed" % self.BOOTDRIVE)
            return False
        logger.debug("Old LVM partitions should be gone.")
        logger.debug(_functions.passthrough("vgdisplay -v"))

        self.boot_size_si = self.BOOT_SIZE * (1024 * 1024) / (1000 * 1000)
        if _functions.is_iscsi_install():
            if "OVIRT_ISCSI_NAME" in _functions.OVIRT_VARS:
                iscsi_name = _functions.OVIRT_VARS["OVIRT_ISCSI_NAME"]
                set_iscsi_initiator(iscsi_name)
            # login to target and setup disk
            get_targets = ("iscsiadm -m discovery -p %s:%s -t sendtargets" %
                           (_functions.OVIRT_VARS["OVIRT_ISCSI_TARGET_HOST"],
                           _functions.OVIRT_VARS["OVIRT_ISCSI_TARGET_PORT"]))
            _functions.system(get_targets)
            before_login_drvs = self.get_dev_name()
            logger.debug(before_login_drvs)
            login_cmd = ("iscsiadm -m node -T %s -p %s:%s -l" %
                        (_functions.OVIRT_VARS["OVIRT_ISCSI_TARGET_NAME"],
                        _functions.OVIRT_VARS["OVIRT_ISCSI_TARGET_HOST"],
                        _functions.OVIRT_VARS["OVIRT_ISCSI_TARGET_PORT"]))
            _functions.system(login_cmd)
            _functions.system("multipath -r")
            after_login_drvs = self.get_dev_name()
            logger.debug(after_login_drvs)
            logger.info("iSCSI enabled, partitioning boot drive: %s" %
                        self.BOOTDRIVE)
            _functions.wipe_partitions(self.BOOTDRIVE)
            self.reread_partitions(self.BOOTDRIVE)
            logger.info("Creating boot partition")
            parted_cmd = "parted %s -s \"mklabel %s\"" % (self.BOOTDRIVE,
                                                          self.LABEL_TYPE)
            _functions.system(parted_cmd)
            self.create_efi_partition()
            boot_end_mb = self.EFI_SIZE + self.BOOT_SIZE
            parted_cmd = ("parted \"%s\" -s \"mkpart primary ext2 %sM %sM\"" %
                         (self.BOOTDRIVE, self.EFI_SIZE, boot_end_mb))
            _functions.system(parted_cmd)
            parted_cmd = ("parted \"%s\" -s \"mkpart primary ext2 %sM %sM\"" %
                         (self.BOOTDRIVE , boot_end_mb, boot_end_mb + self.BOOT_SIZE))
            _functions.system(parted_cmd)
            parted_cmd = ("parted \"" + self.BOOTDRIVE + "\" -s \"set 1 " +
                         "boot on\"")
            _functions.system(parted_cmd)
            self.reread_partitions(self.BOOTDRIVE)
            partboot = self.BOOTDRIVE + "2"
            partbootbackup = self.BOOTDRIVE + "3"

            if not os.path.exists(partboot):
                logger.debug("%s does not exist" % partboot)
                partboot = self.BOOTDRIVE + "p2"
                partbootbackup = self.BOOTDRIVE + "p3"

            # sleep to ensure filesystems are created before continuing
            _functions.system("udevadm settle")
            _functions.system("mke2fs \"" + str(partboot) + "\" -L Boot")
            _functions.system("tune2fs -c 0 -i 0 \"" + str(partboot) + "\"")
            _functions.system("ln -snf \"" + partboot + \
                              "\" /dev/disk/by-label/Boot")
            _functions.system("mke2fs \"" + str(partbootbackup) + \
                              "\" -L BootBackup")
            _functions.system("tune2fs -c 0 -i 0 \"" + \
                              str(partbootbackup) + "\"")
            _functions.system("ln -snf \"" + partbootbackup +
                   "\" /dev/disk/by-label/BootBackup")
            self.ISCSIDRIVE = _functions.translate_multipath_device(
                               _functions.OVIRT_VARS["OVIRT_ISCSI_INIT"])
            logger.debug(self.ISCSIDRIVE)
            if self.create_iscsiroot():
                logger.info("iSCSI Root Partitions Created")
                if self.create_hostvg():
                    if len(self.APPVGDRIVE) > 0:
                        self.create_appvg()
                    logger.info("Completed!")
                    return True

        if ("OVIRT_ROOT_INSTALL" in _functions.OVIRT_VARS and
                  _functions.OVIRT_VARS["OVIRT_ROOT_INSTALL"] == "y" and not \
                      _functions.is_iscsi_install()):
            logger.info("Partitioning root drive: " + self.ROOTDRIVE)
            _functions.wipe_partitions(self.ROOTDRIVE)
            self.reread_partitions(self.ROOTDRIVE)
            logger.info("Labeling Drive: " + self.ROOTDRIVE)
            parted_cmd = ("parted \"" + self.ROOTDRIVE + "\" -s \"mklabel " +
                         self.LABEL_TYPE + "\"")
            _functions.passthrough(parted_cmd, logger.debug)
            logger.debug("Creating Root and RootBackup Partitions")
            if _functions.is_efi_boot():
                self.create_efi_partition()
            else:
                # create partition labeled bios_grub
                parted_cmd = ("parted \"" + self.ROOTDRIVE +
                             "\" -s \"mkpart primary 1M " +
                             str(self.EFI_SIZE) + "M\"")
                _functions.passthrough(parted_cmd, logger.debug)
                parted_cmd = ("parted \"" + self.ROOTDRIVE +
                             "\" -s \"set 1 bios_grub on\"")
                _functions.passthrough(parted_cmd, logger.debug)
            parted_cmd = ("parted \"" + self.ROOTDRIVE +
                         "\" -s \"mkpart primary ext2 " + str(self.EFI_SIZE) +
                         "M " + str(self.Root_end) + "M\"")
            _functions.passthrough(parted_cmd, logger.debug)
            parted_cmd = ("parted \"" + self.ROOTDRIVE +
                         "\" -s \"mkpart primary ext2 " +
                         str(self.Root_end) + "M " +
                         str(self.RootBackup_end) + "M\"")
            logger.debug(parted_cmd)
            _functions.system(parted_cmd)
            _functions.system("sync ; udevadm settle ; partprobe")
            parted_cmd = ("parted \"" + self.ROOTDRIVE +
                         "\" -s \"set 2 boot on\"")
            logger.debug(parted_cmd)
            _functions.system(parted_cmd)
            # force reload some cciss devices will fail to mkfs
            _functions.system("multipath -r &>/dev/null")
            self.reread_partitions(self.ROOTDRIVE)
            partroot = self.ROOTDRIVE + "2"
            partrootbackup = self.ROOTDRIVE + "3"
            if not os.path.exists(partroot):
                partroot = self.ROOTDRIVE + "p2"
                partrootbackup = self.ROOTDRIVE + "p3"
            _functions.system("mke2fs \"" + partroot + "\" -L Root")
            _functions.system("tune2fs -c 0 -i 0 \"" + partroot + "\"")
            _functions.system("ln -snf \"" + partrootbackup +
                   "\" /dev/disk/by-label/RootBackup")
            _functions.system("mke2fs \"" + partrootbackup + \
                              "\" -L RootBackup")
            _functions.system("tune2fs -c 0 -i 0 \"" + partrootbackup + "\"")
        hostvg1 = self.HOSTVGDRIVE.split(",")[0]
        self.reread_partitions(self.ROOTDRIVE)
        if self.ROOTDRIVE != hostvg1:
            _functions.system("parted \"" + hostvg1 + "\" -s \"mklabel " +
                   self.LABEL_TYPE + "\"")
        if self.create_hostvg():
            if len(self.APPVGDRIVE) > 0:
                self.create_appvg()
        else:
            return False
        if ("OVIRT_CRYPT_SWAP2" in _functions.OVIRT_VARS or
            "OVIRT_CRYPT_SWAP" in _functions.OVIRT_VARS):
            _functions.ovirt_store_config("/etc/ovirt-crypttab")
        return True
Exemple #4
0
 def storage_apply(self, obj):
     from ocsetup.ocsetup import ocs
     log("enter storage apply")
     set_iscsi_initiator(
         ocs.page_Storage.iscsi_initiator_name_value_Entry.get_text())
Exemple #5
0
 def storage_apply(self, obj):
     from ocsetup.ocsetup import ocs
     log("enter storage apply")
     set_iscsi_initiator(
         ocs.page_Storage.iscsi_initiator_name_value_Entry.get_text())