disable/enable a service has no output
When disable/enable a cinder service, there is no output, this caused end user does not know if the service was disabled/enabled successfully. It is better add some output for the command just like nova to tell end user the service status. Change-Id: I9d440ab7437c268b17627e255f152db0b3bf4f53 Closes-Bug: #1261120
This commit is contained in:
parent
a1a36499f4
commit
c2ef5eaf49
@ -696,11 +696,11 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
|
||||
def put_os_services_enable(self, body, **kw):
|
||||
return (200, {}, {'host': body['host'], 'binary': body['binary'],
|
||||
'status': 'disabled'})
|
||||
'status': 'enabled'})
|
||||
|
||||
def put_os_services_disable(self, body, **kw):
|
||||
return (200, {}, {'host': body['host'], 'binary': body['binary'],
|
||||
'status': 'enabled'})
|
||||
'status': 'disabled'})
|
||||
|
||||
def get_os_availability_zone(self, **kw):
|
||||
return (200, {}, {
|
||||
|
@ -52,11 +52,15 @@ class ServicesTest(utils.TestCase):
|
||||
[self.assertEqual(s.binary, 'cinder-volume') for s in svs]
|
||||
|
||||
def test_services_enable(self):
|
||||
cs.services.enable('host1', 'cinder-volume')
|
||||
s = cs.services.enable('host1', 'cinder-volume')
|
||||
values = {"host": "host1", 'binary': 'cinder-volume'}
|
||||
cs.assert_called('PUT', '/os-services/enable', values)
|
||||
self.assertTrue(isinstance(s, services.Service))
|
||||
self.assertEqual(s.status, 'enabled')
|
||||
|
||||
def test_services_disable(self):
|
||||
cs.services.disable('host1', 'cinder-volume')
|
||||
s = cs.services.disable('host1', 'cinder-volume')
|
||||
values = {"host": "host1", 'binary': 'cinder-volume'}
|
||||
cs.assert_called('PUT', '/os-services/disable', values)
|
||||
self.assertTrue(isinstance(s, services.Service))
|
||||
self.assertEqual(s.status, 'disabled')
|
||||
|
@ -335,3 +335,13 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('readonly-mode-update 1234 False')
|
||||
expected = {'os-update_readonly_flag': {'readonly': False}}
|
||||
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||
|
||||
def test_service_disable(self):
|
||||
self.run_command('service-disable host cinder-volume')
|
||||
self.assert_called('PUT', '/os-services/disable',
|
||||
{"binary": "cinder-volume", "host": "host"})
|
||||
|
||||
def test_service_disable(self):
|
||||
self.run_command('service-enable host cinder-volume')
|
||||
self.assert_called('PUT', '/os-services/enable',
|
||||
{"binary": "cinder-volume", "host": "host"})
|
||||
|
@ -706,11 +706,11 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
|
||||
def put_os_services_enable(self, body, **kw):
|
||||
return (200, {}, {'host': body['host'], 'binary': body['binary'],
|
||||
'status': 'disabled'})
|
||||
'status': 'enabled'})
|
||||
|
||||
def put_os_services_disable(self, body, **kw):
|
||||
return (200, {}, {'host': body['host'], 'binary': body['binary'],
|
||||
'status': 'enabled'})
|
||||
'status': 'disabled'})
|
||||
|
||||
def get_os_availability_zone(self, **kw):
|
||||
return (200, {}, {
|
||||
|
@ -52,11 +52,15 @@ class ServicesTest(utils.TestCase):
|
||||
[self.assertEqual(s.binary, 'cinder-volume') for s in svs]
|
||||
|
||||
def test_services_enable(self):
|
||||
cs.services.enable('host1', 'cinder-volume')
|
||||
s = cs.services.enable('host1', 'cinder-volume')
|
||||
values = {"host": "host1", 'binary': 'cinder-volume'}
|
||||
cs.assert_called('PUT', '/os-services/enable', values)
|
||||
self.assertTrue(isinstance(s, services.Service))
|
||||
self.assertEqual(s.status, 'enabled')
|
||||
|
||||
def test_services_disable(self):
|
||||
cs.services.disable('host1', 'cinder-volume')
|
||||
s = cs.services.disable('host1', 'cinder-volume')
|
||||
values = {"host": "host1", 'binary': 'cinder-volume'}
|
||||
cs.assert_called('PUT', '/os-services/disable', values)
|
||||
self.assertTrue(isinstance(s, services.Service))
|
||||
self.assertEqual(s.status, 'disabled')
|
||||
|
@ -313,3 +313,13 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('readonly-mode-update 1234 False')
|
||||
expected = {'os-update_readonly_flag': {'readonly': False}}
|
||||
self.assert_called('POST', '/volumes/1234/action', body=expected)
|
||||
|
||||
def test_service_disable(self):
|
||||
self.run_command('service-disable host cinder-volume')
|
||||
self.assert_called('PUT', '/os-services/disable',
|
||||
{"binary": "cinder-volume", "host": "host"})
|
||||
|
||||
def test_service_disable(self):
|
||||
self.run_command('service-enable host cinder-volume')
|
||||
self.assert_called('PUT', '/os-services/enable',
|
||||
{"binary": "cinder-volume", "host": "host"})
|
||||
|
@ -48,9 +48,11 @@ class ServiceManager(base.ManagerWithFind):
|
||||
def enable(self, host, binary):
|
||||
"""Enable the service specified by hostname and binary."""
|
||||
body = {"host": host, "binary": binary}
|
||||
self._update("/os-services/enable", body)
|
||||
result = self._update("/os-services/enable", body)
|
||||
return self.resource_class(self, result)
|
||||
|
||||
def disable(self, host, binary):
|
||||
"""Enable the service specified by hostname and binary."""
|
||||
body = {"host": host, "binary": binary}
|
||||
self._update("/os-services/disable", body)
|
||||
result = self._update("/os-services/disable", body)
|
||||
return self.resource_class(self, result)
|
||||
|
@ -993,7 +993,9 @@ def do_service_list(cs, args):
|
||||
@utils.service_type('volume')
|
||||
def do_service_enable(cs, args):
|
||||
"""Enable the service."""
|
||||
cs.services.enable(args.host, args.binary)
|
||||
result = cs.services.enable(args.host, args.binary)
|
||||
columns = ["Host", "Binary", "Status"]
|
||||
utils.print_list([result], columns)
|
||||
|
||||
|
||||
@utils.arg('host', metavar='<hostname>', help='Name of host.')
|
||||
@ -1001,7 +1003,9 @@ def do_service_enable(cs, args):
|
||||
@utils.service_type('volume')
|
||||
def do_service_disable(cs, args):
|
||||
"""Disable the service."""
|
||||
cs.services.disable(args.host, args.binary)
|
||||
result = cs.services.disable(args.host, args.binary)
|
||||
columns = ["Host", "Binary", "Status"]
|
||||
utils.print_list([result], columns)
|
||||
|
||||
|
||||
def _treeizeAvailabilityZone(zone):
|
||||
|
@ -48,9 +48,11 @@ class ServiceManager(base.ManagerWithFind):
|
||||
def enable(self, host, binary):
|
||||
"""Enable the service specified by hostname and binary."""
|
||||
body = {"host": host, "binary": binary}
|
||||
self._update("/os-services/enable", body)
|
||||
result = self._update("/os-services/enable", body)
|
||||
return self.resource_class(self, result)
|
||||
|
||||
def disable(self, host, binary):
|
||||
"""Enable the service specified by hostname and binary."""
|
||||
body = {"host": host, "binary": binary}
|
||||
self._update("/os-services/disable", body)
|
||||
result = self._update("/os-services/disable", body)
|
||||
return self.resource_class(self, result)
|
||||
|
@ -1087,7 +1087,9 @@ def do_service_list(cs, args):
|
||||
@utils.service_type('volumev2')
|
||||
def do_service_enable(cs, args):
|
||||
"""Enable the service."""
|
||||
cs.services.enable(args.host, args.binary)
|
||||
result = cs.services.enable(args.host, args.binary)
|
||||
columns = ["Host", "Binary", "Status"]
|
||||
utils.print_list([result], columns)
|
||||
|
||||
|
||||
@utils.arg('host', metavar='<hostname>', help='Name of host.')
|
||||
@ -1095,7 +1097,9 @@ def do_service_enable(cs, args):
|
||||
@utils.service_type('volumev2')
|
||||
def do_service_disable(cs, args):
|
||||
"""Disable the service."""
|
||||
cs.services.disable(args.host, args.binary)
|
||||
result = cs.services.disable(args.host, args.binary)
|
||||
columns = ["Host", "Binary", "Status"]
|
||||
utils.print_list([result], columns)
|
||||
|
||||
|
||||
def _treeizeAvailabilityZone(zone):
|
||||
|
Loading…
x
Reference in New Issue
Block a user