Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vmware_migrate_vmk: Add VLAN parameter #1305

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/1297-vmware_migrate_vmk-add_vlan.yml
Original file line number Diff line number Diff line change
@@ -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).
12 changes: 10 additions & 2 deletions plugins/modules/vmware_migrate_vmk.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
- Portgroup name to migrate VMK interface to
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
type: int
extends_documentation_fragment:
- community.vmware.vmware.documentation

Expand Down Expand Up @@ -91,6 +97,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']
Expand Down Expand Up @@ -130,7 +137,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
Expand Down Expand Up @@ -209,7 +216,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)

Expand Down