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: Add support in VMWare modules for BIOS and instance UUID's #44399

Merged
merged 14 commits into from
Feb 25, 2019

Conversation

naphta
Copy link
Contributor

@naphta naphta commented Aug 20, 2018

SUMMARY

Adding support for specifying the type of UUID to match against, by default it will continue to use the bios UUID which originally was the only one which worked.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

lib/ansible/module_utils/vmware.py
lib/ansible/modules/cloud/vmware/vmware_guest_boot_facts.py
lib/ansible/modules/cloud/vmware/vmware_guest_boot_manager.py
lib/ansible/modules/cloud/vmware/vmware_guest_custom_attributes.py
lib/ansible/modules/cloud/vmware/vmware_guest_disk_facts.py
lib/ansible/modules/cloud/vmware/vmware_guest_facts.py
lib/ansible/modules/cloud/vmware/vmware_guest_file_operation.py
lib/ansible/modules/cloud/vmware/vmware_guest_find.py
lib/ansible/modules/cloud/vmware/vmware_guest_move.py
lib/ansible/modules/cloud/vmware/vmware_guest_powerstate.py
lib/ansible/modules/cloud/vmware/vmware_guest_snapshot.py
lib/ansible/modules/cloud/vmware/vmware_guest_snapshot_facts.py
lib/ansible/modules/cloud/vmware/vmware_guest_tools_wait.py
lib/ansible/modules/cloud/vmware/vmware_vm_shell.py
lib/ansible/modules/cloud/vmware/vmware_vmotion.py
test/integration/targets/vmware_guest_facts/tasks/main.yml

ANSIBLE VERSION
ansible 2.7.0.dev0
  config file = None
  configured module search path = [u'/Users/jhill/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]
ADDITIONAL INFORMATION

I've put this in (and to every referenced module) to increase the options of how you can refer to a VM. In-house where I work we created a lot of VMWare modules before they were available directly from Ansible so in doing this we personally can migrate to Ansible code more easily. Broadly speaking it seemed logical to support either kind of UUID as in PyVmomi it boils down to a true/false to determine which one it searched on.

@naphta naphta changed the title Feature/vmware instance UUID Add support in VMWare modules for BIOS and instance UUID's Aug 20, 2018
@ansibot
Copy link
Contributor

ansibot commented Aug 20, 2018

Hi @naphta,

Thank you for the pullrequest, just so you are aware we have a dedicated Working Group for vmware.
You can find other people interested in this in #ansible-vmware on Freenode IRC
For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 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. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. vmware VMware community labels Aug 20, 2018
@ansibot

This comment has been minimized.

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. community_review In order to be merged, this PR must follow the community review workflow. and removed community_review In order to be merged, this PR must follow the community review workflow. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 20, 2018
Copy link
Contributor

@pdellaert pdellaert left a comment

Choose a reason for hiding this comment

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

Bunch of changes required. I'm also missing test cases for all the modules you have changed (because it would have identified a few issues, i think).

@pdellaert
Copy link
Contributor

Also think that this could be achieved with a boolean instead of a choice attribute, is_instance_uuid for those modules where a separate attribute makes sense (there's a bunch that already have vm_id_type, which should be reused)

cc @Akasurde

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. needs_triage Needs a first human triage before being processed. labels Aug 20, 2018
@naphta
Copy link
Contributor Author

naphta commented Aug 20, 2018

Boolean probably makes sense in hindsight (I'm sure vmware are unlikely to add another UUID).
Reusing vm_id_type definitely makes sense. Perhaps something like:

instance_uuid: yes/no

I could also wrap this functionality to be invisible so that it tries the BIOS UUID first then if nothing returns it continues with the instance UUID; I didn't do that originally just because it seemed a bit heavy, but asides from speed concerns it would make the user interface pretty simple. The UUID could also just be prefixed instance-.

My intention is to flesh out all of the test cases I just got the pull request open to start working on any of the already existing issues.

@pdellaert
Copy link
Contributor

@naphta, doing it transparent seems a bit dangerous. It's better, in my opinion, to give the choice. I do like the boolean approach more. I'd suggest use_instance_uuid, as it is more clear that it is a boolean and the purpose. Default false, of course.

Thanks!

@naphta
Copy link
Contributor Author

naphta commented Aug 20, 2018

Had a quick run at converting it to use a boolean, I'll look at fleshing out the tests in the coming days. I'm not especially familar with the project but are there any tests beyond the integration ones I need to concern myself with?

@ansibot

This comment has been minimized.

@ansibot

This comment has been minimized.

@naphta
Copy link
Contributor Author

naphta commented Aug 21, 2018

I couldn't see any other integration tests which refer to the UUID other than the one I already included.

@naphta
Copy link
Contributor Author

naphta commented Aug 21, 2018

ready_for_review

@naphta naphta force-pushed the feature/vmware-instance-uuid branch from f72856d to 2ef063c Compare January 30, 2019 09:49
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed merge_commit This PR contains at least one merge commit. Please resolve! needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 30, 2019
@naphta
Copy link
Contributor Author

naphta commented Jan 30, 2019

LGTM, except for some cosmetic/docs changes.

I would also like to see some of the integration tests using this option.

For what it's worth I did add a test in for this using the VMWare mock API included.

Copy link
Contributor

@pdellaert pdellaert left a comment

Choose a reason for hiding this comment

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

LGTM

Cool improvement :)

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 8, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 16, 2019

@Akasurde
Copy link
Member

Closing and re-opening for CI trigger.

@Akasurde Akasurde closed this Feb 22, 2019
@Akasurde Akasurde reopened this Feb 22, 2019
@Akasurde Akasurde changed the title Add support in VMWare modules for BIOS and instance UUID's VMware: Add support in VMWare modules for BIOS and instance UUID's Feb 22, 2019
@ansibot
Copy link
Contributor

ansibot commented Feb 22, 2019

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Feb 22, 2019
@Akasurde Akasurde merged commit e18d5ea into ansible:devel Feb 25, 2019
@Akasurde
Copy link
Member

@naphta Thanks for the contribution. @pdellaert @dagwieers Thanks for the reviews.

@ansible ansible locked and limited conversation to collaborators Jul 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.7 This issue/PR affects Ansible v2.7 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. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. test This PR relates to tests. vmware VMware community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants