Documentation ¶
Index ¶
- func Clone(c *govmomi.Client, src *object.VirtualMachine, f *object.Folder, name string, ...) (*object.VirtualMachine, error)
- func ConfigOptions(vm *object.VirtualMachine) (*types.VirtualMachineConfigOption, error)
- func Create(c *govmomi.Client, f *object.Folder, s types.VirtualMachineConfigSpec, ...) (*object.VirtualMachine, error)
- func Customize(vm *object.VirtualMachine, spec types.CustomizationSpec) error
- func Deploy(deployData *VCenterDeploy) (*types.ManagedObjectReference, error)
- func Destroy(vm *object.VirtualMachine) error
- func DiskType(d *schema.ResourceData) string
- func FromMOID(client *govmomi.Client, id string) (*object.VirtualMachine, error)
- func FromPath(client *govmomi.Client, path string, dc *object.Datacenter) (*object.VirtualMachine, error)
- func FromUUID(client *govmomi.Client, uuid string) (*object.VirtualMachine, error)
- func GetHardwareVersionID(vint int) string
- func GetHardwareVersionNumber(vstring string) int
- func GracefulPowerOff(client *govmomi.Client, vm *object.VirtualMachine, timeout int, force bool) error
- func IsUUIDNotFoundError(err error) bool
- func List(client *govmomi.Client) ([]*object.VirtualMachine, error)
- func MoveToFolder(client *govmomi.Client, vm *object.VirtualMachine, relative string) error
- func PowerOff(vm *object.VirtualMachine) error
- func PowerOn(vm *object.VirtualMachine, pTimeout time.Duration) error
- func Properties(vm *object.VirtualMachine) (*mo.VirtualMachine, error)
- func Reconfigure(vm *object.VirtualMachine, spec types.VirtualMachineConfigSpec) error
- func Relocate(vm *object.VirtualMachine, spec types.VirtualMachineRelocateSpec, timeout int) error
- func SetHardwareVersion(vm *object.VirtualMachine, target int) error
- func ShutdownGuest(client *govmomi.Client, vm *object.VirtualMachine, timeout int) error
- func VAppProperties(propertyMap map[string]interface{}) []vcenter.Property
- func ValidateHardwareVersion(current, target int) error
- func WaitForGuestIP(client *govmomi.Client, vm *object.VirtualMachine, timeout int, ...) error
- func WaitForGuestNet(client *govmomi.Client, vm *object.VirtualMachine, routable bool, timeout int, ...) error
- type MOIDForUUIDResult
- type MOIDForUUIDResults
- type UUIDNotFoundError
- type VCenterDeploy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone(c *govmomi.Client, src *object.VirtualMachine, f *object.Folder, name string, spec types.VirtualMachineCloneSpec, timeout int) (*object.VirtualMachine, error)
Clone wraps the creation of a virtual machine and the subsequent waiting of the task. A higher-level virtual machine object is returned.
func ConfigOptions ¶ added in v1.23.0
func ConfigOptions(vm *object.VirtualMachine) (*types.VirtualMachineConfigOption, error)
ConfigOptions is a convenience method that wraps fetching the VirtualMachine ConfigOptions as returned by QueryConfigOption.
func Create ¶
func Create(c *govmomi.Client, f *object.Folder, s types.VirtualMachineConfigSpec, p *object.ResourcePool, h *object.HostSystem, timeout time.Duration) (*object.VirtualMachine, error)
Create wraps the creation of a virtual machine and the subsequent waiting of the task. A higher-level virtual machine object is returned.
func Customize ¶
func Customize(vm *object.VirtualMachine, spec types.CustomizationSpec) error
Customize wraps the customization of a virtual machine and the subsequent waiting of the task.
func Deploy ¶ added in v1.21.0
func Deploy(deployData *VCenterDeploy) (*types.ManagedObjectReference, error)
Deploy clones a virtual machine from a content library item.
func Destroy ¶
func Destroy(vm *object.VirtualMachine) error
Destroy wraps the Destroy task and the subsequent waiting for the task to complete.
func DiskType ¶ added in v1.24.0
func DiskType(d *schema.ResourceData) string
DiskType converts standard disk type labels into labels used in content library deployment specs.
func FromPath ¶
func FromPath(client *govmomi.Client, path string, dc *object.Datacenter) (*object.VirtualMachine, error)
FromPath returns a VirtualMachine via its supplied path.
func GetHardwareVersionID ¶ added in v1.21.0
GetHardwareVersionID gets the hardware version string from integer
func GetHardwareVersionNumber ¶ added in v1.21.0
GetHardwareVersionNumber gets the hardware version number from string.
func GracefulPowerOff ¶
func GracefulPowerOff(client *govmomi.Client, vm *object.VirtualMachine, timeout int, force bool) error
GracefulPowerOff is a meta-operation that handles powering down of virtual machines. A graceful shutdown is attempted first if possible (VMware tools is installed, and the guest state is not suspended), and then, if allowed, a power-off is forced if that fails.
func IsUUIDNotFoundError ¶ added in v1.5.0
IsUUIDNotFoundError returns true if the error is a UUIDNotFoundError.
func MoveToFolder ¶
MoveToFolder moves a virtual machine to the specified folder.
func PowerOff ¶
func PowerOff(vm *object.VirtualMachine) error
PowerOff wraps powering off a VM and the waiting for the subsequent task.
func PowerOn ¶
func PowerOn(vm *object.VirtualMachine, pTimeout time.Duration) error
PowerOn wraps powering on a VM and the waiting for the subsequent task.
func Properties ¶
func Properties(vm *object.VirtualMachine) (*mo.VirtualMachine, error)
Properties is a convenience method that wraps fetching the VirtualMachine MO from its higher-level object.
func Reconfigure ¶
func Reconfigure(vm *object.VirtualMachine, spec types.VirtualMachineConfigSpec) error
Reconfigure wraps the Reconfigure task and the subsequent waiting for the task to complete.
func Relocate ¶
func Relocate(vm *object.VirtualMachine, spec types.VirtualMachineRelocateSpec, timeout int) error
Relocate wraps the Relocate task and the subsequent waiting for the task to complete.
func SetHardwareVersion ¶ added in v1.21.0
func SetHardwareVersion(vm *object.VirtualMachine, target int) error
SetHardwareVersion sets the virtual machine's hardware version. The virtual machine must be powered off, and the version can only be increased.
func ShutdownGuest ¶
ShutdownGuest wraps the graceful shutdown of a guest VM, and then waiting an appropriate amount of time for the guest power state to go to powered off. If the VM does not power off in the shutdown period specified by timeout (in minutes), an error is returned.
The minimum value for timeout is 1 minute - setting to a 0 or negative value is not allowed and will just reset the timeout to the minimum.
func VAppProperties ¶ added in v1.24.0
VAppProperties converts the vApp properties from the configuration and converts them into a slice of vcenter.Properties to be used while deploying content library items as VMs.
func ValidateHardwareVersion ¶ added in v1.21.0
ValidateHardwareVersion checks that the target hardware version is equal to or greater than the current hardware version.
func WaitForGuestIP ¶ added in v1.21.0
func WaitForGuestIP(client *govmomi.Client, vm *object.VirtualMachine, timeout int, ignoredGuestIPs []interface{}) error
WaitForGuestIP waits for a virtual machine to have an IP address.
The timeout is specified in minutes. If zero or a negative value is passed, the waiter returns without error immediately.
func WaitForGuestNet ¶
func WaitForGuestNet(client *govmomi.Client, vm *object.VirtualMachine, routable bool, timeout int, ignoredGuestIPs []interface{}) error
WaitForGuestNet waits for a virtual machine to have routable network access. This is denoted as a gateway, and at least one IP address that can reach that gateway. This function supports both IPv4 and IPv6, and returns the moment either stack is routable - it doesn't wait for both.
The timeout is specified in minutes. If zero or a negative value is passed, the waiter returns without error immediately.
Types ¶
type MOIDForUUIDResult ¶ added in v1.5.0
type MOIDForUUIDResult struct { // The UUID of a virtual machine. UUID string // The matching managed object reference ID for the virtual machine at the ID // referenced by UUID. MOID string }
MOIDForUUIDResult is a struct that holds a virtual machine UUID -> MOID association, designed to be used as a helper for mass returning the results of translating multiple UUIDs to managed object IDs for various virtual machine operations.
func MOIDForUUID ¶ added in v1.5.0
func MOIDForUUID(client *govmomi.Client, uuid string) (MOIDForUUIDResult, error)
MOIDForUUID returns the managed object reference ID for a specific virtual machine UUID and returns a MOIDForUUIDResult with the appropriate association.
func UUIDForMOID ¶ added in v1.5.0
func UUIDForMOID(client *govmomi.Client, moid string) (MOIDForUUIDResult, error)
UUIDForMOID returns the managed object reference ID for a specific virtual machine MOID and returns a MOIDForUUIDResult with the appropriate association.
type MOIDForUUIDResults ¶ added in v1.5.0
type MOIDForUUIDResults []MOIDForUUIDResult
MOIDForUUIDResults is a slice that holds multiple MOIDForUUIDResult structs.
func MOIDsForUUIDs ¶ added in v1.5.0
func MOIDsForUUIDs(client *govmomi.Client, uuids []string) (MOIDForUUIDResults, error)
MOIDsForUUIDs returns a MOIDForUUIDResults for a list of UUIDs. If one UUID cannot be found, an error is returned. There are no partial results returned.
func UUIDsForMOIDs ¶ added in v1.5.0
func UUIDsForMOIDs(client *govmomi.Client, moids []string) (MOIDForUUIDResults, error)
UUIDsForMOIDs returns a MOIDForUUIDResults for a list of MOIDs. If one MOID cannot be found, an error is returned. There are no partial results returned.
func UUIDsForManagedObjectReferences ¶ added in v1.5.0
func UUIDsForManagedObjectReferences(client *govmomi.Client, refs []types.ManagedObjectReference) (MOIDForUUIDResults, error)
UUIDsForManagedObjectReferences returns a MOIDForUUIDResults for a list of ManagedObjectReferences. If one cannot be found, an error is returned. There are no partial results returned.
func (MOIDForUUIDResults) MOIDs ¶ added in v1.5.0
func (r MOIDForUUIDResults) MOIDs() []string
MOIDs returns all MOIDs in a MOIDForUUIDResults.
func (MOIDForUUIDResults) ManagedObjectReferences ¶ added in v1.5.0
func (r MOIDForUUIDResults) ManagedObjectReferences() []types.ManagedObjectReference
ManagedObjectReferences returns all MOIDs in a MOIDForUUIDResults, as ManagedObjectReferences as type VirtualMachine.
func (MOIDForUUIDResults) UUIDs ¶ added in v1.5.0
func (r MOIDForUUIDResults) UUIDs() []string
UUIDs returns all UUIDs in a MOIDForUUIDResults.
type UUIDNotFoundError ¶ added in v1.1.1
type UUIDNotFoundError struct {
// contains filtered or unexported fields
}
UUIDNotFoundError is an error type that is returned when a virtual machine could not be found by UUID.
func (*UUIDNotFoundError) Error ¶ added in v1.1.1
func (e *UUIDNotFoundError) Error() string
Error implements error for UUIDNotFoundError.
type VCenterDeploy ¶ added in v1.24.0
type VCenterDeploy struct { VCenterManager *vcenter.Manager VMName string Annotation string FolderID string DatastoreID string ResourcePoolID string HostSystemID string StoragePolicyID string DiskType string NetworkMap []vcenter.NetworkMapping VAppProperties []vcenter.Property LibraryItem *library.Item }
VCenterDeploy containss everything required to create a VM from a content library item, and reduces the number of arguments passed between functions.