Merge "Adding Nova Client support for auto find host APIv3"
This commit is contained in:
commit
74bb2ce0be
|
@ -197,11 +197,11 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
|
|||
}
|
||||
body_param_check_exists = {
|
||||
'rebuild': 'image_ref',
|
||||
'resize': 'flavor_ref'}
|
||||
'resize': 'flavor_ref',
|
||||
'evacuate': 'on_shared_storage'}
|
||||
body_params_check_exact = {
|
||||
'reboot': ['type'],
|
||||
'add_fixed_ip': ['network_id'],
|
||||
'evacuate': ['host', 'on_shared_storage'],
|
||||
'remove_fixed_ip': ['address'],
|
||||
'change_password': ['admin_password'],
|
||||
'get_console_output': ['length'],
|
||||
|
@ -226,9 +226,6 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
|
|||
if action in body_param_check_exists:
|
||||
assert body_param_check_exists[action] in body[action]
|
||||
|
||||
if action == 'evacuate':
|
||||
body[action].pop('admin_password', None)
|
||||
|
||||
if action in body_params_check_exact:
|
||||
assert set(body[action]) == set(body_params_check_exact[action])
|
||||
|
||||
|
|
|
@ -563,6 +563,39 @@ class ShellTest(utils.TestCase):
|
|||
self.assertRaises(exceptions.InstanceInErrorState, self.run_command,
|
||||
'boot --flavor 1 --image 1 some-bad-server --poll')
|
||||
|
||||
def test_evacuate(self):
|
||||
self.run_command('evacuate sample-server new_host')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'host': 'new_host',
|
||||
'on_shared_storage': False}})
|
||||
self.run_command('evacuate sample-server new_host '
|
||||
'--password NewAdminPass')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'host': 'new_host',
|
||||
'on_shared_storage': False,
|
||||
'admin_password': 'NewAdminPass'}})
|
||||
self.run_command('evacuate sample-server new_host')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'host': 'new_host',
|
||||
'on_shared_storage': False}})
|
||||
self.run_command('evacuate sample-server new_host '
|
||||
'--on-shared-storage')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'host': 'new_host',
|
||||
'on_shared_storage': True}})
|
||||
|
||||
def test_evacuate_with_no_target_host(self):
|
||||
self.run_command('evacuate sample-server')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'on_shared_storage': False}})
|
||||
self.run_command('evacuate sample-server --password NewAdminPass')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'on_shared_storage': False,
|
||||
'admin_password': 'NewAdminPass'}})
|
||||
self.run_command('evacuate sample-server --on-shared-storage')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'evacuate': {'on_shared_storage': True}})
|
||||
|
||||
def test_boot_named_flavor(self):
|
||||
self.run_command(["boot", "--image", "1",
|
||||
"--flavor", "512 MB Server",
|
||||
|
|
|
@ -320,7 +320,7 @@ class Server(base.Resource):
|
|||
"""
|
||||
self.manager.reset_network(self)
|
||||
|
||||
def evacuate(self, host, on_shared_storage, password=None):
|
||||
def evacuate(self, host=None, on_shared_storage=True, password=None):
|
||||
"""
|
||||
Evacuate an instance from failed host to specified host.
|
||||
|
||||
|
@ -950,7 +950,8 @@ class ServerManager(base.BootingManagerWithFind):
|
|||
"""
|
||||
self._action('reset_network', server)
|
||||
|
||||
def evacuate(self, server, host, on_shared_storage, password=None):
|
||||
def evacuate(self, server, host=None,
|
||||
on_shared_storage=True, password=None):
|
||||
"""
|
||||
Evacuate a server instance.
|
||||
|
||||
|
@ -960,10 +961,9 @@ class ServerManager(base.BootingManagerWithFind):
|
|||
on shared storage
|
||||
:param password: string to set as password on the evacuated server.
|
||||
"""
|
||||
body = {
|
||||
'host': host,
|
||||
'on_shared_storage': on_shared_storage,
|
||||
}
|
||||
body = {'on_shared_storage': on_shared_storage}
|
||||
if host is not None:
|
||||
body['host'] = host
|
||||
|
||||
if password is not None:
|
||||
body['admin_password'] = password
|
||||
|
|
|
@ -2923,11 +2923,12 @@ def do_quota_delete(cs, args):
|
|||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
@utils.arg('host', metavar='<host>', help='Name or ID of target host.')
|
||||
@utils.arg('host', metavar='<host>', nargs='?',
|
||||
help="Name or ID of the target host. "
|
||||
"If no host is specified, the scheduler will choose one.")
|
||||
@utils.arg('--password',
|
||||
dest='password',
|
||||
metavar='<password>',
|
||||
default=None,
|
||||
help="Set the provided password on the evacuated server. Not applicable "
|
||||
"with on-shared-storage flag")
|
||||
@utils.arg('--on-shared-storage',
|
||||
|
|
Loading…
Reference in New Issue