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

add vmware_all_snapshots_info new module #2029

Merged
merged 8 commits into from
Apr 9, 2024

Conversation

valkiriaaquatica
Copy link
Contributor

SUMMARY

The new module returns all snapshots in the datacenter with no need of indicating from where machine or folder they have to belong. It also lhas filters options that can be sctrict or included, based if the user wants to retrieve all snapshots that in their name contains the word "test" or all snapshots that their state is "poweredOn". There is no need to filter, if no filter is applied it just returns all snapshots.

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME

vmware_all_snapshots_info

ADDITIONAL INFORMATION

With the actual module community.vmware.vmware_guest_snapshot_info the user needs to write or if the uuid or the moid is not supplied, also no filters can be applied. With this module all snapshots of th vmware are returned by default and one or more filters can be aplpied.

Below to get all snapshtos of the datacenter and then filter

- name: Old approach to gather VM snapshots info of all snapshots
  hosts: localhost
  gather_facts: no
  tasks:
    - name: List all VMs in the datacenter
      community.vmware.vmware_vm_info:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: yes
      delegate_to: localhost
      register: vm_list
      tags: 
        - old 
  
    - name: Gather snapshot info for each VM
      community.vmware.vmware_guest_snapshot_info:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: yes
        name: "{{ item.guest_name }}"
        folder: "{{ folder }}"
        datacenter: "{{ datacenter_name }}"
      loop: "{{ vm_list.virtual_machines }}"
      delegate_to: localhost
      register: snapshot_info
      tags: 
        - old
  
    - name: Display snapshot info
      debug:
        msg: "{{ snapshot_info.results }}"
      tags: 
        - old 
     ##then here applied filter to get the snapshot you want

New approach

- name: New approach to directly gather VM snapshots info using filters
  hosts: localhost
  gather_facts: no
  tasks:
    - name: Gather snapshot info directly using VM MOID
      community.vmware.vmware_all_snapshots_info:
        hostname: "{{ vcenter_hostname }}"
        username: "{{ vcenter_username }}"
        password: "{{ vcenter_password }}"
        validate_certs: yes
        #here you can place filters
      delegate_to: localhost
      register: snapshot_info

    - name: Display snapshot info
      debug:
        msg: "{{ snapshot_info }}"

@ihumster
Copy link
Collaborator

Why you close and open new PR? Please don't do that! If your PR don't build, you can add fixes (commits) in your branch and build will be relaunched automatically. If need run build in manual mode, you can just write commentary with word recheck.

@ihumster
Copy link
Collaborator

And don't be shy to ask for advice.

@valkiriaaquatica
Copy link
Contributor Author

And don't be shy to ask for advice.

Thank you so much ihumster !! I didn't know how this test was working, I will now post the new code

@mariolenz
Copy link
Collaborator

mariolenz commented Mar 14, 2024

@valkiriaaquatica The summery of the failed CI job doesn't look really helpful. But if you look at the log, there are a lot of whitespace issues. Maybe this helps.

Just click on the failed job (ansible-tox-linters in this case) and you should see a View log link on the right. In most cases, there should be enough information in the logs to find out why the CI job failed.

@ihumster
Copy link
Collaborator

@valkiriaaquatica you also can use Black formatting and use flake8 for linting.

Co-authored-by: Mario Lenz <m@riolenz.de>
@mariolenz
Copy link
Collaborator

ansible-tox-linters seems to succeed now, but there are some sanity issues.

BTW I hope you don't see the CI as an enemy. It's your / our friend helping us to keep the collection healthy ;-)

@valkiriaaquatica
Copy link
Contributor Author

thanks @mariolenz and @ihumster for being so helpful! I passed the ansible-doc and andible-test sanity and of course test the module, so i thought that testing was valid but didn´t count on whitespaces to be honest

@ihumster
Copy link
Collaborator

recheck

@mariolenz
Copy link
Collaborator

recheck

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/d730c317223940c6b94d7068e4202cbf

✔️ ansible-tox-linters SUCCESS in 17m 09s
build-ansible-collection POST_FAILURE in 15m 21s
⚠️ ansible-test-cloud-integration-vcenter7_only-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_2esxi-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection

@mariolenz
Copy link
Collaborator

@valkiriaaquatica I don't understand why the CI failes here, and failed again.

Anyway, while I'm trying to find out what's going on here could you please add the new module vmware_all_snapshots_info to the action_groups in meta/runtime.yml?

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/ce0eb64b94a149c7825d389b1e700787

⚠️ ansible-tox-linters CANCELED
build-ansible-collection RETRY_LIMIT in 5m 29s
⚠️ ansible-test-cloud-integration-vcenter7_only-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_2esxi-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection

@mariolenz
Copy link
Collaborator

recheck

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/20d7187f946c4220b9765825cd7f2ef2

⚠️ ansible-tox-linters CANCELED
build-ansible-collection RETRY_LIMIT in 9m 43s
⚠️ ansible-test-cloud-integration-vcenter7_only-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_2esxi-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection

@mariolenz mariolenz closed this Apr 2, 2024
@valkiriaaquatica
Copy link
Contributor Author

Hi @mariolenz can i now why you closed it?
I have been now reading the failed ci and no idea about them.. no much info is shown
Is there anything I can help with...

@mariolenz mariolenz reopened this Apr 2, 2024
@mariolenz
Copy link
Collaborator

Hi @mariolenz can i now why you closed it?

I'm hoping closing and re-opening would help. Nothing against your PR, just trying to make the CI succeed ;-)

I have been now reading the failed ci and no idea about them

Me neither. At the moment, it looks more like an issue in our CI pipeline and no problem with your code. As I've said, I wanted to try if closing and re-opening helps.

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/24a06477a8224636b9377cd5f6753e61

⚠️ ansible-tox-linters CANCELED
build-ansible-collection RETRY_LIMIT in 9m 12s
⚠️ ansible-test-cloud-integration-vcenter7_only-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_2esxi-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection

@mariolenz
Copy link
Collaborator

I don't understand why build-ansible-collection fails, there are not logs. It worked fine in #2036. This is really weird...

@mariolenz
Copy link
Collaborator

recheck

@valkiriaaquatica
Copy link
Contributor Author

recheck

@mariolenz
Copy link
Collaborator

recheck

Copy link

Build failed.
https://ansible.softwarefactory-project.io/zuul/buildset/f3818264966a45ae8fb2ce249c27f1b1

⚠️ ansible-tox-linters CANCELED
build-ansible-collection RETRY_LIMIT in 8m 54s
⚠️ ansible-test-cloud-integration-vcenter7_only-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_2esxi-stable216 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_1_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-test-cloud-integration-vcenter7_1esxi-stable216_2_of_2 SKIPPED Skipped due to failed job build-ansible-collection
⚠️ ansible-galaxy-importer SKIPPED Skipped due to failed job build-ansible-collection

@mariolenz
Copy link
Collaborator

recheck

@mariolenz
Copy link
Collaborator

recheck

@mariolenz
Copy link
Collaborator

recheck

@valkiriaaquatica
Copy link
Contributor Author

@mariolenz I see the CI is working, the problem was with Zool? Because I saw that you uploaded versions of the CI packages but it was still crashing and then suddenly it worked, btw thanks for the attention :)

Copy link
Collaborator

@mariolenz mariolenz left a comment

Choose a reason for hiding this comment

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

LGTM

Thanks @valkiriaaquatica!

Copy link

Build succeeded (gate pipeline).
https://ansible.softwarefactory-project.io/zuul/buildset/3029e4bdbe4b4da3a444b20155f5cf1c

✔️ ansible-tox-linters SUCCESS in 9m 40s
✔️ build-ansible-collection SUCCESS in 8m 05s
✔️ ansible-galaxy-importer SUCCESS in 3m 37s

Copy link

Pull request merge failed: Resource not accessible by integration, You may need to manually rebase your PR and retry.

@mariolenz mariolenz merged commit 49c481b into ansible-collections:main Apr 9, 2024
23 checks passed
@valkiriaaquatica valkiriaaquatica deleted the patch-7 branch April 12, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants