Adding --force support for nsxadmin backup-edges resources

Change-Id: Ic4d55c734230460225091c8e002cc68dbb785efb
This commit is contained in:
yuyangbj 2018-04-10 11:01:34 +08:00
parent 4013b4ca65
commit 2ffa65f5b9
2 changed files with 26 additions and 23 deletions

View File

@ -125,11 +125,11 @@ Backup Edges
- Delete backup edge:: - Delete backup edge::
nsxadmin -r backup-edges -o clean --property edge-id=edge-9 nsxadmin -r backup-edges -o clean --property edge-id=edge-9 [--force]
- Delete all backup edges:: - Delete all backup edges::
nsxadmin -r backup-edges -o clean-all nsxadmin -r backup-edges -o clean-all [--force]
- List Edge name mismatches between DB and backend, and backup edges that are missing from the backend:: - List Edge name mismatches between DB and backend, and backup edges that are missing from the backend::
@ -137,7 +137,7 @@ Backup Edges
- Fix Edge name mismatch between DB and backend by updating the name on the backend:: - Fix Edge name mismatch between DB and backend by updating the name on the backend::
nsxadmin -r backup-edges -o fix-mismatch --property edge-id=edge-9 nsxadmin -r backup-edges -o fix-mismatch --property edge-id=edge-9 [--force]
- Delete a backup edge from the DB and NSX by it's router ID:: - Delete a backup edge from the DB and NSX by it's router ID::

View File

@ -125,6 +125,7 @@ def nsx_clean_backup_edge(resource, event, trigger, **kwargs):
if not edge_id: if not edge_id:
LOG.error("%s", errmsg) LOG.error("%s", errmsg)
return return
if not kwargs.get('force'):
#ask for the user confirmation #ask for the user confirmation
confirm = admin_utils.query_yes_no( confirm = admin_utils.query_yes_no(
"Do you want to delete edge: %s" % edge_id, default="no") "Do you want to delete edge: %s" % edge_id, default="no")
@ -139,6 +140,7 @@ def nsx_clean_all_backup_edges(resource, event, trigger, **kwargs):
"""Delete all backup edges""" """Delete all backup edges"""
backup_edges = get_nsxv_backup_edges() backup_edges = get_nsxv_backup_edges()
if not kwargs.get('force'):
#ask for the user confirmation #ask for the user confirmation
confirm = admin_utils.query_yes_no( confirm = admin_utils.query_yes_no(
"Do you want to delete %s backup edges?" % len(backup_edges), "Do you want to delete %s backup edges?" % len(backup_edges),
@ -299,9 +301,10 @@ def nsx_fix_name_mismatch(resource, event, trigger, **kwargs):
'Edge %s', edge_id) 'Edge %s', edge_id)
return return
if not kwargs.get('force'):
confirm = admin_utils.query_yes_no( confirm = admin_utils.query_yes_no(
"Do you want to rename edge %s to %s" % (edge_id, "Do you want to rename edge %s to %s" %
edge['name']), (edge_id, edge['name']),
default="no") default="no")
if not confirm: if not confirm: