vmware / go-vcloud-director

Golang SDK for VMware Cloud Director
Other
82 stars 75 forks source link

Add native way to create a vApp template out of existing vApp #295

Open sansaid opened 4 years ago

sansaid commented 4 years ago

Having looked through the code, I couldn't find a method on the vApp struct which enables creating a vApp template out of an existing vApp. Is there a reason for this?

Suggested method signature:

func (vapp *VApp) CreateVappTemplate(name string, catalog Catalog) (Task, error) { ... }

Happy to implement this myself, but want to make sure this doesn't deviate away from an intended design. This is a feature natively supported within the REST API, which would be great to have implemented in this library: https://code.vmware.com/apis/553/vcloud/doc/doc/operations/POST-CaptureVApp-catalog.html

Having a method like this would be particularly useful when creating a Packer plugin for vCloud Director (which is something I'm currently trying to implement until I stumbled upon this issue).

Didainius commented 4 years ago

Hello @sansaid , There is no reason for it not to exist. We just haven't come across it yet. Interesting project you are working on - would be interesting if you can share repo as it goes. You can surely make a PR. It is worth having a look at CONTRIBUTING_GUIDELINES.md section ## Create new entities. We try to standardize function naming and provide Async functions (returning task) and regular ones (returning Entity - pointer to entity). Entity makes it easier to check if it was returned as nil...

Also it would be nice if you could include an automated test. There is some info in TESTING.md on how to run tests, etc.

Feel free to ask anything else

sansaid commented 4 years ago

Brilliant, thanks @didainius! Link to vCD Packer builder (massively a WIP, started it about a week ago): https://github.com/sansaid/packer-vcd-builder

I'll start work on this feature. Wondering if you know of any vCloud Director labs online I can test against? There's an AWS CloudFormation project which enables deployment of vCD on AWS but not sure if you can vouch for it.

A testing environment I intended to use is no longer an option unfortunately hence looking for alternatives.

johnnycuse commented 4 years ago

The AWS CloudFormation project is good, but it is overkill and costly for what you need. VCD can run as a single VM, so you don't need all the complexity that the CloudFormation template brings. If I were you I would setup a nested instance of vSphere with VCD locally for testing.

Another option may be using the HOL to test: http://docs.hol.vmware.com/HOL-2020/hol-2083-01-hbd_html_en/

sansaid commented 4 years ago

Brilliant, thanks @johnnycuse ! I tried HOL but it doesn't look like the system's IP address is public facing. Have you managed to get any testing done with HOL? Otherwise will fall back onto the VM creation in AWS like you suggested (going for the cheaper option here before I try that).

prologic commented 2 years ago

@sansaid Were you able to make much process here? I to have an interest in a Packer builder for vCloud Director.

bogi0704 commented 2 years ago

@Didainius I too am looking at ways to provision and build VM instances in VCD. I was thinking of using Cloud-init to pre-build VM images and then convert them to templates, so I can use them for future or automatic deployments. This would greately reduce downtime and increase comfort. This should also work nicely with the VCD Autoscaling Plugin in mind. Is there any possibility that you would either implement the mentioned feature or implement a Packer builder for this purpose? The Packer builder would of course be the best option imho.