From e9e993b8cda86df2884543ded45cb8e23042edd3 Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Thu, 14 Jan 2016 10:50:04 -0800 Subject: [PATCH] LeftHand: Updating minimum client version Updated HPE LeftHand driver to have a minimum client version of 2.1.0. This is a follow up to the following patches: https://review.openstack.org/#/c/255002/ https://review.openstack.org/#/c/255544/ https://review.openstack.org/#/c/255015/ DocImpact Change-Id: I85f49116bfb669673d090c12e80d8d363730ab9e --- cinder/tests/unit/fake_hpe_lefthand_client.py | 4 +- cinder/tests/unit/test_hpelefthand.py | 20 ------- .../volume/drivers/hpe/hpe_lefthand_iscsi.py | 60 ++++++++----------- 3 files changed, 27 insertions(+), 57 deletions(-) diff --git a/cinder/tests/unit/fake_hpe_lefthand_client.py b/cinder/tests/unit/fake_hpe_lefthand_client.py index 404f00bff..2360de097 100644 --- a/cinder/tests/unit/fake_hpe_lefthand_client.py +++ b/cinder/tests/unit/fake_hpe_lefthand_client.py @@ -1,4 +1,4 @@ -# (c) Copyright 2014-2015 Hewlett Packard Enterprise Development LP +# (c) Copyright 2014-2016 Hewlett Packard Enterprise Development LP # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -22,7 +22,7 @@ import mock from cinder.tests.unit import fake_hpe_client_exceptions as hpeexceptions hpelefthand = mock.Mock() -hpelefthand.version = "2.0.0" +hpelefthand.version = "2.1.0" hpelefthand.exceptions = hpeexceptions sys.modules['hpelefthandclient'] = hpelefthand diff --git a/cinder/tests/unit/test_hpelefthand.py b/cinder/tests/unit/test_hpelefthand.py index 0fa657aa9..e51dd04fe 100644 --- a/cinder/tests/unit/test_hpelefthand.py +++ b/cinder/tests/unit/test_hpelefthand.py @@ -151,9 +151,6 @@ class HPELeftHandBaseDriver(object): driver_startup_call_stack = [ mock.call.login('foo1', 'bar2'), mock.call.getClusterByName('CloudCluster1'), - ] - - driver_startup_ssh = [ mock.call.setSSHOptions( HPELEFTHAND_SSH_IP, HPELEFTHAND_USERNAME, @@ -2075,7 +2072,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): ctxt, cgsnapshot, expected_snaps) self.assertEqual('deleting', cgsnap['status']) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_create_volume_replicated_managed(self, _mock_get_volume_type): # set up driver with default config @@ -2127,7 +2123,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0' rep_data = json.dumps({"location": HPELEFTHAND_API_URL}) @@ -2136,7 +2131,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'provider_location': prov_location}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_create_volume_replicated_unmanaged(self, _mock_get_volume_type): # set up driver with default config @@ -2188,7 +2182,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0' rep_data = json.dumps({"location": HPELEFTHAND_API_URL}) @@ -2197,7 +2190,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'provider_location': prov_location}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_delete_volume_replicated(self, _mock_get_volume_type): # set up driver with default config @@ -2230,10 +2222,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): mock.call.deleteVolume(1)] mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_enable_no_snapshot_schedule(self, _mock_get_volume_type): @@ -2278,13 +2268,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'bar2')] mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) self.assertEqual({'replication_status': 'enabled'}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_enable_with_snapshot_schedule(self, _mock_get_volume_type): @@ -2319,13 +2307,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'fakevolume_replicated_SCHED_Pri')] mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) self.assertEqual({'replication_status': 'enabled'}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_disable(self, _mock_get_volume_type): # set up driver with default config @@ -2356,13 +2342,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'fakevolume_replicated_SCHED_Pri')] mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) self.assertEqual({'replication_status': 'disabled'}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_disable_fail(self, _mock_get_volume_type): # set up driver with default config @@ -2395,13 +2379,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'fakevolume_replicated_SCHED_Pri')] mock_client.assert_has_calls( self.driver_startup_call_stack + - self.driver_startup_ssh + expected) self.assertEqual({'replication_status': 'disable_failed'}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_list_replication_targets(self, _mock_get_volume_type): # set up driver with default config @@ -2432,7 +2414,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'targets': targets}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_failover_managed(self, _mock_get_volume_type): ctxt = context.get_admin_context() @@ -2480,7 +2461,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase): 'host': FAKE_FAILOVER_HOST}, return_model) - @mock.patch('hpelefthandclient.version', "2.0.1") @mock.patch.object(volume_types, 'get_volume_type') def test_replication_failover_unmanaged(self, _mock_get_volume_type): ctxt = context.get_admin_context() diff --git a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py index 6605deec6..ac5f9a9b1 100644 --- a/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py +++ b/cinder/volume/drivers/hpe/hpe_lefthand_iscsi.py @@ -99,8 +99,7 @@ CONF = cfg.CONF CONF.register_opts(hpelefthand_opts) MIN_API_VERSION = "1.1" -MIN_CLIENT_VERSION = '2.0.0' -MIN_REP_CLIENT_VERSION = '2.0.1' +MIN_CLIENT_VERSION = '2.1.0' # map the extra spec key to the REST client option key extra_specs_key_map = { @@ -149,9 +148,10 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): 2.0.2 - Adds v2 managed replication support 2.0.3 - Adds v2 unmanaged replication support 2.0.4 - Add manage/unmanage snapshot support + 2.0.5 - Changed minimum client version to be 2.1.0 """ - VERSION = "2.0.4" + VERSION = "2.0.5" device_stats = {} @@ -232,25 +232,22 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): virtual_ips = cluster_info['virtualIPAddresses'] self.cluster_vip = virtual_ips[0]['ipV4Address'] - # SSH is only available in the 2.0.1 release of the - # python-lefthandclient. - if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: - # Extract IP address from API URL - ssh_ip = self._extract_ip_from_url( - self._client_conf['hpelefthand_api_url']) - known_hosts_file = CONF.ssh_hosts_key_file - policy = "AutoAddPolicy" - if CONF.strict_ssh_host_key_policy: - policy = "RejectPolicy" - client.setSSHOptions( - ssh_ip, - self._client_conf['hpelefthand_username'], - self._client_conf['hpelefthand_password'], - port=self._client_conf['hpelefthand_ssh_port'], - conn_timeout=self._client_conf['ssh_conn_timeout'], - privatekey=self._client_conf['san_private_key'], - missing_key_policy=policy, - known_hosts_file=known_hosts_file) + # Extract IP address from API URL + ssh_ip = self._extract_ip_from_url( + self._client_conf['hpelefthand_api_url']) + known_hosts_file = CONF.ssh_hosts_key_file + policy = "AutoAddPolicy" + if CONF.strict_ssh_host_key_policy: + policy = "RejectPolicy" + client.setSSHOptions( + ssh_ip, + self._client_conf['hpelefthand_username'], + self._client_conf['hpelefthand_password'], + port=self._client_conf['hpelefthand_ssh_port'], + conn_timeout=self._client_conf['ssh_conn_timeout'], + privatekey=self._client_conf['san_private_key'], + missing_key_policy=policy, + known_hosts_file=known_hosts_file) return client except hpeexceptions.HTTPNotFound: @@ -267,11 +264,8 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): # Timeout is only supported in version 2.0.1 and greater of the # python-lefthandclient. hpelefthand_api_url = self._client_conf['hpelefthand_api_url'] - if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: - client = hpe_lh_client.HPELeftHandClient( - hpelefthand_api_url, timeout=timeout) - else: - client = hpe_lh_client.HPELeftHandClient(hpelefthand_api_url) + client = hpe_lh_client.HPELeftHandClient( + hpelefthand_api_url, timeout=timeout) return client def _create_replication_client(self, remote_array): @@ -328,9 +322,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): LOG.error(ex_msg) raise exception.InvalidInput(reason=ex_msg) - # v2 replication check - if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: - self._do_replication_setup() + self._do_replication_setup() def check_for_setup_error(self): """Checks for incorrect LeftHand API being used on backend.""" @@ -675,11 +667,9 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver): data['filter_function'] = self.get_filter_function() data['goodness_function'] = self.get_goodness_function() data['consistencygroup_support'] = True - - if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: - data['replication_enabled'] = self._replication_enabled - data['replication_type'] = ['periodic'] - data['replication_count'] = len(self._replication_targets) + data['replication_enabled'] = self._replication_enabled + data['replication_type'] = ['periodic'] + data['replication_count'] = len(self._replication_targets) self.device_stats = data -- 2.45.2