mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fixing managed disk facts (#51781)
This commit is contained in:
parent
27dfdb6a6a
commit
0c8c72a0bf
2 changed files with 16 additions and 1 deletions
|
@ -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.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
|
||||
|
@ -210,6 +210,19 @@ class AzureRMManagedDiskFacts(AzureRMModuleBase):
|
|||
results.append(managed_disk_to_dict(item))
|
||||
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():
|
||||
"""Main module execution code path"""
|
||||
|
|
Loading…
Reference in a new issue