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
This commit is contained in:
Anthony Lee 2016-01-14 10:50:04 -08:00
parent 8ed2d59395
commit e9e993b8cd
3 changed files with 27 additions and 57 deletions

View File

@ -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. # All Rights Reserved.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may # 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 from cinder.tests.unit import fake_hpe_client_exceptions as hpeexceptions
hpelefthand = mock.Mock() hpelefthand = mock.Mock()
hpelefthand.version = "2.0.0" hpelefthand.version = "2.1.0"
hpelefthand.exceptions = hpeexceptions hpelefthand.exceptions = hpeexceptions
sys.modules['hpelefthandclient'] = hpelefthand sys.modules['hpelefthandclient'] = hpelefthand

View File

@ -151,9 +151,6 @@ class HPELeftHandBaseDriver(object):
driver_startup_call_stack = [ driver_startup_call_stack = [
mock.call.login('foo1', 'bar2'), mock.call.login('foo1', 'bar2'),
mock.call.getClusterByName('CloudCluster1'), mock.call.getClusterByName('CloudCluster1'),
]
driver_startup_ssh = [
mock.call.setSSHOptions( mock.call.setSSHOptions(
HPELEFTHAND_SSH_IP, HPELEFTHAND_SSH_IP,
HPELEFTHAND_USERNAME, HPELEFTHAND_USERNAME,
@ -2075,7 +2072,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
ctxt, cgsnapshot, expected_snaps) ctxt, cgsnapshot, expected_snaps)
self.assertEqual('deleting', cgsnap['status']) self.assertEqual('deleting', cgsnap['status'])
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_create_volume_replicated_managed(self, _mock_get_volume_type): def test_create_volume_replicated_managed(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2127,7 +2123,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0' prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0'
rep_data = json.dumps({"location": HPELEFTHAND_API_URL}) rep_data = json.dumps({"location": HPELEFTHAND_API_URL})
@ -2136,7 +2131,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'provider_location': prov_location}, 'provider_location': prov_location},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_create_volume_replicated_unmanaged(self, _mock_get_volume_type): def test_create_volume_replicated_unmanaged(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2188,7 +2182,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0' prov_location = '10.0.1.6:3260,1 iqn.1993-08.org.debian:01:222 0'
rep_data = json.dumps({"location": HPELEFTHAND_API_URL}) rep_data = json.dumps({"location": HPELEFTHAND_API_URL})
@ -2197,7 +2190,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'provider_location': prov_location}, 'provider_location': prov_location},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_delete_volume_replicated(self, _mock_get_volume_type): def test_delete_volume_replicated(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2230,10 +2222,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
mock.call.deleteVolume(1)] mock.call.deleteVolume(1)]
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_enable_no_snapshot_schedule(self, def test_replication_enable_no_snapshot_schedule(self,
_mock_get_volume_type): _mock_get_volume_type):
@ -2278,13 +2268,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'bar2')] 'bar2')]
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
self.assertEqual({'replication_status': 'enabled'}, self.assertEqual({'replication_status': 'enabled'},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_enable_with_snapshot_schedule(self, def test_replication_enable_with_snapshot_schedule(self,
_mock_get_volume_type): _mock_get_volume_type):
@ -2319,13 +2307,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'fakevolume_replicated_SCHED_Pri')] 'fakevolume_replicated_SCHED_Pri')]
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
self.assertEqual({'replication_status': 'enabled'}, self.assertEqual({'replication_status': 'enabled'},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_disable(self, _mock_get_volume_type): def test_replication_disable(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2356,13 +2342,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'fakevolume_replicated_SCHED_Pri')] 'fakevolume_replicated_SCHED_Pri')]
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
self.assertEqual({'replication_status': 'disabled'}, self.assertEqual({'replication_status': 'disabled'},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_disable_fail(self, _mock_get_volume_type): def test_replication_disable_fail(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2395,13 +2379,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'fakevolume_replicated_SCHED_Pri')] 'fakevolume_replicated_SCHED_Pri')]
mock_client.assert_has_calls( mock_client.assert_has_calls(
self.driver_startup_call_stack + self.driver_startup_call_stack +
self.driver_startup_ssh +
expected) expected)
self.assertEqual({'replication_status': 'disable_failed'}, self.assertEqual({'replication_status': 'disable_failed'},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_list_replication_targets(self, _mock_get_volume_type): def test_list_replication_targets(self, _mock_get_volume_type):
# set up driver with default config # set up driver with default config
@ -2432,7 +2414,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'targets': targets}, 'targets': targets},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_failover_managed(self, _mock_get_volume_type): def test_replication_failover_managed(self, _mock_get_volume_type):
ctxt = context.get_admin_context() ctxt = context.get_admin_context()
@ -2480,7 +2461,6 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
'host': FAKE_FAILOVER_HOST}, 'host': FAKE_FAILOVER_HOST},
return_model) return_model)
@mock.patch('hpelefthandclient.version', "2.0.1")
@mock.patch.object(volume_types, 'get_volume_type') @mock.patch.object(volume_types, 'get_volume_type')
def test_replication_failover_unmanaged(self, _mock_get_volume_type): def test_replication_failover_unmanaged(self, _mock_get_volume_type):
ctxt = context.get_admin_context() ctxt = context.get_admin_context()

