[Admin-Util] add missing edges to nsxv backup-edges list-mismatches

output example:
==== [NSX] List Name Mismatches ====
backup-edges with name mismatch:
+---------+----------------------+----------------------+
| edge_id | edge_name            | router_id            |
+---------+----------------------+----------------------+
| edge-13 | backup-339b906a-d707 | 339b906a-d707        |
+---------+----------------------+----------------------+
backup-edges missing from backend:
+---------+----------------------+----------------+
| edge_id | router_id            | db_status      |
+---------+----------------------+----------------+
| edge-80 | backup-5c70d0e6-5da6 | ACTIVE         |
| None    | backup-74fbaa4a-2bd6 | PENDING_CREATE |
+---------+----------------------+----------------+

Change-Id: Iecbebe114f545218aa90ed9112e8fe836700102c
This commit is contained in:
Adit Sarfaty 2016-07-05 12:19:52 +03:00
parent 2607643ddb
commit ab2809581b
1 changed files with 23 additions and 1 deletions

View File

@ -111,8 +111,11 @@ def nsx_list_name_mismatches(resource, event, trigger, **kwargs):
edges = nsxv.get_edges()[1]
edges = edges['edgePage'].get('data', [])
plugin_nsx_mismatch = []
backend_edge_ids = []
edgeapi = utils.NeutronDbClient()
# Look for edges with the wrong names:
for edge in edges:
backend_edge_ids.append(edge['id'])
rtr_binding = nsxv_db.get_nsxv_router_binding_by_edge(
edgeapi.context.session, edge['id'])
@ -125,9 +128,28 @@ def nsx_list_name_mismatches(resource, event, trigger, **kwargs):
'router_id': rtr_binding['router_id']})
LOG.info(formatters.output_formatter(
constants.BACKUP_EDGES, plugin_nsx_mismatch,
constants.BACKUP_EDGES + ' with name mismatch:',
plugin_nsx_mismatch,
['edge_id', 'edge_name', 'router_id']))
# Also look for missing edges
like_filters = {'router_id': vcns_const.BACKUP_ROUTER_PREFIX + "%"}
rtr_bindings = nsxv_db.get_nsxv_router_bindings(edgeapi.context.session,
like_filters=like_filters)
plugin_nsx_missing = []
for rtr_binding in rtr_bindings:
if rtr_binding['edge_id'] not in backend_edge_ids:
plugin_nsx_missing.append(
{'edge_id': rtr_binding['edge_id'],
'router_id': rtr_binding['router_id'],
'db_status': rtr_binding['status']})
LOG.info(formatters.output_formatter(
constants.BACKUP_EDGES + ' missing from backend:',
plugin_nsx_missing,
['edge_id', 'router_id', 'db_status']))
def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
errmsg = ("Need to specify edge-id property. Add --property "