Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vmware_guest_network speedup module (#2277)
SUMMARY Speedup vmware_guest_network module. Current design loop though all networks and slow for big infrastructure with many networks (more then 100). ISSUE TYPE Bugfix Pull Request Docs Pull Request COMPONENT NAME vmware_guest_network.py ADDITIONAL INFORMATION In my scenario current module spend 5 min to find network (this function run twice during module work and lead to 10min waiting) if compute_resource: for 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: if network.config.name == network_name: return network if hasattr(network.config.defaultPortConfig.vlan, 'vlanId') and \ network.config.defaultPortConfig.vlan.vlanId == vlan_id: return network if hasattr(network.config.defaultPortConfig.vlan, 'pvlanId') and \ network.config.defaultPortConfig.vlan.pvlanId == vlan_id: return network elif isinstance(network, vim.Network): if network_name and network_name == network.name: return network if vlan_id: for k in pg_lookup.keys(): if vlan_id == pg_lookup[k]['vlan_id']: if k == network.name: return network break This code loop through networks and check if its name equal to self.params['network_name']. Its slow. Its about 30s to check 100 networks. vmware.py has perfect function for this. PyVmomi.find_network_by_name works perfect and find network immediately Reviewed-by: Mario Lenz <[email protected]>
- Loading branch information