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_guest_snapshot - remove datacenter and folder parameter #1982

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions changelogs/fragments/1982-vmware_guest_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
minor_changes:
- vmware_guest_snapshot - Remove Parameter datacenter and folder because it's not used anywhere in the code.
(https://github.com/ansible-collections/community.vmware/pull/1982).
49 changes: 0 additions & 49 deletions plugins/modules/vmware_guest_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,6 @@
- Whether to use the VMware instance UUID rather than the BIOS UUID.
default: false
type: bool
folder:
description:
- Destination folder, absolute or relative path to find an existing guest.
- This is required parameter, if O(name) is supplied.
- The folder should include the datacenter. ESX's datacenter is ha-datacenter.
- 'Examples:'
- ' folder: /ha-datacenter/vm'
- ' folder: ha-datacenter/vm'
- ' folder: /datacenter1/vm'
- ' folder: datacenter1/vm'
- ' folder: /datacenter1/vm/folder1'
- ' folder: datacenter1/vm/folder1'
- ' folder: /folder1/datacenter1/vm'
- ' folder: folder1/datacenter1/vm'
- ' folder: /folder1/datacenter1/vm/folder2'
type: str
datacenter:
description:
- Destination datacenter for the deploy operation.
required: true
type: str
snapshot_name:
description:
- Sets the snapshot name to manage.
Expand Down Expand Up @@ -139,8 +118,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: snap1
Expand All @@ -152,8 +129,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: absent
snapshot_name: snap1
Expand All @@ -164,8 +139,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: revert
snapshot_name: snap1
Expand All @@ -176,8 +149,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: remove_all
delegate_to: localhost
Expand All @@ -187,8 +158,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
moid: vm-42
state: remove_all
delegate_to: localhost
Expand All @@ -198,8 +167,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: dummy_vm_snap_0001
Expand All @@ -212,8 +179,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: absent
remove_children: true
Expand All @@ -225,8 +190,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
snapshot_id: 10
state: absent
Expand All @@ -237,8 +200,6 @@
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
datacenter: "{{ datacenter_name }}"
folder: "/{{ datacenter_name }}/vm/"
name: "{{ guest_name }}"
state: present
snapshot_name: current_snap_name
Expand Down Expand Up @@ -444,8 +405,6 @@ def main():
uuid=dict(type='str'),
moid=dict(type='str'),
use_instance_uuid=dict(type='bool', default=False),
folder=dict(type='str'),
datacenter=dict(required=True, type='str'),
snapshot_name=dict(type='str'),
snapshot_id=dict(type='int'),
description=dict(type='str', default=''),
Expand All @@ -457,9 +416,6 @@ def main():
)
module = AnsibleModule(
argument_spec=argument_spec,
required_together=[
['name', 'folder']
],
required_one_of=[
['name', 'uuid', 'moid']
],
Expand All @@ -468,11 +424,6 @@ def main():
]
)

if module.params['folder']:
# FindByInventoryPath() does not require an absolute path
# so we should leave the input folder path unmodified
module.params['folder'] = module.params['folder'].rstrip('/')

pyv = PyVmomiHelper(module)
# Check if the VM exists before continuing
vm = pyv.get_vm()
Expand Down
27 changes: 0 additions & 27 deletions tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: absent
snapshot_name: snap_a

Expand All @@ -25,9 +23,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: "snap_{{item}}"
description: "snap named {{item}}"
Expand All @@ -42,9 +38,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: snap_a
new_snapshot_name: snap_c
Expand All @@ -56,9 +50,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: snap_a
description: "snap named a"
Expand All @@ -70,9 +62,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: snap_c
new_description: "renamed to snap_c from snap_a"
Expand All @@ -84,9 +74,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: absent
snapshot_name: snap_b
remove_children: true
Expand All @@ -98,9 +86,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: remove_all

# Test0008: Create snap_a again and revert to it
Expand All @@ -110,9 +96,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: snap_a
description: "snap named a"
Expand All @@ -123,9 +107,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: revert
snapshot_name: snap_a

Expand All @@ -136,9 +118,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: snap_a
description: "snap named a"
Expand All @@ -158,7 +138,6 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
state: present
snapshot_name: snap_a
description: "snap named a"
Expand All @@ -178,9 +157,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: present
snapshot_name: "snap_{{item}}"
description: "snap named {{item}}"
Expand All @@ -206,9 +183,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: revert
snapshot_id: "{{ item.snapshot_id }}"
loop: "{{ snapshot_ids }}"
Expand All @@ -230,9 +205,7 @@
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
password: '{{ vcenter_password }}'
datacenter: "{{ dc1 }}"
name: "{{ virtual_machines[0].name }}"
folder: "{{ virtual_machines[0].folder }}"
state: absent
snapshot_id: "{{ item.snapshot_id }}"
loop: "{{ snapshot_ids }}"
Expand Down
Loading