vcenter

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewVMNotFoundError

func NewVMNotFoundError(name string, err error) error

Types

type AdapterNotFoundError

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

func NewAdapterNotFoundError

func NewAdapterNotFoundError(vmName, networkName string) *AdapterNotFoundError

func (*AdapterNotFoundError) Error

func (e *AdapterNotFoundError) Error() string

type AdapterUpdater

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

func NewAdapterUpdater

func NewAdapterUpdater(finder *Finder) *AdapterUpdater

func (*AdapterUpdater) TargetNewNetwork

func (a *AdapterUpdater) TargetNewNetwork(ctx context.Context, adapter *anyAdapter, targetNetName string) (*anyAdapter, error)

type Client

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

func New

func New(host, username, password, datacenter string, insecure bool) *Client

func NewFromGovmomiClient

func NewFromGovmomiClient(client *govmomi.Client, datacenter string) *Client

func (*Client) CreateFolder added in v0.7.0

func (c *Client) CreateFolder(ctx context.Context, folderPath string) error

CreateFolder creates the specified folder including any parent folders If the folder(s) already exists, no folders are created and nil is returned

func (*Client) Datacenter added in v0.6.0

func (c *Client) Datacenter() string

func (*Client) FindVMInClusters added in v0.6.0

func (c *Client) FindVMInClusters(ctx context.Context, azName, vmNameOrPath string, clusters []string) (*VM, error)

func (*Client) HostName

func (c *Client) HostName() string

func (*Client) Insecure

func (c *Client) Insecure() bool

func (*Client) Logout

func (c *Client) Logout(ctx context.Context)

func (*Client) Password

func (c *Client) Password() string

func (*Client) URL

func (c *Client) URL() *url.URL

func (*Client) UserName added in v0.6.0

func (c *Client) UserName() string

type Disk added in v0.2.0

type Disk struct {
	ID        int32
	Datastore string
}

type Finder

type Finder struct {
	Datacenter string
	// contains filtered or unexported fields
}

func NewFinder

func NewFinder(datacenter string, client *govmomi.Client) *Finder

func (*Finder) Adapter

func (f *Finder) Adapter(ctx context.Context, vmNameOrPath, networkName string) (*anyAdapter, error)

func (*Finder) AdapterBackingInfo

func (f *Finder) AdapterBackingInfo(ctx context.Context, networkName string) (types.BaseVirtualDeviceBackingInfo, error)

func (*Finder) Cluster added in v0.4.0

func (f *Finder) Cluster(ctx context.Context, clusterName string) (*object.ClusterComputeResource, error)

func (*Finder) Datastore

func (f *Finder) Datastore(ctx context.Context, datastoreName string) (*object.Datastore, error)

func (*Finder) DatastoreRef

func (f *Finder) DatastoreRef(ctx context.Context, datastoreName string) (*types.ManagedObjectReference, error)

func (*Finder) Disks added in v0.2.0

func (f *Finder) Disks(ctx context.Context, vm *object.VirtualMachine) ([]Disk, error)

func (*Finder) Folder added in v0.7.0

func (f *Finder) Folder(ctx context.Context, folderPath string) (*object.Folder, error)

func (*Finder) FolderRef added in v0.7.0

func (f *Finder) FolderRef(ctx context.Context, folderPath string) (*types.ManagedObjectReference, error)

func (*Finder) HostsInCluster

func (f *Finder) HostsInCluster(ctx context.Context, clusterName string) ([]*object.HostSystem, error)

func (*Finder) Networks

func (f *Finder) Networks(ctx context.Context, vm *object.VirtualMachine) ([]string, error)

func (*Finder) ResourcePool

func (f *Finder) ResourcePool(ctx context.Context, fullyQualifiedResourcePoolName string) (*object.ResourcePool, error)

func (*Finder) ResourcePoolRef added in v0.7.0

func (f *Finder) ResourcePoolRef(ctx context.Context, fullyQualifiedResourcePoolName string) (*types.ManagedObjectReference, error)

func (*Finder) VMClusterName added in v0.7.0

func (f *Finder) VMClusterName(ctx context.Context, vm *object.VirtualMachine) (string, error)

func (*Finder) VirtualMachine

func (f *Finder) VirtualMachine(ctx context.Context, vmNameOrPath string) (*object.VirtualMachine, error)

type HostPool

type HostPool struct {
	MaxLeasePerHost             int
	LeaseWaitTimeoutInMinutes   int
	LeaseCheckIntervalInSeconds int
	// contains filtered or unexported fields
}

func NewHostPool

func NewHostPool(clientPool *Pool, config *HostPoolConfig) *HostPool

func (*HostPool) Initialize

func (hp *HostPool) Initialize(ctx context.Context) error

func (*HostPool) LeaseAvailableHost

func (hp *HostPool) LeaseAvailableHost(ctx context.Context, azName string) (*object.HostSystem, error)

LeaseAvailableHost returns the best host system to copy a VM to If no hosts are currently available a nil host will be returned, the caller should wait and retry later Release should be called by the caller when done with the host

func (*HostPool) Release

func (hp *HostPool) Release(ctx context.Context, host *object.HostSystem)

Release releases the specified host back into the pool and makes it available for lease again

func (*HostPool) WaitForLeaseAvailableHost

func (hp *HostPool) WaitForLeaseAvailableHost(ctx context.Context, azName string) (*object.HostSystem, error)

WaitForLeaseAvailableHost returns the best host system to copy a VM to If no hosts are currently available this func will block until one is available or configured timeout Release should be called by the caller when done with the host

