Merge "Fixing host-action on V2"

This commit is contained in:
Jenkins 2013-07-31 05:32:45 +00:00 committed by Gerrit Code Review
commit 4ab2b60850
4 changed files with 19 additions and 11 deletions

@ -1444,8 +1444,17 @@ class FakeHTTPClient(base_client.HTTPClient):
'status': 'enabled',
'maintenance_mode': 'on_maintenance'})
def post_os_hosts_sample_host_action(self, **kw):
return (202, {}, None)
def get_os_hosts_sample_host_reboot(self, **kw):
return (200, {}, {'host': 'sample_host',
'power_action': 'reboot'})
def get_os_hosts_sample_host_startup(self, **kw):
return (200, {}, {'host': 'sample_host',
'power_action': 'startup'})
def get_os_hosts_sample_host_shutdown(self, **kw):
return (200, {}, {'host': 'sample_host',
'power_action': 'shutdown'})
def put_os_hosts_sample_host(self, body, **kw):
result = {'host': 'dummy'}

@ -51,16 +51,16 @@ class HostsTest(utils.TestCase):
host = cs.hosts.get('sample_host')[0]
result = host.startup()
cs.assert_called(
'POST', '/os-hosts/sample_host/action', {'startup': None})
'GET', '/os-hosts/sample_host/startup')
def test_host_reboot(self):
host = cs.hosts.get('sample_host')[0]
result = host.reboot()
cs.assert_called(
'POST', '/os-hosts/sample_host/action', {'reboot': None})
'GET', '/os-hosts/sample_host/reboot')
def test_host_shutdown(self):
host = cs.hosts.get('sample_host')[0]
result = host.shutdown()
cs.assert_called(
'POST', '/os-hosts/sample_host/action', {'shutdown': None})
'GET', '/os-hosts/sample_host/shutdown')

@ -1070,17 +1070,17 @@ 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/action', {'startup': None})
'GET', '/os-hosts/sample-host/startup')
def test_host_shutdown(self):
self.run_command('host-action sample-host --action shutdown')
self.assert_called(
'POST', '/os-hosts/sample-host/action', {'shutdown': None})
'GET', '/os-hosts/sample-host/shutdown')
def test_host_reboot(self):
self.run_command('host-action sample-host --action reboot')
self.assert_called(
'POST', '/os-hosts/sample-host/action', {'reboot': None})
'GET', '/os-hosts/sample-host/reboot')
def test_host_evacuate(self):
self.run_command('host-evacuate hyper --target target_hyper')

@ -58,9 +58,8 @@ class HostManager(base.ManagerWithFind):
def host_action(self, host, action):
"""Perform an action on a host."""
body = {action: None}
url = '/os-hosts/%s/action' % host
return self.api.client.post(url, body=body)
url = '/os-hosts/{0}/{1}'.format(host, action)
return self.api.client.get(url)
def list(self, zone=None):
url = '/os-hosts'