Merge "VNX: Fix issue when creating without type"
This commit is contained in:
commit
6af48d7bd9
@ -25,6 +25,7 @@ from cinder.tests.unit.volume.drivers.dell_emc.vnx import res_mock
|
|||||||
from cinder.tests.unit.volume.drivers.dell_emc.vnx import utils as ut_utils
|
from cinder.tests.unit.volume.drivers.dell_emc.vnx import utils as ut_utils
|
||||||
from cinder.volume.drivers.dell_emc.vnx import common
|
from cinder.volume.drivers.dell_emc.vnx import common
|
||||||
from cinder.volume.drivers.dell_emc.vnx import utils as vnx_utils
|
from cinder.volume.drivers.dell_emc.vnx import utils as vnx_utils
|
||||||
|
from cinder.volume import volume_types
|
||||||
|
|
||||||
|
|
||||||
class FakeDriver(object):
|
class FakeDriver(object):
|
||||||
@ -215,25 +216,26 @@ class TestUtils(test.TestCase):
|
|||||||
@ut_utils.patch_extra_specs({})
|
@ut_utils.patch_extra_specs({})
|
||||||
@res_mock.mock_driver_input
|
@res_mock.mock_driver_input
|
||||||
def test_get_backend_qos_specs(self, cinder_input):
|
def test_get_backend_qos_specs(self, cinder_input):
|
||||||
volume = mock.Mock()
|
volume = cinder_input['volume']
|
||||||
volume.volume_type.qos_specs = mock.Mock()
|
with mock.patch.object(volume_types, 'get_volume_type_qos_specs',
|
||||||
volume.volume_type.qos_specs.__getitem__ = mock.Mock(return_value=None)
|
return_value={'qos_specs': None}):
|
||||||
r = vnx_utils.get_backend_qos_specs(volume)
|
r = vnx_utils.get_backend_qos_specs(volume)
|
||||||
self.assertIsNone(r)
|
self.assertIsNone(r)
|
||||||
|
|
||||||
volume.volume_type.qos_specs.__getitem__ = mock.Mock(
|
with mock.patch.object(volume_types, 'get_volume_type_qos_specs',
|
||||||
return_value={'consumer': 'frontend'})
|
return_value={
|
||||||
r = vnx_utils.get_backend_qos_specs(volume)
|
'qos_specs': {'consumer': 'frontend'}}):
|
||||||
self.assertIsNone(r)
|
r = vnx_utils.get_backend_qos_specs(volume)
|
||||||
|
self.assertIsNone(r)
|
||||||
|
|
||||||
volume.volume_type.qos_specs.__getitem__ = mock.Mock(
|
with mock.patch.object(volume_types, 'get_volume_type_qos_specs',
|
||||||
return_value={'id': 'test', 'consumer': 'back-end',
|
return_value={
|
||||||
'specs': {common.QOS_MAX_BWS: 100,
|
'qos_specs': {'id': 'test', 'consumer': 'back-end', 'specs': {
|
||||||
common.QOS_MAX_IOPS: 10}})
|
common.QOS_MAX_BWS: 100, common.QOS_MAX_IOPS: 10}}}):
|
||||||
r = vnx_utils.get_backend_qos_specs(volume)
|
r = vnx_utils.get_backend_qos_specs(volume)
|
||||||
self.assertIsNotNone(r)
|
self.assertIsNotNone(r)
|
||||||
self.assertEqual(100, r[common.QOS_MAX_BWS])
|
self.assertEqual(100, r[common.QOS_MAX_BWS])
|
||||||
self.assertEqual(10, r[common.QOS_MAX_IOPS])
|
self.assertEqual(10, r[common.QOS_MAX_IOPS])
|
||||||
|
|
||||||
@ut_utils.patch_group_specs({
|
@ut_utils.patch_group_specs({
|
||||||
'consistent_group_replication_enabled': '<is> True'})
|
'consistent_group_replication_enabled': '<is> True'})
|
||||||
|
@ -28,6 +28,7 @@ from cinder.objects import fields
|
|||||||
from cinder.volume.drivers.dell_emc.vnx import common
|
from cinder.volume.drivers.dell_emc.vnx import common
|
||||||
from cinder.volume.drivers.san.san import san_opts
|
from cinder.volume.drivers.san.san import san_opts
|
||||||
from cinder.volume import utils as vol_utils
|
from cinder.volume import utils as vol_utils
|
||||||
|
from cinder.volume import volume_types
|
||||||
|
|
||||||
storops = importutils.try_import('storops')
|
storops = importutils.try_import('storops')
|
||||||
|
|
||||||
@ -454,7 +455,12 @@ def calc_migrate_and_provision(volume):
|
|||||||
|
|
||||||
|
|
||||||
def get_backend_qos_specs(volume):
|
def get_backend_qos_specs(volume):
|
||||||
qos_specs = volume.volume_type.qos_specs
|
type_id = volume.volume_type_id
|
||||||
|
if type_id is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# Use the provided interface to avoid permission issue
|
||||||
|
qos_specs = volume_types.get_volume_type_qos_specs(type_id)
|
||||||
if qos_specs is None:
|
if qos_specs is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -463,13 +469,12 @@ def get_backend_qos_specs(volume):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
consumer = qos_specs['consumer']
|
consumer = qos_specs['consumer']
|
||||||
# Front end QoS specs are handled by nova. Just ignore them here.
|
# Front end QoS specs are handled by nova. We ignore them here.
|
||||||
if consumer not in common.BACKEND_QOS_CONSUMERS:
|
if consumer not in common.BACKEND_QOS_CONSUMERS:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
max_iops = qos_specs['specs'].get(common.QOS_MAX_IOPS)
|
max_iops = qos_specs['specs'].get(common.QOS_MAX_IOPS)
|
||||||
max_bws = qos_specs['specs'].get(common.QOS_MAX_BWS)
|
max_bws = qos_specs['specs'].get(common.QOS_MAX_BWS)
|
||||||
|
|
||||||
if max_iops is None and max_bws is None:
|
if max_iops is None and max_bws is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user