Fix huawei driver cannot delete qos while status is idle

Currently, there are 3 statuses for qos:
  - 'active', 'inactivated' and 'idle'

If qos status is 'idle', the qos deletion will fail because
huawei driver doesn't deactivate it before deleting.

This change fixes this bug by deactivating qos first if qos
status is not 'inactivated'.

Change-Id: I40f937c22d77d8e07fba176bdc09ca461f01733a
Closes-Bug: #1625424
This commit is contained in:
zengyingzhe 2016-09-20 11:49:47 +08:00 committed by Yingzhe Zeng
parent 0a2fcb86bd
commit f20ab15beb
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

@ -4522,3 +4522,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.