Admin util: verify that a backup edge is a backup

Due to bugs we ran into cases where an edge is prefixed with 'backup-' but is
functioning as a DHCP or router edge.
Therefore we have to validate that the edge is unattached before we conclude
that it is really a backup.

Change-Id: I73fab0997edf36490df7c7db5c674baf2370f28d
This commit is contained in:
Kobi Samoray 2015-12-27 11:48:04 +02:00
parent 307133d844
commit bb06aecf8d

View File

@ -38,9 +38,13 @@ def get_nsxv_backup_edges():
edges = nsxv.get_edges()[1]
edges = edges['edgePage'].get('data', [])
backup_edges = []
edgeapi = utils.NeutronDbClient()
for edge in edges:
if edge['name'].startswith("backup-"):
backup_edges.append(edge)
edge_vnic_binds = nsxv_db.get_edge_vnic_bindings_by_edge(
edgeapi.context.session, edge['id'])
if not edge_vnic_binds:
backup_edges.append(edge)
return backup_edges
@ -71,7 +75,9 @@ def nsx_clean_backup_edge(resource, event, trigger, **kwargs):
else:
# edge[0] is response status code
# edge[1] is response body
if not edge[1]['name'].startswith('backup-'):
backup_edges = [e['id'] for e in get_nsxv_backup_edges()]
if (not edge[1]['name'].startswith('backup-')
or edge[1]['id'] not in backup_edges):
LOG.error(
_LE('Edge: %s is not a backup edge; aborting delete'), edge_id)
return