vclib

package
v1.31.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 26 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// ThinDiskType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	ThinDiskType = "thin"
	// PreallocatedDiskType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	PreallocatedDiskType = "preallocated"
	// EagerZeroedThickDiskType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	EagerZeroedThickDiskType = "eagerZeroedThick"
	// ZeroedThickDiskType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	ZeroedThickDiskType = "zeroedThick"
)

Volume Constnts

View Source
const (
	// SCSIControllerLimit is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	SCSIControllerLimit = 4
	// SCSIControllerDeviceLimit is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	SCSIControllerDeviceLimit = 15
	// SCSIDeviceSlots is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	SCSIDeviceSlots = 16
	// SCSIReservedSlot is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	SCSIReservedSlot = 7

	// SCSIControllerType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	SCSIControllerType = "scsi"
	// LSILogicControllerType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	LSILogicControllerType = "lsiLogic"
	// BusLogicControllerType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	BusLogicControllerType = "busLogic"
	// LSILogicSASControllerType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	LSILogicSASControllerType = "lsiLogic-sas"
	// PVSCSIControllerType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	PVSCSIControllerType = "pvscsi"
)

Controller Constants

View Source
const (
	// LogLevel is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	LogLevel = 4
	// DatastoreProperty is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	DatastoreProperty = "datastore"
	// ResourcePoolProperty is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	ResourcePoolProperty = "resourcePool"
	// DatastoreInfoProperty is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	DatastoreInfoProperty = "info"
	// StoragePodDrsEntryProperty is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	StoragePodDrsEntryProperty = "podStorageDrsEntry"
	// StoragePodProperty is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	StoragePodProperty = "summary"
	// VirtualMachineType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	VirtualMachineType = "VirtualMachine"
	// RoundTripperDefaultCount is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	RoundTripperDefaultCount = 3
	// VSANDatastoreType is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	VSANDatastoreType = "vsan"
	// DummyVMPrefixName is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	DummyVMPrefixName = "vsphere-k8s"
	// ActivePowerState is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	ActivePowerState = "poweredOn"
)

Other Constants

View Source
const (
	// TestDefaultDatacenter is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	TestDefaultDatacenter = "DC0"
	// TestDefaultDatastore is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	TestDefaultDatastore = "LocalDS_0"
	// TestDefaultNetwork is a good constant, yes it is!
	// TODO(?) Provide better documentation.
	TestDefaultNetwork = "VM Network"
)

Test Constants

View Source
const (
	FileAlreadyExistErrMsg         = "File requested already exist"
	NoDevicesFoundErrMsg           = "No devices found"
	DiskNotFoundErrMsg             = "No vSphere disk ID/Name found"
	InvalidVolumeOptionsErrMsg     = "VolumeOptions verification failed"
	NoVMFoundErrMsg                = "No VM found"
	MultipleVMsFoundErrMsg         = "Multiple VMs found"
	NoZoneRegionFoundErrMsg        = "Unable to find the Zone/Region pair"
	NoDatastoreFoundErrMsg         = "Datastore not found"
	NoDatacenterFoundErrMsg        = "Datacenter not found"
	NoDataStoreClustersFoundErrMsg = "No DatastoreClusters Found"
)

Error Messages

View Source
const (
	APICreateVolume = "CreateVolume"
	APIDeleteVolume = "DeleteVolume"
	APIAttachVolume = "AttachVolume"
	APIDetachVolume = "DetachVolume"
)

Cloud Provider API constants

View Source
const (
	OperationDeleteVolume                  = "DeleteVolumeOperation"
	OperationAttachVolume                  = "AttachVolumeOperation"
	OperationDetachVolume                  = "DetachVolumeOperation"
	OperationDiskIsAttached                = "DiskIsAttachedOperation"
	OperationDisksAreAttached              = "DisksAreAttachedOperation"
	OperationCreateVolume                  = "CreateVolumeOperation"
	OperationCreateVolumeWithPolicy        = "CreateVolumeWithPolicyOperation"
	OperationCreateVolumeWithRawVSANPolicy = "CreateVolumeWithRawVSANPolicyOperation"
)

Cloud Provider Operation constants

Variables

View Source
var (
	ErrFileAlreadyExist         = errors.New(FileAlreadyExistErrMsg)
	ErrNoDevicesFound           = errors.New(NoDevicesFoundErrMsg)
	ErrNoDiskIDFound            = errors.New(DiskNotFoundErrMsg)
	ErrInvalidVolumeOptions     = errors.New(InvalidVolumeOptionsErrMsg)
	ErrNoVMFound                = errors.New(NoVMFoundErrMsg)
	ErrMultipleVMsFound         = errors.New(MultipleVMsFoundErrMsg)
	ErrNoZoneRegionFound        = errors.New(NoZoneRegionFoundErrMsg)
	ErrNoDatastoreFound         = errors.New(NoDatastoreFoundErrMsg)
	ErrNoDatacenterFound        = errors.New(NoDatacenterFoundErrMsg)
	ErrNoDataStoreClustersFound = errors.New(NoDataStoreClustersFoundErrMsg)
)

Error constants

View Source
var (
	// DiskFormatValidType specifies the valid disk formats
	DiskFormatValidType = map[string]string{
		ThinDiskType: ThinDiskType,
		strings.ToLower(EagerZeroedThickDiskType): EagerZeroedThickDiskType,
		strings.ToLower(ZeroedThickDiskType):      PreallocatedDiskType,
	}
	// SCSIControllerValidType specifies the supported SCSI controllers
	SCSIControllerValidType = []string{LSILogicControllerType, LSILogicSASControllerType, PVSCSIControllerType}
)

Functions

func CheckControllerSupported

func CheckControllerSupported(ctrlType string) bool

CheckControllerSupported checks if the given controller type is valid

func CheckDiskFormatSupported

func CheckDiskFormatSupported(diskFormat string) bool

CheckDiskFormatSupported checks if the diskFormat is valid

func DiskformatValidOptions

func DiskformatValidOptions() string

DiskformatValidOptions generates Valid Options for Diskformat

func ExistsInList

func ExistsInList(needle string, haystack []string, caseSensitive bool) bool

ExistsInList determines whether or not the provided string exists in the provided list with optional case-sensitivity.

func GetDatastorePathObjFromVMDiskPath

func GetDatastorePathObjFromVMDiskPath(vmDiskPath string) (*object.DatastorePath, error)

GetDatastorePathObjFromVMDiskPath gets the datastorePathObj from VM disk path.

func GetNumberOfDatacenters added in v0.2.0

func GetNumberOfDatacenters(ctx context.Context, connection *VSphereConnection) (int, error)

GetNumberOfDatacenters returns the number of DataCenters in this vCenter

func GetPathFromVMDiskPath

func GetPathFromVMDiskPath(vmDiskPath string) string

GetPathFromVMDiskPath retrieves the path from VM Disk Path. Example: For vmDiskPath - [vsanDatastore] kubevols/volume.vmdk, the path is kubevols/volume.vmdk

func IsInvalidCredentialsError

func IsInvalidCredentialsError(err error) bool

IsInvalidCredentialsError returns true if error is of type InvalidLogin

func IsManagedObjectNotFoundError

func IsManagedObjectNotFoundError(err error) bool

IsManagedObjectNotFoundError returns true if error is of type ManagedObjectNotFound

func IsNotFound

func IsNotFound(err error) bool

IsNotFound return true if err is NotFoundError or DefaultNotFoundError

func IsValidUUID

func IsValidUUID(uuid string) bool

IsValidUUID checks if the string is a valid UUID.

func RecordCreateVolumeMetric

func RecordCreateVolumeMetric(volumeOptions *VolumeOptions, requestTime time.Time, err error)

RecordCreateVolumeMetric records the Create Volume metric

func RecordvSphereMetric

func RecordvSphereMetric(actionName string, requestTime time.Time, err error)

RecordvSphereMetric records the vSphere API and Operation metrics

func RegisterMetrics

func RegisterMetrics()

RegisterMetrics registers all the API and Operation metrics

func RemoveStorageClusterORFolderNameFromVDiskPath

