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

add enable threading option #108

Merged
merged 1 commit into from
Sep 11, 2023
Merged
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
8 changes: 7 additions & 1 deletion nornir_nautobot/plugins/inventory/nautobot.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ def __init__( # pylint: disable=R0913
ssl_verify: Union[bool, None] = True,
filter_parameters: Union[Dict[str, Any], None] = None,
pynautobot_dict: Union[bool, None] = True,
enable_threading: Union[bool, None] = False,
) -> None:
"""Nautobot nornir class initialization."""
self.nautobot_url = nautobot_url or os.getenv("NAUTOBOT_URL")
self.nautobot_token = nautobot_token or os.getenv("NAUTOBOT_TOKEN")
self.filter_parameters = filter_parameters
self.ssl_verify = ssl_verify
self.pynautobot_dict = pynautobot_dict
self.enable_threading = enable_threading
self._verify_required()
self._api_session = None
self._devices = None
Expand Down Expand Up @@ -105,7 +107,11 @@ def pynautobot_obj(self) -> pynautobot.core.api.Api:
pynautobot object: Object to interact with the pynautobot SDK.
"""
if self._pynautobot_obj is None:
self._pynautobot_obj = pynautobot.api(self.nautobot_url, token=self.nautobot_token)
self._pynautobot_obj = pynautobot.api(
self.nautobot_url,
token=self.nautobot_token,
threading=self.enable_threading,
)
self._pynautobot_obj.http_session = self.api_session

return self._pynautobot_obj
Expand Down