Example #1
0
    def map_luns(self, config):
        """
        LIO will have blockstorage objects already defined by the igw_lun module, so this
        method, brings those objects into the gateways TPG
        """

        lio_root = root.RTSRoot()

        # process each storage object added to the gateway, and map to the tpg
        for stg_object in lio_root.storage_objects:

            for tpg in self.tpg_list:

                if not self.lun_mapped(tpg, stg_object):

                    # use the iblock number for the lun id - /sys/kernel/config/target/core/iblock_1/ansible4
                    #                                                                              ^
                    lun_id = int(stg_object._path.split('/')[-2].split('_')[1])

                    try:
                        mapped_lun = LUN(tpg,
                                         lun=lun_id,
                                         storage_object=stg_object)
                        self.changes_made = True
                    except RTSLibError as err:
                        self.error = True
                        self.error_msg = err
                        break

                    self.bind_alua_group_to_lun(config, mapped_lun)
Example #2
0
    def _map_lun(self, config, stg_object):
        for tpg in self.tpg_list:
            self.logger.debug("processing tpg{}".format(tpg.tag))

            lun_id = int(stg_object.path.split('/')[-2].split('_')[1])

            try:
                mapped_lun = LUN(tpg, lun=lun_id, storage_object=stg_object)
                self.changes_made = True
            except RTSLibError as err:
                if "already exists in configFS" not in str(err):
                    self.logger.error("LUN mapping failed: {}".format(err))
                    self.error = True
                    self.error_msg = err
                    return

                # Already created. Ignore and loop to the next tpg.
                continue

            try:
                self.bind_alua_group_to_lun(config, mapped_lun)
            except CephiSCSIInval as err:
                self.logger.error("Could not bind LUN to ALUA group: "
                                  "{}".format(err))
                self.error = True
                self.error_msg = err
                return
Example #3
0
    def map_luns(self, config):
        """
        LIO will have objects already defined by the lun module,
        so this method, brings those objects into the gateways TPG
        """

        lio_root = root.RTSRoot()

        # process each storage object added to the gateway, and map to the tpg
        for stg_object in lio_root.storage_objects:

            for tpg in self.tpg_list:
                self.logger.debug("processing tpg{}".format(tpg.tag))

                if not self.lun_mapped(tpg, stg_object):
                    self.logger.debug("{} needed mapping to "
                                      "tpg{}".format(stg_object.name,
                                                     tpg.tag))

                    lun_id = int(stg_object.path.split('/')[-2].split('_')[1])

                    try:
                        mapped_lun = LUN(tpg, lun=lun_id, storage_object=stg_object)
                        self.changes_made = True
                    except RTSLibError as err:
                        self.logger.error("LUN mapping failed: {}".format(err))
                        self.error = True
                        self.error_msg = err
                        return

                    self.bind_alua_group_to_lun(config, mapped_lun)
Example #4
0
    def map_luns(self, config):
        """
        LIO will have objects already defined by the lun module,
        so this method, brings those objects into the gateways TPG
        """

        lio_root = root.RTSRoot()
        target_config = config.config["targets"][self.iqn]
        target_stg_object = [
            stg_object for stg_object in lio_root.storage_objects
            if stg_object.name in target_config['disks']
        ]

        # a dict, key with tpg and storage object name
        tpg_stg_object_dict = {}
        for tpg in self.tpg_list:

            for l in tpg.luns:
                key = str(tpg.tag) + "-" + l.storage_object.name
                tpg_stg_object_dict[key] = l.storage_object.name

        # process each storage object added to the gateway, and map to the tpg
        for stg_object in target_stg_object:

            for tpg in self.tpg_list:
                self.logger.debug("processing tpg{}".format(tpg.tag))

                if str(tpg.tag
                       ) + "-" + stg_object.name not in tpg_stg_object_dict:
                    self.logger.debug("{} needed mapping to "
                                      "tpg{}".format(stg_object.name, tpg.tag))

                    lun_id = int(stg_object.path.split('/')[-2].split('_')[1])

                    try:
                        mapped_lun = LUN(tpg,
                                         lun=lun_id,
                                         storage_object=stg_object)
                        self.changes_made = True
                    except RTSLibError as err:
                        self.logger.error("LUN mapping failed: {}".format(err))
                        self.error = True
                        self.error_msg = err
                        return

                    try:
                        self.bind_alua_group_to_lun(config, mapped_lun)
                    except CephiSCSIInval as err:
                        self.logger.error("Could not bind LUN to ALUA group: "
                                          "{}".format(err))
                        self.error = True
                        self.error_msg = err
                        return