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
This commit is contained in:
huyang 2017-03-01 09:28:34 +08:00
parent a55a6b5c71
commit b268b842bd
3 changed files with 16 additions and 8 deletions
cinder
tests/unit/volume/drivers/huawei
volume/drivers/huawei

@ -2934,7 +2934,6 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
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'])
@ -2947,6 +2946,7 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
lun_info = self.driver.create_volume(self.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',
@ -2958,14 +2958,14 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
'partitionname': 'partition-test'})
@mock.patch.object(huawei_driver.HuaweiBaseDriver, '_get_volume_type',
return_value={'qos_specs_id': u'025ce295-15e9-41a7'})
@mock.patch.object(qos_specs, 'get_qos_specs',
return_value={'specs': {'maxBandWidth': '100',
'IOType': '0'},
'consumer': 'back-end'})
def test_create_smartqos_success(self,
mock_consumer,
mock_qos_specs,
mock_value_type,
mock_volume_params):
mock_value_type):
self.mock_object(qos_specs, 'get_qos_specs',
return_value={'specs': {'maxBandWidth': '100',
'IOType': '0'},
'consumer': mock_consumer})
self.driver.support_func = FAKE_POOLS_SUPPORT_REPORT
lun_info = self.driver.create_volume(self.volume)
self.assertEqual('1', lun_info['provider_location'])

@ -19,6 +19,7 @@ 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'

@ -19,6 +19,7 @@ from oslo_utils import excutils
from cinder import context
from cinder import exception
from cinder.i18n import _
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('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: