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

Speedup vmware_guest_network module #2277

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

GuideGlyph
Copy link
Contributor

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

@GuideGlyph
Copy link
Contributor Author

guess this failed because esxi MOB is disabled by default, gonna return part of old code to be compatible

Build failed. https://ansible.softwarefactory-project.io/zuul/buildset/8f9786e13bd147a482ee5496198a3336

✔️ ansible-tox-linters SUCCESS in 4m 22s ✔️ build-ansible-collection SUCCESS in 7m 30s ✔️ ansible-test-cloud-integration-vcenter7_only-stable218 SUCCESS in 17m 02s ✔️ ansible-test-cloud-integration-vcenter7_2esxi-stable218 SUCCESS in 17m 54s ❌ ansible-test-cloud-integration-vcenter7_1esxi-stable218_1_of_2 FAILURE in 42m 44s ⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable218_2_of_2 CANCELED ✔️ ansible-galaxy-importer SUCCESS in 4m 42s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant