Skip to content
This repository has been archived by the owner on Aug 10, 2024. It is now read-only.

Commit

Permalink
Process Azure VM extension information
Browse files Browse the repository at this point in the history
Extended the `AzVM` cloud plugin to extract the extenstion names from
the VM instance view details and put it in the `ext` bucket. This
extension information can be used to audit (whitelisted, blacklisted,
required) extensions installed on the Azure VMs.
  • Loading branch information
mitprasoon committed Mar 6, 2020
1 parent 1149dfd commit 3108d77
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion cloudmarker/clouds/azvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,8 @@ def _process_vm_instance_view(vm_index, vm, vm_iv,
record['ext'] = util.merge_dicts(
record['ext'],
_get_normalized_vm_statuses(vm_iv),
_get_normalized_vm_disk_encryption_status(vm, vm_iv)
_get_normalized_vm_disk_encryption_status(vm, vm_iv),
_get_vm_extension_list(vm_iv)
)
_log.info('Found vm_instance_view #%d: %s; %s',
vm_index, vm.get('name'),
Expand All @@ -246,6 +247,24 @@ def _get_normalized_vm_statuses(vm_iv):
return normalized_statuses


def _get_vm_extension_list(vm_iv):
"""Iterate over a list of virtual machine extensions.
Arguments:
vm_iv (dict): Raw virtual machine instance view record.
Returns:
dict: List of names of installed extensions
"""
extensions = {}
extension_list = []
for e in vm_iv.get('extensions', []):
extension_list.append(e['name'])
extensions['extensions'] = extension_list
return extensions


def _get_normalized_vm_disk_encryption_status(vm, vm_iv):
"""Iterate over a list of virtual machine disks normalize them.
Expand Down

0 comments on commit 3108d77

Please sign in to comment.