Beispiel #1
0
    def summary(self):
        msg = ["({})".format(self.desc)]
        msg.append("Commit: {}/{} ({}%)".format(human_size(self.commit),
                                                human_size(self.max_bytes),
                                                self.overcommit_PCT))
        msg.append("Used: {}".format(human_size(self.used_bytes)))

        return ', '.join(msg), True
Beispiel #2
0
    def get_meta_data_krbd(self):
        """
        KRBD based method to get size and rbd features information
        :return:
        """
        # image_path is a symlink to the actual /dev/rbdX file
        image_path = "/dev/rbd/{}/{}".format(self.pool, self.rbd_image)
        dev_id = os.path.realpath(image_path)[8:]
        rbd_path = "/sys/devices/rbd/{}".format(dev_id)

        try:
            self.features = readcontents(os.path.join(rbd_path, 'features'))
            self.size = int(readcontents(os.path.join(rbd_path, 'size')))
        except IOError:
            # if we get an ioError here, it means the config object passed
            # back from the API is out of step with the physical configuration
            # this can happen after a purge_gateways ansible playbook run if
            # the gateways do not have there rbd-target-gw daemons reloaded
            error_msg = "The API has returned disks that are not on this " \
                        "server...reload rbd-target-api?"
            self.logger.critical(error_msg)
            raise GatewayError(error_msg)
        else:

            self.size_h = human_size(self.size)

            # update the parent's disk info map
            disk_map = self.parent.disk_info

            disk_map[self.image_id]['size'] = self.size
            disk_map[self.image_id]['size_h'] = self.size_h
Beispiel #3
0
 def _parse_snapshots(self, snapshots):
     self.snapshots = [
         "{name} ({size})".format(name=s['name'],
                                  size=human_size(s['size']))
         for s in snapshots
     ]
     self.snapshot_names = [s['name'] for s in snapshots]
Beispiel #4
0
    def summary(self):

        all_disks = self.parent.parent.parent.parent.disks.children
        total_bytes = 0

        client_luns = [lun.rbd_name for lun in self.children]

        for disk in all_disks:
            if disk.image_id in client_luns:
                total_bytes += disk.size

        msg = ['LOGGED-IN'] if self.logged_in else []

        # Default stance is no chap, so we need to detect it
        auth_text = "Auth: None"
        status = False

        if 'chap' in self.auth:
            if self.auth['chap']:
                auth_text = "Auth: CHAP"
                status = True

        msg.append(auth_text)

        msg.append("Disks: {}({})".format(len(client_luns),
                                          human_size(total_bytes)))

        return ", ".join(msg), status
Beispiel #5
0
    def ui_command_info(self):

        color = {
            "HEALTH_OK": "green",
            "HEALTH_WARN": "yellow",
            "HEALTH_ERR": "red"
        }

        status = self.ceph_status
        osdmap = status['osdmap']['osdmap']
        output = "Cluster name: {}\n".format(self.cluster_name)
        output += "Ceph version: {}\n".format(self.version)
        output += "Health      : {}\n".format(self.health_status)
        if self.health_status != 'HEALTH_OK':
            output += " - {}\n".format(','.join(self.health_list))

        mon_names = [mon.get('name') for mon in status["monmap"]["mons"]]

        q_str = "quorum {}".format(','.join(status['quorum_names']))
        q_out = set(mon_names) - set(status['quorum_names'])
        if q_out:
            q_str += ", out of quorum: {}".format(','.join(q_out))
        output += "\nMONs : {:>4} ({})\n".format(self.topology.num_mons, q_str)
        output += "OSDs : {:>4} ({} up, {} in)\n".format(
            self.topology.num_osds, osdmap['num_up_osds'],
            osdmap['num_in_osds'])
        output += "Pools: {:>4}\n".format(self.num_pools)
        raw = status['pgmap']['bytes_total']
        output += "Raw capacity: {}\n".format(human_size(raw))
        output += "\nConfig : {}\n".format(self.conf)
        output += "Keyring: {}\n".format(
            os.path.join(CephGroup.ceph_config_dir, self.keyring))

        console_message(output, color=color[self.health_status])
Beispiel #6
0
    def __init__(self,
                 parent,
                 image_id,
                 image_config,
                 size=None,
                 features=None,
                 snapshots=None):
        """
        Create a disk entry under the Disks subtree
        :param parent: parent object (instance of the Disks class)
        :param image_id: key used in the config object for this rbd image
               (pool.image_name) - str
        :param image_config: meta data for this image
        :return:
        """
        self.pool, self.rbd_image = image_id.split('.', 1)

        UINode.__init__(self, image_id, parent)

        self.image_id = image_id
        self.size = 0
        self.size_h = ''
        self.features = 0
        self.feature_list = []
        self.controls = {}
        self.control_values = {}
        self.ceph_cluster = self.parent.parent.ceph.local_ceph.name

        disk_map = self.parent.disk_info
        if image_id not in disk_map:
            disk_map[image_id] = {}

        if image_id not in self.parent.disk_lookup:
            self.parent.disk_lookup[image_id] = self

        self._apply_config(image_config)

        if not size:
            # Size/features are not stored in the config, since it can be changed
            # outside of this tool-chain, so we get them dynamically
            self._refresh_config()
        else:
            # size and features have been passed in from the Disks.refresh
            # method
            self.size = size
            self.size_h = human_size(self.size)
            self.features = features
            self.feature_list = self._get_features()
            self._parse_snapshots(snapshots)

        # update the parent's disk info map
        disk_map = self.parent.disk_info
        disk_map[self.image_id]['size'] = self.size
        disk_map[self.image_id]['size_h'] = self.size_h
