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_guest_network speedup module #2277

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions plugins/modules/vmware_guest_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
network_name:
description:
- Name of network in vSphere.
- Work faster then o(vlan_id) for big infrastructure with many networks.
type: str
device_type:
default: vmxnet3
Expand Down Expand Up @@ -319,6 +320,17 @@ def _get_network_object(self, vm_obj):
for pg in vm_obj.runtime.host.config.network.portgroup:
pg_lookup[pg.spec.name] = {'switch': pg.spec.vswitchName, 'vlan_id': pg.spec.vlanId}

if network_name:
networks = self.find_network_by_name(network_name)
for network in networks:
if network in compute_resource.network:
if isinstance(network, vim.dvs.DistributedVirtualPortgroup):
dvs = network.config.distributedVirtualSwitch
if (switch_name and dvs.config.name == switch_name) or not switch_name:
return network
elif isinstance(network, vim.Network):
return network

if compute_resource:
for network in compute_resource.network:
if isinstance(network, vim.dvs.DistributedVirtualPortgroup):
Expand Down
Loading