From a6feadbba306763fdc98e1f2d0333abcaf61265c Mon Sep 17 00:00:00 2001 From: mldmld68 <22813818+mldmld68@users.noreply.github.com> Date: Tue, 21 Nov 2017 05:29:52 +0100 Subject: [PATCH] VMware: Allow users to specify DVS switch version (#32925) This fix adds option to specify DVS Switch version which is tuneable parameter. --- lib/ansible/modules/cloud/vmware/vmware_dvswitch.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py b/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py index 60369e8700..b4f02f7fdd 100644 --- a/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py +++ b/lib/ansible/modules/cloud/vmware/vmware_dvswitch.py @@ -22,7 +22,7 @@ description: version_added: 2.0 author: "Joseph Callen (@jcpowermac)" notes: - - Tested on vSphere 5.5 + - Tested on vSphere 6.5 requirements: - "python >= 2.6" - PyVmomi @@ -35,6 +35,12 @@ options: description: - The name of the switch to create or remove required: True + switch_version: + description: + - The version of the switch to create. Can be 6.5.0, 6.0.0, 5.5.0, 5.1.0, 5.0.0 with a vcenter running vSphere 6.5 + - Needed if you have a vcenter version > ESXi version to join DVS. If not specified version=version of vcenter + required: False + version_added: 2.5 mtu: description: - The switch maximum transmission unit @@ -77,6 +83,7 @@ EXAMPLES = ''' password: vcenter_password datacenter_name: datacenter switch_name: dvSwitch + switch_version: 6.0.0 mtu: 9000 uplink_quantity: 2 discovery_proto: lldp @@ -106,6 +113,7 @@ class VMwareDVSwitch(object): self.module = module self.dvs = None self.switch_name = self.module.params['switch_name'] + self.switch_version = self.module.params['switch_version'] self.datacenter_name = self.module.params['datacenter_name'] self.mtu = self.module.params['mtu'] self.uplink_quantity = self.module.params['uplink_quantity'] @@ -151,6 +159,7 @@ class VMwareDVSwitch(object): spec.productInfo = vim.dvs.ProductSpec() spec.productInfo.name = "DVS" spec.productInfo.vendor = "VMware" + spec.productInfo.version = self.switch_version for count in range(1, self.uplink_quantity + 1): spec.configSpec.uplinkPortPolicy.uplinkPortName.append("uplink%d" % count) @@ -193,6 +202,7 @@ def main(): argument_spec.update(dict(datacenter_name=dict(required=True, type='str'), switch_name=dict(required=True, type='str'), mtu=dict(required=True, type='int'), + switch_version=dict(type='str'), uplink_quantity=dict(required=True, type='int'), discovery_proto=dict(required=True, choices=['cdp', 'lldp'], type='str'), discovery_operation=dict(required=True, choices=['both', 'none', 'advertise', 'listen'], type='str'),