Fixing managed disk facts (#51781)

pull/52315/head
Zim Kalinowski 6 years ago committed by GitHub
parent 27dfdb6a6a
commit 0c8c72a0bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- azure_rm_managed_disk_facts - added missing implementation of listing managed disks by resource group

@ -175,7 +175,7 @@ class AzureRMManagedDiskFacts(AzureRMModuleBase):
self.results['ansible_facts']['azure_managed_disk'] = ( self.results['ansible_facts']['azure_managed_disk'] = (
self.get_item() if self.name self.get_item() if self.name
else self.list_items() else (self.list_items_by_resource_group() if self.resource_group else self.list_items())
) )
return self.results return self.results
@ -210,6 +210,19 @@ class AzureRMManagedDiskFacts(AzureRMModuleBase):
results.append(managed_disk_to_dict(item)) results.append(managed_disk_to_dict(item))
return results return results
def list_items_by_resource_group(self):
"""Get managed disks in a resource group"""
try:
response = self.compute_client.disks.list_by_resource_group(resource_group_name=self.resource_group)
except CloudError as exc:
self.fail('Failed to list items by resource group - {}'.format(str(exc)))
results = []
for item in response:
if self.has_tags(item.tags, self.tags):
results.append(managed_disk_to_dict(item))
return results
def main(): def main():
"""Main module execution code path""" """Main module execution code path"""

Loading…
Cancel
Save