Merge pull request #129 from cloudbuilders/floating_ip_cli
Add cli for floating ips
This commit is contained in:
commit
960cfbe328
@ -71,6 +71,7 @@ You'll find complete documentation on the shell by running
|
|||||||
Positional arguments:
|
Positional arguments:
|
||||||
<subcommand>
|
<subcommand>
|
||||||
add-fixed-ip Add a new fixed IP address to a servers network.
|
add-fixed-ip Add a new fixed IP address to a servers network.
|
||||||
|
add-floating-ip Add a floating IP address to a server.
|
||||||
backup Backup a server.
|
backup Backup a server.
|
||||||
backup-schedule Show or edit the backup schedule for a server.
|
backup-schedule Show or edit the backup schedule for a server.
|
||||||
backup-schedule-delete
|
backup-schedule-delete
|
||||||
@ -79,6 +80,9 @@ You'll find complete documentation on the shell by running
|
|||||||
delete Immediately shut down and delete a server.
|
delete Immediately shut down and delete a server.
|
||||||
flavor-list Print a list of available 'flavors' (sizes of
|
flavor-list Print a list of available 'flavors' (sizes of
|
||||||
servers).
|
servers).
|
||||||
|
floating-ip-create Allocate a floating IP to the current tenant.
|
||||||
|
floating-ip-delete De-allocate a floating IP from the current tenant.
|
||||||
|
floating-ip-list List allocated floating IPs for the current tenant.
|
||||||
help Display help about this program or one of its
|
help Display help about this program or one of its
|
||||||
subcommands.
|
subcommands.
|
||||||
image-create Create a new image by taking a snapshot of a running
|
image-create Create a new image by taking a snapshot of a running
|
||||||
@ -97,6 +101,7 @@ You'll find complete documentation on the shell by running
|
|||||||
reboot Reboot a server.
|
reboot Reboot a server.
|
||||||
rebuild Shutdown, re-image, and re-boot a server.
|
rebuild Shutdown, re-image, and re-boot a server.
|
||||||
remove-fixed-ip Remove an IP address from a server.
|
remove-fixed-ip Remove an IP address from a server.
|
||||||
|
remove-floating-ip Remove a floating IP address from a server.
|
||||||
rename Rename a server.
|
rename Rename a server.
|
||||||
rescue Rescue a server.
|
rescue Rescue a server.
|
||||||
resize Resize a server.
|
resize Resize a server.
|
||||||
|
@ -703,3 +703,43 @@ def do_remove_fixed_ip(cs, args):
|
|||||||
"""Remove an IP address from a server."""
|
"""Remove an IP address from a server."""
|
||||||
server = _find_server(cs, args.server)
|
server = _find_server(cs, args.server)
|
||||||
server.remove_fixed_ip(args.address)
|
server.remove_fixed_ip(args.address)
|
||||||
|
|
||||||
|
|
||||||
|
def _print_floating_ip_list(floating_ips):
|
||||||
|
utils.print_list(floating_ips, ['Ip', 'Instance Id', 'Fixed Ip'])
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||||
|
@utils.arg('address', metavar='<address>', help='IP Address.')
|
||||||
|
def do_add_floating_ip(cs, args):
|
||||||
|
"""Add a floating IP address to a server."""
|
||||||
|
server = _find_server(cs, args.server)
|
||||||
|
server.add_floating_ip(args.address)
|
||||||
|
|
||||||
|
|
||||||
|
@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."""
|
||||||
|
server = _find_server(cs, args.server)
|
||||||
|
server.remove_floating_ip(args.address)
|
||||||
|
|
||||||
|
|
||||||
|
def do_floating_ip_create(cs, args):
|
||||||
|
"""Allocate a floating IP for the current tenant."""
|
||||||
|
_print_floating_ip_list([cs.floating_ips.create()])
|
||||||
|
|
||||||
|
|
||||||
|
@utils.arg('address', metavar='<address>', help='IP of Floating Ip.')
|
||||||
|
def do_floating_ip_delete(cs, args):
|
||||||
|
"""De-allocate a floating IP."""
|
||||||
|
floating_ips = cs.floating_ips.list()
|
||||||
|
for floating_ip in floating_ips:
|
||||||
|
if floating_ip.ip == args.address:
|
||||||
|
return cs.floating_ips.delete(floating_ip.id)
|
||||||
|
raise exceptions.CommandError("Floating ip %s not found.", args.address)
|
||||||
|
|
||||||
|
|
||||||
|
def do_floating_ip_list(cs, args):
|
||||||
|
"""List floating ips for this tenant."""
|
||||||
|
_print_floating_ip_list(cs.floating_ips.list())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user