Merge "Fix huawei driver cannot delete qos while status is idle"

This commit is contained in:
Jenkins 2016-09-23 15:33:30 +00:00 committed by Gerrit Code Review
commit 77d245618f
4 changed files with 33 additions and 2 deletions

View File

@ -20,7 +20,10 @@ STATUS_FSSNAPSHOT_HEALTH = '1'
STATUS_JOIN_DOMAIN = '1'
STATUS_EXIT_DOMAIN = '0'
STATUS_SERVICE_RUNNING = "2"
STATUS_QOS_ACTIVE = '2'
QOS_STATUSES = (STATUS_QOS_ACTIVE,
STATUS_QOS_INACTIVATED,
STATUS_QOS_IDLE) = ('2', '45', '46')
DEFAULT_WAIT_INTERVAL = 3
DEFAULT_TIMEOUT = 60

View File

@ -95,7 +95,7 @@ class SmartQos(object):
def delete_qos(self, qos_id):
qos_info = self.helper.get_qos_info(qos_id)
qos_status = qos_info['RUNNINGSTATUS']
if qos_status == constants.STATUS_QOS_ACTIVE:
if qos_status != constants.STATUS_QOS_INACTIVATED:
self.helper.activate_deactivate_qos(qos_id, False)
self.helper.delete_qos_policy(qos_id)

View File

@ -4458,3 +4458,27 @@ class HuaweiShareDriverTestCase(test.TestCase):
'fake_pair_id')
self.assertEqual(expected_state, result_state)
@ddt.data(*constants.QOS_STATUSES)
def test_delete_qos(self, qos_status):
self.driver.plugin.helper.custom_results['/ioclass/11'] = {
"GET": """{"error":{"code":0}, "data":{"RUNNINGSTATUS": "%s"}}""" %
qos_status
}
activate_deactivate_qos_mock = self.mock_object(
self.driver.plugin.helper,
'activate_deactivate_qos')
delete_qos_mock = self.mock_object(
self.driver.plugin.helper,
'delete_qos_policy')
qos = smartx.SmartQos(self.driver.plugin.helper)
qos.delete_qos('11')
if qos_status == constants.STATUS_QOS_INACTIVATED:
activate_deactivate_qos_mock.assert_not_called()
else:
activate_deactivate_qos_mock.assert_called_once_with('11', False)
delete_qos_mock.assert_called_once_with('11')

View File

@ -0,0 +1,4 @@
---
fixes:
- Fixed qos deletion failing in huawei driver when qos status is 'idle'
by deactivating it first.