vsphere

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2016 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DestinationTypeHost represents an ESXi host in the vSphere inventory.
	DestinationTypeHost = "host"
	// DestinationTypeCluster represents a cluster in the vSphere inventory.
	DestinationTypeCluster = "cluster"
	// DestinationTypeResourcePool represents a resource pool in the vSphere inventory.
	DestinationTypeResourcePool = "resource_pool"
)

Variables

View Source
var (
	// ErrorVMExists is returned when the VM being provisioned already exists.
	ErrorVMExists = errors.New("VM already exists")
	//ErrorDestinationNotSupported is returned when the destination is not supported for provisioning.
	ErrorDestinationNotSupported = errors.New("destination is not supported by this provisioner")
	// ErrorVMPowerStateChanging is returned when the power state of the VM is resetting or shuttingdown
	// The VM can't be started in this state
	ErrorVMPowerStateChanging = errors.New("the power state of the vm is changing, try again later")
)
View Source
var NewLease = func(ctx context.Context, lease *object.HttpNfcLease) Lease {
	return VMwareLease{
		Ctx:   ctx,
		Lease: lease,
	}
}

NewLease creates a VMwareLease.

View Source
var NewProgressReader = func(r io.Reader, t int64, l Lease) ProgressReader {
	return ReadProgress{
		Reader:     r,
		TotalBytes: t,
		Lease:      l,
		ch:         make(chan int64, 1),
		wg:         &sync.WaitGroup{},
	}
}

NewProgressReader returns a functional instance of ReadProgress.

Functions

This section is empty.

Types

type Destination

type Destination struct {
	// Represents the name of the destination as described in the API
	DestinationName string
	// Only the "host" type is supported for now. The VI SDK supports host, cluster
	// and resource pool.
	DestinationType string
	// HostSystem specifies the name of the host to run the VM on. DestinationType ESXi
	// will have one host system. A cluster will have more than one,
	HostSystem string
}

Destination represents a destination on which to provision a Virtual Machine

type Disk

type Disk struct {
	Size       int64
	Controller string
}

Disk represents a vSphere Disk to attach to the VM

type ErrorBadResponse

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

ErrorBadResponse is returned when an HTTP request gets a bad response

func NewErrorBadResponse

func NewErrorBadResponse(r *http.Response) ErrorBadResponse

NewErrorBadResponse returns an ErrorBadResponse error.

func (ErrorBadResponse) Error

func (e ErrorBadResponse) Error() string

type ErrorClientFailed

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

ErrorClientFailed is returned when a client cannot be created using the given creds

func NewErrorClientFailed

func NewErrorClientFailed(e error) ErrorClientFailed

NewErrorClientFailed returns an ErrorClientFailed error.

func (ErrorClientFailed) Error

func (e ErrorClientFailed) Error() string

type ErrorInvalidHost

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

ErrorInvalidHost is returned when the host does not have a datastore or network selected by the user

func NewErrorInvalidHost

func NewErrorInvalidHost(h string, d string, n map[string]string) ErrorInvalidHost

NewErrorInvalidHost returns an ErrorInvalidHost error.

func (ErrorInvalidHost) Error

func (e ErrorInvalidHost) Error() string

type ErrorObjectNotFound

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

ErrorObjectNotFound is returned when the object being searched for is not found.

func NewErrorObjectNotFound

func NewErrorObjectNotFound(e error, o string) ErrorObjectNotFound

NewErrorObjectNotFound returns an ErrorObjectNotFound error.

func (ErrorObjectNotFound) Error

func (e ErrorObjectNotFound) Error() string

type ErrorParsingURL

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

ErrorParsingURL is returned when the sdk url passed to the vSphere provider is not valid

func NewErrorParsingURL

func NewErrorParsingURL(u string, e error) ErrorParsingURL

NewErrorParsingURL returns an ErrorParsingURL error.

func (ErrorParsingURL) Error

func (e ErrorParsingURL) Error() string

type ErrorPropertyRetrieval

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

ErrorPropertyRetrieval is returned when the object being searched for is not found.

func NewErrorPropertyRetrieval

func NewErrorPropertyRetrieval(m types.ManagedObjectReference, p []string, e error) ErrorPropertyRetrieval

NewErrorPropertyRetrieval returns an ErrorPropertyRetrieval error.

func (ErrorPropertyRetrieval) Error

func (e ErrorPropertyRetrieval) Error() string

type Lease

type Lease interface {
	HTTPNfcLeaseProgress(int)
	Wait() (*types.HttpNfcLeaseInfo, error)
	Complete() error
}

Lease represents a type that wraps around a HTTPNfcLease

type ProgressReader

type ProgressReader interface {
	StartProgress()
	Wait()
	Read(p []byte) (n int, err error)
}

ProgressReader is an interface for interacting with the vSphere SDK. It provides a `Start` method to start a monitoring go-routine which monitors the progress of the upload as well as a `Wait` method to wait until the upload is complete.

type ReadProgress

type ReadProgress struct {
	Reader     io.Reader
	TotalBytes int64
	Lease      Lease
	// contains filtered or unexported fields
}

ReadProgress wraps a io.Reader and submits progress reports on an embedded channel

func (ReadProgress) Read

func (r ReadProgress) Read(p []byte) (n int, err error)

Read implements the Reader interface.

func (ReadProgress) StartProgress

func (r ReadProgress) StartProgress()

StartProgress starts a goroutine that updates local progress on the lease as well as pass it down to the underlying lease.

func (ReadProgress) Wait

func (r ReadProgress) Wait()

Wait waits for the underlying waitgroup to be complete.

type VM

type VM struct {
	// Host represents the vSphere host to use for creating this VM.
	Host string
	// Destination represents the destination on which to clone this VM.
	Destination Destination
	// Username represents the username to use for connecting to the sdk.
	Username string
	// Password represents the password to use for connecting to the sdk.
	Password string
	// Insecure allows connecting without cert validation when set to true.
	Insecure bool
	// Datacenter configures the datacenter onto which to import the VM.
	Datacenter string
	// OvfPath represents the location of the OVF file on disk.
	OvfPath string
	// Networks defines a mapping from each network label inside the ovf file
	// to a vSphere network. Must be available on the host or deploy will fail.
	Networks map[string]string
	// Name is the name to use for the VM on vSphere and internally.
	Name string
	// Template is the name to use for the VM's template
	Template string
	// Datastores is a slice of permissible datastores. One is picked out of these.
	Datastores []string

	// UseLocalTemplates is a flag to indicate whether a template should be uploaded on all
	// the datastores that were passed in.
	UseLocalTemplates bool
	// SkipExisting when set to `true` lets Provision succeed even if the VM already exists.
	SkipExisting bool
	// Credentials are the credentials to use when connecting to the VM over SSH
	Credentials ssh.Credentials
	// Disks is a slice of extra disks to attach to the VM
	Disks []Disk
	// contains filtered or unexported fields
}

VM represents a vSphere VM.

func (*VM) Destroy

func (vm *VM) Destroy() (err error)

Destroy deletes this VM from vSphere.

func (*VM) GetIPs

func (vm *VM) GetIPs() ([]net.IP, error)

GetIPs returns the IPs of this VM. Returns all the IPs known to the API for the different network cards for this VM. Includes IPV4 and IPV6 addresses.

func (*VM) GetName

func (vm *VM) GetName() string

GetName returns the name of this VM.

func (*VM) GetSSH

func (vm *VM) GetSSH(options ssh.Options) (ssh.Client, error)

GetSSH returns an ssh client configured for this VM.

func (*VM) GetState

func (vm *VM) GetState() (state string, err error)

GetState returns the power state of this VM.

func (*VM) Halt

func (vm *VM) Halt() (err error)

Halt halts this VM.

func (*VM) Provision

func (vm *VM) Provision() (err error)

Provision provisions this VM.

func (*VM) Resume

func (vm *VM) Resume() (err error)

Resume resumes this VM from a suspended or powered off state.

func (*VM) Start

func (vm *VM) Start() (err error)

Start powers on this VM.

func (*VM) Suspend

func (vm *VM) Suspend() (err error)

Suspend suspends this VM.

type VMwareLease

type VMwareLease struct {
	Ctx   context.Context
	Lease *object.HttpNfcLease
}

VMwareLease implements the Lease interface.

func (VMwareLease) Complete

func (v VMwareLease) Complete() error

Complete marks the underlying lease as complete.

func (VMwareLease) HTTPNfcLeaseProgress

func (v VMwareLease) HTTPNfcLeaseProgress(p int)

HTTPNfcLeaseProgress takes a percentage as an int and sets that percentage as the completed percent.

func (VMwareLease) Wait

func (v VMwareLease) Wait() (*types.HttpNfcLeaseInfo, error)

Wait waits for the underlying lease to finish.

Jump to

Keyboard shortcuts

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