[Admin-Util]: List networks associated with missing edges

Admin utility to list missing edges from the backend must also
display the networks attached to those edges. If no network is
attached to the missing edge, output N/A.

nsxadmin -r missing-edges -o list
NSX Plugin in use: nsxv
==== [NSX] List Missing Edges ====
NSXv edges present in Neutron DB but not present on the NSXv backend

+----------+--------------------------------------+
| edge_id  |              network_id              |
+----------+--------------------------------------+
| edge-122 |                 N/A                  |
| edge-121 | c58ba6d4-2280-4c31-9c11-2ecb048d7d72 |
| edge-126 |                 N/A                  |
| edge-125 | 0409492e-2548-420a-b799-4fc7d04ccdfb |
| edge-124 |                 N/A                  |
+----------+--------------------------------------+

Change-Id: I7e958f1e09a10b0e79b7ae8f41e0276a56308d7c
Closes-Bug: #1566738
This commit is contained in:
Abhishek Raut 2016-04-06 01:52:21 -07:00
parent f0002cb3c7
commit c3632ba304
1 changed files with 16 additions and 4 deletions

View File

@ -130,9 +130,15 @@ def get_missing_edges():
return neutron_edge_bindings - nsxv_edge_ids
def get_router_edge_vnic_bindings(edge_id):
edgeapi = utils.NeutronDbClient()
return nsxv_db.get_edge_vnic_bindings_by_edge(
edgeapi.context.session, edge_id)
@admin_utils.output_header
def nsx_list_missing_edges(resource, event, trigger, **kwargs):
"""List missing Edges on NSXv.
"""List missing edges and networks serviced by those edges.
Missing edges are NSXv edges that have a binding in Neutron DB
but are currently missing from the NSXv backend.
@ -144,10 +150,16 @@ def nsx_list_missing_edges(resource, event, trigger, **kwargs):
LOG.info(_LI("\nNo edges are missing."
"\nNeutron DB and NSXv backend are in sync\n"))
else:
LOG.info(constants.MISSING_EDGES)
data = [('edge_id',)]
data = [('edge_id', 'network_id')]
for edge in missing_edges:
data.append((edge,))
# Retrieve all networks which are serviced by this edge.
edge_serviced_networks = get_router_edge_vnic_bindings(edge)
if not edge_serviced_networks:
# If the edge is missing on the backend but no network
# is serviced by this edge, output N/A.
data.append((edge, 'N/A'))
for bindings in edge_serviced_networks:
data.append((edge, bindings.network_id))
LOG.info(formatters.tabulate_results(data))