Merge "disable/enable a service has no output"

This commit is contained in:
Jenkins
2014-01-25 14:23:20 +00:00
committed by Gerrit Code Review
10 changed files with 56 additions and 16 deletions

View File

@@ -699,11 +699,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, {}, {

View File

@@ -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')

View File

@@ -341,3 +341,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"})

View File

@@ -709,11 +709,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, {}, {

View File

@@ -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')

View File

@@ -319,3 +319,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"})

View File

@@ -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)

View File

@@ -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):

View File

@@ -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)

View File

@@ -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):