Merge "Update hosts API action calls (startup etc.)"
This commit is contained in:
commit
0295fca1a2
@ -58,8 +58,9 @@ class HostManager(base.ManagerWithFind):
|
||||
|
||||
def host_action(self, host, action):
|
||||
"""Performs an action on a host."""
|
||||
url = "/os-hosts/%s/%s" % (host, action)
|
||||
return self._create(url, None, "host")
|
||||
body = {action: None}
|
||||
url = '/os-hosts/%s/action' % host
|
||||
return self.api.client.post(url, body=body)
|
||||
|
||||
def list_all(self, zone=None):
|
||||
url = '/os-hosts'
|
||||
|
@ -1155,17 +1155,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
'status': 'enabled',
|
||||
'maintenance_mode': 'on_maintenance'}})
|
||||
|
||||
def post_os_hosts_sample_host_startup(self, **kw):
|
||||
return (200, {}, {'host': {'host_name': 'sample_host',
|
||||
'power_action': 'startup'}})
|
||||
|
||||
def post_os_hosts_sample_host_reboot(self, **kw):
|
||||
return (200, {}, {'host': {'host_name': 'sample_host',
|
||||
'power_action': 'reboot'}})
|
||||
|
||||
def post_os_hosts_sample_host_shutdown(self, **kw):
|
||||
return (200, {}, {'host': {'host_name': 'sample_host',
|
||||
'power_action': 'shutdown'}})
|
||||
def post_os_hosts_sample_host_action(self, **kw):
|
||||
return (202, {}, None)
|
||||
|
||||
def put_os_hosts_sample_host(self, body, **kw):
|
||||
result = {'host_name': 'dummy'}
|
||||
|
@ -50,17 +50,14 @@ class HostsTest(utils.TestCase):
|
||||
def test_host_startup(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.startup()
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/startup')
|
||||
self.assertTrue(isinstance(result, hosts.Host))
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/action', {'startup': None})
|
||||
|
||||
def test_host_reboot(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.reboot()
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/reboot')
|
||||
self.assertTrue(isinstance(result, hosts.Host))
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/action', {'reboot': None})
|
||||
|
||||
def test_host_shutdown(self):
|
||||
host = cs.hosts.get('sample_host')[0]
|
||||
result = host.shutdown()
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/shutdown')
|
||||
self.assertTrue(isinstance(result, hosts.Host))
|
||||
cs.assert_called('POST', '/os-hosts/sample_host/action', {'shutdown': None})
|
||||
|
@ -642,15 +642,15 @@ class ShellTest(utils.TestCase):
|
||||
|
||||
def test_host_startup(self):
|
||||
self.run_command('host-action sample-host --action startup')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/startup')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/action', {'startup': None})
|
||||
|
||||
def test_host_shutdown(self):
|
||||
self.run_command('host-action sample-host --action shutdown')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/shutdown')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/action', {'shutdown': None})
|
||||
|
||||
def test_host_reboot(self):
|
||||
self.run_command('host-action sample-host --action reboot')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/reboot')
|
||||
self.assert_called('POST', '/os-hosts/sample-host/action', {'reboot': None})
|
||||
|
||||
def test_coverage_start(self):
|
||||
self.run_command('coverage-start')
|
||||
|
Loading…
x
Reference in New Issue
Block a user