-
Notifications
You must be signed in to change notification settings - Fork 23.7k
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
VMware: refactor REST APIs #60220
VMware: refactor REST APIs #60220
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall this change looks pretty good but I wonder if we could remove some of the boilerplate by changing to a general purpose get_tags
type of method that takes an argument of the DynamicID
type, then module writers could create new tag lookups on the fly without having to add to vmware_rest_client.py
. Do you think something like this would work in practice? (Not sure if the method name here makes the most sense, but just as an example).
def get_tags_for_dynamic_obj(self, mid=None, type=None):
"""
Return list of tag object associated with object
Args:
mid: Dynamic object for specified object
type: Type of DynamicID to lookup
Returns: List of tag object associated with the given host system
"""
tags = []
if mid is None:
return tags
dynamic_managed_object = DynamicID(type=type, id=mid)
temp_tags_model = self.get_tags_for_object(dynamic_managed_object)
category_service = self.api_client.tagging.Category
for tag_obj in temp_tags_model:
tags.append({
'id': tag_obj.id,
'category_name': category_service.get(tag_obj.category_id).name,
'name': tag_obj.name,
'description': tag_obj.description,
'category_id': tag_obj.category_id,
})
return tags```
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
69e3f7f
to
a1b6ee6
Compare
SUMMARY
Signed-off-by: Abhijeet Kasurde akasurde@redhat.com
ISSUE TYPE
COMPONENT NAME
lib/ansible/module_utils/vmware_rest_client.py
lib/ansible/modules/cloud/vmware/vmware_cluster_facts.py
lib/ansible/modules/cloud/vmware/vmware_host_facts.py
lib/ansible/modules/cloud/vmware/vmware_vm_facts.py