diff --git a/novaclient/v1_1/hosts.py b/novaclient/v1_1/hosts.py index a6f5a04a0..3dea7021e 100644 --- a/novaclient/v1_1/hosts.py +++ b/novaclient/v1_1/hosts.py @@ -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' diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py index 6597819d9..478fc9df0 100644 --- a/tests/v1_1/fakes.py +++ b/tests/v1_1/fakes.py @@ -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'} diff --git a/tests/v1_1/test_hosts.py b/tests/v1_1/test_hosts.py index 57c2891a8..28964279d 100644 --- a/tests/v1_1/test_hosts.py +++ b/tests/v1_1/test_hosts.py @@ -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}) diff --git a/tests/v1_1/test_shell.py b/tests/v1_1/test_shell.py index 6d86bd93c..f9628beea 100644 --- a/tests/v1_1/test_shell.py +++ b/tests/v1_1/test_shell.py @@ -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')