Merge "[Admin-Util]: Add support to list missing edges for NSXv plugin"

This commit is contained in:
Jenkins 2016-04-06 09:08:23 +00:00 committed by Gerrit Code Review
commit 42cc581c01
3 changed files with 39 additions and 0 deletions

View File

@ -31,4 +31,5 @@ SPOOFGUARD_POLICY = 'spoofguard-policy'
DHCP_BINDING = 'dhcp-binding' DHCP_BINDING = 'dhcp-binding'
BACKUP_EDGES = 'backup-edges' BACKUP_EDGES = 'backup-edges'
ORPHANED_EDGES = 'orphaned-edges' ORPHANED_EDGES = 'orphaned-edges'
MISSING_EDGES = 'missing-edges'
NETWORKS = 'networks' NETWORKS = 'networks'

View File

@ -118,6 +118,39 @@ def nsx_delete_orphaned_edges(resource, event, trigger, **kwargs):
pprint.pformat(get_orphaned_edges())) pprint.pformat(get_orphaned_edges()))
def get_missing_edges():
nsxv_edge_ids = set()
for edge in get_nsxv_edges():
nsxv_edge_ids.add(edge.get('id'))
neutron_edge_bindings = set()
for binding in get_router_edge_bindings():
neutron_edge_bindings.add(binding.edge_id)
return neutron_edge_bindings - nsxv_edge_ids
@admin_utils.output_header
def nsx_list_missing_edges(resource, event, trigger, **kwargs):
"""List missing Edges on NSXv.
Missing edges are NSXv edges that have a binding in Neutron DB
but are currently missing from the NSXv backend.
"""
LOG.info(_LI("NSXv edges present in Neutron DB but not present "
"on the NSXv backend\n"))
missing_edges = get_missing_edges()
if not missing_edges:
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',)]
for edge in missing_edges:
data.append((edge,))
LOG.info(formatters.tabulate_results(data))
def change_edge_ha(properties): def change_edge_ha(properties):
ha = bool(properties.get('highavailability').lower() == "true") ha = bool(properties.get('highavailability').lower() == "true")
request = { request = {
@ -179,6 +212,9 @@ registry.subscribe(nsx_list_orphaned_edges,
registry.subscribe(nsx_delete_orphaned_edges, registry.subscribe(nsx_delete_orphaned_edges,
constants.ORPHANED_EDGES, constants.ORPHANED_EDGES,
shell.Operations.CLEAN.value) shell.Operations.CLEAN.value)
registry.subscribe(nsx_list_missing_edges,
constants.MISSING_EDGES,
shell.Operations.LIST.value)
registry.subscribe(nsx_update_edge, registry.subscribe(nsx_update_edge,
constants.EDGES, constants.EDGES,
shell.Operations.NSX_UPDATE.value) shell.Operations.NSX_UPDATE.value)

View File

@ -92,6 +92,8 @@ nsxv_resources = {
constants.ORPHANED_EDGES: Resource(constants.ORPHANED_EDGES, constants.ORPHANED_EDGES: Resource(constants.ORPHANED_EDGES,
[Operations.LIST.value, [Operations.LIST.value,
Operations.CLEAN.value]), Operations.CLEAN.value]),
constants.MISSING_EDGES: Resource(constants.MISSING_EDGES,
[Operations.LIST.value]),
constants.SPOOFGUARD_POLICY: Resource(constants.SPOOFGUARD_POLICY, constants.SPOOFGUARD_POLICY: Resource(constants.SPOOFGUARD_POLICY,
[Operations.LIST.value, [Operations.LIST.value,
Operations.CLEAN.value]), Operations.CLEAN.value]),