Revert API changes in "Unify Manager._update behaviour"

This revert some of commit 6307310466,
specifically the changes made to the API since those changes were
never merged in Nova.

Resolves bug 1145768.

Change-Id: I8f83c5a33cfed0c3a659f5221b8b2e730ca9463f
This commit is contained in:
Hans Lindgren 2013-03-07 21:49:30 +01:00
parent f73df49e4f
commit 65b55d8f9b
4 changed files with 19 additions and 19 deletions

View File

@ -54,7 +54,7 @@ class HostManager(base.ManagerWithFind):
def update(self, host, values):
"""Update status or maintenance mode for the host."""
return self._update("/os-hosts/%s" % host, {"host": values}, "host")
return self._update("/os-hosts/%s" % host, values)
def host_action(self, host, action):
"""Performs an action on a host."""

View File

@ -1357,10 +1357,10 @@ class FakeHTTPClient(base_client.HTTPClient):
def get_os_hosts(self, **kw):
zone = kw.get('zone', 'nova1')
return (200, {}, {'hosts':
[{'host_name': 'host1',
[{'host': 'host1',
'service': 'nova-compute',
'zone': zone},
{'host_name': 'host1',
{'host': 'host1',
'service': 'nova-cert',
'zone': zone}]})
@ -1368,25 +1368,25 @@ class FakeHTTPClient(base_client.HTTPClient):
return (200, {}, {'host': [{'resource': {'host': 'sample_host'}}], })
def put_os_hosts_sample_host_1(self, body, **kw):
return (200, {}, {'host': {'host_name': 'sample-host_1',
'status': 'enabled'}})
return (200, {}, {'host': 'sample-host_1',
'status': 'enabled'})
def put_os_hosts_sample_host_2(self, body, **kw):
return (200, {}, {'host': {'host_name': 'sample-host_2',
'maintenance_mode': 'on_maintenance'}})
return (200, {}, {'host': 'sample-host_2',
'maintenance_mode': 'on_maintenance'})
def put_os_hosts_sample_host_3(self, body, **kw):
return (200, {}, {'host': {'host_name': 'sample-host_3',
'status': 'enabled',
'maintenance_mode': 'on_maintenance'}})
return (200, {}, {'host': 'sample-host_3',
'status': 'enabled',
'maintenance_mode': 'on_maintenance'})
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'}
result.update(body['host'])
return (200, {}, {'host': result})
result = {'host': 'dummy'}
result.update(body)
return (200, {}, result)
def get_os_hypervisors(self, **kw):
return (200, {}, {"hypervisors": [

View File

@ -29,14 +29,14 @@ class HostsTest(utils.TestCase):
host = cs.hosts.get('sample_host')[0]
values = {"status": "enabled"}
result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {'host': values})
cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host))
def test_update_maintenance(self):
host = cs.hosts.get('sample_host')[0]
values = {"maintenance_mode": "enable"}
result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {'host': values})
cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host))
def test_update_both(self):
@ -44,7 +44,7 @@ class HostsTest(utils.TestCase):
values = {"status": "enabled",
"maintenance_mode": "enable"}
result = host.update(values)
cs.assert_called('PUT', '/os-hosts/sample_host', {'host': values})
cs.assert_called('PUT', '/os-hosts/sample_host', values)
self.assertTrue(isinstance(result, hosts.Host))
def test_host_startup(self):

View File

@ -814,18 +814,18 @@ class ShellTest(utils.TestCase):
def test_host_update_status(self):
self.run_command('host-update sample-host_1 --status enabled')
body = {'host': {'status': 'enabled'}}
body = {'status': 'enabled'}
self.assert_called('PUT', '/os-hosts/sample-host_1', body)
def test_host_update_maintenance(self):
self.run_command('host-update sample-host_2 --maintenance enable')
body = {'host': {'maintenance_mode': 'enable'}}
body = {'maintenance_mode': 'enable'}
self.assert_called('PUT', '/os-hosts/sample-host_2', body)
def test_host_update_multiple_settings(self):
self.run_command('host-update sample-host_3 '
'--status disabled --maintenance enable')
body = {'host': {'status': 'disabled', 'maintenance_mode': 'enable'}}
body = {'status': 'disabled', 'maintenance_mode': 'enable'}
self.assert_called('PUT', '/os-hosts/sample-host_3', body)
def test_host_startup(self):