Port HP 3PAR driver to Python 3
* Use oslo_serialization.base64.encode_as_text() to get Unicode on Python 3. * Replace sys.maxint with sys.maxsize, sys.maxint was removed in Python 3. * test_hpe3par: use list(set()) to get FCWWNs is the right order. On Python 3, the hash function is randomized by default. * test_hpe3par: fix client getWsApiVersion() to return a valid version. Before, the comparison between mock.Mock and int raised a TypeError. * hpe_3par_common: set version to 3.0.2 * hpe_3par_iscsi: set version to 3.0.1 * tox.ini: add test_hpe3par to Python 3.4 Partial-Implements: blueprint cinder-python3 Change-Id: I2bed171c0db93b8ea83127a69a63c3bb2317b10b
This commit is contained in:
parent
a61b0e6c22
commit
3e002b57c3
@ -544,6 +544,8 @@ class HPE3PARBaseDriver(object):
|
|||||||
# Configure the base constants, defaults etc...
|
# Configure the base constants, defaults etc...
|
||||||
_m_client.configure_mock(**self.mock_client_conf)
|
_m_client.configure_mock(**self.mock_client_conf)
|
||||||
|
|
||||||
|
_m_client.getWsApiVersion.return_value = self.wsapi_version_latest
|
||||||
|
|
||||||
# If m_conf, drop those over the top of the base_conf.
|
# If m_conf, drop those over the top of the base_conf.
|
||||||
if m_conf is not None:
|
if m_conf is not None:
|
||||||
_m_client.configure_mock(**m_conf)
|
_m_client.configure_mock(**m_conf)
|
||||||
@ -4336,14 +4338,16 @@ class TestHPE3PARFCDriver(HPE3PARBaseDriver, test.TestCase):
|
|||||||
common,
|
common,
|
||||||
self.volume,
|
self.volume,
|
||||||
self.connector)
|
self.connector)
|
||||||
|
# On Python 3, hash is randomized, and so set() is used to get
|
||||||
|
# the expected order
|
||||||
|
fcwwns = list(set(('123456789054321', '123456789012345')))
|
||||||
expected = [
|
expected = [
|
||||||
mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
|
mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
|
||||||
mock.call.getCPG(HPE3PAR_CPG),
|
mock.call.getCPG(HPE3PAR_CPG),
|
||||||
mock.call.getHost('fakehost'),
|
mock.call.getHost('fakehost'),
|
||||||
mock.call.modifyHost(
|
mock.call.modifyHost('fakehost',
|
||||||
'fakehost', {
|
{'FCWWNs': fcwwns,
|
||||||
'FCWWNs': ['123456789012345', '123456789054321'],
|
'pathOperation': 1}),
|
||||||
'pathOperation': 1}),
|
|
||||||
mock.call.getHost('fakehost')]
|
mock.call.getHost('fakehost')]
|
||||||
|
|
||||||
mock_client.assert_has_calls(expected)
|
mock_client.assert_has_calls(expected)
|
||||||
|
@ -35,7 +35,6 @@ array.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
import base64
|
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
import pprint
|
import pprint
|
||||||
@ -43,6 +42,7 @@ import re
|
|||||||
import six
|
import six
|
||||||
import uuid
|
import uuid
|
||||||
|
|
||||||
|
from oslo_serialization import base64
|
||||||
from oslo_utils import importutils
|
from oslo_utils import importutils
|
||||||
|
|
||||||
hpe3parclient = importutils.try_import("hpe3parclient")
|
hpe3parclient = importutils.try_import("hpe3parclient")
|
||||||
@ -213,10 +213,11 @@ class HPE3PARCommon(object):
|
|||||||
2.0.53 - Fix volume size conversion. bug #1513158
|
2.0.53 - Fix volume size conversion. bug #1513158
|
||||||
3.0.0 - Rebranded HP to HPE.
|
3.0.0 - Rebranded HP to HPE.
|
||||||
3.0.1 - Fixed find_existing_vluns bug #1515033
|
3.0.1 - Fixed find_existing_vluns bug #1515033
|
||||||
|
3.0.2 - Python 3 support
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VERSION = "3.0.1"
|
VERSION = "3.0.2"
|
||||||
|
|
||||||
stats = {}
|
stats = {}
|
||||||
|
|
||||||
@ -786,7 +787,7 @@ class HPE3PARCommon(object):
|
|||||||
def _encode_name(self, name):
|
def _encode_name(self, name):
|
||||||
uuid_str = name.replace("-", "")
|
uuid_str = name.replace("-", "")
|
||||||
vol_uuid = uuid.UUID('urn:uuid:%s' % uuid_str)
|
vol_uuid = uuid.UUID('urn:uuid:%s' % uuid_str)
|
||||||
vol_encoded = base64.b64encode(vol_uuid.bytes)
|
vol_encoded = base64.encode_as_text(vol_uuid.bytes)
|
||||||
|
|
||||||
# 3par doesn't allow +, nor /
|
# 3par doesn't allow +, nor /
|
||||||
vol_encoded = vol_encoded.replace('+', '.')
|
vol_encoded = vol_encoded.replace('+', '.')
|
||||||
|
@ -100,10 +100,11 @@ class HPE3PARISCSIDriver(driver.TransferVD,
|
|||||||
2.0.22 - Update driver to use ABC metaclasses
|
2.0.22 - Update driver to use ABC metaclasses
|
||||||
2.0.23 - Added update_migrated_volume. bug # 1492023
|
2.0.23 - Added update_migrated_volume. bug # 1492023
|
||||||
3.0.0 - Rebranded HP to HPE.
|
3.0.0 - Rebranded HP to HPE.
|
||||||
|
3.0.1 - Python 3 support
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
VERSION = "3.0.0"
|
VERSION = "3.0.1"
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs)
|
super(HPE3PARISCSIDriver, self).__init__(*args, **kwargs)
|
||||||
@ -719,7 +720,7 @@ class HPE3PARISCSIDriver(driver.TransferVD,
|
|||||||
nsp_counts[nsp] = nsp_counts[nsp] + 1
|
nsp_counts[nsp] = nsp_counts[nsp] + 1
|
||||||
|
|
||||||
# identify key (nsp) of least used nsp
|
# identify key (nsp) of least used nsp
|
||||||
current_smallest_count = sys.maxint
|
current_smallest_count = sys.maxsize
|
||||||
for (nsp, count) in nsp_counts.items():
|
for (nsp, count) in nsp_counts.items():
|
||||||
if count < current_smallest_count:
|
if count < current_smallest_count:
|
||||||
current_least_used_nsp = nsp
|
current_least_used_nsp = nsp
|
||||||
|
@ -69,6 +69,7 @@ cinder.tests.unit.test_hitachi_hbsd_snm2_iscsi
|
|||||||
cinder.tests.unit.test_hitachi_hnas_backend
|
cinder.tests.unit.test_hitachi_hnas_backend
|
||||||
cinder.tests.unit.test_hitachi_hnas_iscsi
|
cinder.tests.unit.test_hitachi_hnas_iscsi
|
||||||
cinder.tests.unit.test_hitachi_hnas_nfs
|
cinder.tests.unit.test_hitachi_hnas_nfs
|
||||||
|
cinder.tests.unit.test_hpe3par
|
||||||
cinder.tests.unit.test_hp_xp_fc
|
cinder.tests.unit.test_hp_xp_fc
|
||||||
cinder.tests.unit.test_hplefthand
|
cinder.tests.unit.test_hplefthand
|
||||||
cinder.tests.unit.test_huawei_drivers
|
cinder.tests.unit.test_huawei_drivers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user