Пример #1
0
def cim_vol_of_cim_pool_path(smis_common, cim_pool_path, property_list=None):
    """
    Use this association to get a list of CIM_StorageVolume:
        CIM_StoragePool
            |
            |   CIM_AllocatedFromStoragePool
            |
            v
        CIM_StorageVolume
    CIM_StorageVolume['Usage'] == dmtf.VOL_USAGE_SYS_RESERVED will be filtered
    out.
    Return a list of CIM_StorageVolume.
    """
    if property_list is None:
        property_list = ['Usage']
    else:
        property_list = merge_list(property_list, ['Usage'])

    cim_vols = smis_common.Associators(
        cim_pool_path,
        AssocClass='CIM_AllocatedFromStoragePool',
        ResultClass='CIM_StorageVolume',
        PropertyList=property_list)

    needed_cim_vols = []
    for cim_vol in cim_vols:
        if 'Usage' not in cim_vol or \
           cim_vol['Usage'] != dmtf.VOL_USAGE_SYS_RESERVED:
            needed_cim_vols.append(cim_vol)
    return needed_cim_vols
Пример #2
0
def cim_vol_of_cim_pool_path(smis_common, cim_pool_path, property_list=None):
    """
    Use this association to get a list of CIM_StorageVolume:
        CIM_StoragePool
            |
            |   CIM_AllocatedFromStoragePool
            |
            v
        CIM_StorageVolume
    CIM_StorageVolume['Usage'] == dmtf.VOL_USAGE_SYS_RESERVED will be filtered
    out.
    Return a list of CIM_StorageVolume.
    """
    if property_list is None:
        property_list = ['Usage']
    else:
        property_list = merge_list(property_list, ['Usage'])

    cim_vols = smis_common.Associators(
        cim_pool_path,
        AssocClass='CIM_AllocatedFromStoragePool',
        ResultClass='CIM_StorageVolume',
        PropertyList=property_list)

    needed_cim_vols = []
    for cim_vol in cim_vols:
        if 'Usage' not in cim_vol or \
           cim_vol['Usage'] != dmtf.VOL_USAGE_SYS_RESERVED:
            needed_cim_vols.append(cim_vol)
    return needed_cim_vols
Пример #3
0
def cim_pools_of_cim_sys_path(smis_common, cim_sys_path, property_list=None):
    """
    Use this association to get a list of CIM_StoragePool:
            CIM_ComputerSystem
                 |
                 | (CIM_HostedStoragePool)
                 |
                 v
            CIM_StoragePool
    As 'Block Services Package' is mandatory for 'Array' profile which already
    checked by plugin_register(), we don't do any profile check here.
    Primordial pool will be eliminated from return list.
    These pools will be eliminated also:
        * Spare pool with CIM_StoragePool['Usage'] == dmtf.POOL_USAGE_SPARE
        * IBM ArrayPool(IBMTSDS_ArrayPool)
        * IBM ArraySitePool(IBMTSDS_ArraySitePool)
    """
    if property_list is None:
        property_list = ['Primordial', 'Usage']
    else:
        property_list = merge_list(property_list, ['Primordial', 'Usage'])

    cim_pools = smis_common.Associators(
        cim_sys_path,
        AssocClass='CIM_HostedStoragePool',
        ResultClass='CIM_StoragePool',
        PropertyList=property_list)

    rc = []
    for cim_pool in cim_pools:
        if 'Primordial' in cim_pool and cim_pool['Primordial']:
            continue
        if 'Usage' in cim_pool and cim_pool['Usage'] == dmtf.POOL_USAGE_SPARE:
            continue
        # Skip IBM ArrayPool and ArraySitePool
        # ArrayPool is holding RAID info.
        # ArraySitePool is holding 8 disks. Predefined by array.
        # ArraySite --(1to1 map) --> Array --(1to1 map)--> Rank

        # By design when user get a ELEMENT_TYPE_POOL only pool,
        # user can assume he/she can allocate spaces from that pool
        # to create a new pool with ELEMENT_TYPE_VOLUME or
        # ELEMENT_TYPE_FS ability.

        # If we expose them out, we will have two kind of pools
        # (ArrayPool and ArraySitePool) having element_type &
        # ELEMENT_TYPE_POOL, but none of them can create a
        # ELEMENT_TYPE_VOLUME pool.
        # Only RankPool can create a ELEMENT_TYPE_VOLUME pool.

        # We are trying to hide the detail to provide a simple
        # abstraction.
        if cim_pool.classname == 'IBMTSDS_ArrayPool' or \
           cim_pool.classname == 'IBMTSDS_ArraySitePool':
            continue
        rc.append(cim_pool)

    return rc