Beispiel #7
0
    def __init__(self,
                 parent,
                 image_id,
                 image_config,
                 size=None,
                 features=None):
        """
        Create a disk entry under the Disks subtree
        :param parent: parent object (instance of the Disks class)
        :param image_id: key used in the config object for this rbd image
               (pool.image_name) - str
        :param image_config: meta data for this image
        :return:
        """
        self.pool, self.rbd_image = image_id.split('.', 1)

        UINode.__init__(self, image_id, parent)

        self.image_id = image_id
        self.size = 0
        self.size_h = ''
        self.features = 0
        self.feature_list = []
        self.ceph_cluster = self.parent.parent.ceph.local_ceph.name

        disk_map = self.parent.disk_info
        if image_id not in disk_map:
            disk_map[image_id] = {}

        if image_id not in self.parent.disk_lookup:
            self.parent.disk_lookup[image_id] = self

        # set the remaining attributes based on the fields in the dict
        for k, v in image_config.iteritems():
            disk_map[image_id][k] = v
            self.__setattr__(k, v)

        if not size:
            # Size/features are not stored in the config, since it can be changed
            # outside of this tool-chain, so we get them dynamically
            self.get_meta_data_tcmu()
        else:
            # size and features have been passed in from the Disks.refresh
            # method
            self.size = size
            self.features = features

        self.size_h = human_size(self.size)
        self.feature_list = self._get_features()

        # update the parent's disk info map
        disk_map = self.parent.disk_info
        disk_map[self.image_id]['size'] = self.size
        disk_map[self.image_id]['size_h'] = self.size_h
Beispiel #8
0
 def _get_meta_data_tcmu(self):
     """
     query the rbd to get the features and size of the rbd
     :return:
     """
     self.logger.debug("Refreshing image metadata")
     with rados.Rados(conffile=settings.config.cephconf) as cluster:
         with cluster.open_ioctx(self.pool) as ioctx:
             with rbd.Image(ioctx, self.image) as rbd_image:
                 self.size = rbd_image.size()
                 self.size_h = human_size(self.size)
                 self.features = rbd_image.features()
                 self.feature_list = self._get_features()
                 self._parse_snapshots(list(rbd_image.list_snaps()))
Beispiel #9
0
    def get_meta_data(self):
        # image_path is a symlink to the actual /dev/rbdX file
        image_path = "/dev/rbd/{}/{}".format(self.pool, self.rbd_image)
        dev_id = os.path.realpath(image_path)[8:]
        rbd_path = "/sys/devices/rbd/{}".format(dev_id)
        self.features = readcontents(os.path.join(rbd_path, 'features'))
        self.size = int(readcontents(os.path.join(rbd_path, 'size')))
        self.size_h = human_size(self.size)

        # update the parent's disk info map
        disk_map = self.parent.disk_info

        disk_map[self.image_id]['size'] = self.size
        disk_map[self.image_id]['size_h'] = self.size_h
Beispiel #10
0
    def get_meta_data_tcmu(self):
        """
        query the rbd to get the features and size of the rbd
        :return:
        """
        with rados.Rados(conffile=settings.config.cephconf) as cluster:
            with cluster.open_ioctx(self.pool) as ioctx:
                with rbd.Image(ioctx, self.image) as rbd_image:
                    self.size = rbd_image.size()
                    self.size_h = human_size(self.size)
                    self.features = rbd_image.features()
                    self.feature_list = self._get_features()

        # update the parent's disk info map
        disk_map = self.parent.disk_info

        disk_map[self.image_id]['size'] = self.size
        disk_map[self.image_id]['size_h'] = self.size_h
Beispiel #11
0
 def summary(self):
     msg = ["Commit: {}".format(human_size(self.commit))]
     msg.append("Avail: {}".format(human_size(self.max_bytes)))
     msg.append("Used: {}".format(human_size(self.used_bytes)))
     msg.append("Commit%: {}%".format(self.overcommit_PCT))
     return ', '.join(msg), True
Beispiel #12
0
 def summary(self):
     total_bytes = 0
     for disk in self.children:
         total_bytes += disk.size
     return '{}, Disks: {}'.format(human_size(total_bytes),
                                   len(self.children)), None