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 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.º 3
0
def cim_init_mg_to_lsm_ag(smis_common, cim_init_mg, system_id):
    """
    Convert CIM_InitiatorMaskingGroup to lsm.AccessGroup
    """
    ag_name = cim_init_mg['ElementName']
    ag_id = md5(cim_init_mg['InstanceID'])
    cim_inits = cim_init_of_cim_init_mg_path(smis_common, cim_init_mg.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_init_mg.path)
    return AccessGroup(ag_id, ag_name, init_ids, init_type, system_id,
                       plugin_data)
Exemplo n.º 4
0
def cim_spc_to_lsm_ag(smis_common, cim_spc, system_id):
    """
    Convert CIM_SCSIProtocolController to lsm.AccessGroup
    """
    ag_id = md5(cim_spc['DeviceID'])
    ag_name = cim_spc['ElementName']
    cim_inits = cim_init_of_cim_spc_path(smis_common, cim_spc.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_spc.path)
    return AccessGroup(ag_id, ag_name, init_ids, init_type, system_id,
                       plugin_data)
Exemplo n.º 5
0
def cim_init_mg_to_lsm_ag(smis_common, cim_init_mg, system_id):
    """
    Convert CIM_InitiatorMaskingGroup to lsm.AccessGroup
    """
    ag_name = cim_init_mg['ElementName']
    ag_id = md5(cim_init_mg['InstanceID'])
    cim_inits = cim_init_of_cim_init_mg_path(smis_common, cim_init_mg.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_init_mg.path)
    return AccessGroup(
        ag_id, ag_name, init_ids, init_type, system_id, plugin_data)
Exemplo n.º 6
0
def cim_spc_to_lsm_ag(smis_common, cim_spc, system_id):
    """
    Convert CIM_SCSIProtocolController to lsm.AccessGroup
    """
    ag_id = md5(cim_spc['DeviceID'])
    ag_name = cim_spc['ElementName']
    cim_inits = cim_init_of_cim_spc_path(smis_common, cim_spc.path)
    (init_ids, init_type) = _init_id_and_type_of(cim_inits)
    plugin_data = cim_path_to_path_str(cim_spc.path)
    return AccessGroup(
        ag_id, ag_name, init_ids, init_type, system_id, plugin_data)
Exemplo n.º 7
0
def cim_vol_to_lsm_vol(cim_vol, pool_id, sys_id):
    """
    Takes a CIMInstance that represents a volume and returns a lsm Volume
    """

    # This is optional (User friendly name)
    if 'ElementName' in cim_vol:
        user_name = cim_vol["ElementName"]
    else:
        # Better fallback value?
        user_name = cim_vol['DeviceID']

    vpd_83 = _vpd83_of_cim_vol(cim_vol)

    admin_state = Volume.ADMIN_STATE_ENABLED

    plugin_data = cim_path_to_path_str(cim_vol.path)

    return Volume(vol_id_of_cim_vol(cim_vol), user_name, vpd_83,
                  cim_vol["BlockSize"], cim_vol["NumberOfBlocks"], admin_state,
                  sys_id, pool_id, plugin_data)
Exemplo n.º 8
0
def cim_vol_to_lsm_vol(cim_vol, pool_id, sys_id):
    """
    Takes a CIMInstance that represents a volume and returns a lsm Volume
    """

    # This is optional (User friendly name)
    if 'ElementName' in cim_vol:
        user_name = cim_vol["ElementName"]
    else:
        #Better fallback value?
        user_name = cim_vol['DeviceID']

    vpd_83 = _vpd83_of_cim_vol(cim_vol)

    admin_state = Volume.ADMIN_STATE_ENABLED

    plugin_data = cim_path_to_path_str(cim_vol.path)

    return Volume(
        vol_id_of_cim_vol(cim_vol), user_name, vpd_83,
        cim_vol["BlockSize"], cim_vol["NumberOfBlocks"], admin_state, sys_id,
        pool_id, plugin_data)