[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,17 +20,21 @@ 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
- Update the size of an edge::
nsxadmin -r edges -o nsx-update --property edge-id=edge-55 --property size=compact
nsxadmin -r edges -o nsx-update --property edge-id=edge-55 --property size=compact
- Update the high availability of an edge: enable/disable high availability of an edge::
nsxadmin -r edges -o nsx-update --property edge-id=edge-55 --property highavailability=<True/False>
nsxadmin -r edges -o nsx-update --property edge-id=edge-55 --property highavailability=<True/False>
Orphaned Edges
~~~~~~~~~~~~~~
@ -55,98 +59,98 @@ Backup Edges
- List backend backup edges with their id, name and some more information::
nsxadmin -r backup-edges -o list
nsxadmin -r backup-edges -o list
- 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
- List Edge name mismatches between DB and backend, and backup edges that are missing from the backend::
nsxadmin -r backup-edges -o list-mismatches
nsxadmin -r backup-edges -o list-mismatches
- 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
DHCP Bindings
~~~~~~~~~~~~~
- List missing DHCP bindings: list dhcp edges that are missing from the NSXv backend::
nsxadmin -r dhcp-binding -o list
nsxadmin -r dhcp-binding -o list
- Update DHCP bindings on an edge::
nsxadmin -r dhcp-binding -o nsx-update --property edge-id=edge-15
nsxadmin -r dhcp-binding -o nsx-update --property edge-id=edge-15
- Recreate DHCP edge by moving all the networks to other edges::
nsxadmin -r dhcp-binding -o nsx-recreate --property edge-id=edge-222
nsxadmin -r dhcp-binding -o nsx-recreate --property edge-id=edge-222
Routers
~~~~~~~
- Recreate a router edge by moving the router/s to other edge/s::
nsxadmin -r routers -o nsx-recreate --property edge-id=edge-308
nsxadmin -r routers -o nsx-recreate --property edge-id=edge-308
Networks
~~~~~~~~
- Ability to update or get the teaming policy for a DVS::
nsxadmin -r networks -o nsx-update --property dvs-id=<id> --property teamingpolicy=<policy>
nsxadmin -r networks -o nsx-update --property dvs-id=<id> --property teamingpolicy=<policy>
- List backend networks and their network morefs::
nsxadmin -r networks -o list
nsxadmin -r networks -o list
Missing Networks
~~~~~~~~~~~~~~~~
- List networks which are missing from the backend::
nsxadmin -r missing-networks -o list
nsxadmin -r missing-networks -o list
Orphaned Networks
~~~~~~~~~~~~~~~~~
- List networks which are missing from the neutron DB::
nsxadmin -r orphaned-networks -o list
nsxadmin -r orphaned-networks -o list
- Delete a backend network by it's moref::
nsxadmin -r orphaned-networks -o nsx-clean --property moref=<moref>
nsxadmin -r orphaned-networks -o nsx-clean --property moref=<moref>
Security Groups, Firewall and Spoofguard
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Security groups. This adds support to list security-groups mappings and miss-matches between the mappings and backend resources as: firewall-sections and nsx-security-groups::
nsxadmin --resource security-groups --operation list
nsxadmin -r nsx-security-groups -o {list, list-missmatches}
nsxadmin -r firewall-sections -o {list, list-missmatches}
nsxadmin --resource security-groups --operation list
nsxadmin -r nsx-security-groups -o {list, list-missmatches}
nsxadmin -r firewall-sections -o {list, list-missmatches}
- Spoofguard support::
nsxadmin -r spoofguard-policy -o list-mismatches
nsxadmin -r spoofguard-policy -o clean --property policy-id=spoofguardpolicy-10
nsxadmin -r spoofguard-policy -o list --property reverse (entries defined on NSXv and not in Neutron)
nsxadmin -r spoofguard-policy -o list-mismatches
nsxadmin -r spoofguard-policy -o clean --property policy-id=spoofguardpolicy-10
nsxadmin -r spoofguard-policy -o list --property reverse (entries defined on NSXv and not in Neutron)
Metadata
~~~~~~~~
- Update loadbalancer members on router and DHCP edges::
nsxadmin -r metadata -o nsx-update
nsxadmin -r metadata -o nsx-update
- Update shared secret on router and DHCP edges::
nsxadmin -r metadata -o nsx-update-secret
nsxadmin -r metadata -o nsx-update-secret
- Retrieve metadata connectivity - optionally for a specific network::
nsxadmin -r metadata -o status [--property network_id=<net_id>]
nsxadmin -r metadata -o status [--property network_id=<net_id>]
NSXv3
-----
@ -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,