Merge "Huawei driver supports front-end qos" into stable/ocata

This commit is contained in:
Jenkins 2017-07-25 14:23:01 +00:00 committed by Gerrit Code Review
commit 8267a97329
3 changed files with 16 additions and 8 deletions

View File

@ -2981,7 +2981,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'])
@ -2997,6 +2996,7 @@ class HuaweiISCSIDriverTestCase(HuaweiTestBase):
self.assertDictEqual(expect_value,
json.loads(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',
@ -3008,14 +3008,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)
expect_value = {"huawei_lun_id": "1",

View File

@ -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'

View File

@ -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: