vmware / go-vcloud-director

Golang SDK for VMware Cloud Director
Other
76 stars 79 forks source link

Add VDC Template support #686

Closed adambarreiro closed 3 weeks ago

adambarreiro commented 1 month ago

Overview

This PR adds support for VDC Templates with CRUD methods, Access level methods and an instantiation method.

Description

A VDC Template is a System administrator feature that can make VDC creation easier, by defining how the VDCs should look like in terms of configuration. The templates can then be published to tenants, or remain in the System administrator realm if not published. The published tenants can then be instantiated by either Organizations (inside of it, in Libraries) or in the System org.

Methods

The new file vcd_template.go contains several new methods:

Binding IDs

There's this odd concept from VMWVdcTemplate.[]ProviderVdcReference.[]Binding that is worth mentioning, specially when the new methods are consumed from the Terraform Provider

A Binding looks like:

type VMWVdcTemplateBinding struct {
    Name  string
    Value *Reference
}

To understand it easily, a Binding.Name represents a "field" (or an "option") in the Provider VDC configuration of the VDC Template, for example "External network", "Gateway Edge cluster" or "Service Edge cluster". In UI, these options are visible drop-down menus for the users to select. Then, the Binding.Value represents the value of that field. In UI, this would be the selected value.

The Binding.Name must be generated on our own, and looks like urn:vcloud:binding:.....

With this information, we can understand that, given many Provider VDCs in the VDC Template, each one of them share the same Binding.Name (the same sections, eg: "External network"), but differ in values.

Summary:

Binding.Name is an self-generated UUID that replaces a human readable field (eg: "External network") with a generic URN (urn:vcloud:binding:....). Binding.Value is the value for that field/option.

Quirks

The XML flavor of the /admin/extension/vdcTemplate doesn't work, as it fails to marshal the VMWVdcTemplate structure, hence JSON is used. For that reason, all relevant types and fields now have a mapping to JSON.