type HostPoolAZ added in v0.6.0

type HostPoolAZ struct {
	Clusters []string
}

type HostPoolConfig added in v0.6.0

type HostPoolConfig struct {
	AZs map[string]HostPoolAZ
}

type ISOEjector

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

func NewISOEjector

func NewISOEjector(vm *object.VirtualMachine) *ISOEjector

func (*ISOEjector) EjectISO

func (e *ISOEjector) EjectISO(ctx context.Context) error

type Pool added in v0.6.0

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

Pool is a pool of vcenter client instances

func NewPool added in v0.6.0

func NewPool() *Pool

NewPool creates a new empty pool Call AddSource and AddTarget to fully initialize the pool

func NewPoolWithExternalClients added in v0.6.0

func NewPoolWithExternalClients(sourceClientsByAZ, targetClientsByAZ map[string]*Client) *Pool

NewPoolWithExternalClients creates a new vcenter pool using externally managed vcenter clients This is used for testing purposes

func (*Pool) AddSource added in v0.6.0

func (p *Pool) AddSource(az, host, username, password, datacenter string, insecure bool)

AddSource adds a new source az/client pair If the AZ's vcenter matches another AZ's source vcenter then the client is re-used

func (*Pool) AddTarget added in v0.6.0

func (p *Pool) AddTarget(az, host, username, password, datacenter string, insecure bool)

AddTarget adds a new target az/client pair If the AZ's vcenter matches another AZ's target vcenter then the client is re-used

func (*Pool) Close added in v0.6.0

func (p *Pool) Close(ctx context.Context)

Close calls logout on all managed vcenter clients

func (*Pool) GetClients added in v0.6.0

func (p *Pool) GetClients() []*Client

GetClients returns all target and source vcenter clients

func (*Pool) GetSourceClientByAZ added in v0.6.0

func (p *Pool) GetSourceClientByAZ(az string) *Client

GetSourceClientByAZ returns the source vcenter client associated with the AZ, otherwise nil

func (*Pool) GetSourceClients added in v0.6.0

func (p *Pool) GetSourceClients() []*Client

GetSourceClients returns all source vcenter clients

func (*Pool) GetTargetClientByAZ added in v0.6.0

func (p *Pool) GetTargetClientByAZ(az string) *Client

GetTargetClientByAZ returns the target vcenter client associated with the AZ, otherwise nil

func (*Pool) GetTargetClients added in v0.6.0

func (p *Pool) GetTargetClients() []*Client

GetTargetClients returns all target vcenter clients

func (*Pool) SourceAZs added in v0.6.0

func (p *Pool) SourceAZs() []string

SourceAZs returns all source AZs This should always match TargetAZs except during initialization

func (*Pool) TargetAZs added in v0.6.0

func (p *Pool) TargetAZs() []string

TargetAZs returns all target AZs This should always match SourceAZs except during initialization

type ProgressLogger

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

func NewProgressLogger

func NewProgressLogger(updatableStdout *log.UpdatableStdout) *ProgressLogger

func (*ProgressLogger) NewProgressSink

func (p *ProgressLogger) NewProgressSink(taskName string) *ProgressSink

func (*ProgressLogger) SinkDone

func (p *ProgressLogger) SinkDone()

type ProgressSink

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

func (*ProgressSink) Sink

func (p *ProgressSink) Sink() chan<- progress.Report

type RelocateSpec

type RelocateSpec struct {
	DryRun bool
	// contains filtered or unexported fields
}

func NewRelocateSpec

func NewRelocateSpec(sourceClient *Client, destinationClient *Client) *RelocateSpec

func (*RelocateSpec) Build

func (*RelocateSpec) WithDryRun added in v0.7.0

func (rs *RelocateSpec) WithDryRun(dryRun bool) *RelocateSpec

func (*RelocateSpec) WithSourceVM

func (rs *RelocateSpec) WithSourceVM(vm *VM) *RelocateSpec

func (*RelocateSpec) WithTargetHost

func (rs *RelocateSpec) WithTargetHost(host *object.HostSystem) *RelocateSpec

func (*RelocateSpec) WithTargetSpec

func (rs *RelocateSpec) WithTargetSpec(vmTargetSpec *TargetSpec) *RelocateSpec

type TargetSpec

type TargetSpec struct {
	Name         string
	Datacenter   string
	Cluster      string
	ResourcePool string
	Folder       string
	Datastores   map[string]string
	Networks     map[string]string
}

type VM

type VM struct {
	Name         string
	AZ           string
	Datacenter   string
	Cluster      string
	ResourcePool string
	Folder       string
	Disks        []Disk
	Networks     []string
}

type VMNotFoundError

type VMNotFoundError struct {
	Name string
	Err  error
}

func (*VMNotFoundError) Error

func (e *VMNotFoundError) Error() string

type VMRelocator

type VMRelocator struct {
	DryRun bool
	// contains filtered or unexported fields
}

func NewVMRelocator

func NewVMRelocator(clientPool *Pool, destinationHostPool *HostPool, updatableStdout *log.UpdatableStdout) *VMRelocator

func (*VMRelocator) RelocateVM

func (r *VMRelocator) RelocateVM(ctx context.Context, srcVM *VM, vmTargetSpec *TargetSpec) error

func (*VMRelocator) WithDryRun

func (r *VMRelocator) WithDryRun(dryRun bool) *VMRelocator

Jump to

Keyboard shortcuts

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