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
This commit is contained in:
Tong Li
2012-07-18 11:26:12 -04:00
parent ad544b182d
commit 17625dd662

View File

@@ -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"""