Skip to content

Commit

Permalink
fixes for nova-manage network list if network has been deleted
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Tong Li committed Jul 19, 2012
1 parent 8d06ad4 commit 458a5d6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions bin/nova-manage
Expand Up @@ -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"""
Expand Down

0 comments on commit 458a5d6

Please sign in to comment.