govcd

package
v2.1.1-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 13, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Package govcd provides a simple binding for vCloud Director REST APIs.

Contains auxiliary functions to show library entities structure. Used for debugging and testing.

Index

Constants

View Source
const MinimumDiskSize int = 1048576 // = 1Mb

While theoretically we can use smaller amounts, there is an issue when updating disks with size < 1MB

Variables

This section is empty.

Functions

func GetExternalNetworkByName

func GetExternalNetworkByName(vcdClient *VCDClient, networkName string) (*types.ExternalNetworkReference, error)

func LogAdminCatalog

func LogAdminCatalog(catalog types.AdminCatalog)

func LogAdminOrg

func LogAdminOrg(org types.AdminOrg)

func LogCatalog

func LogCatalog(catalog types.Catalog)

func LogCatalogItem

func LogCatalogItem(catalogItem types.CatalogItem)

func LogDisk

func LogDisk(disk types.Disk)

func LogExternalNetwork

func LogExternalNetwork(network types.ExternalNetworkReference)

func LogNetwork

func LogNetwork(conf types.OrgVDCNetwork)

func LogOrg

func LogOrg(org types.Org)

func LogTask

func LogTask(task *types.Task, howManyTimes int, elapsed time.Duration, first, last bool)

func LogVapp

func LogVapp(vapp types.VApp)

func LogVdc

func LogVdc(vdc types.Vdc)

func RemoveMediaImageIfExists

func RemoveMediaImageIfExists(vdc Vdc, mediaName string) error

Looks for an Org Vdc network and, if found, will delete it.

func RemoveOrgVdcNetworkIfExists

func RemoveOrgVdcNetworkIfExists(vdc Vdc, networkName string) error

Looks for an Org Vdc network and, if found, will delete it.

func ShowAdminCatalog

func ShowAdminCatalog(catalog types.AdminCatalog)

func ShowAdminOrg

func ShowAdminOrg(org types.AdminOrg)

func ShowCatalog

func ShowCatalog(catalog types.Catalog)

func ShowCatalogItem

func ShowCatalogItem(catalogItem types.CatalogItem)

func ShowDisk

func ShowDisk(disk types.Disk)

func ShowExternalNetwork

func ShowExternalNetwork(network types.ExternalNetworkReference)

func ShowNetwork

func ShowNetwork(conf types.OrgVDCNetwork)

func ShowOrg

func ShowOrg(org types.Org)

func ShowTask

func ShowTask(task *types.Task, howManyTimes int, elapsed time.Duration, first, last bool)

func ShowVapp

func ShowVapp(vapp types.VApp)

func ShowVdc

func ShowVdc(vdc types.Vdc)

Types

type AdminCatalog

type AdminCatalog struct {
	AdminCatalog *types.AdminCatalog
	// contains filtered or unexported fields
}

AdminCatalog is a admin view of a vCloud Director Catalog To be able to get an AdminCatalog representation, users must have admin credentials to the System org. AdminCatalog is used for creating, updating, and deleting a Catalog. Definition: https://code.vmware.com/apis/220/vcloud#/doc/doc/types/AdminCatalogType.html

func CreateCatalog

func CreateCatalog(client *Client, links types.LinkList, Name, Description string) (AdminCatalog, error)

func NewAdminCatalog

func NewAdminCatalog(client *Client) *AdminCatalog

func (*AdminCatalog) Delete

func (adminCatalog *AdminCatalog) Delete(force, recursive bool) error

Deletes the Catalog, returning an error if the vCD call fails. Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Catalog.html

func (*AdminCatalog) Update

func (adminCatalog *AdminCatalog) Update() error

Updates the Catalog definition from current Catalog struct contents. Any differences that may be legally applied will be updated. Returns an error if the call to vCD fails. Update automatically performs a refresh with the admin catalog it gets back from the rest api Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/PUT-Catalog.html

func (*AdminCatalog) UploadOvf

func (adminCatalog *AdminCatalog) UploadOvf(ovaFileName, itemName, description string, uploadPieceSize int64) (UploadTask, error)

Uploads an ova file to a catalog. This method only uploads bits to vCD spool area. Returns errors if any occur during upload from vCD or upload process. On upload fail client may need to remove vCD catalog item which waits for files to be uploaded. Files from ova are extracted to system temp folder "govcd+random number" and left for inspection on error.

type AdminOrg

type AdminOrg struct {
	AdminOrg *types.AdminOrg
	// contains filtered or unexported fields
}

AdminOrg gives an admin representation of an org. Administrators can delete and update orgs with an admin org object. AdminOrg includes all members of the Org element, and adds several elements that can be viewed and modified only by system administrators. Definition: https://code.vmware.com/apis/220/vcloud#/doc/doc/types/AdminOrgType.html

func GetAdminOrgByName

func GetAdminOrgByName(vcdClient *VCDClient, orgName string) (AdminOrg, error)

If user specifies valid organization name, then this returns an admin organization object. If no valid org is found, it returns an empty org and no error. Otherwise returns an empty AdminOrg and an error. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/GET-Organization-AdminView.html

func NewAdminOrg

func NewAdminOrg(cli *Client) *AdminOrg

func (*AdminOrg) CreateCatalog

func (adminOrg *AdminOrg) CreateCatalog(name, description string) (AdminCatalog, error)

CreateCatalog creates a catalog with given name and description under the the given organization. Returns an AdminCatalog that contains a creation task. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/POST-CreateCatalog.html

func (*AdminOrg) CreateVdc

func (org *AdminOrg) CreateVdc(vdcConfiguration *types.VdcConfiguration) (Task, error)

CreateVdc creates a VDC with the given params under the given organization. Returns an AdminVdc. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/POST-VdcConfiguration.html

func (*AdminOrg) CreateVdcWait

func (org *AdminOrg) CreateVdcWait(vdcDefinition *types.VdcConfiguration) error

Creates the vdc and waits for the asynchronous task to complete.

func (*AdminOrg) Delete

func (adminOrg *AdminOrg) Delete(force bool, recursive bool) error

Deletes the org, returning an error if the vCD call fails. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Organization.html

func (*AdminOrg) Disable

func (adminOrg *AdminOrg) Disable() error

Disables the org. Returns an error if the call to vCD fails. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/POST-DisableOrg.html

func (*AdminOrg) FindAdminCatalog

func (adminOrg *AdminOrg) FindAdminCatalog(catalogName string) (AdminCatalog, error)

Given a valid catalog name, FindCatalog returns an AdminCatalog object. If no catalog is found, then returns an empty AdminCatalog and no error. Otherwise it returns an error. Function allows user to use an AdminOrg to also fetch a Catalog. If user does not have proper credentials to perform administrator tasks then function returns an error. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/GET-Catalog-AdminView.html

func (*AdminOrg) FindCatalog

func (adminOrg *AdminOrg) FindCatalog(catalogName string) (Catalog, error)

Given a valid catalog name, FindCatalog returns a Catalog object. If no catalog is found, then returns an empty catalog and no error. Otherwise it returns an error. Function allows user to use an AdminOrg to also fetch a Catalog.

func (*AdminOrg) GetVdcByName

func (adminOrg *AdminOrg) GetVdcByName(vdcname string) (Vdc, error)

If user specifies valid vdc name then this returns a vdc object. If no vdc is found, then it returns an empty vdc and no error. Otherwise it returns an empty vdc and an error. This function allows users to use an AdminOrg to fetch a vdc as well.

func (*AdminOrg) Refresh

func (adminOrg *AdminOrg) Refresh() error

Given an adminorg with a valid HREF, the function refetches the adminorg and updates the user's adminorg data. Otherwise if the function fails, it returns an error. Users should use refresh whenever they have a stale org due to the creation/update/deletion of a resource within the org or the org itself.

func (*AdminOrg) Update

func (adminOrg *AdminOrg) Update() (Task, error)

Updates the Org definition from current org struct contents. Any differences that may be legally applied will be updated. Returns an error if the call to vCD fails. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/PUT-Organization.html

type AdminVdc

type AdminVdc struct {
	AdminVdc *types.AdminVdc

	VApp *types.VApp
	// contains filtered or unexported fields
}

func NewAdminVdc

func NewAdminVdc(cli *Client) *AdminVdc

type Catalog

type Catalog struct {
	Catalog *types.Catalog
	// contains filtered or unexported fields
}

func NewCatalog

func NewCatalog(client *Client) *Catalog

func (*Catalog) Delete

func (catalog *Catalog) Delete(force, recursive bool) error

Deletes the Catalog, returning an error if the vCD call fails. Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Catalog.html

func (*Catalog) FindCatalogItem

func (cat *Catalog) FindCatalogItem(catalogItemName string) (CatalogItem, error)

If catalog item is a valid CatalogItem and the call succeeds, then the function returns a CatalogItem. If the item does not exist, then it returns an empty CatalogItem. If the call fails at any point, it returns an error.

func (*Catalog) UploadMediaImage

func (cat *Catalog) UploadMediaImage(mediaName, mediaDescription, filePath string, uploadPieceSize int64) (UploadTask, error)

func (*Catalog) UploadOvf

func (cat *Catalog) UploadOvf(ovaFileName, itemName, description string, uploadPieceSize int64) (UploadTask, error)

Uploads an ova file to a catalog. This method only uploads bits to vCD spool area. Returns errors if any occur during upload from vCD or upload process. On upload fail client may need to remove vCD catalog item which waits for files to be uploaded. Files from ova are extracted to system temp folder "govcd+random number" and left for inspection on error.

type CatalogItem

type CatalogItem struct {
	CatalogItem *types.CatalogItem
	// contains filtered or unexported fields
}

func FindMediaAsCatalogItem

func FindMediaAsCatalogItem(org *Org, catalogName, mediaName string) (CatalogItem, error)

Finds media in catalog and returns catalog item

func NewCatalogItem

func NewCatalogItem(cli *Client) *CatalogItem

func (*CatalogItem) Delete

func (catalogItem *CatalogItem) Delete() error

Deletes the Catalog Item, returning an error if the vCD call fails. Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-CatalogItem.html

func (*CatalogItem) GetVAppTemplate

func (catalogItem *CatalogItem) GetVAppTemplate() (VAppTemplate, error)

type CatalogOperations

type CatalogOperations interface {
	FindCatalogItem(catalogItem string) (CatalogItem, error)
}

type Client

type Client struct {
	APIVersion    string      // The API version required
	VCDToken      string      // Access Token (authorization header)
	VCDAuthHeader string      // Authorization header
	VCDHREF       url.URL     // VCD API ENDPOINT
	Http          http.Client // HttpClient is the client to use. Default will be used if not provided.
	IsSysAdmin    bool        // flag if client is connected as system administrator
}

Client provides a client to vCloud Director, values can be populated automatically using the Authenticate method.

func (*Client) FindVMByHREF

func (cli *Client) FindVMByHREF(vmHREF string) (VM, error)

func (*Client) NewRequest

func (cli *Client) NewRequest(params map[string]string, method string, reqUrl url.URL, body io.Reader) *http.Request

NewRequest creates a new HTTP request and applies necessary auth headers if set.

func (*Client) NewRequestWitNotEncodedParams

func (cli *Client) NewRequestWitNotEncodedParams(params map[string]string, notEncodedParams map[string]string, method string, reqUrl url.URL, body io.Reader) *http.Request

Function allow to pass complex values params which shouldn't be encoded like for queries. e.g. /query?filter=(name=foo)

type DhcpSettings

type DhcpSettings struct {
	IsEnabled        bool
	MaxLeaseTime     int
	DefaultLeaseTime int
	IPRange          *types.IPRange
}

struct type used to pass information for vApp network DHCP

type Disk

type Disk struct {
	Disk *types.Disk
	// contains filtered or unexported fields
}

Independent disk

func FindDiskByHREF

func FindDiskByHREF(client *Client, href string) (*Disk, error)

Find an independent disk by VDC client and disk href

func NewDisk

func NewDisk(cli *Client) *Disk

Init independent disk struct

func (*Disk) AttachedVM

func (d *Disk) AttachedVM() (*types.Reference, error)

Get a VM that is attached the disk An independent disk can be attached to at most one virtual machine. If the disk isn't attached to any VM, return empty VM reference and no error. Otherwise return the first VM reference and no error. Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 107, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

func (*Disk) Delete

func (d *Disk) Delete() (Task, error)

Remove an independent disk 1 Verify the independent disk is not connected to any VM 2 Delete the independent disk. Make a DELETE request to the URL in the rel="remove" link in the Disk 3 Return task of independent disk deletion If the independent disk is connected to a VM, the task will be failed. Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 106 - 107, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

func (*Disk) Refresh

func (d *Disk) Refresh() error

Refresh the disk information by disk href

func (*Disk) Update

func (d *Disk) Update(newDiskInfo *types.Disk) (Task, error)

Update an independent disk 1 Verify the independent disk is not connected to any VM 2 Use newDiskInfo to change update the independent disk 3 Return task of independent disk update If the independent disk is connected to a VM, the task will be failed. Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 104 - 106, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

type EdgeGateway

type EdgeGateway struct {
	EdgeGateway *types.EdgeGateway
	// contains filtered or unexported fields
}

func NewEdgeGateway

func NewEdgeGateway(cli *Client) *EdgeGateway

func (*EdgeGateway) AddDhcpPool

func (eGW *EdgeGateway) AddDhcpPool(network *types.OrgVDCNetwork, dhcppool []interface{}) (Task, error)

func (*EdgeGateway) AddIpsecVPN

func (eGW *EdgeGateway) AddIpsecVPN(ipsecVPNConfig *types.EdgeGatewayServiceConfiguration) (Task, error)

func (*EdgeGateway) AddNATMapping

func (eGW *EdgeGateway) AddNATMapping(natType, externalIP, internalIP string) (Task, error)

func (*EdgeGateway) AddNATPortMapping

func (eGW *EdgeGateway) AddNATPortMapping(natType, externalIP, externalPort, internalIP, internalPort, protocol, icmpSubType string) (Task, error)
func (eGW *EdgeGateway) AddNATPortMappingWithUplink(network *types.OrgVDCNetwork, natType, externalIP, externalPort, internalIP, internalPort, protocol, icmpSubType string) (Task, error)

func (*EdgeGateway) Create1to1Mapping

func (eGW *EdgeGateway) Create1to1Mapping(internal, external, description string) (Task, error)

func (*EdgeGateway) CreateFirewallRules

func (eGW *EdgeGateway) CreateFirewallRules(defaultAction string, rules []*types.FirewallRule) (Task, error)

func (*EdgeGateway) Refresh

func (eGW *EdgeGateway) Refresh() error

func (*EdgeGateway) Remove1to1Mapping

func (eGW *EdgeGateway) Remove1to1Mapping(internal, external string) (Task, error)

func (*EdgeGateway) RemoveIpsecVPN

func (eGW *EdgeGateway) RemoveIpsecVPN() (Task, error)

Removes an Edge Gateway VPN, by passing an empty configuration

func (*EdgeGateway) RemoveNATMapping

func (eGW *EdgeGateway) RemoveNATMapping(natType, externalIP, internalIP, port string) (Task, error)

func (*EdgeGateway) RemoveNATPortMapping

func (eGW *EdgeGateway) RemoveNATPortMapping(natType, externalIP, externalPort string, internalIP, internalPort string) (Task, error)

type Envelope

type Envelope struct {
	File []struct {
		HREF      string `xml:"href,attr"`
		ID        string `xml:"id,attr"`
		Size      int    `xml:"size,attr"`
		ChunkSize int    `xml:"chunkSize,attr"`
	} `xml:"References>File"`
}

Envelope is a ovf description root element. File contains information for vmdk files. Namespace: http://schemas.dmtf.org/ovf/envelope/1 Description: Envelope is a ovf description root element. File contains information for vmdk files..

type InspectionFunc

type InspectionFunc func(task *types.Task, howManyTimes int, elapsed time.Duration, first, last bool)

This callback function can be passed to task.WaitInspectTaskCompletion to perform user defined operations * task is the task object being processed * howManyTimes is the number of times the task has been refreshed * elapsed is how much time since the task was initially processed * first is true if this is the first refresh of the task * last is true if the function is being called for the last time.

type MediaItem

type MediaItem struct {
	MediaItem *types.MediaRecordType
	// contains filtered or unexported fields
}

func NewMediaItem

func NewMediaItem(cli *Client) *MediaItem

func (*MediaItem) Delete

func (mediaItem *MediaItem) Delete() (Task, error)

Deletes the Media Item, returning an error if the vCD call fails. Link to API call: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Media.html

type Org

type Org struct {
	Org *types.Org
	// contains filtered or unexported fields
}

func GetOrgByName

func GetOrgByName(vcdClient *VCDClient, orgName string) (Org, error)

If user specifies a valid organization name, then this returns a organization object. If no valid org is found, it returns an empty org and no error. Otherwise it returns an error and an empty Org object

func NewOrg

func NewOrg(client *Client) *Org

func (*Org) CreateCatalog

func (org *Org) CreateCatalog(name, description string) (Catalog, error)

CreateCatalog creates a catalog with given name and description under the the given organization. Returns an Catalog that contains a creation task. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/POST-CreateCatalog.html

func (*Org) FindCatalog

func (org *Org) FindCatalog(catalogName string) (Catalog, error)

Given a valid catalog name, FindCatalog returns a Catalog object. If no catalog is found, then returns an empty catalog and no error. Otherwise it returns an error.

