diff --git a/README.rst b/README.rst index 868675107..5c167b76a 100644 --- a/README.rst +++ b/README.rst @@ -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. diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 0e6a03302..2dbd2030a 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -705,6 +705,46 @@ def do_remove_fixed_ip(cs, args): 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()) + + def _print_secgroup_rules(rules): class FormattedRule: def __init__(self, obj):