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

Fix dynamic VM fetch failure when I(batch_fetch=true) #1344

Merged
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
16 changes: 14 additions & 2 deletions plugins/inventory/azure_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
from azure.core.pipeline.policies import BearerTokenCredentialPolicy
from azure.core.configuration import Configuration
from azure.mgmt.core.tools import parse_resource_id
from azure.core.pipeline import PipelineResponse
from azure.mgmt.core.polling.arm_polling import ARMPolling
except ImportError:
Configuration = object
parse_resource_id = object
Expand Down Expand Up @@ -441,8 +443,18 @@ def _send_batch(self, batched_requests):

request_new = self.new_client.post(url, query_parameters, header_parameters, body_content)
response = self.new_client.send_request(request_new)

return json.loads(response.body())
if response.status_code == 202:
try:
poller = ARMPolling(timeout=3)
poller.initialize(client=self.new_client,
initial_response=PipelineResponse(None, response, None),
deserialization_callback=lambda r: r)
poller.run()
return poller.resource().context['deserialized_data']
except Exception as ec:
raise
else:
return json.loads(response.body())

def send_request(self, url, api_version):
query_parameters = {'api-version': api_version}
Expand Down