Skip to content

azure_rm inventory -- improvement via early filtering #1880

@Klaas-

Description

@Klaas-
SUMMARY

Currently the azure_rm inventory script is getting details on all virtual machines (instance view and nic details) for every VM in your defined resource groups (include_vm_resource_groups) or your whole subscription. It does not take into account *_host_filters until filtering the results. This means depending on how restrictive your filters are you may do a lot of unnecessary calls to the azure batch api.

Looking at the code I had no good idea how to easily filter it, but I guess you can do it either in:

inventory_client._enqueue_get(url="{0}/instanceView".format(vm_model['id']),
api_version=self._inventory_client._compute_api_version,
handler=self._on_instanceview_response)

and
inventory_client._enqueue_get(url=nic['id'],
api_version=api_version,
handler=self._on_nic_response,
handler_args=dict(is_primary=is_primary))

or maybe directly in

def _enqueue_get(self, url, api_version, handler, handler_args=None):
if not handler_args:
handler_args = {}
self._request_queue.put_nowait(UrlAction(url=url, api_version=api_version, handler=handler, handler_args=handler_args))

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

azure_rm

ADDITIONAL INFORMATION

Metadata

Metadata

Assignees

No one assigned

    Labels

    medium_priorityMedium prioritywork inIn trying to solve, or in working with contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions