Example #1
0
def query_aggr_storage_disk(na_server, aggr):
    """Queries for storage disks associated to an aggregate."""
    query = {'storage-disk-info': {'disk-raid-info':
                                   {'disk-aggregate-info':
                                       {'aggregate-name': aggr}}}}
    des_attr = {'storage-disk-info':
                {'disk-raid-info': ['effective-disk-type']}}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='storage-disk-get-iter',
                                     api_family='cm', query=query,
                                     des_result=des_attr,
                                     additional_elems=None,
                                     is_iter=True)
        for res in result:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                storage_disks = attr_list.get_children()
                for disk in storage_disks:
                    raid_info = disk.get_child_by_name('disk-raid-info')
                    if raid_info:
                        eff_disk_type =\
                            raid_info.get_child_content('effective-disk-type')
                        if eff_disk_type:
                            return eff_disk_type
                        else:
                            continue
    except Exception as e:
        LOG.debug("Exception querying storage disk. %s", e)
    return 'unknown'
Example #2
0
def query_cluster_vols_for_ssc(na_server, vserver, volume=None):
    """Queries cluster volumes for ssc."""
    query = {'volume-attributes': None}
    volume_id = {'volume-id-attributes': {'owning-vserver-name': vserver}}
    if volume:
        volume_id['volume-id-attributes']['name'] = volume
    query['volume-attributes'] = volume_id
    des_attr = {'volume-attributes':
                ['volume-id-attributes',
                 'volume-space-attributes',
                 'volume-state-attributes',
                 'volume-qos-attributes']}
    result = na_utils.invoke_api(na_server, api_name='volume-get-iter',
                                 api_family='cm', query=query,
                                 des_result=des_attr,
                                 additional_elems=None,
                                 is_iter=True)
    vols = set()
    for res in result:
        records = res.get_child_content('num-records')
        if records > 0:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                vol_attrs = attr_list.get_children()
                vols_found = create_vol_list(vol_attrs)
                vols.update(vols_found)
    return vols
Example #3
0
def get_snapmirror_vol_dict(na_server, vserver, volume=None):
    """Queries snapmirror volumes."""
    mirrored_vols = {}
    query_attr = {'source-vserver': vserver}
    if volume:
        query_attr['source-volume'] = volume
    query = {'snapmirror-info': query_attr}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='snapmirror-get-iter',
                                     api_family='cm', query=query,
                                     is_iter=True)
        for res in result:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                snap_info = attr_list.get_children()
                for snap in snap_info:
                    src_volume = snap.get_child_content('source-volume')
                    v_snap = {}
                    v_snap['dest_loc'] =\
                        snap.get_child_content('destination-location')
                    v_snap['rel_type'] =\
                        snap.get_child_content('relationship-type')
                    v_snap['mirr_state'] =\
                        snap.get_child_content('mirror-state')
                    if mirrored_vols.get(src_volume):
                        mirrored_vols.get(src_volume).append(v_snap)
                    else:
                        mirrored_vols[src_volume] = [v_snap]
    except Exception as e:
        LOG.debug("Exception querying mirror information. %s", e)
    return mirrored_vols
Example #4
0
def query_aggr_options(na_server, aggr_name):
    """Queries cluster aggr for attributes.

        Currently queries for raid and ha-policy.
    """

    add_elems = {'aggregate': aggr_name}
    attrs = {}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='aggr-options-list-info',
                                     api_family='cm', query=None,
                                     des_result=None,
                                     additional_elems=add_elems,
                                     is_iter=False)
        for res in result:
            options = res.get_child_by_name('options')
            if options:
                op_list = options.get_children()
                for op in op_list:
                    if op.get_child_content('name') == 'ha_policy':
                        attrs['ha_policy'] = op.get_child_content('value')
                    if op.get_child_content('name') == 'raidtype':
                        attrs['raid_type'] = op.get_child_content('value')
    except Exception as e:
        LOG.debug("Exception querying aggr options. %s", e)
    return attrs
Example #5
0
def query_aggr_storage_disk(na_server, aggr):
    """Queries for storage disks assosiated to an aggregate."""
    query = {'storage-disk-info': {'disk-raid-info':
                                   {'disk-aggregate-info':
                                       {'aggregate-name': aggr}}}}
    des_attr = {'storage-disk-info':
                {'disk-raid-info': ['effective-disk-type']}}
    result = na_utils.invoke_api(na_server,
                                 api_name='storage-disk-get-iter',
                                 api_family='cm', query=query,
                                 des_result=des_attr,
                                 additional_elems=None,
                                 is_iter=True)
    for res in result:
        attr_list = res.get_child_by_name('attributes-list')
        if attr_list:
            storage_disks = attr_list.get_children()
            for disk in storage_disks:
                raid_info = disk.get_child_by_name('disk-raid-info')
                if raid_info:
                    eff_disk_type =\
                        raid_info.get_child_content('effective-disk-type')
                    if eff_disk_type:
                        return eff_disk_type
                    else:
                        continue
    return 'unknown'
Example #6
0
def query_cluster_vols_for_ssc(na_server, vserver, volume=None):
    """Queries cluster volumes for ssc."""
    query = {'volume-attributes': None}
    volume_id = {'volume-id-attributes': {'owning-vserver-name': vserver}}
    if volume:
        volume_id['volume-id-attributes']['name'] = volume
    query['volume-attributes'] = volume_id
    des_attr = {'volume-attributes':
                ['volume-id-attributes',
                 'volume-mirror-attributes',
                 'volume-space-attributes',
                 'volume-state-attributes',
                 'volume-qos-attributes']}
    result = na_utils.invoke_api(na_server, api_name='volume-get-iter',
                                 api_family='cm', query=query,
                                 des_result=des_attr,
                                 additional_elems=None,
                                 is_iter=True)
    vols = set()
    for res in result:
        records = res.get_child_content('num-records')
        if records > 0:
            attr_list = res['attributes-list']
            vol_attrs = attr_list.get_children()
            vols_found = create_vol_list(vol_attrs)
            vols.update(vols_found)
    return vols
