Admin util: add in option to set the DVS teaming policy
The patch adds support to the admin utility to enable an admin to update the teaming policy of a DVS. This is done as follows: nsxadmin -r networks -o nsx-update --property dvs-id=<id> --property teamingpolicy=<policy> Supported polices currently are: FAILOVER_ORDER|ETHER_CHANNEL|LACP_ACTIVE|LACP_PASSIVE|LOADBALANCE_LOADBASED |LOADBALANCE_SRCID|LOADBALANCE_SRCMAC|LACP_V2 DocImpact Change-Id: I04a5ed67f3b54a522b5790a959fad62f8bed51a4
This commit is contained in:
parent
1466b7156c
commit
29c576ac04
@ -455,6 +455,14 @@ class Vcns(object):
|
||||
portgroup_id)
|
||||
return self.do_request(HTTP_DELETE, uri, format='xml', decode=False)
|
||||
|
||||
def get_vdn_switch(self, dvs_id):
|
||||
uri = '/api/2.0/vdn/switches/%s' % dvs_id
|
||||
return self.do_request(HTTP_GET, uri, decode=True)
|
||||
|
||||
def update_vdn_switch(self, switch):
|
||||
uri = '/api/2.0/vdn/switches'
|
||||
return self.do_request(HTTP_PUT, uri, switch)
|
||||
|
||||
def query_interface(self, edge_id, vnic_index):
|
||||
uri = "%s/%s/vnics/%d" % (URI_PREFIX, edge_id, vnic_index)
|
||||
return self.do_request(HTTP_GET, uri, decode=True)
|
||||
|
@ -16,6 +16,7 @@
|
||||
import logging
|
||||
import xml.etree.ElementTree as et
|
||||
|
||||
from vmware_nsx._i18n import _LE, _LI
|
||||
from vmware_nsx.shell.admin.plugins.common import constants
|
||||
from vmware_nsx.shell.admin.plugins.common import formatters
|
||||
|
||||
@ -51,6 +52,40 @@ def neutron_list_networks(resource, event, trigger,
|
||||
['type', 'moref', 'name']))
|
||||
|
||||
|
||||
@admin_utils.output_header
|
||||
def nsx_update_switch(resource, event, trigger, **kwargs):
|
||||
nsxv = utils.get_nsxv_client()
|
||||
if not kwargs.get('property'):
|
||||
LOG.error(_LE("Need to specify dvs-id parameter and "
|
||||
"attribute to update. Add --property dvs-id=<dvs-id> "
|
||||
"--property teamingpolicy=<policy>"))
|
||||
return
|
||||
properties = admin_utils.parse_multi_keyval_opt(kwargs['property'])
|
||||
dvs_id = properties.get('dvs-id')
|
||||
if not dvs_id:
|
||||
LOG.error(_LE("Need to specify dvs-id. "
|
||||
"Add --property dvs-id=<dvs-id>"))
|
||||
return
|
||||
h, switch = nsxv.get_vdn_switch(dvs_id)
|
||||
policy = properties.get('teamingpolicy')
|
||||
if policy:
|
||||
if switch['teamingPolicy'] == policy:
|
||||
LOG.info(_LI("Policy already set!"))
|
||||
return
|
||||
LOG.info(_LI("Updating NSXv switch %(dvs)s teaming policy to "
|
||||
"%(policy)s"), {'dvs': dvs_id, 'policy': policy})
|
||||
switch['teamingPolicy'] = policy
|
||||
switch = nsxv.update_vdn_switch(switch)
|
||||
LOG.info(_LI("Switch value after update: %s"), switch)
|
||||
else:
|
||||
LOG.error(_LE("No teaming policy set. "
|
||||
"Add --property teamingpolicy=<policy>"))
|
||||
LOG.info(_LI("Current switch value is: %s"), switch)
|
||||
|
||||
|
||||
registry.subscribe(neutron_list_networks,
|
||||
constants.NETWORKS,
|
||||
shell.Operations.LIST.value)
|
||||
registry.subscribe(nsx_update_switch,
|
||||
constants.NETWORKS,
|
||||
shell.Operations.NSX_UPDATE.value)
|
||||
|
@ -99,7 +99,8 @@ nsxv_resources = {
|
||||
[Operations.LIST.value,
|
||||
Operations.NSX_UPDATE.value]),
|
||||
constants.NETWORKS: Resource(constants.NETWORKS,
|
||||
[Operations.LIST.value]),
|
||||
[Operations.LIST.value,
|
||||
Operations.NSX_UPDATE.value]),
|
||||
constants.SECURITY_GROUPS: Resource(constants.SECURITY_GROUPS,
|
||||
[Operations.LIST.value]),
|
||||
constants.FIREWALL_SECTIONS: Resource(constants.FIREWALL_SECTIONS,
|
||||
|
Loading…
Reference in New Issue
Block a user