Using floating-ip-{associate|disassociate}
This patch implements a blueprint to add more consistency into nova command, especially for the subcommand "floating-ip-*" Currently when we want to associate or disassociate an ip with nova we have to use add-floating-ip and remove-floating-ip. This is not consitent with the actual scheme of the subcommands: example: nova image-* nova flavor-* nova floating-ip-* + In the client v1.1 this patch displays a deprecated message when printing the help message for add-floating-ip and remove-floating-ip. + In the client v3 this patch do nothing because all floating ip commands are being removed. $:~/python-novaclient$ nova help | grep floating add-floating-ip DEPRECATED, use floating-ip-associate instead. floating-ip-associate Associate a floating IP address to a server. floating-ip-bulk-create Bulk create floating ips by range. floating-ip-bulk-delete Bulk delete floating ips by range. floating-ip-bulk-list List all floating ips. floating-ip-create Allocate a floating IP for the current tenant. floating-ip-delete De-allocate a floating IP. floating-ip-disassociate Remove a floating IP address from a server. floating-ip-list List floating ips for this tenant. floating-ip-pool-list List all floating ip pools. remove-floating-ip DEPRECATED, use floating-ip-disassociate instead. Implements: blueprint commands-floating-ip Change-Id: I5337d0f1ce5ec4826da6ecd2b6ae4ae7b97801e0
This commit is contained in:
parent
77a9574238
commit
4f92f7ba02
@ -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',
|
||||
|
@ -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='<server>', help='Name or ID of server.')
|
||||
@utils.arg('address', metavar='<address>', help='IP Address.')
|
||||
@utils.arg('--fixed-address',
|
||||
metavar='<fixed_address>',
|
||||
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='<server>', help='Name or ID of server.')
|
||||
@utils.arg('address', metavar='<address>', 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='<server>', help='Name or ID of server.')
|
||||
@utils.arg('address', metavar='<address>', 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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user