Merge "Specify a user-agent in Pure volume drivers"
This commit is contained in:
commit
8996d0867d
@ -382,6 +382,16 @@ class PureDriverTestCase(test.TestCase):
|
|||||||
func, *args, **kwargs)
|
func, *args, **kwargs)
|
||||||
mock_func.side_effect = original_side_effect
|
mock_func.side_effect = original_side_effect
|
||||||
|
|
||||||
|
@mock.patch('platform.platform')
|
||||||
|
def test_for_user_agent(self, mock_platform):
|
||||||
|
mock_platform.return_value = 'MyFavoritePlatform'
|
||||||
|
driver = pure.PureBaseVolumeDriver(configuration=self.mock_config)
|
||||||
|
expected_agent = "OpenStack Cinder %s/%s (MyFavoritePlatform)" % (
|
||||||
|
driver.__class__.__name__,
|
||||||
|
driver.VERSION
|
||||||
|
)
|
||||||
|
self.assertEqual(expected_agent, driver._user_agent)
|
||||||
|
|
||||||
|
|
||||||
class PureBaseSharedDriverTestCase(PureDriverTestCase):
|
class PureBaseSharedDriverTestCase(PureDriverTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
@ -1888,14 +1898,7 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
|
|||||||
remvollist=[VOLUME_PURITY_NAME]
|
remvollist=[VOLUME_PURITY_NAME]
|
||||||
)
|
)
|
||||||
|
|
||||||
@ddt.data(
|
def test_get_flasharray_verify_https(self):
|
||||||
dict(version='1.5.0'),
|
|
||||||
dict(version='2.0.0'),
|
|
||||||
dict(version='1.4.1'),
|
|
||||||
)
|
|
||||||
@ddt.unpack
|
|
||||||
def test_get_flasharray_verify_https(self, version):
|
|
||||||
self.purestorage_module.VERSION = version
|
|
||||||
san_ip = '1.2.3.4'
|
san_ip = '1.2.3.4'
|
||||||
api_token = 'abcdef'
|
api_token = 'abcdef'
|
||||||
cert_path = '/my/ssl/certs'
|
cert_path = '/my/ssl/certs'
|
||||||
@ -1910,38 +1913,8 @@ class PureBaseVolumeDriverTestCase(PureBaseSharedDriverTestCase):
|
|||||||
api_token=api_token,
|
api_token=api_token,
|
||||||
rest_version=None,
|
rest_version=None,
|
||||||
verify_https=True,
|
verify_https=True,
|
||||||
ssl_cert=cert_path
|
ssl_cert=cert_path,
|
||||||
)
|
user_agent=self.driver._user_agent,
|
||||||
|
|
||||||
def test_get_flasharray_dont_verify_https_version_too_old(self):
|
|
||||||
self.purestorage_module.VERSION = '1.4.0'
|
|
||||||
san_ip = '1.2.3.4'
|
|
||||||
api_token = 'abcdef'
|
|
||||||
self.purestorage_module.FlashArray.return_value = mock.MagicMock()
|
|
||||||
|
|
||||||
self.driver._get_flasharray(san_ip,
|
|
||||||
api_token,
|
|
||||||
verify_https=False,
|
|
||||||
ssl_cert_path=None)
|
|
||||||
self.purestorage_module.FlashArray.assert_called_with(
|
|
||||||
san_ip,
|
|
||||||
api_token=api_token,
|
|
||||||
rest_version=None
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_get_flasharray_verify_https_version_too_old(self):
|
|
||||||
self.purestorage_module.VERSION = '1.4.0'
|
|
||||||
san_ip = '1.2.3.4'
|
|
||||||
api_token = 'abcdef'
|
|
||||||
self.purestorage_module.FlashArray.return_value = mock.MagicMock()
|
|
||||||
|
|
||||||
self.assertRaises(
|
|
||||||
exception.PureDriverException,
|
|
||||||
self.driver._get_flasharray,
|
|
||||||
san_ip,
|
|
||||||
api_token,
|
|
||||||
verify_https=True,
|
|
||||||
ssl_cert_path='/my/ssl/certs'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ This driver requires Purity version 4.0.0 or later.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import platform
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
@ -102,7 +103,6 @@ EXTRA_SPECS_REPL_ENABLED = "replication_enabled"
|
|||||||
|
|
||||||
CONNECT_LOCK_NAME = 'PureVolumeDriver_connect'
|
CONNECT_LOCK_NAME = 'PureVolumeDriver_connect'
|
||||||
|
|
||||||
|
|
||||||
UNMANAGED_SUFFIX = '-unmanaged'
|
UNMANAGED_SUFFIX = '-unmanaged'
|
||||||
MANAGE_SNAP_REQUIRED_API_VERSIONS = ['1.4', '1.5']
|
MANAGE_SNAP_REQUIRED_API_VERSIONS = ['1.4', '1.5']
|
||||||
REPLICATION_REQUIRED_API_VERSIONS = ['1.3', '1.4', '1.5']
|
REPLICATION_REQUIRED_API_VERSIONS = ['1.3', '1.4', '1.5']
|
||||||
@ -110,6 +110,8 @@ REPLICATION_REQUIRED_API_VERSIONS = ['1.3', '1.4', '1.5']
|
|||||||
REPL_SETTINGS_PROPAGATE_RETRY_INTERVAL = 5 # 5 seconds
|
REPL_SETTINGS_PROPAGATE_RETRY_INTERVAL = 5 # 5 seconds
|
||||||
REPL_SETTINGS_PROPAGATE_MAX_RETRIES = 36 # 36 * 5 = 180 seconds
|
REPL_SETTINGS_PROPAGATE_MAX_RETRIES = 36 # 36 * 5 = 180 seconds
|
||||||
|
|
||||||
|
USER_AGENT_BASE = 'OpenStack Cinder'
|
||||||
|
|
||||||
|
|
||||||
def pure_driver_debug_trace(f):
|
def pure_driver_debug_trace(f):
|
||||||
"""Log the method entrance and exit including active backend name.
|
"""Log the method entrance and exit including active backend name.
|
||||||
@ -156,6 +158,12 @@ class PureBaseVolumeDriver(san.SanDriver):
|
|||||||
self._is_replication_enabled = False
|
self._is_replication_enabled = False
|
||||||
self._active_backend_id = kwargs.get('active_backend_id', None)
|
self._active_backend_id = kwargs.get('active_backend_id', None)
|
||||||
self._failed_over_primary_array = None
|
self._failed_over_primary_array = None
|
||||||
|
self._user_agent = '%(base)s %(class)s/%(version)s (%(platform)s)' % {
|
||||||
|
'base': USER_AGENT_BASE,
|
||||||
|
'class': self.__class__.__name__,
|
||||||
|
'version': self.VERSION,
|
||||||
|
'platform': platform.platform()
|
||||||
|
}
|
||||||
|
|
||||||
def parse_replication_configs(self):
|
def parse_replication_configs(self):
|
||||||
self._replication_interval = (
|
self._replication_interval = (
|
||||||
@ -959,26 +967,13 @@ class PureBaseVolumeDriver(san.SanDriver):
|
|||||||
|
|
||||||
def _get_flasharray(self, san_ip, api_token, rest_version=None,
|
def _get_flasharray(self, san_ip, api_token, rest_version=None,
|
||||||
verify_https=None, ssl_cert_path=None):
|
verify_https=None, ssl_cert_path=None):
|
||||||
# Older versions of the module (1.4.0) do not support setting ssl certs
|
|
||||||
# TODO(patrickeast): In future releases drop support for 1.4.0
|
|
||||||
if self._client_version_greater_than([1, 4, 0]):
|
|
||||||
array = purestorage.FlashArray(san_ip,
|
array = purestorage.FlashArray(san_ip,
|
||||||
api_token=api_token,
|
api_token=api_token,
|
||||||
rest_version=rest_version,
|
rest_version=rest_version,
|
||||||
verify_https=verify_https,
|
verify_https=verify_https,
|
||||||
ssl_cert=ssl_cert_path)
|
ssl_cert=ssl_cert_path,
|
||||||
else:
|
user_agent=self._user_agent)
|
||||||
if verify_https or ssl_cert_path is not None:
|
|
||||||
msg = _('HTTPS certificate verification was requested '
|
|
||||||
'but cannot be enabled with purestorage '
|
|
||||||
'module version %(version)s. Upgrade to a '
|
|
||||||
'newer version to enable this feature.') % {
|
|
||||||
'version': purestorage.VERSION
|
|
||||||
}
|
|
||||||
raise exception.PureDriverException(reason=msg)
|
|
||||||
array = purestorage.FlashArray(san_ip,
|
|
||||||
api_token=api_token,
|
|
||||||
rest_version=rest_version)
|
|
||||||
array_info = array.get()
|
array_info = array.get()
|
||||||
array.array_name = array_info["array_name"]
|
array.array_name = array_info["array_name"]
|
||||||
array.array_id = array_info["id"]
|
array.array_id = array_info["id"]
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
upgrade:
|
||||||
|
- Pure volume drivers will need 'purestorage' python module v1.6.0 or newer.
|
||||||
|
Support for 1.4.x has been removed.
|
Loading…
Reference in New Issue
Block a user