Add cli for floating ips

This commit is contained in:
Anthony Young 2011-10-11 04:07:08 +00:00
parent 16b083ddca
commit 4154b90364
2 changed files with 41 additions and 0 deletions

View File

@ -71,6 +71,7 @@ You'll find complete documentation on the shell by running
Positional arguments:
<subcommand>
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-schedule Show or edit the backup schedule for a server.
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.
flavor-list Print a list of available 'flavors' (sizes of
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
subcommands.
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.
rebuild Shutdown, re-image, and re-boot 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.
rescue Rescue a server.
resize Resize a server.

View File

@ -703,3 +703,39 @@ def do_remove_fixed_ip(cs, args):
"""Remove an IP address from a server."""
server = _find_server(cs, args.server)
server.remove_fixed_ip(args.address)
@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."""
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)
def do_floating_ip_list(cs, args):
"""List floating ips for this tenant."""
utils.print_list(cs.floating_ips.list(), ['Ip', 'Instance Id', \
'Fixed Ip'])