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

Remove or revert snapshot by its id #1844

Closed
yyosha opened this issue Sep 18, 2023 · 2 comments · Fixed by #1847
Closed

Remove or revert snapshot by its id #1844

yyosha opened this issue Sep 18, 2023 · 2 comments · Fixed by #1847
Assignees

Comments

@yyosha
Copy link

yyosha commented Sep 18, 2023

SUMMARY

In module "community.vmware.vmware_guest_snapshot":
Removing a snapshot is done by the snapshot name.
If there are multiple snapshots with the same name, and not ALL need to be removed, there is no way to differentiate them from one another.

ISSUE TYPE
  • Add a new parameter "snapshot_id" to the "community.vmware.vmware_guest_snapshot" module which will be used to select a unique snapshot.
COMPONENT NAME

community.vmware.vmware_guest_snapshot

ADDITIONAL INFORMATION

The new parameter will be used as an alternative to "snapshot_name".
Only one of the parameters could be used, to prevent conflicts.

---
- name: create new snapshot and then delete old snapshots
  hosts: all
  gather_facts: false

  tasks:
    - name: Gather detailed information about tags and category associated with the given VM
      community.vmware.vmware_guest_snapshot_info:
        datacenter: "{{ datacenter_name }}"
        folder: "{{ path | regex_replace('^(.*)vm', '') }}"
        name: "{{ config.name }}"
      delegate_to: localhost
      register: snapshots_info

    - name: create new snapshot
      community.vmware.vmware_guest_snapshot:
        snapshot_name: "mySnapshot"
        description: "This snapshot is created by AWX"
        datacenter: "{{ datacenter_name }}"
        folder: "{{ path | regex_replace('^(.*)vm', '') }}"
        name: "{{ config.name }}"
        state: present
        memory_dump: true
      delegate_to: localhost

    - name: Remove only snapshots from list, 
      community.vmware.vmware_guest_snapshot:
        datacenter: "{{ datacenter_name }}"
        folder: "{{ path | regex_replace('^(.*)vm', '') }}"
        name: "{{ config.name }}"
        snapshot_id: "{{ item.id }}"
        state: absent
      delegate_to: localhost
      loop: "{{ snapshots_info.guest_snapshots.snapshots }}"
@sky-joker
Copy link
Collaborator

Hi @yyosha
Thank you for requesting the feature!

I will try to make a patch for implementing the feature.

@sky-joker
Copy link
Collaborator

Hi @yyosha

I made the patch to implement the feature. #1847
Could you please check the module behavior in your environment?
And let me know the result.

softwarefactory-project-zuul bot pushed a commit that referenced this issue Oct 6, 2023
Add snapshot_id option to vmware_guest_snapshot module

SUMMARY
This PR is to add snapshot_id option to the module.
fixes: #1844
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
changelogs/fragments/1847_vmware_guest_snapshot.yml
docs/community.vmware.vmware_guest_snapshot_module.rst
plugins/modules/vmware_guest_snapshot.py
tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
ADDITIONAL INFORMATION
I will add the integration test in a few days.
Done

Reviewed-by: Mario Lenz <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants