Clear out service disabled reason on enable

When a service gets re-enabled, clear out the 'disabled_reason' column.

Fix bug 1197423.

Change-Id: I78c9e40c65e96fbc6eff0e3426cfd87b0810cd69
This commit is contained in:
Russell Bryant 2013-07-03 12:15:06 -04:00
parent ef26aa31c4
commit 16b4efdb0d
2 changed files with 10 additions and 2 deletions

View File

@ -166,7 +166,10 @@ class ServiceController(object):
'status': status,
},
}
status_detail = {'disabled': disabled}
status_detail = {
'disabled': disabled,
'disabled_reason': None,
}
if id == "disable-log-reason":
reason = body['disabled_reason']
if not self._is_valid_as_reason(reason):

View File

@ -320,10 +320,15 @@ class ServicesTest(test.TestCase):
self.assertEqual(res_dict, response)
def test_services_enable(self):
def _service_update(context, service_id, values):
self.assertEqual(values['disabled_reason'], None)
self.stubs.Set(db, "service_update", _service_update)
body = {'host': 'host1', 'binary': 'nova-compute'}
req = fakes.HTTPRequest.blank('/v2/fake/os-services/enable')
res_dict = self.controller.update(req, "enable", body)
res_dict = self.controller.update(req, "enable", body)
self.assertEqual(res_dict['service']['status'], 'enabled')
self.assertFalse('disabled_reason' in res_dict['service'])