Exemplo n.º 1
0
def cim_pool_to_lsm_pool(smis_common, cim_pool, system_id):
    """
    Return a Pool object base on information of cim_pool.
    Assuming cim_pool already holding correct properties.
    """
    status_info = ''
    pool_id = pool_id_of_cim_pool(cim_pool)
    name = ''
    total_space = Pool.TOTAL_SPACE_NOT_FOUND
    free_space = Pool.FREE_SPACE_NOT_FOUND
    status = Pool.STATUS_OK
    if 'ElementName' in cim_pool:
        name = cim_pool['ElementName']
    if 'TotalManagedSpace' in cim_pool:
        total_space = cim_pool['TotalManagedSpace']
    if 'RemainingManagedSpace' in cim_pool:
        free_space = cim_pool['RemainingManagedSpace']
    if 'OperationalStatus' in cim_pool:
        (status,
         status_info) = _pool_status_of_cim_pool(cim_pool['OperationalStatus'])

    element_type, unsupported = _pool_element_type(smis_common, cim_pool)

    plugin_data = cim_path_to_path_str(cim_pool.path)

    return Pool(pool_id, name, element_type, unsupported, total_space,
                free_space, status, status_info, system_id, plugin_data)
Exemplo n.º 2
0
    def _dg_top_to_lsm_pool(self, dg_top, free_space_list, ctrl_num,
                            dg_show_output, is_in_cc):
        sys_id = self._sys_id_of_ctrl_num(ctrl_num)
        pool_id = _pool_id_of(dg_top['DG'], sys_id)
        name = '%s Disk Group %s' % (dg_top['Type'], dg_top['DG'])
        elem_type = Pool.ELEMENT_TYPE_VOLUME | Pool.ELEMENT_TYPE_VOLUME_FULL
        unsupported_actions = 0
        # TODO(Gris Ge): contact LSI to get accurate total space and free
        #                space. The size we are using here is not what host
        #                got.
        total_space = _mega_size_to_lsm(dg_top['Size'])
        free_space = MegaRAID._dg_free_size(dg_top['DG'], free_space_list)
        status = _pool_status_of(dg_top)
        status_info = ''

        for dg_drv in dg_show_output['DG Drive LIST']:
            if dg_drv['DG'] != dg_top['DG']:
                continue
            if dg_drv['State'] == 'Rbld':
                status |= Pool.STATUS_RECONSTRUCTING

        if is_in_cc:
            status |= Pool.STATUS_VERIFYING

        if status == Pool.STATUS_UNKNOWN:
            status_info = dg_top['State']

        plugin_data = "/c%d/d%s" % (ctrl_num, dg_top['DG'])

        return Pool(pool_id, name, elem_type, unsupported_actions, total_space,
                    free_space, status, status_info, sys_id, plugin_data)
Exemplo n.º 3
0
    def pools(self, search_key=None, search_value=None, flags=0):
        pools = []
        for pool in self._jsonrequest("pool_list"):
            if pool['name'].startswith('/'):
                et = Pool.ELEMENT_TYPE_FS
            else:
                et = Pool.ELEMENT_TYPE_VOLUME

            pools.append(
                Pool(pool['name'], pool['name'], et, 0, pool['size'],
                     pool['free_size'], Pool.STATUS_UNKNOWN, '', 'targetd'))
        return search_property(pools, search_key, search_value)
Exemplo n.º 4
0
    def _arcconf_array_to_lsm_pool(ld_name, sys_id, ctrl_num):
        pool_id = '%s:%s' % (ctrl_num, ld_name)
        name = 'Array' + str(ld_name)
        elem_type = Pool.ELEMENT_TYPE_VOLUME | Pool.ELEMENT_TYPE_VOLUME_FULL
        unsupported_actions = 0
        free_space = 0
        total_space = 0
        # TODO Need to have a logic for finding free space and total space.

        status = Pool.STATUS_OK
        status_info = ''
        plugin_data = "%s:%s" % (ctrl_num, ld_name)

        return Pool(pool_id, name, elem_type, unsupported_actions, total_space,
                    free_space, status, status_info, sys_id, plugin_data)
Exemplo n.º 5
0
 def pools(self, search_key=None, search_value=None, flags=0):
     pools = []
     parts = list_mounts()
     for prt in parts:
         try:
             (total_size, avail_size) = NFSPlugin._get_fs_sizes(prt)
             fsid = get_fsid(prt)
             pooltype = Pool.ELEMENT_TYPE_FS
             unsup_actions = 0
             status = System.STATUS_OK
             status_info = ''
             pools.append(
                 Pool(fsid, prt, pooltype, unsup_actions, total_size,
                      avail_size, status, status_info, self._SYSID))
         except OSError:
             pass
     return search_property(pools, search_key, search_value)
Exemplo n.º 6
0
    def _hp_array_to_lsm_pool(hp_array, array_name, sys_id, ctrl_num):
        pool_id = _pool_id_of(sys_id, array_name)
        name = array_name
        elem_type = Pool.ELEMENT_TYPE_VOLUME | Pool.ELEMENT_TYPE_VOLUME_FULL
        unsupported_actions = 0
        # TODO(Gris Ge): HP does not provide a precise number of bytes.
        free_space = _hp_size_to_lsm(hp_array['Unused Space'])
        total_space = free_space
        for key_name in hp_array.keys():
            if key_name.startswith('Logical Drive'):
                total_space += _hp_size_to_lsm(hp_array[key_name]['Size'])

        (status, status_info) = _pool_status_of(hp_array)

        plugin_data = "%s:%s" % (ctrl_num, array_name[len("Array: "):])

        return Pool(pool_id, name, elem_type, unsupported_actions, total_space,
                    free_space, status, status_info, sys_id, plugin_data)
Exemplo n.º 7
0
    def pools(self, search_key=None, search_value=None, flags=0):
        pools_list = self._request("get_all_names", "volume", [""])

        pools = []
        for pool in pools_list:
            if pool == 'syspool':
                continue
            pool_info = self._request("get_child_props", "volume",
                                      [str(pool), ""])

            pools.append(Pool(pool_info['name'], pool_info['name'],
                              Pool.ELEMENT_TYPE_VOLUME |
                              Pool.ELEMENT_TYPE_VOLUME_THIN |
                              Pool.ELEMENT_TYPE_FS,
                              0,
                              NexentaStor._to_bytes(pool_info['size']),
                              NexentaStor._to_bytes(pool_info['free']),
                              Pool.STATUS_UNKNOWN, '', self.system.id))

        return search_property(pools, search_key, search_value)
Exemplo n.º 8
0
    def _arcconf_array_to_lsm_pool(arcconf_array):
        sys_id = arcconf_array['sys_id']
        array_id = arcconf_array['arrayID']
        array_name = arcconf_array['arrayName']
        block_size = arcconf_array['blockSize']
        total_size = arcconf_array['totalSize']
        unused_size = arcconf_array['unUsedSpace']
        ctrl_num = arcconf_array['ctrl_num']

        pool_id = '%s:%s' % (sys_id, array_id)
        name = 'Array ' + str(array_name)
        elem_type = Pool.ELEMENT_TYPE_VOLUME | Pool.ELEMENT_TYPE_VOLUME_FULL
        unsupported_actions = 0
        free_space = int(block_size) * int(unused_size)
        total_space = int(block_size) * int(total_size)

        status = Pool.STATUS_OK
        status_info = ''
        plugin_data = '%s:%s' % (ctrl_num, array_id)

        return Pool(pool_id, name, elem_type, unsupported_actions, total_space,
                    free_space, status, status_info, sys_id, plugin_data)