vsphere

package
v0.0.0-...-aa771b6 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrAffinityRuleDupKey is raised when the name of the affinity rule
	// conflicts with another one in system that has already been enabled.
	ErrAffinityRuleDupKey = errors.New("name of affinity rule is duplicated")
)

Functions

func NewClient

func NewClient(ctx context.Context) (*govmomi.Client, error)

NewClient creates a govmomi.Client for use in the examples

Types

type Querier

type Querier interface {
	// GetHostFromVMID gets ESX server's hostname from VMID.
	GetHostFromVMID(vmid string) (string, error)

	// GetHostnameFromVMID gets the hostname of a virtual machine identified by
	// VMID. Empty string will be returned if it isn't found.
	GetHostnameFromVMID(hostname string) string

	// GetVMIDFromHostname gets the vSphere VMID from the virtual machine's
	// hostname. Empty string will be returned if it isn't found.
	GetVMIDFromHostname(vmid string) string
}

Querier is a read-only interface for client to query vSphere.

VMID: unique reference id inside vSphere to represent VM as a managed object.

It's a string that looks like this: "VirtualMachine:vm-1".

type Rule

type Rule struct {
	Name     string
	VMs      []string
	Affinity bool
}

Rule represents a VM-to-VM affinity/anti-affinity rule

type Vsphere

type Vsphere interface {
	// Apply affinity rule to a list of vms so that DRS will schedule them on the
	// same host
	ApplyAffinityRule(name string, vms ...string) error

	// Apply anti-affinity rule to a list of vms so that DRS will schedule them on
	// different hosts
	ApplyAntiAffinityRule(name string, vms ...string) error

	// DeleteAffinityRule deletes an affinity rule
	DeleteAffinityRule(name string) error

	// DeleteAntiAffinityRule deletes an anti-affinity rule
	DeleteAntiAffinityRule(name string) error

	// Rules returns the applied VM-to-VM affinity and anti-affinity rules
	Rules() map[string]Rule

	// Logout signs off the session
	Logout()

	// Client returns the govmomi client
	Client() *govmomi.Client

	Querier
}

Vsphere is the vSphere client to talk to vSphere

func NewCachedClient

func NewCachedClient(clusterName string) Vsphere

NewCachedClient creates a cached vsphere client.

Jump to

Keyboard shortcuts

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