connectionmanager

package
v1.31.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FindVMByUUID finds VMs with the provided UUID.
	FindVMByUUID FindVM = iota // 0
	// FindVMByName finds VMs with the provided name.
	FindVMByName // 1
	// FindVMByIP finds VMs with the provided IP adress.
	FindVMByIP // 2

	// PoolSize is the number of goroutines used in parallel to find a VM.
	PoolSize int = 8

	// QueueSize is the size of the channel buffer used to find objects.
	// Only QueueSize objects may be placed into the queue before blocking.
	QueueSize int = PoolSize * 10

	// NumConnectionAttempts is the number of allowed connection attempts
	// before an error is returned.
	NumConnectionAttempts int = 3

	// RetryAttemptDelaySecs is the number of seconds to wait between
	// connection attempts.
	RetryAttemptDelaySecs int = 1
)
View Source
const (
	ConnectionNotFoundErrMsg       = "vCenter not found"
	MustHaveAtLeastOneVCDCErrMsg   = "Must have at least one vCenter/Datacenter configured"
	MultiVCRequiresZonesErrMsg     = "The use of multiple vCenters require the use of zones"
	MultiDCRequiresZonesErrMsg     = "The use of multiple Datacenters within a vCenter require the use of zones"
	UnsupportedConfigurationErrMsg = "Unsupported configuration"
	UnableToFindCredentialManager  = "Unable to find Credential Manager"
)

Error Messages

View Source
const (

	// ZoneLabel is the label for zones.
	ZoneLabel = "Zone"

	// RegionLabel is the label for regions.
	RegionLabel = "Region"
)

Well-known keys for k/v maps

Variables

View Source
var (
	ErrConnectionNotFound            = errors.New(ConnectionNotFoundErrMsg)
	ErrMustHaveAtLeastOneVCDC        = errors.New(MustHaveAtLeastOneVCDCErrMsg)
	ErrMultiVCRequiresZones          = errors.New(MultiVCRequiresZonesErrMsg)
	ErrMultiDCRequiresZones          = errors.New(MultiDCRequiresZonesErrMsg)
	ErrUnsupportedConfiguration      = errors.New(UnsupportedConfigurationErrMsg)
	ErrUnableToFindCredentialManager = errors.New(UnableToFindCredentialManager)
)

Error constants

Functions

This section is empty.

Types

type ConnectionManager

type ConnectionManager struct {
	sync.Mutex

	// Maps the VC server to VSphereInstance
	VsphereInstanceMap map[string]*VSphereInstance
	// contains filtered or unexported fields
}

ConnectionManager encapsulates vCenter connections

func NewConnectionManager

func NewConnectionManager(cfg *vcfg.Config, informMgr *k8s.InformerManager, client clientset.Interface) *ConnectionManager

NewConnectionManager returns a new ConnectionManager object This function also initializes the Default/Global lister for secrets. In other words, If a single global secret is used for all VCs, the informMgr param will be used to obtain those secrets

func (*ConnectionManager) APIVersion added in v0.2.0

func (connMgr *ConnectionManager) APIVersion(vcInstance *VSphereInstance) (string, error)

APIVersion returns the version of the vCenter API

func (*ConnectionManager) Connect

func (connMgr *ConnectionManager) Connect(ctx context.Context, vcInstance *VSphereInstance) error

Connect connects to vCenter with existing credentials If credentials are invalid:

  1. It will fetch credentials from credentialManager
  2. Update the credentials
  3. Connects again to vCenter with fetched credentials

func (*ConnectionManager) InitializeSecretLister added in v1.1.0

func (connMgr *ConnectionManager) InitializeSecretLister()

InitializeSecretLister initializes the individual secret listers that are NOT handled through the Default/Global lister tied to the default service account.

func (*ConnectionManager) ListAllVCandDCPairs added in v0.2.0

func (cm *ConnectionManager) ListAllVCandDCPairs(ctx context.Context) ([]*ListDiscoveryInfo, error)

ListAllVCandDCPairs returns all VC/DC pairs

func (*ConnectionManager) Logout

func (connMgr *ConnectionManager) Logout()

Logout closes existing connections to remote vCenter endpoints.

func (*ConnectionManager) LookupZoneByMoref added in v0.2.0

func (cm *ConnectionManager) LookupZoneByMoref(ctx context.Context, tenantRef string,
	moRef types.ManagedObjectReference, zoneLabel string, regionLabel string) (map[string]string, error)

LookupZoneByMoref searches for a zone using the provided managed object reference.

func (*ConnectionManager) Verify

func (connMgr *ConnectionManager) Verify() error

Verify validates the configuration by attempting to connect to the configured, remote vCenter endpoints.

func (*ConnectionManager) VerifyWithContext

func (connMgr *ConnectionManager) VerifyWithContext(ctx context.Context) error

VerifyWithContext is the same as Verify but allows a Go Context to control the lifecycle of the connection event.

func (*ConnectionManager) WhichVCandDCByFCDId

func (cm *ConnectionManager) WhichVCandDCByFCDId(ctx context.Context, fcdID string) (*FcdDiscoveryInfo, error)

WhichVCandDCByFCDId searches for an FCD using the provided ID.

func (*ConnectionManager) WhichVCandDCByNodeID added in v0.2.0

func (cm *ConnectionManager) WhichVCandDCByNodeID(ctx context.Context, nodeID string, searchBy FindVM) (*VMDiscoveryInfo, error)

WhichVCandDCByNodeID finds the VC/DC combo that owns a particular VM

func (*ConnectionManager) WhichVCandDCByZone

func (cm *ConnectionManager) WhichVCandDCByZone(ctx context.Context,
	zoneLabel string, regionLabel string, zoneLooking string, regionLooking string) (*ZoneDiscoveryInfo, error)

WhichVCandDCByZone gets the corresponding VC+DC combo that supports the availability zone

type FcdDiscoveryInfo

type FcdDiscoveryInfo struct {
	TenantRef  string
	DataCenter *vclib.Datacenter
	FCDInfo    *vclib.FirstClassDiskInfo
	VcServer   string
}

FcdDiscoveryInfo contains FCD info about a discovered FCD

type FindVM

type FindVM int

FindVM is the type that represents the types of searches used to discover VMs.

func (FindVM) String added in v0.2.0

func (f FindVM) String() string

String returns the string representation of the FindVM constant.

type ListDiscoveryInfo added in v0.2.0

type ListDiscoveryInfo struct {
	TenantRef  string
	VcServer   string
	DataCenter *vclib.Datacenter
}

ListDiscoveryInfo represents a VC/DC pair

type VMDiscoveryInfo added in v0.2.0

type VMDiscoveryInfo struct {
	TenantRef  string
	DataCenter *vclib.Datacenter
	VM         *vclib.VirtualMachine
	VcServer   string
	UUID       string
	NodeName   string
}

VMDiscoveryInfo contains VM info about a discovered VM

type VSphereInstance

type VSphereInstance struct {
	Conn *vclib.VSphereConnection
	Cfg  *vcfg.VirtualCenterConfig
}

VSphereInstance represents a vSphere instance where one or more kubernetes nodes are running.

type ZoneDiscoveryInfo added in v0.2.0

type ZoneDiscoveryInfo struct {
	TenantRef  string
	DataCenter *vclib.Datacenter
	VcServer   string
}

ZoneDiscoveryInfo contains VC+DC info based on a given zone

Jump to

Keyboard shortcuts

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