Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing managed disk facts #51781

Merged
merged 5 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelogs/fragments/51781-fixing-managed-disk-facts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- azure_rm_managed_disk_facts - added missing implementation of listing managed disks by resource group
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this into backport rather than devel?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jborean93 mentioned that it's best practice to add changelog fragments with pr in devel already, so I am adding now.

15 changes: 14 additions & 1 deletion lib/ansible/modules/cloud/azure/azure_rm_managed_disk_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def exec_module(self, **kwargs):

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
Expand Down Expand Up @@ -210,6 +210,19 @@ def list_items(self):
results.append(managed_disk_to_dict(item))
return results

def list_items_by_resource_group(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least one test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yungezz the test is there. and it just started failing, so this fix is fixing that test

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zikalino why it didn't failed during time of module merging?

"""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"""
Expand Down