func (*Org) GetVdcByName

func (org *Org) GetVdcByName(vdcname string) (Vdc, error)

If user specifies valid vdc name then this returns a vdc object. If no vdc is found, then it returns an empty vdc and no error. Otherwise it returns an empty vdc and an error.

func (*Org) Refresh

func (org *Org) Refresh() error

Given an org with a valid HREF, the function refetches the org and updates the user's org data. Otherwise if the function fails, it returns an error. Users should use refresh whenever they have a stale org due to the creation/update/deletion of a resource within the org or the org itself.

type OrgOperations

type OrgOperations interface {
	FindCatalog(catalog string) (Catalog, error)
	GetVdcByName(vdcname string) (Vdc, error)
	Refresh() error
}

Interface for methods in common for Org and AdminOrg

type OrgVDCNetwork

type OrgVDCNetwork struct {
	OrgVDCNetwork *types.OrgVDCNetwork
	// contains filtered or unexported fields
}

OrgVDCNetwork an org vdc network client

func NewOrgVDCNetwork

func NewOrgVDCNetwork(cli *Client) *OrgVDCNetwork

NewOrgVDCNetwork creates an org vdc network client

func (*OrgVDCNetwork) Delete

func (orgVdcNet *OrgVDCNetwork) Delete() (Task, error)

Delete a network. Fails if the network is busy. Returns a task to monitor the deletion.

func (*OrgVDCNetwork) Refresh

func (orgVdcNet *OrgVDCNetwork) Refresh() error

type Results

type Results struct {
	Results *types.QueryResultRecordsType
	// contains filtered or unexported fields
}

func NewResults

func NewResults(cli *Client) *Results

type Task

type Task struct {
	Task *types.Task
	// contains filtered or unexported fields
}

func CreateOrg

func CreateOrg(vcdClient *VCDClient, name string, fullName string, description string, settings *types.OrgSettings, isEnabled bool) (Task, error)

Creates an Organization based on settings, network, and org name. The Organization created will have these settings specified in the settings parameter. The settings variable is defined in types.go. Method will fail unless user has an admin token. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/POST-CreateOrganization.html Organization creation in vCD has two bugs BZ 2177355, BZ 2228936 (fixes are in 9.1.0.3 and 9.5.0.2) which require organization settings to be provided as workarounds. At least one element among DelayAfterPowerOnSeconds, DeployedVMQuota, StoredVmQuota, UseServerBootSequence, getVdcQuota should be set when providing generalOrgSettings. If either VAppLeaseSettings or VAppTemplateLeaseSettings is provided then all elements need to have values, otherwise don't provide them at all. Overall elements must be in the correct order.

func NewTask

func NewTask(cli *Client) *Task

func (*Task) CancelTask

func (task *Task) CancelTask() error

func (*Task) GetTaskProgress

func (task *Task) GetTaskProgress() (string, error)

func (*Task) Refresh

func (task *Task) Refresh() error

func (*Task) WaitInspectTaskCompletion

func (task *Task) WaitInspectTaskCompletion(inspectionFunc InspectionFunc, delay time.Duration) error

Customizable version of WaitTaskCompletion. Users can define the sleeping duration and an optional callback function for extra monitoring.

func (*Task) WaitTaskCompletion

func (task *Task) WaitTaskCompletion() error

Checks the status of the task every 3 seconds and returns when the task is either completed or failed

type UploadTask

type UploadTask struct {
	*Task
	// contains filtered or unexported fields
}

func NewUploadTask

func NewUploadTask(task *Task, uploadProgress *float64, uploadError *error) *UploadTask

Creates wrapped Task which is dedicated for upload functionality and provides additional functionality to monitor upload progress.

func (*UploadTask) GetUploadError

func (uploadTask *UploadTask) GetUploadError() error

func (*UploadTask) GetUploadProgress

func (uploadTask *UploadTask) GetUploadProgress() string

func (*UploadTask) ShowUploadProgress

func (uploadTask *UploadTask) ShowUploadProgress() error

type VApp

type VApp struct {
	VApp *types.VApp
	// contains filtered or unexported fields
}

func NewVApp

func NewVApp(cli *Client) *VApp

func (*VApp) AddIsolatedNetwork

func (vapp *VApp) AddIsolatedNetwork(newIsolatedNetworkSettings *VappNetworkSettings) (Task, error)

Function allows to create isolated network for vApp. This is equivalent to vCD UI function - vApp network creation.

func (*VApp) AddMetadata

func (vapp *VApp) AddMetadata(key, value string) (Task, error)

func (*VApp) AddRAWNetworkConfig

func (vapp *VApp) AddRAWNetworkConfig(orgvdcnetworks []*types.OrgVDCNetwork) (Task, error)

Function adds existing VDC network to vApp

func (*VApp) AddVM

func (vapp *VApp) AddVM(orgVdcNetworks []*types.OrgVDCNetwork, vappNetworkName string, vappTemplate VAppTemplate, name string, acceptAllEulas bool) (Task, error)

Function create vm in vApp using vApp template orgVdcNetworks - adds org VDC networks to be available for vApp. Can be empty. vappNetworkName - adds vApp network to be available for vApp. Can be empty. vappTemplate - vApp Template which will be used for VM creation. name - name for VM. acceptAllEulas - setting allows to automatically accept or not Eulas.

func (*VApp) ChangeCPUcount

func (vapp *VApp) ChangeCPUcount(size int) (Task, error)

func (*VApp) ChangeMemorySize

func (vapp *VApp) ChangeMemorySize(size int) (Task, error)

func (*VApp) ChangeNetworkConfig

func (vapp *VApp) ChangeNetworkConfig(networks []map[string]interface{}, ip string) (Task, error)

func (*VApp) ChangeStorageProfile

func (vapp *VApp) ChangeStorageProfile(name string) (Task, error)

func (*VApp) ChangeVMName

func (vapp *VApp) ChangeVMName(name string) (Task, error)

func (*VApp) Customize

func (vapp *VApp) Customize(computername, script string, changeSid bool) (Task, error)

func (*VApp) Delete

func (vapp *VApp) Delete() (Task, error)

func (*VApp) DeleteMetadata

func (vapp *VApp) DeleteMetadata(key string) (Task, error)

func (*VApp) Deploy

func (vapp *VApp) Deploy() (Task, error)

func (*VApp) GetNetworkConfig

func (vapp *VApp) GetNetworkConfig() (*types.NetworkConfigSection, error)

func (*VApp) GetNetworkConnectionSection

func (vapp *VApp) GetNetworkConnectionSection() (*types.NetworkConnectionSection, error)

func (*VApp) GetStatus

func (vapp *VApp) GetStatus() (string, error)

func (*VApp) PowerOff

func (vapp *VApp) PowerOff() (Task, error)

func (*VApp) PowerOn

func (vapp *VApp) PowerOn() (Task, error)

func (*VApp) Reboot

func (vapp *VApp) Reboot() (Task, error)

func (*VApp) Refresh

func (vapp *VApp) Refresh() error

func (*VApp) RemoveIsolatedNetwork

func (vapp *VApp) RemoveIsolatedNetwork(networkName string) (Task, error)

Removes vApp isolated network

func (*VApp) RemoveVM

func (vapp *VApp) RemoveVM(vm VM) error

func (*VApp) Reset

func (vapp *VApp) Reset() (Task, error)

func (*VApp) RunCustomizationScript

func (vapp *VApp) RunCustomizationScript(computername, script string) (Task, error)

func (*VApp) SetOvf

func (vapp *VApp) SetOvf(parameters map[string]string) (Task, error)

func (*VApp) Shutdown

func (vapp *VApp) Shutdown() (Task, error)

func (*VApp) Suspend

func (vapp *VApp) Suspend() (Task, error)

func (*VApp) Undeploy

func (vapp *VApp) Undeploy() (Task, error)

type VAppTemplate

type VAppTemplate struct {
	VAppTemplate *types.VAppTemplate
	// contains filtered or unexported fields
}

func NewVAppTemplate

func NewVAppTemplate(cli *Client) *VAppTemplate

type VCDClient

type VCDClient struct {
	Client Client // Client for the underlying VCD instance

	QueryHREF url.URL // HREF for the query API
	Mutex     sync.Mutex
	// contains filtered or unexported fields
}

func NewVCDClient

func NewVCDClient(vcdEndpoint url.URL, insecure bool) *VCDClient

func (*VCDClient) Authenticate

func (vdcCli *VCDClient) Authenticate(username, password, org string) error

Authenticate is an helper function that performs a login in vCloud Director.

func (*VCDClient) Disconnect

func (vdcCli *VCDClient) Disconnect() error

Disconnect performs a disconnection from the vCloud Director API endpoint.

