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

Make polling interval and timeout variable for inventory batch fetch #1804

Merged
merged 1 commit into from
Jan 23, 2025
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
17 changes: 13 additions & 4 deletions plugins/inventory/azure_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
DOCUMENTATION = r'''
name: azure_rm
short_description: Azure Resource Manager inventory plugin
options:
batch_fetch_interval:
description: Interval with which to check if the batched requests are completed
default: 30
type: int
batch_fetch_timeout:
description: The timeout to use when polling for batched requests
default: 600
type: int
extends_documentation_fragment:
- azure.azcollection.azure
- azure.azcollection.azure_rm
Expand Down Expand Up @@ -239,6 +248,8 @@ def parse(self, inventory, loader, path, cache=True):
self._sanitize_group_name = self._legacy_script_compatible_group_sanitization

self._batch_fetch = self.get_option('batch_fetch')
self._batch_fetch_interval = self.get_option('batch_fetch_interval')
self._batch_fetch_timeout = self.get_option('batch_fetch_timeout')

self._legacy_hostnames = self.get_option('plain_host_names')

Expand Down Expand Up @@ -561,8 +572,6 @@ def _send_batch(self, batched_requests):
url = '/batch'
query_parameters = {'api-version': '2015-11-01'}
header_parameters = {'x-ms-client-request-id': str(uuid.uuid4()), 'Content-Type': 'application/json; charset=utf-8'}
polling_timeout = 600
polling_interval = 30
operation_config = {}
body_content = dict(requests=batched_requests)

Expand All @@ -578,8 +587,8 @@ def get_long_running_output(response):
poller = LROPoller(self.new_client,
PipelineResponse(None, response, None),
get_long_running_output,
ARMPolling(polling_interval, **operation_config))
response = self.get_poller_result(poller, polling_timeout)
ARMPolling(self._batch_fetch_interval, **operation_config))
response = self.get_poller_result(poller, self._batch_fetch_timeout)
if hasattr(response, 'body'):
response = json.loads(response.body())
elif hasattr(response, 'context'):
Expand Down