func RemoveStorageClusterORFolderNameFromVDiskPath(vDiskPath string) string

RemoveStorageClusterORFolderNameFromVDiskPath removes the cluster or folder path from the vDiskPath for vDiskPath DatastoreCluster/sharedVmfs-0 kubevols/e2e-vmdk-1234.vmdk, return value is [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk for vDiskPath [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk, return value remains same [sharedVmfs-0] kubevols/e2e-vmdk-1234.vmdk

func SCSIControllerTypeValidOptions

func SCSIControllerTypeValidOptions() string

SCSIControllerTypeValidOptions generates valid options for SCSIControllerType

func VerifyVolumePathsForVM

func VerifyVolumePathsForVM(vmMo mo.VirtualMachine, volPaths []string, nodeName string, nodeVolumeMap map[string]map[string]bool)

VerifyVolumePathsForVM verifies if the volume paths (volPaths) are attached to VM.

func VerifyVolumePathsForVMDevices

func VerifyVolumePathsForVMDevices(vmDevices object.VirtualDeviceList, volPaths []string, nodeName string, nodeVolumeMap map[string]map[string]bool)

VerifyVolumePathsForVMDevices verifies if the volume paths (volPaths) are attached to VM.

Types

type Datacenter

type Datacenter struct {
	*object.Datacenter
}

Datacenter extends the govmomi Datacenter object

func GetAllDatacenter

func GetAllDatacenter(ctx context.Context, connection *VSphereConnection) ([]*Datacenter, error)

GetAllDatacenter returns all the DataCenter Objects

func GetDatacenter

func GetDatacenter(ctx context.Context, connection *VSphereConnection, datacenterPath string) (*Datacenter, error)

GetDatacenter returns the DataCenter Object for the given datacenterPath If datacenter is located in a folder, include full path to datacenter else just provide the datacenter name

func (*Datacenter) CheckDisksAttached

func (dc *Datacenter) CheckDisksAttached(ctx context.Context, nodeVolumes map[string][]string) (map[string]map[string]bool, error)

CheckDisksAttached checks if the disk is attached to node. This is done by comparing the volume path with the backing.FilePath on the VM Virtual disk devices.

func (*Datacenter) CreateFirstClassDisk

func (dc *Datacenter) CreateFirstClassDisk(ctx context.Context,
	datastoreName string, datastoreType ParentDatastoreType,
	diskName string, diskSize int64) error

CreateFirstClassDisk creates a new first class disk.

func (*Datacenter) DeleteFirstClassDisk

func (dc *Datacenter) DeleteFirstClassDisk(ctx context.Context,
	datastoreName string, datastoreType ParentDatastoreType, diskID string) error

DeleteFirstClassDisk deletes an FCD.

func (*Datacenter) DoesFirstClassDiskExist

func (dc *Datacenter) DoesFirstClassDiskExist(ctx context.Context, fcdID string) (*FirstClassDiskInfo, error)

DoesFirstClassDiskExist returns information about an FCD if it exists.

func (*Datacenter) GetAllDatastoreClusters

func (dc *Datacenter) GetAllDatastoreClusters(ctx context.Context, child bool) (map[string]*StoragePodInfo, error)

GetAllDatastoreClusters returns all datastore clusters and optionally their children.

func (*Datacenter) GetAllDatastores

func (dc *Datacenter) GetAllDatastores(ctx context.Context) (map[string]*DatastoreInfo, error)

GetAllDatastores gets the datastore URL to DatastoreInfo map for all the datastores in the datacenter.

func (*Datacenter) GetAllFirstClassDisks

func (dc *Datacenter) GetAllFirstClassDisks(ctx context.Context) ([]*FirstClassDiskInfo, error)

GetAllFirstClassDisks returns all known FCDs.

func (*Datacenter) GetDatastoreByName

func (dc *Datacenter) GetDatastoreByName(ctx context.Context, name string) (*DatastoreInfo, error)

GetDatastoreByName gets the Datastore object for the given datastore name

func (*Datacenter) GetDatastoreByPath

func (dc *Datacenter) GetDatastoreByPath(ctx context.Context, vmDiskPath string) (*DatastoreInfo, error)

GetDatastoreByPath gets the Datastore object from the given vmDiskPath

func (*Datacenter) GetDatastoreClusterByName

func (dc *Datacenter) GetDatastoreClusterByName(ctx context.Context, name string) (*StoragePodInfo, error)

GetDatastoreClusterByName gets the DatastoreCluster object for the given name

func (*Datacenter) GetDatastoreMoList

func (dc *Datacenter) GetDatastoreMoList(ctx context.Context, dsObjList []*Datastore, properties []string) ([]mo.Datastore, error)

GetDatastoreMoList gets the Datastore Managed Objects with the given properties from the datastore objects

func (*Datacenter) GetFirstClassDisk

func (dc *Datacenter) GetFirstClassDisk(ctx context.Context,
	datastoreName string, datastoreType ParentDatastoreType,
	diskID string, findBy FindFCD) (*FirstClassDiskInfo, error)

GetFirstClassDisk searches for an existing FCD.

func (*Datacenter) GetFolderByPath

func (dc *Datacenter) GetFolderByPath(ctx context.Context, folderPath string) (*Folder, error)

GetFolderByPath gets the Folder Object from the given folder path folderPath should be the full path to folder

func (*Datacenter) GetResourcePool

func (dc *Datacenter) GetResourcePool(ctx context.Context, computePath string) (*object.ResourcePool, error)

GetResourcePool gets the resource pool for the given path

func (*Datacenter) GetVMByDNSName

func (dc *Datacenter) GetVMByDNSName(ctx context.Context, dnsName string) (*VirtualMachine, error)

GetVMByDNSName gets the VM object from the given dns name

func (*Datacenter) GetVMByIP added in v0.2.1

func (dc *Datacenter) GetVMByIP(ctx context.Context, ipAddy string) (*VirtualMachine, error)

GetVMByIP gets the VM object from the given IP address

func (*Datacenter) GetVMByPath

func (dc *Datacenter) GetVMByPath(ctx context.Context, vmPath string) (*VirtualMachine, error)

GetVMByPath gets the VM object from the given vmPath vmPath should be the full path to VM and not just the name

func (*Datacenter) GetVMByUUID

func (dc *Datacenter) GetVMByUUID(ctx context.Context, vmUUID string) (*VirtualMachine, error)

GetVMByUUID gets the VM object from the given vmUUID

func (*Datacenter) GetVMMoList

func (dc *Datacenter) GetVMMoList(ctx context.Context, vmObjList []*VirtualMachine, properties []string) ([]mo.VirtualMachine, error)

GetVMMoList gets the VM Managed Objects with the given properties from the VM object

func (*Datacenter) GetVirtualDiskPage83Data

func (dc *Datacenter) GetVirtualDiskPage83Data(ctx context.Context, diskPath string) (string, error)

GetVirtualDiskPage83Data gets the virtual disk UUID by diskPath

type Datastore

type Datastore struct {
	*object.Datastore
	Datacenter *Datacenter
}

Datastore extends the govmomi Datastore object

func (*Datastore) CreateDirectory

func (ds *Datastore) CreateDirectory(ctx context.Context, directoryPath string, createParents bool) error

CreateDirectory creates the directory at location specified by directoryPath. If the intermediate level folders do not exist, and the parameter createParents is true, all the non-existent folders are created. directoryPath must be in the format "[vsanDatastore] kubevols"

func (*Datastore) GetFirstClassDisk

func (ds *Datastore) GetFirstClassDisk(ctx context.Context, diskID string, findBy FindFCD) (*FirstClassDisk, error)

GetFirstClassDisk gets a specific first class disks (FCD) on this datastore

func (*Datastore) GetName

func (ds *Datastore) GetName(ctx context.Context) (string, error)

GetName returns the type of datastore

func (*Datastore) GetType

func (ds *Datastore) GetType(ctx context.Context) (string, error)

GetType returns the type of datastore

func (*Datastore) IsCompatibleWithStoragePolicy

func (ds *Datastore) IsCompatibleWithStoragePolicy(ctx context.Context, storagePolicyID string) (bool, string, error)

IsCompatibleWithStoragePolicy returns true if datastore is compatible with given storage policy else return false for not compatible datastore, fault message is also returned

func (*Datastore) ListFirstClassDisks

func (ds *Datastore) ListFirstClassDisks(ctx context.Context) ([]*FirstClassDisk, error)

ListFirstClassDisks gets a list of first class disks (FCD) on this datastore

type DatastoreInfo

type DatastoreInfo struct {
	*Datastore
	Info *types.DatastoreInfo
}

DatastoreInfo is a structure to store the Datastore and it's Info.

func (*DatastoreInfo) GetFirstClassDiskInfo

func (di *DatastoreInfo) GetFirstClassDiskInfo(ctx context.Context, diskID string, findBy FindFCD) (*FirstClassDiskInfo, error)

GetFirstClassDiskInfo gets a specific first class disks (FCD) on this datastore

func (*DatastoreInfo) ListFirstClassDiskInfos

func (di *DatastoreInfo) ListFirstClassDiskInfos(ctx context.Context) ([]*FirstClassDiskInfo, error)

ListFirstClassDiskInfos gets a list of first class disks (FCD) on this datastore

func (DatastoreInfo) String

func (di DatastoreInfo) String() string

type FindFCD

type FindFCD int

FindFCD is the type that represents the types of searches used to discover FCDs.

const (
	// FindFCDByID finds FCDs with the provided ID.
	FindFCDByID FindFCD = iota // 0

	// FindFCDByName finds FCDs with the provided name.
	FindFCDByName // 1
)

type FirstClassDisk

type FirstClassDisk struct {
	Datacenter *Datacenter
	*types.VStorageObject
	ParentType ParentDatastoreType

	Datastore  *Datastore
	StoragePod *StoragePod
}

FirstClassDisk extends the govmomi FirstClassDisk object

type FirstClassDiskInfo

type FirstClassDiskInfo struct {
	*FirstClassDisk

	DatastoreInfo  *DatastoreInfo
	StoragePodInfo *StoragePodInfo
}

FirstClassDiskInfo extends the govmomi FirstClassDisk object

type Folder

type Folder struct {
	*object.Folder
	Datacenter *Datacenter
}

Folder extends the govmomi Folder object

func (*Folder) GetVirtualMachines

func (folder *Folder) GetVirtualMachines(ctx context.Context) ([]*VirtualMachine, error)

GetVirtualMachines returns list of VirtualMachine inside a folder.

type ParentDatastoreType

type ParentDatastoreType string

ParentDatastoreType represents the possible parent types of a datastore.

const (
	// TypeDatastore is a datastore parent that's another datastore.
	TypeDatastore ParentDatastoreType = "Datastore"

	// TypeDatastoreCluster is a datastore parent that's a cluster.
	TypeDatastoreCluster ParentDatastoreType = "DatastoreCluster"
)

type PbmClient

type PbmClient struct {
	*pbm.Client
}

PbmClient is extending govmomi pbm, and provides functions to get compatible list of datastore for given policy

func NewPbmClient

func NewPbmClient(ctx context.Context, client *vim25.Client) (*PbmClient, error)

NewPbmClient returns a new PBM Client object

func (*PbmClient) GetCompatibleDatastores

func (pbmClient *PbmClient) GetCompatibleDatastores(ctx context.Context, dc *Datacenter, storagePolicyID string, datastores []*DatastoreInfo) ([]*DatastoreInfo, string, error)

GetCompatibleDatastores filters and returns compatible list of datastores for given storage policy id For Non Compatible Datastores, fault message with the Datastore Name is also returned

func (*PbmClient) GetPlacementCompatibilityResult

func (pbmClient *PbmClient) GetPlacementCompatibilityResult(ctx context.Context, storagePolicyID string, datastore []*DatastoreInfo) (pbm.PlacementCompatibilityResult, error)

GetPlacementCompatibilityResult gets placement compatibility result based on storage policy requirements.

func (*PbmClient) IsDatastoreCompatible

func (pbmClient *PbmClient) IsDatastoreCompatible(ctx context.Context, storagePolicyID string, datastore *Datastore) (bool, string, error)

IsDatastoreCompatible check if the datastores is compatible for given storage policy id if datastore is not compatible with policy, fault message with the Datastore Name is returned

type StoragePod

type StoragePod struct {
	Datacenter *Datacenter
	*object.StoragePod
	Datastores []*Datastore
}

StoragePod extends the govmomi StoragePod object

func (*StoragePod) GetFirstClassDisk

func (sp *StoragePod) GetFirstClassDisk(ctx context.Context, diskID string, findBy FindFCD) (*FirstClassDisk, error)

GetFirstClassDisk gets a specific first class disks (FCD) on this datastore backed by this StoragePod

func (*StoragePod) ListFirstClassDisks

func (sp *StoragePod) ListFirstClassDisks(ctx context.Context) ([]*FirstClassDisk, error)

ListFirstClassDisks gets a list of first class disks (FCD) on this datastore backed by this StoragePod

func (*StoragePod) PopulateChildDatastores

func (sp *StoragePod) PopulateChildDatastores(ctx context.Context, refresh bool) error

PopulateChildDatastores discovers the child Datastores backed by this StoragePod

type StoragePodInfo

type StoragePodInfo struct {
	*StoragePod
	Summary        *types.StoragePodSummary
	Config         *types.StorageDrsConfigInfo
	DatastoreInfos []*DatastoreInfo
}

StoragePodInfo is a structure to store the StoragePod and it's Info.

func (*StoragePodInfo) GetDatastoreThatOwnsFCD

func (spi *StoragePodInfo) GetDatastoreThatOwnsFCD(ctx context.Context, diskID string) (*DatastoreInfo, error)

GetDatastoreThatOwnsFCD gets datastore that owns first class disks (FCD) backed by this StoragePod

func (*StoragePodInfo) GetFirstClassDiskInfo

func (spi *StoragePodInfo) GetFirstClassDiskInfo(ctx context.Context, diskID string, findBy FindFCD) (*FirstClassDiskInfo, error)

GetFirstClassDiskInfo gets a specific first class disks (FCD) on this datastore backed by this StoragePodInfo

func (*StoragePodInfo) ListFirstClassDisksInfo

func (spi *StoragePodInfo) ListFirstClassDisksInfo(ctx context.Context) ([]*FirstClassDiskInfo, error)

ListFirstClassDisksInfo gets a list of first class disks (FCD) on this datastore backed by this StoragePodInfo

func (*StoragePodInfo) PopulateChildDatastoreInfos

func (spi *StoragePodInfo) PopulateChildDatastoreInfos(ctx context.Context, refresh bool) error

PopulateChildDatastoreInfos discovers the child DatastoreInfos backed by this StoragePodInfo

type VMOptions

type VMOptions struct {
	VMFolder       *Folder
	VMResourcePool *object.ResourcePool
}

VMOptions provides helper objects for provisioning volume with SPBM Policy

type VSphereConnection

type VSphereConnection struct {
	Client            *vim25.Client
	Username          string
	Password          string
	Hostname          string
	Port              string
	CACert            string
	Thumbprint        string
	Insecure          bool
	RoundTripperCount uint
	// contains filtered or unexported fields
}

VSphereConnection contains information for connecting to vCenter

func (*VSphereConnection) Connect

func (connection *VSphereConnection) Connect(ctx context.Context) error

Connect makes connection to vCenter and sets VSphereConnection.Client. If connection.Client is already set, it obtains the existing user session. if user session is not valid, connection.Client will be set to the new client.

func (*VSphereConnection) Logout

func (connection *VSphereConnection) Logout(ctx context.Context)

Logout calls SessionManager.Logout for the given connection.

func (*VSphereConnection) NewClient

func (connection *VSphereConnection) NewClient(ctx context.Context) (*vim25.Client, error)

NewClient creates a new govmomi client for the VSphereConnection obj

func (*VSphereConnection) Signer added in v1.0.0

func (connection *VSphereConnection) Signer(ctx context.Context, client *vim25.Client) (*sts.Signer, error)

Signer returns an sts.Signer for use with SAML token auth if connection is configured for such. Returns nil if username/password auth is configured for the connection.

func (*VSphereConnection) UpdateCredentials

func (connection *VSphereConnection) UpdateCredentials(username string, password string)

UpdateCredentials updates username and password. Note: Updated username and password will be used when there is no session active

type VirtualMachine

type VirtualMachine struct {
	*object.VirtualMachine
	Datacenter *Datacenter
}

VirtualMachine extends the govmomi VirtualMachine object

func (*VirtualMachine) AttachDisk

func (vm *VirtualMachine) AttachDisk(ctx context.Context, vmDiskPath string, volumeOptions *VolumeOptions) (string, error)

AttachDisk attaches the disk at location - vmDiskPath from Datastore - dsObj to the Virtual Machine Additionally the disk can be configured with SPBM policy if volumeOptions.StoragePolicyID is non-empty.

func (*VirtualMachine) CreateDiskSpec

func (vm *VirtualMachine) CreateDiskSpec(ctx context.Context, diskPath string, dsObj *Datastore, volumeOptions *VolumeOptions) (*types.VirtualDisk, types.BaseVirtualDevice, error)

CreateDiskSpec creates a disk spec for disk

func (*VirtualMachine) DeleteVM

func (vm *VirtualMachine) DeleteVM(ctx context.Context) error

DeleteVM deletes the VM.

func (*VirtualMachine) DetachDisk

func (vm *VirtualMachine) DetachDisk(ctx context.Context, vmDiskPath string) error

DetachDisk detaches the disk specified by vmDiskPath

func (*VirtualMachine) Exists added in v1.23.2

func (vm *VirtualMachine) Exists(ctx context.Context) (bool, error)

Exists chech whether VM exist by searching by managed object reference

func (*VirtualMachine) GetAllAccessibleDatastores

func (vm *VirtualMachine) GetAllAccessibleDatastores(ctx context.Context) ([]*DatastoreInfo, error)

GetAllAccessibleDatastores gets the list of accessible Datastores for the given Virtual Machine

func (*VirtualMachine) GetResourcePool

func (vm *VirtualMachine) GetResourcePool(ctx context.Context) (*object.ResourcePool, error)

GetResourcePool gets the resource pool for VM.

func (*VirtualMachine) GetVMNodeName

func (vm *VirtualMachine) GetVMNodeName() (string, error)

GetVMNodeName returns host name from the VM's guest operating system.

func (*VirtualMachine) GetVMUUID

func (vm *VirtualMachine) GetVMUUID() (string, error)

GetVMUUID returns the VM's UUID.

func (*VirtualMachine) GetVirtualDiskPath

func (vm *VirtualMachine) GetVirtualDiskPath(ctx context.Context) (string, error)

GetVirtualDiskPath gets the first available virtual disk devicePath from the VM

func (*VirtualMachine) IsActive

func (vm *VirtualMachine) IsActive(ctx context.Context) (bool, error)

IsActive checks if the VM is active. Returns true if VM is in poweredOn state.

func (*VirtualMachine) IsDiskAttached

func (vm *VirtualMachine) IsDiskAttached(ctx context.Context, diskPath string) (bool, error)

IsDiskAttached checks if disk is attached to the VM.

func (*VirtualMachine) RenewVM

func (vm *VirtualMachine) RenewVM(client *vim25.Client) VirtualMachine

RenewVM renews this virtual machine with new client connection.

type VolumeOptions

type VolumeOptions struct {
	CapacityKB             int
	Tags                   map[string]string
	Name                   string
	DiskFormat             string
	Datastore              string
	VSANStorageProfileData string
	StoragePolicyName      string
	StoragePolicyID        string
	SCSIControllerType     string
}

VolumeOptions specifies various options for a volume.

func (VolumeOptions) VerifyVolumeOptions

func (volumeOptions VolumeOptions) VerifyVolumeOptions() bool

VerifyVolumeOptions checks if volumeOptions.SCIControllerType is valid controller type

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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