Пример #4
0
def cim_pools_of_cim_sys_path(smis_common, cim_sys_path, property_list=None):
    """
    Use this association to get a list of CIM_StoragePool:
            CIM_ComputerSystem
                 |
                 | (CIM_HostedStoragePool)
                 |
                 v
            CIM_StoragePool
    As 'Block Services Package' is mandatory for 'Array' profile which already
    checked by plugin_register(), we don't do any profile check here.
    Primordial pool will be eliminated from return list.
    These pools will be eliminated also:
        * Spare pool with CIM_StoragePool['Usage'] == dmtf.POOL_USAGE_SPARE
        * IBM ArrayPool(IBMTSDS_ArrayPool)
        * IBM ArraySitePool(IBMTSDS_ArraySitePool)
    """
    if property_list is None:
        property_list = ['Primordial', 'Usage']
    else:
        property_list = merge_list(property_list, ['Primordial', 'Usage'])

    cim_pools = smis_common.Associators(cim_sys_path,
                                        AssocClass='CIM_HostedStoragePool',
                                        ResultClass='CIM_StoragePool',
                                        PropertyList=property_list)

    rc = []
    for cim_pool in cim_pools:
        if 'Primordial' in cim_pool and cim_pool['Primordial']:
            continue
        if 'Usage' in cim_pool and cim_pool['Usage'] == dmtf.POOL_USAGE_SPARE:
            continue
        # Skip IBM ArrayPool and ArraySitePool
        # ArrayPool is holding RAID info.
        # ArraySitePool is holding 8 disks. Predefined by array.
        # ArraySite --(1to1 map) --> Array --(1to1 map)--> Rank

        # By design when user get a ELEMENT_TYPE_POOL only pool,
        # user can assume he/she can allocate spaces from that pool
        # to create a new pool with ELEMENT_TYPE_VOLUME or
        # ELEMENT_TYPE_FS ability.

        # If we expose them out, we will have two kind of pools
        # (ArrayPool and ArraySitePool) having element_type &
        # ELEMENT_TYPE_POOL, but none of them can create a
        # ELEMENT_TYPE_VOLUME pool.
        # Only RankPool can create a ELEMENT_TYPE_VOLUME pool.

        # We are trying to hide the detail to provide a simple
        # abstraction.
        if cim_pool.classname == 'IBMTSDS_ArrayPool' or \
           cim_pool.classname == 'IBMTSDS_ArraySitePool':
            continue
        rc.append(cim_pool)

    return rc
Пример #5
0
def cim_sys_of_sys_id(smis_common, sys_id, property_list=None):
    """
    Find out the CIM_ComputerSystem for given lsm.System.id using
    root_cim_sys()
    """
    id_pros = cim_sys_id_pros()
    if property_list is None:
        property_list = id_pros
    else:
        property_list = merge_list(property_list, id_pros)

    cim_syss = root_cim_sys(smis_common, property_list)
    for cim_sys in cim_syss:
        if sys_id_of_cim_sys(cim_sys) == sys_id:
            return cim_sys
    raise LsmError(
        ErrorNumber.NOT_FOUND_SYSTEM,
        "Not found System")
Пример #6
0
    def cim_job_of_job_id(self, job_id, property_list=None):
        """
        Return CIM_ConcreteJob for given job_id.
        """
        if property_list is None:
            property_list = SmisCommon.cim_job_pros()
        else:
            property_list = merge_list(property_list,
                                       SmisCommon.cim_job_pros())

        cim_jobs = self.EnumerateInstances('CIM_ConcreteJob',
                                           PropertyList=property_list)
        real_job_id = SmisCommon.parse_job_id(job_id)[0]
        for cim_job in cim_jobs:
            if md5(cim_job['InstanceID']) == real_job_id:
                return cim_job

        raise LsmError(ErrorNumber.NOT_FOUND_JOB, "Job %s not found" % job_id)