View File

@ -99,8 +99,7 @@ CONF = cfg.CONF
CONF.register_opts(hpelefthand_opts) CONF.register_opts(hpelefthand_opts)
MIN_API_VERSION = "1.1" MIN_API_VERSION = "1.1"
MIN_CLIENT_VERSION = '2.0.0' MIN_CLIENT_VERSION = '2.1.0'
MIN_REP_CLIENT_VERSION = '2.0.1'
# map the extra spec key to the REST client option key # map the extra spec key to the REST client option key
extra_specs_key_map = { extra_specs_key_map = {
@ -149,9 +148,10 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
2.0.2 - Adds v2 managed replication support 2.0.2 - Adds v2 managed replication support
2.0.3 - Adds v2 unmanaged replication support 2.0.3 - Adds v2 unmanaged replication support
2.0.4 - Add manage/unmanage snapshot 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 = {} device_stats = {}
@ -232,25 +232,22 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
virtual_ips = cluster_info['virtualIPAddresses'] virtual_ips = cluster_info['virtualIPAddresses']
self.cluster_vip = virtual_ips[0]['ipV4Address'] self.cluster_vip = virtual_ips[0]['ipV4Address']
# SSH is only available in the 2.0.1 release of the # Extract IP address from API URL
# python-lefthandclient. ssh_ip = self._extract_ip_from_url(
if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: self._client_conf['hpelefthand_api_url'])
# Extract IP address from API URL known_hosts_file = CONF.ssh_hosts_key_file
ssh_ip = self._extract_ip_from_url( policy = "AutoAddPolicy"
self._client_conf['hpelefthand_api_url']) if CONF.strict_ssh_host_key_policy:
known_hosts_file = CONF.ssh_hosts_key_file policy = "RejectPolicy"
policy = "AutoAddPolicy" client.setSSHOptions(
if CONF.strict_ssh_host_key_policy: ssh_ip,
policy = "RejectPolicy" self._client_conf['hpelefthand_username'],
client.setSSHOptions( self._client_conf['hpelefthand_password'],
ssh_ip, port=self._client_conf['hpelefthand_ssh_port'],
self._client_conf['hpelefthand_username'], conn_timeout=self._client_conf['ssh_conn_timeout'],
self._client_conf['hpelefthand_password'], privatekey=self._client_conf['san_private_key'],
port=self._client_conf['hpelefthand_ssh_port'], missing_key_policy=policy,
conn_timeout=self._client_conf['ssh_conn_timeout'], known_hosts_file=known_hosts_file)
privatekey=self._client_conf['san_private_key'],
missing_key_policy=policy,
known_hosts_file=known_hosts_file)
return client return client
except hpeexceptions.HTTPNotFound: except hpeexceptions.HTTPNotFound:
@ -267,11 +264,8 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
# Timeout is only supported in version 2.0.1 and greater of the # Timeout is only supported in version 2.0.1 and greater of the
# python-lefthandclient. # python-lefthandclient.
hpelefthand_api_url = self._client_conf['hpelefthand_api_url'] hpelefthand_api_url = self._client_conf['hpelefthand_api_url']
if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: client = hpe_lh_client.HPELeftHandClient(
client = hpe_lh_client.HPELeftHandClient( hpelefthand_api_url, timeout=timeout)
hpelefthand_api_url, timeout=timeout)
else:
client = hpe_lh_client.HPELeftHandClient(hpelefthand_api_url)
return client return client
def _create_replication_client(self, remote_array): def _create_replication_client(self, remote_array):
@ -328,9 +322,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
LOG.error(ex_msg) LOG.error(ex_msg)
raise exception.InvalidInput(reason=ex_msg) raise exception.InvalidInput(reason=ex_msg)
# v2 replication check self._do_replication_setup()
if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION:
self._do_replication_setup()
def check_for_setup_error(self): def check_for_setup_error(self):
"""Checks for incorrect LeftHand API being used on backend.""" """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['filter_function'] = self.get_filter_function()
data['goodness_function'] = self.get_goodness_function() data['goodness_function'] = self.get_goodness_function()
data['consistencygroup_support'] = True data['consistencygroup_support'] = True
data['replication_enabled'] = self._replication_enabled
if hpelefthandclient.version >= MIN_REP_CLIENT_VERSION: data['replication_type'] = ['periodic']
data['replication_enabled'] = self._replication_enabled data['replication_count'] = len(self._replication_targets)
data['replication_type'] = ['periodic']
data['replication_count'] = len(self._replication_targets)
self.device_stats = data self.device_stats = data