community.vmware icon indicating copy to clipboard operation
community.vmware copied to clipboard

Manage objects in a Content Library

Open balnbibarbi opened this issue 2 years ago • 12 comments

SUMMARY

Ability to add/remove/replace/retrieve items in a given Content Library

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

community.vmware.vmware_content_library_items

ADDITIONAL INFORMATION

How it would be used:

  • Add an item to a given CL
  • Retrieve at item from a given CL
  • Enumerate items in a given CL
  • Remove an item from a given CL
  • Replace an existing item in a given CL with a new supplied version

Why it is needed:

  • This would enable upload/update of OVA templates for VMs, prior to creating VMs from those templates, for example using the existing community.vmware.vmware_content_deploy_ovf_template
  • Cannot find any existing way to do this in documentation or in Jira tickets
  • I did find a ticket regarding enumerating the objects in a content library: https://github.com/ansible-collections/community.vmware/issues/1220

To upload an item:

community.vmware.vmware_content_library_items:
- content_library: "abc123"
- item: "my_awesome_template.ova"
- state: present
- file: "my_local_file.ova"

To retrieve an item:

community.vmware.vmware_content_library_items:
- content_library: "abc123"
- item: "my_awesome_template.ova"
- state: download
- file: "my_local_file.ova"

To delete an item:

community.vmware.vmware_content_library_items:
- content_library: "abc123"
- item: "my_awesome_template.ova"
- state: absent

balnbibarbi avatar Nov 07 '22 05:11 balnbibarbi

I'm intending to add this functionality, but I want to make certain it's not already present first, and to design it consistently with the existing modules.

balnbibarbi avatar Nov 07 '22 05:11 balnbibarbi

It looks like we don't have this functionality in this collection yet. I've checked vmware.vmware_rest, and it looks like it's missing there also. That said, I think it would be a good idea to implement this :-)

One thing, though: I think both the UI and the API use the word item, not object. So maybe vmware_content_library_items might be a better name for the module.

mariolenz avatar Nov 15 '22 06:11 mariolenz

Thanks Mario, got it, items not objects.

balnbibarbi avatar Nov 15 '22 07:11 balnbibarbi

Workarounds until implemented:

stackprotector avatar Jan 16 '23 17:01 stackprotector

This would be super useful to have, going the rest api route now :(

VladoPortos avatar Jun 12 '23 21:06 VladoPortos

I updated object -> item.

balnbibarbi avatar Jun 15 '23 01:06 balnbibarbi

This:

community.vmware.vmware_content_library_items:
- content_library: "abc123"
- item: "my_awesome_template.ova"
- state: present
- file: "my_local_file.ova"

should probably look like this:

community.vmware.vmware_content_library_item:
  content_library: "abc123"
  name: "my_awesome_template.ova"
  state: present
  file: "my_local_file.ova"
  • I removed the s from items as you will loop over this module for multiple items
  • I removed the dashes (wrong syntax)
  • I renamed item to name to be more consistent with other modules (could also be an alias)
  • There should probably also be the optional attribute type to specify ItemType (as in PowerCLI)
  • There should be the optional attribute description

mbx64 avatar Jan 18 '24 13:01 mbx64

Heya @mbx64 , I agree, these seem like great improvements. However, no offence meant, these are somewhat cosmetic. Are you therefore generally ok with the overall design? I ask because one of the things I was wondering about was unifying this content library API and other existing APIs that deal with files/blobs, forming some kind of abstraction layer over the underlying vmware APIs. I'm not at all sure this is a good idea. I'm seeking guidance.

balnbibarbi avatar Jan 18 '24 14:01 balnbibarbi

@balnbibarbi Yes, it looks OK to me.

mbx64 avatar Jan 19 '24 09:01 mbx64

A quick notification if this is still being worked on:

Content types in a Content Library are important: For instance OVA vs. Template is an exceptionally important item since with separated VCenters it's our experience that Templates CANNOT be synchronized across dispirit content libraries (content libraries on different VCenters) while OVA/OVF Content CAN be synchronized.

The capability to handle Template and OVF/OVA files makes this slightly more complicated but very much needed.

rgadwagner avatar Feb 06 '24 23:02 rgadwagner

Hello, me and my team would benefit from this module. Is someone activly working on this? Are there any workaround for this that are ansible native?

neevnuv avatar Feb 16 '24 14:02 neevnuv

@neevnuv Hello, as far as I know, no one is currently working on this module. This requires writing a module from scratch. Current maintainers simply don’t have time for this.

A workaround could be to work with CL through the REST API using the uri or get_url ansible modules. (But as noted in the discussion above, it hurts.)

ihumster avatar Feb 16 '24 14:02 ihumster