Huawei driver supports front-end qos
There's a parameter in QoS specs named "consumer" and it's default
value is 'back-end'. When "consumer" is set to 'front-end'/'back-end',
it should create a front-end/back-end QoS.
Now Huawei Driver doesn't consider the "consumer" parameter, fix it.
Change-Id: If76b7525b011c2576cfb669a4dc29ee1d6b870de
Closes-bug:#1667875
(cherry picked from commit b268b842bd
)
This commit is contained in:
parent
8955ba90bc
commit
0e9373ee9b
|
@ -37,6 +37,7 @@ from cinder.volume.drivers.huawei import hypermetro
|
|||
from cinder.volume.drivers.huawei import replication
|
||||
from cinder.volume.drivers.huawei import rest_client
|
||||
from cinder.volume.drivers.huawei import smartx
|
||||
from cinder.volume import qos_specs
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -2307,7 +2308,6 @@ class HuaweiISCSIDriverTestCase(test.TestCase):
|
|||
self.assertEqual(test_info, pool_info)
|
||||
|
||||
def test_get_smartx_specs_opts(self):
|
||||
|
||||
smartx_opts = smartx.SmartX().get_smartx_specs_opts(smarttier_opts)
|
||||
self.assertEqual('3', smartx_opts['policy'])
|
||||
|
||||
|
@ -2315,10 +2315,33 @@ class HuaweiISCSIDriverTestCase(test.TestCase):
|
|||
return_value={'MAXIOPS': '100',
|
||||
'IOType': '2'})
|
||||
def test_create_smartqos(self, mock_qos_value):
|
||||
|
||||
lun_info = self.driver.create_volume(test_volume)
|
||||
self.assertEqual('1', lun_info['provider_location'])
|
||||
|
||||
@ddt.data('front-end', 'back-end')
|
||||
@mock.patch.object(huawei_driver.HuaweiBaseDriver, '_get_volume_params',
|
||||
return_value={'smarttier': 'true',
|
||||
'smartcache': 'true',
|
||||
'smartpartition': 'true',
|
||||
'thin_provisioning_support': 'true',
|
||||
'thick_provisioning_support': 'false',
|
||||
'policy': '2',
|
||||
'cachename': 'cache-test',
|
||||
'partitionname': 'partition-test'})
|
||||
@mock.patch.object(huawei_driver.HuaweiBaseDriver, '_get_volume_type',
|
||||
return_value={'qos_specs_id': u'025ce295-15e9-41a7'})
|
||||
def test_create_smartqos_success(self,
|
||||
mock_consumer,
|
||||
mock_qos_specs,
|
||||
mock_value_type):
|
||||
self.mock_object(qos_specs, 'get_qos_specs',
|
||||
return_value={'specs': {'maxBandWidth': '100',
|
||||
'IOType': '0'},
|
||||
'consumer': mock_consumer})
|
||||
|
||||
lun_info = self.driver.create_volume(self.volume)
|
||||
self.assertEqual('1', lun_info['provider_location'])
|
||||
|
||||
@mock.patch.object(rest_client.RestClient, 'add_lun_to_partition')
|
||||
@mock.patch.object(huawei_driver.HuaweiBaseDriver, '_get_volume_params',
|
||||
return_value={'smarttier': 'true',
|
||||
|
|
|
@ -19,6 +19,9 @@ STATUS_RUNNING = '10'
|
|||
STATUS_VOLUME_READY = '27'
|
||||
STATUS_LUNCOPY_READY = '40'
|
||||
STATUS_QOS_ACTIVE = '2'
|
||||
STATUS_QOS_INACTIVE = '45'
|
||||
LUN_TYPE = '11'
|
||||
SNAPSHOT_TYPE = '27'
|
||||
|
||||
BLOCK_STORAGE_POOL_TYPE = '1'
|
||||
FILE_SYSTEM_POOL_TYPE = '2'
|
||||
|
|
|
@ -19,6 +19,7 @@ from oslo_utils import excutils
|
|||
from cinder import context
|
||||
from cinder import exception
|
||||
from cinder.i18n import _, _LI
|
||||
from cinder import utils
|
||||
from cinder.volume.drivers.huawei import constants
|
||||
from cinder.volume import qos_specs
|
||||
|
||||
|
@ -44,6 +45,10 @@ class SmartQos(object):
|
|||
qos = {}
|
||||
io_type_flag = None
|
||||
ctxt = context.get_admin_context()
|
||||
consumer = qos_specs.get_qos_specs(ctxt, qos_specs_id)['consumer']
|
||||
if consumer == 'front-end':
|
||||
return {}
|
||||
|
||||
kvs = qos_specs.get_qos_specs(ctxt, qos_specs_id)['specs']
|
||||
LOG.info(_LI('The QoS sepcs is: %s.'), kvs)
|
||||
for k, v in kvs.items():
|
||||
|
@ -96,6 +101,7 @@ class SmartQos(object):
|
|||
|
||||
return False
|
||||
|
||||
@utils.synchronized('huawei_qos', external=True)
|
||||
def add(self, qos, lun_id):
|
||||
policy_id = None
|
||||
try:
|
||||
|
@ -119,13 +125,14 @@ class SmartQos(object):
|
|||
if policy_id is not None:
|
||||
self.client.delete_qos_policy(policy_id)
|
||||
|
||||
@utils.synchronized('huawei_qos', external=True)
|
||||
def remove(self, qos_id, lun_id):
|
||||
qos_info = self.client.get_qos_info(qos_id)
|
||||
lun_list = self.client.get_lun_list_in_qos(qos_id, qos_info)
|
||||
if len(lun_list) <= 1:
|
||||
qos_status = qos_info['RUNNINGSTATUS']
|
||||
# 2: Active status.
|
||||
if qos_status == constants.STATUS_QOS_ACTIVE:
|
||||
if qos_status != constants.STATUS_QOS_INACTIVE:
|
||||
self.client.activate_deactivate_qos(qos_id, False)
|
||||
self.client.delete_qos_policy(qos_id)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue