Skip to content

Commit

Permalink
add code
Browse files Browse the repository at this point in the history
  • Loading branch information
GuideGlyph committed Dec 23, 2024
1 parent 290bc26 commit 7b6d9bc
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 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,14 @@ 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:
dvs = network.config.distributedVirtualSwitch
if (switch_name and dvs.config.name == switch_name) or not switch_name:
return network

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

0 comments on commit 7b6d9bc

Please sign in to comment.