vm

package
v1.5.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2018 License: Apache-2.0 Imports: 22 Imported by: 206

Documentation

Index

Constants

View Source
const (
	DestroyTask  = "Destroy_Task"
	UpdateStatus = "UpdateInProgress"
)

Variables

This section is empty.

Functions

func Attributes

func Attributes(ctx context.Context, session *session.Session, refs []types.ManagedObjectReference, attribs ...string) ([]mo.VirtualMachine, error)

Attributes will retrieve the properties for the provided references. A variadic arg of attribs is provided to allow overriding the default properties retrieved

func IsConfigureSnapshot

func IsConfigureSnapshot(node *types.VirtualMachineSnapshotTree, prefix string) bool

IsConfigureSnapshot is the helper func that returns true if node is a snapshot with specified name prefix

Types

type InvalidState

type InvalidState struct {
	// contains filtered or unexported fields
}

func (*InvalidState) Error

func (i *InvalidState) Error() string

type VirtualMachine

type VirtualMachine struct {
	*object.VirtualMachine

	*session.Session
	// contains filtered or unexported fields
}

VirtualMachine struct defines the VirtualMachine which provides additional VIC specific methods over object.VirtualMachine as well as keeps some state

func NewVirtualMachine

func NewVirtualMachine(ctx context.Context, session *session.Session, moref types.ManagedObjectReference) *VirtualMachine

NewVirtualMachine returns a NewVirtualMachine object

func NewVirtualMachineFromVM

func NewVirtualMachineFromVM(ctx context.Context, session *session.Session, vm *object.VirtualMachine) *VirtualMachine

NewVirtualMachineFromVM returns a NewVirtualMachine object

func (*VirtualMachine) DatastoreFolderName

func (vm *VirtualMachine) DatastoreFolderName(ctx context.Context) (string, error)

DatastoreFolderName returns the name of the namespace(vsan) or directory(vmfs) that holds the VM this equates to the normal directory that contains the vmx file, stripped of any parent path

func (*VirtualMachine) DatastoreReference

func (vm *VirtualMachine) DatastoreReference(ctx context.Context) ([]types.ManagedObjectReference, error)

func (*VirtualMachine) DeleteExceptDisks

func (vm *VirtualMachine) DeleteExceptDisks(ctx context.Context) (*types.TaskInfo, error)

DeleteExceptDisks destroys the VM after detaching all virtual disks

func (*VirtualMachine) DisableDestroy

func (vm *VirtualMachine) DisableDestroy(ctx context.Context) error

DisableDestroy attempts to disable the VirtualMachine.Destroy_Task method on the VM After destroy is disabled for the VM, any session other than the session that disables the destroy can't evoke the method The "VM delete" option will be grayed out on VC UI Requires the "Global.Disable" VC privilege

func (*VirtualMachine) EnableDestroy

func (vm *VirtualMachine) EnableDestroy(ctx context.Context) error

EnableDestroy attempts to enable the VirtualMachine.Destroy_Task method for all sessions

func (*VirtualMachine) EnterFixingState

func (vm *VirtualMachine) EnterFixingState()

func (*VirtualMachine) FetchExtraConfig

func (vm *VirtualMachine) FetchExtraConfig(ctx context.Context) (map[string]string, error)

func (*VirtualMachine) FetchExtraConfigBaseOptions

func (vm *VirtualMachine) FetchExtraConfigBaseOptions(ctx context.Context) ([]types.BaseOptionValue, error)

func (*VirtualMachine) Folder

func (vm *VirtualMachine) Folder(op trace.Operation) (*object.Folder, error)

Folder returns a reference to the parent folder that owns the vm

func (*VirtualMachine) GetCurrentSnapshotTree

func (vm *VirtualMachine) GetCurrentSnapshotTree(ctx context.Context) (*types.VirtualMachineSnapshotTree, error)

GetCurrentSnapshotTree returns current snapshot, with tree information

func (*VirtualMachine) GetMacAddressBasedSpecifiedNetworkName added in v1.5.0

func (vm *VirtualMachine) GetMacAddressBasedSpecifiedNetworkName(ctx context.Context, ipaddress string) (string, error)

