コード例 #1
0
    def clear_config(self):
        """
        Remove the target definition form LIO
        :return: None
        """
        # check that there aren't any disks or clients in the configuration
        lio = LIO()

        disk_count = len(
            [disk for disk in lio.ceph_storage_objects(self.config)])
        clients = []
        for tpg in self.tpg_list:
            tpg_clients = [node for node in tpg._list_node_acls()]
            clients += tpg_clients
        client_count = len(clients)

        if disk_count > 0 or client_count > 0:
            self.error = True
            self.error_msg = ("Clients({}) and disks({}) must be removed"
                              "before the gateways".format(
                                  client_count, disk_count))
            return

        self.logger.debug("Clients defined :{}".format(client_count))
        self.logger.debug("Disks defined :{}".format(disk_count))
        self.logger.info("Removing target configuration")

        try:
            self.delete()
        except RTSLibError as err:
            self.error = True
            self.error_msg = "Unable to delete target - {}".format(err)
コード例 #2
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 = LIO()
        # process each storage object added to the gateway, and map to the tpg
        for stg_object in lio.ceph_storage_objects(config):
            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

                    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