exec

package
v1.4.3-rc2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: Apache-2.0 Imports: 50 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Containers *containerCache

Containers is an in-memory cache of containerVMs.

Functions

func Commit

func Commit(op trace.Operation, sess *session.Session, h *Handle, waitTime *int32) error

Commit executes the requires steps on the handle

func Init

Init is the main initializaton function for the exec component. sess - active session object used for vmomi access source - source from which to deserialize component configuration sink - unused at this time but provided for symmetry with source self - a reference to the VM in which this logic is running

func IsConcurrentAccessError

func IsConcurrentAccessError(err error) bool

func IsNotFoundError

func IsNotFoundError(err error) bool

func NewContainerCache

func NewContainerCache()

func ReferenceFromHandle

func ReferenceFromHandle(handle interface{}) interface{}

ReferenceFromHandle returns the reference of the given handle

Types

type ConcurrentAccessError

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

ConcurrentAccessError is returned when concurrent calls tries to modify same object

func (ConcurrentAccessError) Error

func (r ConcurrentAccessError) Error() string

type Configuration

type Configuration struct {
	// Turn on debug logging
	DebugLevel int `vic:"0.1" scope:"read-only" key:"init/diagnostics/debug"`

	SysLogConfig *executor.SysLogConfig `vic:"0.1" scope:"read-only" key:"init/diagnostics/syslog"`

	// Port Layer - exec
	config.Container `vic:"0.1" scope:"read-only" key:"container"`

	// Resource pool is the working version of the compute resource config
	ResourcePool *object.ResourcePool

	// Cluster is the working reference to the cluster the VCH is present in
	Cluster *object.ComputeResource

	// SelfReference is a reference to the endpointVM, added for VM group membership
	SelfReference types.ManagedObjectReference

	// Parent resource will be a VirtualApp on VC
	VirtualApp *object.VirtualApp

	// For now throw the Event Manager here
	EventManager event.EventManager

	// Information about the VCH resource pool and about the real host that we want
	// tol retrieve just once.
	VCHMhz          int64
	VCHMemoryLimit  int64
	HostOS          string
	HostOSVersion   string
	HostProductName string //'VMware vCenter Server' or 'VMare ESXi'

	// Datastore URLs for image stores - the top layer is [0], the bottom layer is [len-1]
	ImageStores []url.URL `vic:"0.1" scope:"read-only" key:"storage/image_stores"`
	// contains filtered or unexported fields
}

Configuration is a slice of the VCH config that is relevant to the exec part of the port layer

var Config Configuration

type Container

type Container struct {
	ContainerInfo
	// contains filtered or unexported fields
}

Container is used for an entry in the container cache - this is a "live" representation of containers in the infrastructure. DANGEROUS USAGE CONSTRAINTS:

None of the containerBase fields should be partially updated - consider them immutable once they're
part of a cache entry
i.e. Do not make changes in containerBase.ExecConfig - only swap, under lock, the pointer for a
completely new ExecConfig.
This constraint allows us to avoid deep copying those structs every time a container is inspected

func (*Container) CurrentState

func (c *Container) CurrentState() State

CurrentState returns current state.

func (*Container) Info

func (c *Container) Info() *ContainerInfo

Info returns a copy of the public container configuration that is consistent and copied under lock

func (*Container) LogReader

func (c *Container) LogReader(op trace.Operation, tail int, follow bool, since int64) (io.ReadCloser, error)

func (*Container) NewHandle

func (c *Container) NewHandle(ctx context.Context) *Handle

func (*Container) OnEvent

func (c *Container) OnEvent(e events.Event)

func (*Container) Refresh

func (c *Container) Refresh(op trace.Operation) error

Refresh updates config and runtime info, holding a lock only while swapping the new data for the old

func (*Container) RefreshFromHandle

func (c *Container) RefreshFromHandle(op trace.Operation, h *Handle)

RefreshFromHandle updates config and runtime info, holding a lock only while swapping the new data for the old

func (*Container) ReloadConfig

func (c *Container) ReloadConfig(op trace.Operation) error

func (*Container) Remove

func (c *Container) Remove(op trace.Operation, sess *session.Session) error

Remove removes a containerVM after detaching the disks

func (*Container) SetState

func (c *Container) SetState(op trace.Operation, s State) State

SetState changes container state.

func (*Container) Signal

func (c *Container) Signal(op trace.Operation, num int64) error

func (*Container) String

func (c *Container) String() string

func (*Container) VMReference

func (c *Container) VMReference() types.ManagedObjectReference

VMReference will provide the vSphere vm managed object reference

func (*Container) WaitForExec

func (c *Container) WaitForExec(op trace.Operation, id string) error

WaitForExec waits exec'ed task to set started field or timeout

func (*Container) WaitForSession

func (c *Container) WaitForSession(ctx context.Context, id string) error

WaitForSession waits non-exec'ed task to set started field or timeout

func (*Container) WaitForState

func (c *Container) WaitForState(s State) <-chan struct{}

WaitForState subscribes a caller to an event returning a channel that will be closed when an expected state is set. If expected state is already set the caller will receive a closed channel immediately.

type ContainerCreateConfig

type ContainerCreateConfig struct {
	Metadata *executor.ExecutorConfig

	ParentImageID  string
	ImageStoreName string
	Resources      Resources
}

ContainerCreateConfig defines the parameters for Create call

type ContainerInfo

type ContainerInfo struct {

	// Size of the leaf (unused)
	VMUnsharedDisk int64
	// contains filtered or unexported fields
}

Container is used to return data about a container during inspection calls It is a copy rather than a live reflection and does not require locking

func (*ContainerInfo) ReloadConfig

func (c *ContainerInfo) ReloadConfig(op trace.Operation) error

func (*ContainerInfo) State

func (c *ContainerInfo) State() State

State returns the state at the time the ContainerInfo object was created

func (*ContainerInfo) String

func (c *ContainerInfo) String() string

func (*ContainerInfo) VMReference

func (c *ContainerInfo) VMReference() types.ManagedObjectReference

VMReference will provide the vSphere vm managed object reference

func (*ContainerInfo) WaitForExec

func (c *ContainerInfo) WaitForExec(op trace.Operation, id string) error

WaitForExec waits exec'ed task to set started field or timeout

func (*ContainerInfo) WaitForSession

func (c *ContainerInfo) WaitForSession(ctx context.Context, id string) error

WaitForSession waits non-exec'ed task to set started field or timeout

type DevicesInUseError

type DevicesInUseError struct {
	Devices []string
}

func (DevicesInUseError) Error

func (e DevicesInUseError) Error() string

type Handle

type Handle struct {

	// desired spec
	Spec *spec.VirtualMachineConfigSpec
	// contains filtered or unexported fields
}

func Create

func Create(ctx context.Context, vmomiSession *session.Session, config *ContainerCreateConfig) (*Handle, error)

Create returns a new handle that can be Committed to create a new container. At this time the config is *not* deep copied so should not be changed once passed

TODO: either deep copy the configuration, or provide an alternative means of passing the data that avoids the need for the caller to unpack/repack the parameters

func GetContainer

func GetContainer(ctx context.Context, id uid.UID) *Handle

func GetHandle

func GetHandle(key string) *Handle

GetHandle finds and returns the handle that is referred by key

func HandleFromInterface

func HandleFromInterface(key interface{}) *Handle

HandleFromInterface returns the Handle

func TestHandle

func TestHandle(id string) *Handle

Added solely to support testing - need a better way to do this

func (*Handle) Close

func (h *Handle) Close()

func (*Handle) Commit

func (h *Handle) Commit(op trace.Operation, sess *session.Session, waitTime *int32) error

func (*Handle) Reload

func (h *Handle) Reload()

func (*Handle) ReloadConfig

func (c *Handle) ReloadConfig(op trace.Operation) error

func (*Handle) Rename

func (h *Handle) Rename(op trace.Operation, newName string) *Handle

Rename updates the container name in ExecConfig as well as the vSphere display name

func (*Handle) SetTargetState

func (h *Handle) SetTargetState(s State)

func (*Handle) State

func (c *Handle) State(op trace.Operation) State

State returns the state of the containerVM based on data in the handle, with no refresh

func (*Handle) String

func (h *Handle) String() string

func (*Handle) TargetState

func (h *Handle) TargetState() State

func (*Handle) VMReference

func (c *Handle) VMReference() types.ManagedObjectReference

VMReference will provide the vSphere vm managed object reference

func (*Handle) WaitForExec

func (c *Handle) WaitForExec(op trace.Operation, id string) error

WaitForExec waits exec'ed task to set started field or timeout

func (*Handle) WaitForSession

func (c *Handle) WaitForSession(ctx context.Context, id string) error

WaitForSession waits non-exec'ed task to set started field or timeout

type NotFoundError

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

NotFoundError is returned when a types.ManagedObjectNotFound is returned from a vmomi call

func (NotFoundError) Error

func (r NotFoundError) Error() string

type NotYetExistError

type NotYetExistError struct {
	ID string
}

NotYetExistError is returned when a call that requires a VM exist is made

func (NotYetExistError) Error

func (e NotYetExistError) Error() string

type RemovePowerError

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

RemovePowerError is returned when attempting to remove a containerVM that is powered on

func (RemovePowerError) Error

func (r RemovePowerError) Error() string

type Resources

type Resources struct {
	NumCPUs  int64
	MemoryMB int64
}

Resources describes the resource allocation for the containerVM

type State

type State int
const (
	StateUnknown State = iota
	StateStarting
	StateRunning
	StateStopping
	StateStopped
	StateSuspending
	StateSuspended
	StateCreated
	StateCreating
	StateRemoving
	StateRemoved
)

func (State) String

func (s State) String() string

type VCHStats

type VCHStats struct {
	CPULimit    int64 // resource pool CPU limit
	CPUUsage    int64 // resource pool CPU usage in MhZ
	MemoryLimit int64 // resource pool Memory limit
	MemoryUsage int64 // resource pool Memory Usage
}

func GetVCHstats

func GetVCHstats(ctx context.Context, moref ...types.ManagedObjectReference) VCHStats

Jump to

Keyboard shortcuts

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