func (*VCDClient) NewVApp

func (vdcCli *VCDClient) NewVApp(client *Client) VApp

func (*VCDClient) Query

func (vdcCli *VCDClient) Query(params map[string]string) (Results, error)

func (*VCDClient) QueryWithNotEncodedParams

func (vdcCli *VCDClient) QueryWithNotEncodedParams(params map[string]string, notEncodedParams map[string]string) (Results, error)

type VM

type VM struct {
	VM *types.VM
	// contains filtered or unexported fields
}

func NewVM

func NewVM(cli *Client) *VM

func (*VM) AttachDisk

func (vm *VM) AttachDisk(diskParams *types.DiskAttachOrDetachParams) (Task, error)

Attach an independent disk Call attachOrDetachDisk with disk and types.RelDiskAttach to attach an independent disk. Please verify the independent disk is not connected to any VM before calling this function. If the independent disk is connected to a VM, the task will be failed. Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 164 - 165, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

func (*VM) ChangeCPUcount

func (vm *VM) ChangeCPUcount(size int) (Task, error)

func (*VM) ChangeMemorySize

func (vm *VM) ChangeMemorySize(size int) (Task, error)

func (*VM) ChangeNetworkConfig

func (vm *VM) ChangeNetworkConfig(networks []map[string]interface{}, ip string) (Task, error)

func (*VM) Customize

func (vm *VM) Customize(computername, script string, changeSid bool) (Task, error)

func (*VM) DetachDisk

func (vm *VM) DetachDisk(diskParams *types.DiskAttachOrDetachParams) (Task, error)

Detach an independent disk Call attachOrDetachDisk with disk and types.RelDiskDetach to detach an independent disk. Please verify the independent disk is connected the VM before calling this function. If the independent disk is not connected to the VM, the task will be failed. Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 164 - 165, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

func (*VM) EjectMedia

func (vm *VM) EjectMedia(mediaParams *types.MediaInsertOrEjectParams) (Task, error)

Eject media from VM Call insertOrEjectMedia with media and types.RelMediaEjectMedia to eject media from VM. If media isn't inserted then task still will be successful.

func (*VM) GetNetworkConnectionSection

func (vm *VM) GetNetworkConnectionSection() (*types.NetworkConnectionSection, error)

func (*VM) GetStatus

func (vm *VM) GetStatus() (string, error)

func (*VM) HandleEjectMedia

func (vm *VM) HandleEjectMedia(org *Org, catalogName, mediaName string) (Task, error)

Helper function which finds media and calls EjectMedia

func (*VM) HandleInsertMedia

func (vm *VM) HandleInsertMedia(org *Org, catalogName, mediaName string) (Task, error)

Helper function which finds media and calls InsertMedia

func (*VM) InsertMedia

func (vm *VM) InsertMedia(mediaParams *types.MediaInsertOrEjectParams) (Task, error)

Insert media for VM Call insertOrEjectMedia with media and types.RelMediaInsertMedia to insert media from VM.

func (*VM) PowerOff

func (vm *VM) PowerOff() (Task, error)

func (*VM) PowerOn

func (vm *VM) PowerOn() (Task, error)

func (*VM) Refresh

func (vm *VM) Refresh() error

func (*VM) RunCustomizationScript

func (vm *VM) RunCustomizationScript(computername, script string) (Task, error)

func (*VM) Undeploy

func (vm *VM) Undeploy() (Task, error)

type VMRecord

type VMRecord struct {
	VM *types.QueryResultVMRecordType
	// contains filtered or unexported fields
}

func NewVMRecord

func NewVMRecord(cli *Client) *VMRecord

create instance with reference to types.QueryResultVMRecordType

type VappNetworkSettings

type VappNetworkSettings struct {
	Name             string
	Gateway          string
	NetMask          string
	DNS1             string
	DNS2             string
	DNSSuffix        string
	GuestVLANAllowed bool
	StaticIPRanges   []*types.IPRange
	DhcpSettings     *DhcpSettings
}

struct type used to pass information for vApp network creation

type Vdc

type Vdc struct {
	Vdc *types.Vdc

	VApp *types.VApp
	// contains filtered or unexported fields
}

func NewVdc

func NewVdc(cli *Client) *Vdc

func (*Vdc) ComposeRawVApp

func (vdc *Vdc) ComposeRawVApp(name string) error

func (*Vdc) ComposeVApp

