[stable-8] Proxmox add storage content listing (#7725) (#7803)

Proxmox add storage content listing (#7725)

Add module to list content on proxmox storage

We first add a method to list storage content for proxmox, then use that
new methode to add an Ansible module to list content on storage attached
to a proxmox node. User can also use content filtering to define what
they want to list (backup, iso, images,...).

This commit also include the integration and unit test for that new
module.

Co-authored-by: Julian Vanden Broeck <julian.vandenbroeck@dalibo.com>
(cherry picked from commit 4f92f39720)

Co-authored-by: Julian <374571+l00ptr@users.noreply.github.com>
This commit is contained in:
Felix Fontein 2023-12-31 15:43:43 +01:00 committed by GitHub
parent 89c56631c8
commit d423b27288
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 269 additions and 0 deletions

View file

@ -180,3 +180,17 @@ class ProxmoxAnsible(object):
return self.proxmox_api.storage.get(type=type)
except Exception as e:
self.module.fail_json(msg="Unable to retrieve storages information with type %s: %s" % (type, e))
def get_storage_content(self, node, storage, content=None, vmid=None):
try:
return (
self.proxmox_api.nodes(node)
.storage(storage)
.content()
.get(content=content, vmid=vmid)
)
except Exception as e:
self.module.fail_json(
msg="Unable to list content on %s, %s for %s and %s: %s"
% (node, storage, content, vmid, e)
)