From a591d2641949985e192ceaaf3cf155310ddd5f97 Mon Sep 17 00:00:00 2001 From: Mike Rooney Date: Mon, 22 Jun 2015 13:58:12 -0400 Subject: [PATCH] Snapmirror targets should not be reported as pools Snapmirror targets that were being reported to the Cinder scheduler as available pools are now no longer reported as such. Change-Id: I04faa9d7c448b91e66192770b09db84df78a8ae1 Closes-Bug: #1468004 --- cinder/tests/unit/test_netapp_ssc.py | 22 +++++++++++++++++++ .../drivers/netapp/dataontap/ssc_cmode.py | 8 ++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/cinder/tests/unit/test_netapp_ssc.py b/cinder/tests/unit/test_netapp_ssc.py index 13a1ef43d..55ee62adc 100644 --- a/cinder/tests/unit/test_netapp_ssc.py +++ b/cinder/tests/unit/test_netapp_ssc.py @@ -15,6 +15,7 @@ """Unit tests for the NetApp-specific ssc module.""" import copy +import ddt from lxml import etree import mock from mox3 import mox @@ -314,6 +315,7 @@ def createNetAppVolume(**kwargs): return vol +@ddt.ddt class SscUtilsTestCase(test.TestCase): """Test ssc utis.""" vol1 = createNetAppVolume(name='vola', vs='openstack', @@ -377,6 +379,26 @@ class SscUtilsTestCase(test.TestCase): self.stubs.Set(http_client, 'HTTPConnection', FakeDirectCmodeHTTPConnection) + @ddt.data({'na_server_exists': False, 'volume': None}, + {'na_server_exists': True, 'volume': 'vol'}, + {'na_server_exists': True, 'volume': None}) + @ddt.unpack + def test_query_cluster_vols_for_ssc(self, na_server_exists, volume): + if na_server_exists: + na_server = netapp_api.NaServer('127.0.0.1') + fake_api_return = mock.Mock(return_value=[]) + self.mock_object(ssc_cmode.netapp_api, 'invoke_api', + new_attr=fake_api_return) + ssc_cmode.query_cluster_vols_for_ssc(na_server, 'vserver', + volume) + else: + na_server = None + fake_api_error = mock.Mock(side_effect=exception.InvalidInput) + self.mock_object(ssc_cmode.netapp_api, 'invoke_api', + new_attr=fake_api_error) + self.assertRaises(KeyError, ssc_cmode.query_cluster_vols_for_ssc, + na_server, 'vserver', volume) + def test_cl_vols_ssc_all(self): """Test cluster ssc for all vols.""" na_server = netapp_api.NaServer('127.0.0.1') diff --git a/cinder/volume/drivers/netapp/dataontap/ssc_cmode.py b/cinder/volume/drivers/netapp/dataontap/ssc_cmode.py index f88e03c0f..411fcce22 100644 --- a/cinder/volume/drivers/netapp/dataontap/ssc_cmode.py +++ b/cinder/volume/drivers/netapp/dataontap/ssc_cmode.py @@ -154,7 +154,13 @@ def get_cluster_vols_with_ssc(na_server, vserver, volume=None): 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}} + volume_id = { + 'volume-id-attributes': { + 'owning-vserver-name': vserver, + 'type': 'rw', + 'style': 'flex', + }, + } if volume: volume_id['volume-id-attributes']['name'] = volume query['volume-attributes'] = volume_id -- 2.45.2