From c71599c4f5cc05fe030f705aa828385c90e9cd27 Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Tue, 3 May 2022 11:59:26 +0200 Subject: [PATCH 1/2] vmware_migrate_vmk: Add VLAN parameter --- .../fragments/1297-vmware_migrate_vmk-add_vlan.yml | 3 +++ plugins/modules/vmware_migrate_vmk.py | 11 +++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/1297-vmware_migrate_vmk-add_vlan.yml diff --git a/changelogs/fragments/1297-vmware_migrate_vmk-add_vlan.yml b/changelogs/fragments/1297-vmware_migrate_vmk-add_vlan.yml new file mode 100644 index 000000000..38451e277 --- /dev/null +++ b/changelogs/fragments/1297-vmware_migrate_vmk-add_vlan.yml @@ -0,0 +1,3 @@ +minor_changes: + - vmware_migrate_vmk - Add `migrate_vlan_id` to use for the VMK interface when migrating from VDS to VSS + (https://github.com/ansible-collections/community.vmware/issues/1297). diff --git a/plugins/modules/vmware_migrate_vmk.py b/plugins/modules/vmware_migrate_vmk.py index c21aaa2de..0dfd53b0d 100644 --- a/plugins/modules/vmware_migrate_vmk.py +++ b/plugins/modules/vmware_migrate_vmk.py @@ -53,6 +53,11 @@ - Portgroup name to migrate VMK interface to required: True type: str + migrate_vlan_id: + description: + - VLAN to use for the VMK interface when migrating from VDS to VSS + - Will be ignored when migrating from VSS to VDS + type: int extends_documentation_fragment: - community.vmware.vmware.documentation @@ -91,6 +96,7 @@ def __init__(self, module): self.host_system = None self.migrate_switch_name = self.module.params['migrate_switch_name'] self.migrate_portgroup_name = self.module.params['migrate_portgroup_name'] + self.migrate_vlan_id = self.module.params['migrate_vlan_id'] self.device = self.module.params['device'] self.esxi_hostname = self.module.params['esxi_hostname'] self.current_portgroup_name = self.module.params['current_portgroup_name'] @@ -130,7 +136,7 @@ def create_port_group_config_vds_vss(self): port_group_config.spec = vim.host.PortGroup.Specification() port_group_config.changeOperation = "add" port_group_config.spec.name = self.migrate_portgroup_name - port_group_config.spec.vlanId = 0 + port_group_config.spec.vlanId = self.migrate_vlan_id if self.migrate_vlan_id is not None else 0 port_group_config.spec.vswitchName = self.migrate_switch_name port_group_config.spec.policy = vim.host.NetworkPolicy() return port_group_config @@ -209,7 +215,8 @@ def main(): current_switch_name=dict(required=True, type='str'), current_portgroup_name=dict(required=True, type='str'), migrate_switch_name=dict(required=True, type='str'), - migrate_portgroup_name=dict(required=True, type='str'))) + migrate_portgroup_name=dict(required=True, type='str'), + migrate_vlan_id=dict(required=False, type='int'))) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=False) From b352c9215fcb64039ac247517cac452cafc857d4 Mon Sep 17 00:00:00 2001 From: Mario Lenz Date: Tue, 3 May 2022 17:05:00 +0200 Subject: [PATCH 2/2] Add version_added to new parameter --- plugins/modules/vmware_migrate_vmk.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/modules/vmware_migrate_vmk.py b/plugins/modules/vmware_migrate_vmk.py index 0dfd53b0d..699e0f7a3 100644 --- a/plugins/modules/vmware_migrate_vmk.py +++ b/plugins/modules/vmware_migrate_vmk.py @@ -54,6 +54,7 @@ required: True type: str migrate_vlan_id: + version_added: '2.4.0' description: - VLAN to use for the VMK interface when migrating from VDS to VSS - Will be ignored when migrating from VSS to VDS