summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTong Li <litong01@us.ibm.com>2012-07-18 11:26:12 -0400
committerTong Li <litong01@us.ibm.com>2012-07-19 12:11:14 -0400
commit458a5d61eac5eb5cef34ab301b67fa37271ba407 (patch)
tree08f68c76812c42d07e2edbebd2433b9e1511acd6
parent8d06ad4605457f909ed7f0cdfc7480b03e1a01b2 (diff)
fixes for nova-manage network list if network has been deleted
this fix addresses the bug #1021810 Currently command 'nova-manage network list' or 'nova-manage fixed list' will return 'Command failed.' message when there is no network defined or networks get deleted. This fix combined with fixes to bug 1025827 will fix both command problem. also change the print out message so that it can be translated. code structure changes according to the suggestion from comments. Change-Id: Id9a1a10217aac971cbbba9db5829c8478892db1a
-rwxr-xr-xbin/nova-manage28
1 files changed, 18 insertions, 10 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index b477ed284..857b7070f 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -542,16 +542,24 @@ class NetworkCommands(object):
_('VlanID'),
_('project'),
_("uuid"))
- for network in db.network_get_all(context.get_admin_context()):
- print _fmt % (network.id,
- network.cidr,
- network.cidr_v6,
- network.dhcp_start,
- network.dns1,
- network.dns2,
- network.vlan,
- network.project_id,
- network.uuid)
+ try:
+ # Since network_get_all can throw exception.NoNetworksFound
+ # for this command to show a nice result, this exception
+ # should be caught and handled as such.
+ networks = db.network_get_all(context.get_admin_context())
+ except exception.NoNetworksFound:
+ print _('No networks found')
+ else:
+ for network in networks:
+ print _fmt % (network.id,
+ network.cidr,
+ network.cidr_v6,
+ network.dhcp_start,
+ network.dns1,
+ network.dns2,
+ network.vlan,
+ network.project_id,
+ network.uuid)
def quantum_list(self):
"""List all created networks with Quantum-relevant fields"""