session

package
v1.5.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2019 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package session caches vSphere objects to avoid having to repeatedly make govmomi client calls.

To obtain a Session, call Create with a Config. The config contains the SDK URL (Service) and the desired vSphere resources. Create then connects to Service and stores govmomi objects for each corresponding value in Config. The Session is returned and the user can use the cached govmomi objects in the exported fields of Session instead of directly using a govmomi Client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LimitConcurrency

func LimitConcurrency(rt http.RoundTripper, limit int) http.RoundTripper

LimitConcurrency limits how many requests can be processed at once

Types

type Config

type Config struct {
	// SDK URL or proxy
	Service string
	// Credentials
	User *url.Userinfo
	// CloneTicket is used to clone an existing session
	CloneTicket string
	// Allow insecure connection to Service
	Insecure bool
	// Target thumbprint
	Thumbprint string
	// Keep alive duration
	Keepalive time.Duration
	// User-Agent to identify login sessions (see: govc session.ls)
	UserAgent string

	ClusterPath    string
	DatacenterPath string
	DatastorePath  string
	HostPath       string
	PoolPath       string
}

Config contains the configuration used to create a Session.

type RoundTripFunc

type RoundTripFunc func(*http.Request) (*http.Response, error)

RoundTripFunc alias

func (RoundTripFunc) RoundTrip

func (rt RoundTripFunc) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip method

type SDKURLError

type SDKURLError struct {
	Service string
	Err     error
}

SDKURLError is returned when the soap SDK URL cannot be parsed

func (SDKURLError) Error

func (e SDKURLError) Error() string

type Session

type Session struct {
	*govmomi.Client

	*Config

	Cluster    *object.ComputeResource
	Datacenter *object.Datacenter
	Datastore  *object.Datastore
	Host       *object.HostSystem
	Pool       *object.ResourcePool

	// Default vSphere VMFolder
	VMFolder *object.Folder
	// Folder where appliance is located
	VCHFolder *object.Folder

	Finder *find.Finder

	DRSEnabled *bool
}

Session caches vSphere objects obtained by querying the SDK.

func NewSession

func NewSession(config *Config) *Session

NewSession creates a new Session struct.

func (*Session) Connect

func (s *Session) Connect(ctx context.Context) (*Session, error)

Connect establishes the connection for the session but nothing more

func (*Session) Create

func (s *Session) Create(ctx context.Context) (*Session, error)

Create accepts a Config and returns a Session with the cached vSphere resources.

func (*Session) IsVC

func (s *Session) IsVC() bool

IsVC returns whether the session is backed by VC

func (*Session) IsVSAN

func (s *Session) IsVSAN(ctx context.Context) bool

IsVSAN returns whether the datastore used in the session is backed by VSAN

func (*Session) Populate

func (s *Session) Populate(ctx context.Context) (*Session, error)

Populate caches resources on the session object. These resources are based off of the config provided at session creation.

vic specific: The values that end in Path (DataCenterPath, ClusterPath, etc..) are either from the CLI or have been retreived from the appliance extraConfig

func (*Session) SetDatacenter added in v1.5.0

func (s *Session) SetDatacenter(op trace.Operation, datacenter *object.Datacenter) error

func (*Session) Vim25

func (s *Session) Vim25() *vim25.Client

Vim25 returns the vim25.Client to the caller

type SoapClientError

type SoapClientError struct {
	Host string
	Err  error
}

SoapClientError is returned when we're unable to obtain a vim client

func (SoapClientError) Error

func (e SoapClientError) Error() string

type UserPassLoginError

type UserPassLoginError struct {
	Host string
	Err  error
}

UserPassLoginError is returned when login via username/password is unsuccessful

func (UserPassLoginError) Error

func (e UserPassLoginError) Error() string

Jump to

Keyboard shortcuts

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