summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2012-02-15 17:08:36 -0500
committerRussell Bryant <rbryant@redhat.com>2012-02-15 17:15:50 -0500
commitb01933a2dcb6386ed89684d319bbe6a964d30402 (patch)
tree8a840e2cd4502401e3765d3a40326367efc21b04
parentf69b0923b8a81bad075d1972cd342d4d018f8170 (diff)
Print friendly message if no floating IPs exist.
Fix bug 932071. Print out a friendly message from nova-manage when the "floating list" command is issued but no floating IPs have been defined. Prior to this change, a generic error message would be printed, pointing to the log for further details. Change-Id: I0d11f93e9f51cf4e99e319bc9296f73380564257
-rwxr-xr-xbin/nova-manage12
1 files changed, 8 insertions, 4 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index 49ec41656..770b95368 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -721,10 +721,14 @@ class FloatingIpCommands(object):
"""Lists all floating ips (optionally by host)
Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
- if host is None:
- floating_ips = db.floating_ip_get_all(ctxt)
- else:
- floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
+ try:
+ if host is None:
+ floating_ips = db.floating_ip_get_all(ctxt)
+ else:
+ floating_ips = db.floating_ip_get_all_by_host(ctxt, host)
+ except exception.NoFloatingIpsDefined:
+ print _("No floating IP addresses have been defined.")
+ return
for floating_ip in floating_ips:
instance_id = None
if floating_ip['fixed_ip_id']: