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

VMware: refactor REST APIs #60220

Merged
merged 1 commit into from
Aug 20, 2019
Merged

VMware: refactor REST APIs #60220

merged 1 commit into from
Aug 20, 2019

Conversation

Akasurde
Copy link
Member

@Akasurde Akasurde commented Aug 7, 2019

SUMMARY

Signed-off-by: Abhijeet Kasurde akasurde@redhat.com

ISSUE TYPE
  • Feature Pull Request
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

@Akasurde Akasurde requested review from goneri and jillr August 7, 2019 16:27
@Akasurde
Copy link
Member Author

Akasurde commented Aug 7, 2019

cc @Tomorrow9 @pgbidkar

@ansibot
Copy link
Contributor

ansibot commented Aug 7, 2019

@ansibot ansibot added affects_2.9 This issue/PR affects Ansible v2.9 cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community labels Aug 7, 2019
@ansibot
Copy link
Contributor

ansibot commented Aug 7, 2019

Copy link
Contributor

@jillr jillr left a 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```

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Aug 8, 2019
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde Akasurde merged commit dae2040 into ansible:devel Aug 20, 2019
@Akasurde Akasurde deleted the rest_refactor branch August 20, 2019 03:45
@ansible ansible locked and limited conversation to collaborators Sep 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.9 This issue/PR affects Ansible v2.9 cloud community_review In order to be merged, this PR must follow the community review workflow. feature This issue/PR relates to a feature request. module This issue/PR relates to a module. support:community This issue/PR relates to code supported by the Ansible community. vmware VMware community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants