Merge "Clear out service disabled reason on enable"

This commit is contained in:
Jenkins 2013-07-14 17:03:07 +00:00 committed by Gerrit Code Review
commit 77a66a248b
2 changed files with 10 additions and 2 deletions

View File

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

View File

@ -320,10 +320,15 @@ class ServicesTest(test.TestCase):
self.assertEqual(res_dict, response) self.assertEqual(res_dict, response)
def test_services_enable(self): 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'} body = {'host': 'host1', 'binary': 'nova-compute'}
req = fakes.HTTPRequest.blank('/v2/fake/os-services/enable') 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.assertEqual(res_dict['service']['status'], 'enabled')
self.assertFalse('disabled_reason' in res_dict['service']) self.assertFalse('disabled_reason' in res_dict['service'])