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: vm_guest - allow existing vmdk files to be attached to guest #45953

Merged
merged 5 commits into from
Jan 30, 2019

Conversation

mrmagooey
Copy link
Contributor

SUMMARY

Allows existing vmdk files to be attached to a new guest vm. Adds the filename parameter to the disk dictionary. Still requires the the datastore to be separately specified as there are many dependencies on this value through the code.

Fixes #30041 , although that issue is for the deprecated vsphere_guest.py module.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

cloud/vmware/vmware_guest.py

ANSIBLE VERSION

2.7.0dev
vsphere vcenter 6.7

ADDITIONAL INFORMATION

Currently there is no method of attaching existing vmdk disks to a new guest vm (as far as I'm aware...). This PR will search for the specified vmdk file, get its size, and create the spec for attaching the existing disk to this vm. The guest vm also seems to be happy booting off a vmdk file attached like this.

A working yml disk definition to add a vmdk file looks like:

 ...
 disk:
   - filename: [datastore_name] path/to/my_disk.vmdk
      datastore: datastore_name

This will need some testing as I don't have a clustered vsphere setup to test on, and that might have some different behaviour that I don't know about.

I also note that there is a separate module being introduced at #36165 which this (should it work properly) might be appropriate to be merged into.

@ansibot
Copy link
Contributor

ansibot commented Sep 21, 2018

@ansibot
Copy link
Contributor

ansibot commented Sep 21, 2018

Hi @mrmagooey,

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.8 This issue/PR affects Ansible v2.8 cloud core_review In order to be merged, this PR must follow the core 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:core This issue/PR relates to code supported by the Ansible Engineering Team. vmware VMware community labels Sep 21, 2018
@ansibot
Copy link
Contributor

ansibot commented Sep 21, 2018

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: has a documentation error formatting or is missing documentation.

The test ansible-test sanity --test validate-modules [explain] failed with 14 errors:

lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E324 Value for "default" from the argument_spec ('first') for "name_match" does not match the documentation (None)
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E324 Value for "default" from the argument_spec ('ha-datacenter') for "datacenter" does not match the documentation (None)
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E324 Value for "default" from the argument_spec ('present') for "state" does not match the documentation (None)
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E324 Value for "default" from the argument_spec (443) for "port" does not match the documentation (None)
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E324 Value for "default" from the argument_spec (True) for "validate_certs" does not match the documentation (False)
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E325 argument_spec for "force" defines type="bool" but documentation does not
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E325 argument_spec for "is_template" defines type="bool" but documentation does not
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E325 argument_spec for "linked_clone" defines type="bool" but documentation does not
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E325 argument_spec for "validate_certs" defines type="bool" but documentation does not
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E325 argument_spec for "wait_for_ip_address" defines type="bool" but documentation does not
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E326 Value for "choices" from the argument_spec (['absent', 'poweredoff', 'poweredon', 'present', 'rebootguest', 'restarted', 'shutdownguest', 'suspended']) for "state" does not match the documentation ([])
lib/ansible/modules/cloud/vmware/vmware_guest.py:0:0: E326 Value for "choices" from the argument_spec (['first', 'last']) for "name_match" does not match the documentation ([])
lib/ansible/modules/cloud/vmware/vmware_guest.py:179:9: E302 DOCUMENTATION is not valid YAML
test/sanity/validate-modules/ignore.txt:487:1: A102 Remove since "lib/ansible/modules/cloud/vmware/vmware_guest.py" passes "E322" test

The test ansible-test sanity --test yamllint [explain] failed with 1 error:

lib/ansible/modules/cloud/vmware/vmware_guest.py:179:9: error DOCUMENTATION: syntax error: sequence entries are not allowed here

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Sep 21, 2018
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Sep 21, 2018
@ansibot ansibot added stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. core_review In order to be merged, this PR must follow the core review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Sep 29, 2018
@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:community This issue/PR relates to code supported by the Ansible community. and removed core_review In order to be merged, this PR must follow the core review workflow. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Oct 9, 2018
Copy link
Contributor

@jeking3 jeking3 left a comment

Choose a reason for hiding this comment

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

This breaks unit numbering.

@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. labels Nov 5, 2018
@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. labels Jan 23, 2019
@Akasurde
Copy link
Member

@pdellaert @mrmagooey @jeking3 Could you please review this ? Thanks in advance.

# index 7 is reserved to SCSI controller
if disk_index == 7:
disk_index += 1

Copy link
Contributor

Choose a reason for hiding this comment

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

This should also be capped at 15 based on today's ESXi scsi controller rules, unless we want to just let VMware enforce it with a task error...

Copy link
Member

Choose a reason for hiding this comment

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

I am planning to have that in this PR #33338

test/units/module_utils/test_vmware.py Show resolved Hide resolved
@jeking3
Copy link
Contributor

jeking3 commented Jan 23, 2019

Could use an integration test.

@Akasurde
Copy link
Member

@jeking3 Not sure if VCSIM supports, but will try to add integration test for this change.

@Akasurde
Copy link
Member

Akasurde commented Jan 23, 2019

@jeking3 VCSIM does not support Datastore.browser.SearchSubFolders API. I have filed an issue against vcsim - vmware/govmomi#1353

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

@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jan 28, 2019
@Akasurde Akasurde merged commit 8eff4ca into ansible:devel Jan 30, 2019
@Akasurde
Copy link
Member

@pdellaert @jeking3 Thanks for the review. @mrmagooey Thanks for the contribution.

Akasurde added a commit to Akasurde/ansible that referenced this pull request Feb 5, 2019
While creating new VM, don't assume the VMDKs are present,
create them as we attache the disk to VM.

Possible regression fix for introduced via ansible#45953

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit that referenced this pull request Feb 8, 2019
While creating new VM, don't assume the VMDKs are present,
create them as we attache the disk to VM.

Possible regression fix for introduced via #45953

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@atodorov
Copy link
Contributor

atodorov commented Mar 4, 2019

Hello, is this fix available in any of the versions released on PyPI? From what I can tell it is not.

@Akasurde
Copy link
Member

Akasurde commented Mar 4, 2019

@atodorov This is merged in 2.8 release which is supposed to be release soon. Meanwhile you can use https://docs.ansible.com/ansible/latest/dev_guide/testing.html#how-to-test-a-pr document to test this PR.

Akasurde pushed a commit to jeking3/ansible that referenced this pull request Mar 13, 2019
Signed-off-by: James E. King III <jking@apache.org>
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@devdil
Copy link

devdil commented Mar 30, 2019

Even after applying the parameters it says "No size mentioned for disk"

@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.8 This issue/PR affects Ansible v2.8 cloud core_review In order to be merged, this PR must follow the core 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. support:core This issue/PR relates to code supported by the Ansible Engineering Team. vmware VMware community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vsphere_guest: need an option to attach an existing disk
8 participants