virtualmachine

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2020 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clone

Clone wraps the creation of a virtual machine and the subsequent waiting of the task. A higher-level virtual machine object is returned.

func Create

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.17.0

func Deploy(c *rest.Client, item *library.Item, deploy *vcenter.Deploy, timeout int) (*types.ManagedObjectReference, error)

func DeployDest added in v1.17.0

func DeployDest(name string, annotation string, rp *object.ResourcePool, host *object.HostSystem, folder *object.Folder, ds viapi.ManagedObject, spId string, nm []vcenter.NetworkMapping) *vcenter.Deploy

func Destroy

func Destroy(vm *object.VirtualMachine) error

Destroy wraps the Destroy task and the subsequent waiting for the task to complete.

func FromMOID

func FromMOID(client *govmomi.Client, id string) (*object.VirtualMachine, error)

FromMOID locates a virtualMachine by its managed object reference ID.

func FromPath

func FromPath(client *govmomi.Client, path string, dc *object.Datacenter) (*object.VirtualMachine, error)

FromPath returns a VirtualMachine via its supplied path.

func FromUUID

func FromUUID(client *govmomi.Client, uuid string) (*object.VirtualMachine, error)

FromUUID locates a virtualMachine by its UUID.

func GetHardwareVersionID added in v1.17.1

func GetHardwareVersionID(vint int) string

GetHardwareVersionID gets the hardware version string from integer

func GetHardwareVersionNumber added in v1.17.1

func GetHardwareVersionNumber(vstring string) int

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

func IsUUIDNotFoundError(err error) bool

IsUUIDNotFoundError returns true if the error is a UUIDNotFoundError.

func MoveToFolder

func MoveToFolder(client *govmomi.Client, vm *object.VirtualMachine, relative string) error

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

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.17.1

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

func ShutdownGuest(client *govmomi.Client, vm *object.VirtualMachine, timeout int) error

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 ValidateHardwareVersion added in v1.17.1

func ValidateHardwareVersion(current, target int) error

ValidateHardwareVersion checks that the target hardware version is equal to or greater than the current hardware version.

func WaitForGuestIP added in v1.10.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.

Jump to

Keyboard shortcuts

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