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

This commit is contained in:
Jenkins 2016-10-09 05:52:56 +00:00 committed by Gerrit Code Review
commit 990cf7475a
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,