copy.deepcopy(self.vol2), copy.deepcopy(self.vol3)])
sis = {'vola': {'dedup': False, 'compression': False},
'volb': {'dedup': True, 'compression': False}}
+ mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
+ 'rel_type': 'data_protection',
+ 'mirr_state': 'broken'},
+ {'dest_loc': 'openstack2:vol2',
+ 'rel_type': 'data_protection',
+ 'mirr_state': 'snapmirrored'}],
+ 'volb': [{'dest_loc': 'openstack1:vol2',
+ 'rel_type': 'data_protection',
+ 'mirr_state': 'broken'}]}
self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
+ self.mox.StubOutWithMock(ssc_utils, 'get_snapmirror_vol_dict')
self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
ssc_utils.query_cluster_vols_for_ssc(
na_server, vserver, None).AndReturn(test_vols)
ssc_utils.get_sis_vol_dict(na_server, vserver, None).AndReturn(sis)
+ ssc_utils.get_snapmirror_vol_dict(na_server, vserver, None).AndReturn(
+ mirrored)
raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
ssc_utils.query_aggr_options(
na_server, IgnoreArg()).AndReturn(raiddp)
vserver = 'openstack'
test_vols = set([copy.deepcopy(self.vol1)])
sis = {'vola': {'dedup': False, 'compression': False}}
+ mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
+ 'rel_type': 'data_protection',
+ 'mirr_state': 'broken'},
+ {'dest_loc': 'openstack2:vol2',
+ 'rel_type': 'data_protection',
+ 'mirr_state': 'snapmirrored'}]}
self.mox.StubOutWithMock(ssc_utils, 'query_cluster_vols_for_ssc')
self.mox.StubOutWithMock(ssc_utils, 'get_sis_vol_dict')
+ self.mox.StubOutWithMock(ssc_utils, 'get_snapmirror_vol_dict')
self.mox.StubOutWithMock(ssc_utils, 'query_aggr_options')
self.mox.StubOutWithMock(ssc_utils, 'query_aggr_storage_disk')
ssc_utils.query_cluster_vols_for_ssc(
na_server, vserver, 'vola').AndReturn(test_vols)
ssc_utils.get_sis_vol_dict(
na_server, vserver, 'vola').AndReturn(sis)
+ ssc_utils.get_snapmirror_vol_dict(
+ na_server, vserver, 'vola').AndReturn(mirrored)
raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
ssc_utils.query_aggr_options(
na_server, 'aggr1').AndReturn(raiddp)
"""Gets ssc vols for cluster vserver."""
volumes = query_cluster_vols_for_ssc(na_server, vserver, volume)
sis_vols = get_sis_vol_dict(na_server, vserver, volume)
+ mirrored_vols = get_snapmirror_vol_dict(na_server, vserver, volume)
aggrs = {}
for vol in volumes:
aggr_name = vol.aggr['name']
vol.space['thin_provisioned'] = False
else:
vol.space['thin_provisioned'] = True
+ vol.mirror['mirrored'] = False
+ if vol.id['name'] in mirrored_vols:
+ for mirr_attrs in mirrored_vols[vol.id['name']]:
+ if (mirr_attrs['rel_type'] == 'data_protection' and
+ mirr_attrs['mirr_state'] == 'snapmirrored'):
+ vol.mirror['mirrored'] = True
+ break
return volumes
query['volume-attributes'] = volume_id
des_attr = {'volume-attributes':
['volume-id-attributes',
- 'volume-mirror-attributes',
'volume-space-attributes',
'volume-state-attributes',
'volume-qos-attributes']}
vol.space['space-guarantee'] =\
v['volume-space-attributes'].get_child_content(
'space-guarantee')
- # mirror attributes optional.
- if v.get_child_by_name('volume-mirror-attributes'):
- vol.mirror['mirrored'] =\
- na_utils.to_bool(
- v['volume-mirror-attributes'].get_child_content(
- 'is-data-protection-mirror'))
- else:
- vol.mirror['mirrored'] = False
# qos attributes optional.
if v.get_child_by_name('volume-qos-attributes'):
vol.qos['qos_policy_group'] =\
return sis_vols
+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}
+ 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]
+ return mirrored_vols
+
+
def query_aggr_storage_disk(na_server, aggr):
"""Queries for storage disks assosiated to an aggregate."""
query = {'storage-disk-info': {'disk-raid-info':