Skip to content

Commit

Permalink
Filtering out flexible parent
Browse files Browse the repository at this point in the history
  • Loading branch information
Justwmz authored Feb 23, 2024
1 parent 1d1e3a4 commit 4a3623f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"dev"
]
}
12 changes: 4 additions & 8 deletions plugins/inventory/azure_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,6 @@ def _on_vm_page_response(self, response, vmss=None):

if 'value' in response:
for h in response['value']:
# FUTURE: add direct VM filtering by tag here (performance optimization)?
self._hosts.append(AzureHost(h, self, vmss=vmss, legacy_name=self._legacy_hostnames))

def _on_vmss_page_response(self, response):
Expand All @@ -408,13 +407,10 @@ def _on_vmss_page_response(self, response):
for vmss in response['value']:
url = '{0}/virtualMachines'.format(vmss['id'])

# Since Flexible instance is a standalone VM, we are replacing ss provider to the vm one in order to allow inventory get instance view.
if vmss['properties']['orchestrationMode'] == 'Flexible':
newProvider = 'Microsoft.Compute/virtualMachineScaleSets/{0}/virtualMachines'.format(vmss['name'])
url = url.replace(newProvider, "Microsoft.Compute/virtualMachines")

# VMSS instances look close enough to regular VMs that we can share the handler impl...
self._enqueue_get(url=url, api_version=self._compute_api_version, handler=self._on_vm_page_response, handler_args=dict(vmss=vmss))
# Since Flexible instance is a standalone VM we are processing them as regular VM.
if vmss['properties']['orchestrationMode'] != 'Flexible':
# VMSS instances look close enough to regular VMs that we can share the handler impl...
self._enqueue_get(url=url, api_version=self._compute_api_version, handler=self._on_vm_page_response, handler_args=dict(vmss=vmss))

# use the undocumented /batch endpoint to bulk-send up to 500 requests in a single round-trip
#
Expand Down

0 comments on commit 4a3623f

Please sign in to comment.