func (vdc *Vdc) ComposeVApp(orgvdcnetworks []*types.OrgVDCNetwork, vapptemplate VAppTemplate, storageprofileref types.Reference, name string, description string, acceptalleulas bool) (Task, error)

ComposeVApp creates a vapp with the given template, name, and description that uses the storageprofile and networks given. If you want all eulas to be accepted set acceptalleulas to true. Returns a successful task if completed successfully, otherwise returns an error and an empty task.

func (*Vdc) CreateDisk

func (vdc *Vdc) CreateDisk(diskCreateParams *types.DiskCreateParams) (Task, error)

Create an independent disk in VDC Reference: vCloud API Programming Guide for Service Providers vCloud API 30.0 PDF Page 102 - 103, https://vdc-download.vmware.com/vmwb-repository/dcr-public/1b6cf07d-adb3-4dba-8c47-9c1c92b04857/ 241956dd-e128-4fcc-8131-bf66e1edd895/vcloud_sp_api_guide_30_0.pdf

func (*Vdc) CreateOrgVDCNetwork

func (vdc *Vdc) CreateOrgVDCNetwork(networkConfig *types.OrgVDCNetwork) (Task, error)

Fine tuning network creation function. Return an error (the result of the network creation) and a task (used to monitor the network configuration) This function can create any type of Org Vdc network. The exact type is determined by the combination of properties given with the network configuration structure.

func (*Vdc) CreateOrgVDCNetworkWait

func (vdc *Vdc) CreateOrgVDCNetworkWait(networkConfig *types.OrgVDCNetwork) error

A wrapper call around CreateOrgVDCNetwork. Creates a network and then uses the associated task to monitor its configuration

func (*Vdc) Delete

func (vdc *Vdc) Delete(force bool, recursive bool) (Task, error)

Deletes the vdc, returning an error of the vCD call fails. API Documentation: https://code.vmware.com/apis/220/vcloud#/doc/doc/operations/DELETE-Vdc.html

func (*Vdc) DeleteWait

func (vdc *Vdc) DeleteWait(force bool, recursive bool) error

Deletes the vdc and waits for the asynchronous task to complete.

func (*Vdc) FindDiskByHREF

func (vdc *Vdc) FindDiskByHREF(href string) (*Disk, error)

Find an independent disk by disk href in VDC

func (*Vdc) FindEdgeGateway

func (vdc *Vdc) FindEdgeGateway(edgegateway string) (EdgeGateway, error)

func (*Vdc) FindMediaImage

func (vdc *Vdc) FindMediaImage(mediaName string) (MediaItem, error)

func (*Vdc) FindStorageProfileReference

func (vdc *Vdc) FindStorageProfileReference(name string) (types.Reference, error)

func (*Vdc) FindVAppByID

func (vdc *Vdc) FindVAppByID(vappid string) (VApp, error)

func (*Vdc) FindVAppByName

func (vdc *Vdc) FindVAppByName(vapp string) (VApp, error)

func (*Vdc) FindVDCNetwork

func (vdc *Vdc) FindVDCNetwork(network string) (OrgVDCNetwork, error)

func (*Vdc) FindVMByName

func (vdc *Vdc) FindVMByName(vapp VApp, vm string) (VM, error)

func (*Vdc) GetDefaultStorageProfileReference

func (vdc *Vdc) GetDefaultStorageProfileReference(storageprofiles *types.QueryResultRecordsType) (types.Reference, error)

func (*Vdc) InstantiateVAppTemplate

func (vdc *Vdc) InstantiateVAppTemplate(template *types.InstantiateVAppTemplateParams) error

func (*Vdc) Query

func (vdc *Vdc) Query(params map[string]string) (Results, error)

func (*Vdc) QueryVM

func (vdc *Vdc) QueryVM(vappName, vmName string) (VMRecord, error)

Find vm using vApp name and VM name. Returns VMRecord query return type

func (*Vdc) QueryWithNotEncodedParams

func (vdc *Vdc) QueryWithNotEncodedParams(params map[string]string, notEncodedParams map[string]string) (Results, error)

func (*Vdc) Refresh

func (vdc *Vdc) Refresh() error

func (*Vdc) UploadMediaImage

func (vdc *Vdc) UploadMediaImage(mediaName, mediaDescription, filePath string, uploadPieceSize int64) (UploadTask, error)

Uploads an ISO file as media. This method only uploads bits to vCD spool area. Returns errors if any occur during upload from vCD or upload process. On upload fail client may need to remove vCD catalog item which waits for files to be uploaded.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL