[Admin-util]: Add support to update resource pool ID for NSXv edges

This patch adds support to the nsxadmin util tool to update
the resource pool ID property for all edges. The resource pool ID
is picked up from the nsx.ini file and updated for all edges in the
backend.
Additionally fix some rendering for admin util.rst

Usage:
nsxadmin -r edges -o nsx-update-all -p appliances=True

Change-Id: I1f4e3137775aefd043da8dda2cd457a4d1f11bf7
This commit is contained in:
Abhishek Raut 2016-09-12 10:46:38 -07:00
parent ea7cbec5f9
commit feb3ce9ee8
3 changed files with 63 additions and 26 deletions

View File

@ -20,6 +20,10 @@ Edges
nsxadmin -r edges -o neutron-list
- Update Resource pool / Datastore on all edges in the backend. This utility can update resource pool and datastore ID of all edges to the nsx.ini configuration::
nsxadmin -r edges -o nsx-update-all --property appliances=True
- Update Resource pool / Datastore / edge HA of an edge: This utility can be used on upgrade after the customer added ha_datastore_id to the nsx.ini configuration or after changing the resource pool / data store globally or per availability zone. This Utility can update the deployment of existing edges::
nsxadmin -r edges -o nsx-update --property edge-id=<edge-id> --property appliances=True
@ -174,7 +178,7 @@ Ports
nsxadmin -r ports -o list-mismatches
- Update the VMs ports on the backend after migrating nsx-v -> nsx-v3
- Update the VMs ports on the backend after migrating nsx-v -> nsx-v3::
nsxadmin -r ports -o nsx-migrate-v-v3

View File

@ -258,6 +258,34 @@ def nsx_update_edge(resource, event, trigger, **kwargs):
LOG.error(usage_msg)
@admin_utils.output_header
def nsx_update_edges(resource, event, trigger, **kwargs):
"""Update all edges with the given property"""
if not kwargs.get('property'):
usage_msg = _LE("Need to specify a property to update all edges. "
"Add --property appliances=<True/False>")
LOG.error(usage_msg)
return
edges = utils.get_nsxv_backend_edges()
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
result = 0
for edge in edges:
if properties.get('appliances', 'false').lower() == "true":
try:
change_edge_appliance(edge.get('edge-id'))
except Exception as e:
result += 1
LOG.error(_LE("Failed to update edge %(edge)s. Exception: "
"%(e)s"), {'edge': edge.get('edge-id'),
'e': str(e)})
if result > 0:
total = len(edges)
msg = (_LE("%(result)s of %(total)s edges failed "
"to update.") % {'result': result, 'total': total})
LOG.error(msg)
registry.subscribe(nsx_list_edges,
constants.EDGES,
shell.Operations.NSX_LIST.value)
@ -276,3 +304,6 @@ registry.subscribe(nsx_list_missing_edges,
registry.subscribe(nsx_update_edge,
constants.EDGES,
shell.Operations.NSX_UPDATE.value)
registry.subscribe(nsx_update_edges,
constants.EDGES,
shell.Operations.NSX_UPDATE_ALL.value)

View File

@ -43,6 +43,7 @@ class Operations(enum.Enum):
NSX_LIST = 'nsx-list'
NSX_CLEAN = 'nsx-clean'
NSX_UPDATE = 'nsx-update'
NSX_UPDATE_ALL = 'nsx-update-all'
NSX_UPDATE_SECRET = 'nsx-update-secret'
NSX_RECREATE = 'nsx-recreate'
MIGRATE_TO_DYNAMIC_CRITERIA = 'migrate-to-dynamic-criteria'
@ -91,7 +92,8 @@ nsxv_resources = {
constants.EDGES: Resource(constants.EDGES,
[Operations.NSX_LIST.value,
Operations.NEUTRON_LIST.value,
Operations.NSX_UPDATE.value]),
Operations.NSX_UPDATE.value,
Operations.NSX_UPDATE_ALL.value]),
constants.BACKUP_EDGES: Resource(constants.BACKUP_EDGES,
[Operations.LIST.value,
Operations.CLEAN.value,