Пример #7
0
def _pri_cim_ext_of_cim_disk(smis_common, cim_disk_path, property_list=None):
    """
    Usage:
        Find out the Primordial CIM_StorageExtent of CIM_DiskDrive
        In SNIA SMI-S 1.4 rev.6 Block book, section 11.1.1 'Base Model'
        quote:
        A disk drive is modeled as a single MediaAccessDevice (DiskDrive)
        That shall be linked to a single StorageExtent (representing the
        storage in the drive) by a MediaPresent association. The
        StorageExtent class represents the storage of the drive and
        contains its size.
    Parameter:
        cim_disk_path   # CIM_InstanceName of CIM_DiskDrive
        property_list   # a List of properties needed on returned
                        # CIM_StorageExtent
    Returns:
        cim_pri_ext     # The CIM_Instance of Primordial CIM_StorageExtent
    Exceptions:
        LsmError
            ErrorNumber.LSM_PLUGIN_BUG  # Failed to find out pri cim_ext
    """
    if property_list is None:
        property_list = ['Primordial']
    else:
        property_list = merge_list(property_list, ['Primordial'])

    cim_exts = smis_common.Associators(
        cim_disk_path,
        AssocClass='CIM_MediaPresent',
        ResultClass='CIM_StorageExtent',
        PropertyList=property_list)
    cim_exts = [p for p in cim_exts if p["Primordial"]]
    if len(cim_exts) == 1:
        # As SNIA commanded, only _ONE_ Primordial CIM_StorageExtent for
        # each CIM_DiskDrive
        return cim_exts[0]
    else:
        raise LsmError(ErrorNumber.PLUGIN_BUG,
                       "_pri_cim_ext_of_cim_disk(): "
                       "Got unexpected count of Primordial " +
                       "CIM_StorageExtent for CIM_DiskDrive: %s, %s " %
                       (cim_disk_path, cim_exts))
Пример #8
0
def _pri_cim_ext_of_cim_disk(smis_common, cim_disk_path, property_list=None):
    """
    Usage:
        Find out the Primordial CIM_StorageExtent of CIM_DiskDrive
        In SNIA SMI-S 1.4 rev.6 Block book, section 11.1.1 'Base Model'
        quote:
        A disk drive is modeled as a single MediaAccessDevice (DiskDrive)
        That shall be linked to a single StorageExtent (representing the
        storage in the drive) by a MediaPresent association. The
        StorageExtent class represents the storage of the drive and
        contains its size.
    Parameter:
        cim_disk_path   # CIM_InstanceName of CIM_DiskDrive
        property_list   # a List of properties needed on returned
                        # CIM_StorageExtent
    Returns:
        cim_pri_ext     # The CIM_Instance of Primordial CIM_StorageExtent
    Exceptions:
        LsmError
            ErrorNumber.LSM_PLUGIN_BUG  # Failed to find out pri cim_ext
    """
    if property_list is None:
        property_list = ['Primordial']
    else:
        property_list = merge_list(property_list, ['Primordial'])

    cim_exts = smis_common.Associators(cim_disk_path,
                                       AssocClass='CIM_MediaPresent',
                                       ResultClass='CIM_StorageExtent',
                                       PropertyList=property_list)
    cim_exts = [p for p in cim_exts if p["Primordial"]]
    if len(cim_exts) == 1:
        # As SNIA commanded, only _ONE_ Primordial CIM_StorageExtent for
        # each CIM_DiskDrive
        return cim_exts[0]
    else:
        raise LsmError(
            ErrorNumber.PLUGIN_BUG, "_pri_cim_ext_of_cim_disk(): "
            "Got unexpected count of Primordial " +
            "CIM_StorageExtent for CIM_DiskDrive: %s, %s " %
            (cim_disk_path, cim_exts))
Пример #9
0
def root_cim_sys(smis_common, property_list=None):
    """
    Use this association to find out the root CIM_ComputerSystem:
        CIM_RegisteredProfile       # Root Profile('Array') in interop
                 |
                 | CIM_ElementConformsToProfile
                 v
        CIM_ComputerSystem          # vendor namespace
    """
    id_pros = cim_sys_id_pros()
    if property_list is None:
        property_list = id_pros
    else:
        property_list = merge_list(property_list, id_pros)

    if smis_common.is_megaraid():
        cim_syss = smis_common.EnumerateInstances(
            'CIM_ComputerSystem', PropertyList=property_list)
    else:
        cim_syss = smis_common.Associators(
            smis_common.root_blk_cim_rp.path,
            ResultClass='CIM_ComputerSystem',
            AssocClass='CIM_ElementConformsToProfile',
            PropertyList=property_list)

        if len(cim_syss) == 0:
            raise LsmError(ErrorNumber.NO_SUPPORT,
                           "Current SMI-S provider does not provide "
                           "the root CIM_ComputerSystem associated "
                           "to 'Array' CIM_RegisteredProfile.")

    # System URI Filtering
    if smis_common.system_list:
        needed_cim_syss = []
        for cim_sys in cim_syss:
            if sys_id_of_cim_sys(cim_sys) in smis_common.system_list:
                needed_cim_syss.extend([cim_sys])
        return needed_cim_syss
    else:
        return cim_syss