func (*VirtualMachine) GetSnapshotTreeByName

func (vm *VirtualMachine) GetSnapshotTreeByName(ctx context.Context, name string) (*types.VirtualMachineSnapshotTree, error)

GetCurrentSnapshotTreeByName returns current snapshot, with tree information

func (*VirtualMachine) InCluster

func (vm *VirtualMachine) InCluster(op trace.Operation) bool

InCluster returns true if the VM belongs to a cluster

func (*VirtualMachine) IsAlreadyPoweredOffError added in v1.5.0

func (vm *VirtualMachine) IsAlreadyPoweredOffError(err error) bool

IsAlreadyPoweredOffError is an accessor method because of the number of times package name and variable name tend to collide for VMs.

func (*VirtualMachine) IsFixing

func (vm *VirtualMachine) IsFixing() bool

func (*VirtualMachine) IsInvalidState

func (vm *VirtualMachine) IsInvalidState(ctx context.Context) bool

func (*VirtualMachine) LeaveFixingState

func (vm *VirtualMachine) LeaveFixingState()

func (*VirtualMachine) Parent

func (*VirtualMachine) PowerOn

func (vm *VirtualMachine) PowerOn(op trace.Operation) error

PowerOn powers on a VM. If the environment is VC without DRS enabled, it will attempt to relocate the VM to the most suitable host in the cluster. If relocation or subsequent power-on fail, it will attempt the next best host, and repeat this process until a successful power-on is achieved or there are no more hosts to try.

func (*VirtualMachine) Properties

func (*VirtualMachine) RemoveSnapshot

func (vm *VirtualMachine) RemoveSnapshot(op trace.Operation, snapshot *types.ManagedObjectReference, removeChildren bool, consolidate *bool) (*object.Task, error)

RemoveSnapshot removes the provided snapshot

func (*VirtualMachine) SetVCHUpdateStatus

func (vm *VirtualMachine) SetVCHUpdateStatus(ctx context.Context, status bool) error

SetVCHUpdateStatus sets the VCH update status in ExtraConfig

func (*VirtualMachine) UUID

func (vm *VirtualMachine) UUID(ctx context.Context) (string, error)

func (*VirtualMachine) VCHUpdateStatus

func (vm *VirtualMachine) VCHUpdateStatus(ctx context.Context) (bool, error)

VCHUpdateStatus tells if an upgrade/configure has already been started based on the UpdateInProgress flag in ExtraConfig It returns the error if the vm operation does not succeed

func (*VirtualMachine) VMPathName

func (vm *VirtualMachine) VMPathName(ctx context.Context) (string, error)

func (*VirtualMachine) VMPathNameAsURL

func (vm *VirtualMachine) VMPathNameAsURL(ctx context.Context) (url.URL, error)

VMPathNameAsURL returns the full datastore path of the VM as a url. The datastore name is in the host portion, the path is in the Path field, the scheme is set to "ds"

func (*VirtualMachine) WaitForExtraConfig

func (vm *VirtualMachine) WaitForExtraConfig(ctx context.Context, waitFunc func(pc []types.PropertyChange) bool) error

WaitForExtraConfig waits until key shows up with the expected value inside the ExtraConfig

func (*VirtualMachine) WaitForKeyChange added in v1.4.1

func (vm *VirtualMachine) WaitForKeyChange(op trace.Operation, keys map[string]string) error

WaitForKeyChange will block until it detects a change in value for ANY of the provided key value combinations. Additionally it will unblock if the container has powered off, returning an error in such a case.

func (*VirtualMachine) WaitForKeyInExtraConfig

func (vm *VirtualMachine) WaitForKeyInExtraConfig(ctx context.Context, key string) (string, error)

func (*VirtualMachine) WaitForResult

func (vm *VirtualMachine) WaitForResult(ctx context.Context, f func(context.Context) (tasks.Task, error)) (*types.TaskInfo, error)

WaitForResult is designed to handle VM invalid state error for any VM operations. It will call tasks.WaitForResult to retry if there is task in progress error.

Jump to

Keyboard shortcuts

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