Example #7
0
def get_snapmirror_vol_dict(na_server, vserver, volume=None):
    """Queries snapmirror volumes."""
    mirrored_vols = {}
    query_attr = {'source-vserver': vserver}
    if volume:
        query_attr['source-volume'] = volume
    query = {'snapmirror-info': query_attr}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='snapmirror-get-iter',
                                     api_family='cm', query=query,
                                     is_iter=True)
        for res in result:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                snap_info = attr_list.get_children()
                for snap in snap_info:
                    src_volume = snap.get_child_content('source-volume')
                    v_snap = {}
                    v_snap['dest_loc'] =\
                        snap.get_child_content('destination-location')
                    v_snap['rel_type'] =\
                        snap.get_child_content('relationship-type')
                    v_snap['mirr_state'] =\
                        snap.get_child_content('mirror-state')
                    if mirrored_vols.get(src_volume):
                        mirrored_vols.get(src_volume).append(v_snap)
                    else:
                        mirrored_vols[src_volume] = [v_snap]
    except Exception as e:
        LOG.debug("Exception querying mirror information. %s", e)
    return mirrored_vols
Example #8
0
def query_aggr_options(na_server, aggr_name):
    """Queries cluster aggr for attributes.

        Currently queries for raid and ha-policy.
    """

    add_elems = {'aggregate': aggr_name}
    attrs = {}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='aggr-options-list-info',
                                     api_family='cm', query=None,
                                     des_result=None,
                                     additional_elems=add_elems,
                                     is_iter=False)
        for res in result:
            options = res.get_child_by_name('options')
            if options:
                op_list = options.get_children()
                for op in op_list:
                    if op.get_child_content('name') == 'ha_policy':
                        attrs['ha_policy'] = op.get_child_content('value')
                    if op.get_child_content('name') == 'raidtype':
                        attrs['raid_type'] = op.get_child_content('value')
    except Exception as e:
        LOG.debug("Exception querying aggr options. %s", e)
    return attrs
Example #9
0
File: nfs.py Project: jcru/cinder
 def _get_verver_ips(self, vserver):
     """Get ips for the vserver."""
     result = na_utils.invoke_api(self._client, api_name="net-interface-get-iter", is_iter=True, tunnel=vserver)
     if_list = []
     for res in result:
         records = res.get_child_content("num-records")
         if records > 0:
             attr_list = res["attributes-list"]
             ifs = attr_list.get_children()
             if_list.extend(ifs)
     return if_list
Example #10
0
 def _get_verver_ips(self, vserver):
     """Get ips for the vserver."""
     result = na_utils.invoke_api(self._client,
                                  api_name='net-interface-get-iter',
                                  is_iter=True,
                                  tunnel=vserver)
     if_list = []
     for res in result:
         records = res.get_child_content('num-records')
         if records > 0:
             attr_list = res['attributes-list']
             ifs = attr_list.get_children()
             if_list.extend(ifs)
     return if_list
Example #11
0
def get_sis_vol_dict(na_server, vserver, volume=None):
    """Queries sis for volumes.

        If volume is present sis is queried for it.
        Records dedup and compression enabled.
    """

    sis_vols = {}
    query_attr = {'vserver': vserver}
    if volume:
        vol_path = '/vol/%s' % (volume)
        query_attr['path'] = vol_path
    query = {'sis-status-info': query_attr}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='sis-get-iter',
                                     api_family='cm',
                                     query=query,
                                     is_iter=True)
        for res in result:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                sis_status = attr_list.get_children()
                for sis in sis_status:
                    path = sis.get_child_content('path')
                    if not path:
                        continue
                    (___, __, vol) = path.rpartition('/')
                    if not vol:
                        continue
                    v_sis = {}
                    v_sis['compression'] = na_utils.to_bool(
                        sis.get_child_content('is-compression-enabled'))
                    v_sis['dedup'] = na_utils.to_bool(
                        sis.get_child_content('state'))
                    sis_vols[vol] = v_sis
    except Exception as e:
        LOG.debug("Exception querying sis information. %s", e)
    return sis_vols
Example #12
0
def get_sis_vol_dict(na_server, vserver, volume=None):
    """Queries sis for volumes.

        If volume is present sis is queried for it.
        Records dedup and compression enabled.
    """

    sis_vols = {}
    query_attr = {'vserver': vserver}
    if volume:
        vol_path = '/vol/%s' % (volume)
        query_attr['path'] = vol_path
    query = {'sis-status-info': query_attr}
    try:
        result = na_utils.invoke_api(na_server,
                                     api_name='sis-get-iter',
                                     api_family='cm',
                                     query=query,
                                     is_iter=True)
        for res in result:
            attr_list = res.get_child_by_name('attributes-list')
            if attr_list:
                sis_status = attr_list.get_children()
                for sis in sis_status:
                    path = sis.get_child_content('path')
                    if not path:
                        continue
                    (___, __, vol) = path.rpartition('/')
                    if not vol:
                        continue
                    v_sis = {}
                    v_sis['compression'] = na_utils.to_bool(
                        sis.get_child_content('is-compression-enabled'))
                    v_sis['dedup'] = na_utils.to_bool(
                        sis.get_child_content('state'))
                    sis_vols[vol] = v_sis
    except Exception as e:
        LOG.debug("Exception querying sis information. %s", e)
    return sis_vols