mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Refactor attribute lookup to make it multithreaded (#45786)
This commit is contained in:
parent
6d7004f367
commit
f6154bb2e3
1 changed files with 19 additions and 7 deletions
|
@ -86,6 +86,7 @@ query_filters:
|
|||
import json
|
||||
import uuid
|
||||
from sys import version as python_version
|
||||
from threading import Thread
|
||||
|
||||
from ansible.plugins.inventory import BaseInventoryPlugin
|
||||
from ansible.module_utils.ansible_release import __version__ as ansible_version
|
||||
|
@ -276,13 +277,24 @@ class InventoryModule(BaseInventoryPlugin):
|
|||
self.manufacturers_lookup = dict((manufacturer["id"], manufacturer["name"]) for manufacturer in manufacturers)
|
||||
|
||||
def refresh_lookups(self):
|
||||
self.refresh_sites_lookup()
|
||||
self.refresh_regions_lookup()
|
||||
self.refresh_tenants_lookup()
|
||||
self.refresh_racks_lookup()
|
||||
self.refresh_device_roles_lookup()
|
||||
self.refresh_device_types_lookup()
|
||||
self.refresh_manufacturers_lookup()
|
||||
lookup_processes = (
|
||||
self.refresh_sites_lookup,
|
||||
self.refresh_regions_lookup,
|
||||
self.refresh_tenants_lookup,
|
||||
self.refresh_racks_lookup,
|
||||
self.refresh_device_roles_lookup,
|
||||
self.refresh_device_types_lookup,
|
||||
self.refresh_manufacturers_lookup,
|
||||
)
|
||||
|
||||
thread_list = []
|
||||
for p in lookup_processes:
|
||||
t = Thread(target=p)
|
||||
thread_list.append(t)
|
||||
t.start()
|
||||
|
||||
for thread in thread_list:
|
||||
thread.join()
|
||||
|
||||
def validate_query_parameters(self, x):
|
||||
if not (isinstance(x, dict) and len(x) == 1):
|
||||
|
|
Loading…
Reference in a new issue