diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index fa012a557..91f60c970 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1054,6 +1054,16 @@ class ShellTest(utils.TestCase): self.assert_called('POST', '/servers/1234/action', {'removeFloatingIp': {'address': '11.0.0.1'}}) + def test_server_floating_ip_associate(self): + self.run_command('floating-ip-associate sample-server 11.0.0.1') + self.assert_called('POST', '/servers/1234/action', + {'addFloatingIp': {'address': '11.0.0.1'}}) + + def test_server_floating_ip_disassociate(self): + self.run_command('floating-ip-disassociate sample-server 11.0.0.1') + self.assert_called('POST', '/servers/1234/action', + {'removeFloatingIp': {'address': '11.0.0.1'}}) + def test_usage_list(self): self.run_command('usage-list --start 2000-01-20 --end 2005-02-01') self.assert_called('GET', diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index e6b3160a3..62e3f5066 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -1925,7 +1925,22 @@ def do_console_log(cs, args): default=None, help='Fixed IP Address to associate with.') def do_add_floating_ip(cs, args): - """Add a floating IP address to a server.""" + """DEPRECATED, use floating-ip-associate instead.""" + _associate_floating_ip(cs, args) + + +@utils.arg('server', metavar='', help='Name or ID of server.') +@utils.arg('address', metavar='
', help='IP Address.') +@utils.arg('--fixed-address', + metavar='', + default=None, + help='Fixed IP Address to associate with.') +def do_floating_ip_associate(cs, args): + """Associate a floating IP address to a server.""" + _associate_floating_ip(cs, args) + + +def _associate_floating_ip(cs, args): server = _find_server(cs, args.server) server.add_floating_ip(args.address, args.fixed_address) @@ -1933,7 +1948,18 @@ def do_add_floating_ip(cs, args): @utils.arg('server', metavar='', help='Name or ID of server.') @utils.arg('address', metavar='
', help='IP Address.') def do_remove_floating_ip(cs, args): - """Remove a floating IP address from a server.""" + """DEPRECATED, use floating-ip-disassociate instead.""" + _disassociate_floating_ip(cs, args) + + +@utils.arg('server', metavar='', help='Name or ID of server.') +@utils.arg('address', metavar='
', help='IP Address.') +def do_floating_ip_disassociate(cs, args): + """Disassociate a floating IP address from a server.""" + _disassociate_floating_ip(cs, args) + + +def _disassociate_floating_ip(cs, args): server = _find_server(cs, args.server) server.remove_floating_ip(args.address)