]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp fix mirrored stats
authorNavneet Singh <singn@netapp.com>
Sat, 19 Oct 2013 18:04:15 +0000 (23:34 +0530)
committerNavneet Singh <singn@netapp.com>
Sat, 19 Oct 2013 23:43:52 +0000 (05:13 +0530)
This fixes the incorrect reporting of mirrorred
statistics for NetApp iscsi and nfs backend.
The uninitialized and broken snapmirror is
not reported and only snapmirrored state
is reported back.

Closes-Bug:#1242808

Change-Id: I4b9f788e1f99b78d12db23bd92b6a277d5f64cb3

cinder/tests/test_netapp_ssc.py
cinder/volume/drivers/netapp/ssc_utils.py

index 860f7b2525d86f99eacfafe01e653db27b55c961..4c10cac3821adf9d505c324caab3e9810819979a 100644 (file)
@@ -379,14 +379,26 @@ class SscUtilsTestCase(test.TestCase):
                          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)
@@ -416,15 +428,24 @@ class SscUtilsTestCase(test.TestCase):
         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)
index 5e53221d92d30b50b8fe2dc228eca81091b36847..715f2470226104036289268fd8b828334c389913 100644 (file)
@@ -100,6 +100,7 @@ def get_cluster_vols_with_ssc(na_server, vserver, volume=None):
     """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']
@@ -126,6 +127,13 @@ def get_cluster_vols_with_ssc(na_server, vserver, volume=None):
             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
 
 
@@ -138,7 +146,6 @@ def query_cluster_vols_for_ssc(na_server, vserver, volume=None):
     query['volume-attributes'] = volume_id
     des_attr = {'volume-attributes':
                 ['volume-id-attributes',
-                 'volume-mirror-attributes',
                  'volume-space-attributes',
                  'volume-state-attributes',
                  'volume-qos-attributes']}
@@ -218,14 +225,6 @@ def create_vol_list(vol_attrs):
             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'] =\
@@ -305,6 +304,35 @@ def get_sis_vol_dict(na_server, vserver, volume=None):
     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':