vsphere

package
v3.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 36 Imported by: 2

Documentation

Index

Constants

View Source
const (
	// DefaultScheme is the default connection scheme.
	DefaultScheme = "https"
	// DefaultRoundTripperCount is the default SOAP round tripper count.
	DefaultRoundTripperCount = 3
)
View Source
const DatastoreInfoProperty = "info"

DatastoreInfoProperty refers to the property name info for the Datastore.

View Source
const (

	// VSphere70u3Version is a 3 digit value to indicate the minimum vSphere
	// version to use query volume async API.
	VSphere70u3Version int = 703
)

Variables

View Source
var (
	// ErrVCAlreadyRegistered is returned when registration for a previously
	// registered virtual center is attempted.
	ErrVCAlreadyRegistered = errors.New("virtual center was already registered")
	// ErrVCNotFound is returned when a virtual center instance isn't found.
	ErrVCNotFound = errors.New("virtual center wasn't found in registry")
)
View Source
var (
	// ErrVMNotFound is returned when a virtual machine isn't found.
	ErrVMNotFound = errors.New("virtual machine wasn't found")
	// ErrNoSharedDatastoresFound is raised when no shared datastores are found among the given NodeVMs.
	ErrNoSharedDatastoresFound = errors.New("no shared datastores found among given NodeVMs")
)
View Source
var (
	// ErrNotSupported represents not supported error.
	ErrNotSupported = errors.New("not supported")
)

Functions

func AsyncGetAllDatacenters

func AsyncGetAllDatacenters(ctx context.Context, buffSize int) (<-chan *Datacenter, <-chan error)

AsyncGetAllDatacenters fetches all Datacenters asynchronously. The *Datacenter chan returns a *Datacenter on discovering one. The error chan returns a single error if one occurs. Both channels are closed when nothing more is to be sent.

The buffer size for the *Datacenter chan can be specified via the buffSize parameter. For example, buffSize could be 1, in which case, the sender will buffer at most 1 *Datacenter instance (and possibly close the channel and terminate, if that was the only instance found).

Note that a context.Canceled error would be returned if the context was canceled at some point during the execution of this function.

func CompareKubernetesMetadata

func CompareKubernetesMetadata(ctx context.Context, k8sMetaData *cnstypes.CnsKubernetesEntityMetadata,
	cnsMetaData *cnstypes.CnsKubernetesEntityMetadata) bool

CompareKubernetesMetadata compares the whole CnsKubernetesEntityMetadata from two given parameters.

func CreateCnsKuberenetesEntityReference

func CreateCnsKuberenetesEntityReference(entityType string, entityName string,
	namespace string, clusterid string) cnstypes.CnsKubernetesEntityReference

CreateCnsKuberenetesEntityReference returns an EntityReference object to which the given entity refers to.

func GetCandidateDatastoresInCluster

func GetCandidateDatastoresInCluster(ctx context.Context, vc *VirtualCenter, clusterID string) (
	[]*DatastoreInfo, []*DatastoreInfo, error)

GetCandidateDatastoresInCluster gets the shared datastores and vSAN-direct managed datastores of given VC cluster. The 1st output parameter will be shared datastores. The 2nd output parameter will be vSAN-direct managed datastores.

func GetCnsKubernetesEntityMetaData

func GetCnsKubernetesEntityMetaData(entityName string, labels map[string]string,
	deleteFlag bool, entityType string, namespace string, clusterID string,
	referredEntity []cnstypes.CnsKubernetesEntityReference) *cnstypes.CnsKubernetesEntityMetadata

GetCnsKubernetesEntityMetaData creates a CnsKubernetesEntityMetadataObject object from given parameters.

func GetContainerCluster

func GetContainerCluster(clusterid string, username string, clusterflavor cnstypes.CnsClusterFlavor,
	clusterdistribution string) cnstypes.CnsContainerCluster

GetContainerCluster creates ContainerCluster object from given parameters.

func GetLabelsMapFromKeyValue

func GetLabelsMapFromKeyValue(labels []types.KeyValue) map[string]string

GetLabelsMapFromKeyValue creates a map object from given parameter.

func GetTagManager

func GetTagManager(ctx context.Context, vc *VirtualCenter) (*tags.Manager, error)

GetTagManager returns tagManager connected to given VirtualCenter.

func GetUUIDFromProviderID

func GetUUIDFromProviderID(providerID string) string

GetUUIDFromProviderID Returns VM UUID from Node's providerID.

func GetUUIDFromVMReference

func GetUUIDFromVMReference(ctx context.Context, vc *VirtualCenter, vmRef types.ManagedObjectReference) (
	string, error)

GetUUIDFromVMReference fetches the UUID of the VM by looking at the config.uuid property from the VM ref.

func GetVcenterIPs

func GetVcenterIPs(cfg *config.Config) ([]string, error)

GetVcenterIPs returns list of vCenter IPs from VSphereConfig.

func IsAlreadyExists

func IsAlreadyExists(err error) (bool, string)

IsAlreadyExists checks if err is the AlreadyExists fault. If the error is AlreadyExists fault, the method returns true along with the name of the managed object. Otherwise, returns false.

func IsCnsSnapshotNotFoundError

func IsCnsSnapshotNotFoundError(err error) bool

IsCnsSnapshotNotFoundError checks if err is the CnsSnapshotNotFoundFault fault returned by CNS QuerySnapshots API

func IsInvalidArgumentError

func IsInvalidArgumentError(err error) bool

func IsInvalidCredentialsError

func IsInvalidCredentialsError(err error) bool

IsInvalidCredentialsError returns true if error is of type InvalidLogin.

func IsManagedObjectNotFound

func IsManagedObjectNotFound(err error, moRef types.ManagedObjectReference) bool

IsManagedObjectNotFound checks if err is the ManagedObjectNotFound fault. Returns true, if 'err' is a MnagedObjectNotFound fault for the intended 'moRef' object. Otherwise, return false.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError checks if err is the NotFound fault.

func IsVimFaultNotFoundError

func IsVimFaultNotFoundError(err error) bool

func IsVolumeCreationSuspended

func IsVolumeCreationSuspended(ctx context.Context, datastoreInfo *DatastoreInfo) bool

IsVolumeCreationSuspended checks whether a given Datastore has cns.vmware.com/datastoreSuspended customValue

func IsvSphereVersion70U3orAbove

func IsvSphereVersion70U3orAbove(ctx context.Context, aboutInfo types.AboutInfo) (bool, error)

IsvSphereVersion70U3orAbove checks if specified version is 7.0 Update 3 or higher. The method takes aboutInfo as input which contains details about VC version, build number and so on. If the version is 7.0 Update 3 or higher, returns true, else returns false along with appropriate errors for the failue.

func NewCnsClient

func NewCnsClient(ctx context.Context, c *vim25.Client) (*cns.Client, error)

NewCnsClient creates a new CNS client

func NewVslmClient

func NewVslmClient(ctx context.Context, c *vim25.Client) (*vslm.Client, error)

NewVslmClient creates a new Vslm client

func UnregisterAllVirtualCenters

func UnregisterAllVirtualCenters(ctx context.Context) error

UnregisterAllVirtualCenters helps unregister and logout all registered vCenter instances This function is called before exiting container to logout current sessions

Types

type Datacenter

type Datacenter struct {
	// Datacenter represents the govmomi Datacenter.
	*object.Datacenter
	// VirtualCenterHost represents the virtual center host address.
	VirtualCenterHost string
}

Datacenter holds virtual center information along with the Datacenter.

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) GetDatastoreInfoByURL

func (dc *Datacenter) GetDatastoreInfoByURL(ctx context.Context, datastoreURL string) (*DatastoreInfo, error)

GetDatastoreInfoByURL returns the *DatastoreInfo instance given its URL.

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) GetVirtualMachineByUUID

func (dc *Datacenter) GetVirtualMachineByUUID(ctx context.Context,
	uuid string, instanceUUID bool) (*VirtualMachine, error)

GetVirtualMachineByUUID returns the VirtualMachine instance given its UUID in a datacenter. If instanceUUID is set to true, then UUID is an instance UUID.

  • In this case, this function searches for virtual machines whose instance UUID matches the given uuid.

If instanceUUID is set to false, then UUID is BIOS UUID.

  • In this case, this function searches for virtual machines whose BIOS UUID matches the given uuid.

func (*Datacenter) String

func (dc *Datacenter) String() string

type Datastore

type Datastore struct {
	// Datastore represents the govmomi Datastore instance.
	*object.Datastore
	// Datacenter represents the datacenter on which the Datastore resides.
	Datacenter *Datacenter
}

Datastore holds Datastore and Datacenter information.

func (*Datastore) GetDatastoreURLAndType

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

GetDatastoreURLAndType returns the URL and Type of datastore

type DatastoreInfo

type DatastoreInfo struct {
	*Datastore
	Info         *types.DatastoreInfo
	CustomValues []types.BaseCustomFieldValue
}

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

func FilterSuspendedDatastores

func FilterSuspendedDatastores(ctx context.Context, datastoreInfoList []*DatastoreInfo) ([]*DatastoreInfo, error)

FilterSuspendedDatastores filters out datastores which cns.vmware.com/datastoreSuspended customValue

func GetDatastoreInfoByURL

func GetDatastoreInfoByURL(ctx context.Context, vc *VirtualCenter, clusterID, dsURL string) (*DatastoreInfo, error)

GetDatastoreInfoByURL returns info of a datastore found in given cluster whose URL matches the specified datastore URL.

func GetSharedDatastoresForVMs

func GetSharedDatastoresForVMs(ctx context.Context, nodeVMs []*VirtualMachine) ([]*DatastoreInfo, error)

GetSharedDatastoresForVMs returns shared datastores accessible to specified nodeVMs list.

func (DatastoreInfo) String

func (di DatastoreInfo) String() string

type DiskHealth

type DiskHealth struct {
	HealthFlags  int   `json:"healthFlags,omitempty"`
	HealthReason int   `json:"healthReason,omitempty"`
	TimeStamp    int64 `json:"timestamp,omitempty"`
}

type HostSystem

type HostSystem struct {
	// HostSystem represents the host system.
	*object.HostSystem
}

HostSystem holds details of a host instance.

func (*HostSystem) GetAllAccessibleDatastores

func (host *HostSystem) GetAllAccessibleDatastores(ctx context.Context) ([]*DatastoreInfo, error)

GetAllAccessibleDatastores gets the list of accessible datastores for the given host.

func (*HostSystem) GetHostVsanCapacity

func (host *HostSystem) GetHostVsanCapacity(ctx context.Context) (*VsanHostCapacity, error)

GetHostVsanCapacity wraps around QueryPhysicalVsanDisks to sum up all the capacity disks of a host.

func (*HostSystem) GetHostVsanNodeUUID

func (host *HostSystem) GetHostVsanNodeUUID(ctx context.Context) (string, error)

GetHostVsanNodeUUID gets the vSAN NodeUuid for this host.

func (*HostSystem) QueryPhysicalVsanDisks

func (host *HostSystem) QueryPhysicalVsanDisks(ctx context.Context) (VsanPhysicalDiskMap, error)

QueryPhysicalVsanDisks wraps the underlying vSAN API and unmarshals the JSON result as well.

type SpbmPolicyContent

type SpbmPolicyContent struct {
	ID       string                 `json:"id,omitempty"`
	Profiles []SpbmPolicySubProfile `json:"profiles"`
}

SpbmPolicyContent corresponds to a single VC SPBM policy. The various sub profilles are ORed. For vSAN there should only be a single sub profile.

type SpbmPolicyRule

type SpbmPolicyRule struct {
	Ns     string `json:"ns,omitempty"`
	CapID  string `json:"capId,omitempty"`
	PropID string `json:"propId,omitempty"`
	Value  string `json:"value,omitempty"`
}

SpbmPolicyRule is an individual policy rule. Not all providers use Ns, CapID, PropID in the same way, so one needs to look at each one individually. Ns + CapID + PropID together are a unique key in all cases

type SpbmPolicySubProfile

type SpbmPolicySubProfile struct {
	Rules []SpbmPolicyRule `json:"rules"`
}

SpbmPolicySubProfile is a combination of rules, which are ANDed to form a sub profile.

type VirtualCenter

type VirtualCenter struct {
	// Config represents the virtual center configuration.
	Config *VirtualCenterConfig
	// Client represents the govmomi client instance for the connection.
	Client *govmomi.Client
	// PbmClient represents the govmomi PBM Client instance.
	PbmClient *pbm.Client
	// CnsClient represents the CNS client instance.
	CnsClient *cns.Client
	// VsanClient represents the VSAN client instance.
	VsanClient *vsan.Client
	// VslmClient represents the Vslm client instance.
	VslmClient *vslm.Client
	// ClientMutex is used for exclusive connection creation.
	ClientMutex *sync.Mutex
}

VirtualCenter holds details of a virtual center instance.

func GetVirtualCenterInstance

func GetVirtualCenterInstance(ctx context.Context,
	config *config.ConfigurationInfo, reinitialize bool) (*VirtualCenter, error)

GetVirtualCenterInstance returns the vcenter object singleton. It is thread safe. Takes in a boolean paramater reloadConfig. If reinitialize is true, the vcenter object is instantiated again and the old object becomes eligible for garbage collection. If reinitialize is false and instance was already initialized, the previous instance is returned.

func GetVirtualCenterInstanceForVCenterConfig

func GetVirtualCenterInstanceForVCenterConfig(ctx context.Context,
	vcconfig *VirtualCenterConfig, reinitialize bool) (*VirtualCenter, error)

GetVirtualCenterInstanceForVCenterConfig returns the vcenter object for given vCenter Config Takes in a boolean paramater reloadConfig. If reinitialize is true, the vcenter object is instantiated again and the old object becomes eligible for garbage collection. If reinitialize is false and instance was already initialized, the previous instance is returned.

func GetVirtualCenterInstanceForVCenterHost

func GetVirtualCenterInstanceForVCenterHost(ctx context.Context, vcHost string,
	reconnect bool) (*VirtualCenter, error)

GetVirtualCenterInstanceForVCenterHost returns the vcenter object for given vCenter host.

func (*VirtualCenter) Connect

func (vc *VirtualCenter) Connect(ctx context.Context) error

Connect establishes a new connection with vSphere with updated credentials. If credentials are invalid then it fails the connection.

func (*VirtualCenter) ConnectCns

func (vc *VirtualCenter) ConnectCns(ctx context.Context) error

ConnectCns creates a CNS client for the virtual center.

func (*VirtualCenter) ConnectPbm

func (vc *VirtualCenter) ConnectPbm(ctx context.Context) error

ConnectPbm creates a PBM client for the virtual center.

func (*VirtualCenter) ConnectVsan

func (vc *VirtualCenter) ConnectVsan(ctx context.Context) error

ConnectVsan creates a VSAN client for the virtual center.

func (*VirtualCenter) ConnectVslm

func (vc *VirtualCenter) ConnectVslm(ctx context.Context) error

ConnectVslm creates a Vslm client for the virtual center.

func (*VirtualCenter) Disconnect

func (vc *VirtualCenter) Disconnect(ctx context.Context) error

Disconnect disconnects the virtual center host connection if connected.

func (*VirtualCenter) DisconnectCns

func (vc *VirtualCenter) DisconnectCns(ctx context.Context)

DisconnectCns destroys the CNS client for the virtual center.

func (*VirtualCenter) DisconnectPbm

func (vc *VirtualCenter) DisconnectPbm(ctx context.Context) error

DisconnectPbm destroys the PBM client for the virtual center.

func (*VirtualCenter) DisconnectVsan

func (vc *VirtualCenter) DisconnectVsan(ctx context.Context) error

DisconnectVsan destroys the VSAN client for the virtual center.

func (*VirtualCenter) DisconnectVslm

func (vc *VirtualCenter) DisconnectVslm(ctx context.Context)

DisconnectVslm destroys the Vslm client for the virtual center.

func (*VirtualCenter) GetAllVirtualMachines

func (vc *VirtualCenter) GetAllVirtualMachines(ctx context.Context,
	hostObjList []*HostSystem) ([]*object.VirtualMachine, error)

GetAllVirtualMachines gets the VM Managed Objects with the given properties from the VM object.

func (*VirtualCenter) GetDatacenters

func (vc *VirtualCenter) GetDatacenters(ctx context.Context) ([]*Datacenter, error)

GetDatacenters returns Datacenters found on the VirtualCenter. If no datacenters are mentioned in the VirtualCenterConfig during registration, all Datacenters for the given VirtualCenter will be returned. If DatacenterPaths is configured in VirtualCenterConfig during registration, only the listed Datacenters are returned.

func (*VirtualCenter) GetDatastoresByCluster

func (vc *VirtualCenter) GetDatastoresByCluster(ctx context.Context,
	clusterMorefValue string) ([]*DatastoreInfo, error)

GetDatastoresByCluster return datastores inside the cluster using its moref. NOTE: The return value can contain duplicates.

func (*VirtualCenter) GetHostsByCluster

func (vc *VirtualCenter) GetHostsByCluster(ctx context.Context,
	clusterMorefValue string) ([]*HostSystem, error)

GetHostsByCluster return hosts inside the cluster using cluster moref.

func (*VirtualCenter) GetStoragePolicyIDByName

func (vc *VirtualCenter) GetStoragePolicyIDByName(ctx context.Context, storagePolicyName string) (string, error)

GetStoragePolicyIDByName gets storage policy ID by name.

func (*VirtualCenter) GetVsanDatastores

func (vc *VirtualCenter) GetVsanDatastores(ctx context.Context,
	datacenters []*Datacenter) (map[string]*DatastoreInfo, error)

GetVsanDatastores returns all the datastore URL to DatastoreInfo map for all the vSAN datastores in the VC.

func (*VirtualCenter) ListDatacenters

func (vc *VirtualCenter) ListDatacenters(ctx context.Context) (
	[]*Datacenter, error)

ListDatacenters returns all Datacenters.

func (*VirtualCenter) NewClient

func (vc *VirtualCenter) NewClient(ctx context.Context) (*govmomi.Client, error)

NewClient creates a new govmomi Client instance.

func (*VirtualCenter) PbmCheckCompatibility

func (vc *VirtualCenter) PbmCheckCompatibility(ctx context.Context,
	datastores []vimtypes.ManagedObjectReference, profileID string) (pbm.PlacementCompatibilityResult, error)

PbmCheckCompatibility performs a compatibility check for the given profileID with the given datastores.

func (*VirtualCenter) PbmRetrieveContent

func (vc *VirtualCenter) PbmRetrieveContent(ctx context.Context, policyIds []string) ([]SpbmPolicyContent, error)

PbmRetrieveContent fetches the policy content of all given policies from SPBM.

func (*VirtualCenter) String

func (vc *VirtualCenter) String() string

type VirtualCenterConfig

type VirtualCenterConfig struct {
	// Scheme represents the connection scheme. (Ex: https)
	Scheme string
	// Host represents the virtual center host address.
	Host string
	// Port represents the virtual center host port.
	Port int
	// Username represents the virtual center username.
	Username string
	// Password represents the virtual center password in clear text.
	Password string
	// Specifies whether to verify the server's certificate chain. Set to true to
	// skip verification.
	Insecure bool
	// Specifies the path to a CA certificate in PEM format. This has no effect
	// if Insecure is enabled. Optional; if not configured, the system's CA
	// certificates will be used.
	CAFile string
	// Thumbprint specifies the certificate thumbprint to use. This has no effect
	// if InsecureFlag is enabled.
	Thumbprint string
	// RoundTripperCount is the SOAP round tripper count.
	// retries = RoundTripperCount - 1
	RoundTripperCount int
	// DatacenterPaths represents paths of datacenters on the virtual center.
	DatacenterPaths []string
	// TargetvSANFileShareDatastoreURLs represents URLs of file service enabled
	// vSAN datastores in the virtual center.
	TargetvSANFileShareDatastoreURLs []string
	// TargetvSANFileShareClusters represents file service enabled vSAN clusters
	// on which file volumes can be created.
	TargetvSANFileShareClusters []string
	// VCClientTimeout is the limit in minutes for requests made by vCenter client.
	VCClientTimeout int
	// QueryLimit specifies the number of volumes that can be fetched by CNS
	// QueryAll API at a time
	QueryLimit int
	// ListVolumeThreshold specifies the maximum number of differences in volume that
	// can exist between CNS and kubernetes
	ListVolumeThreshold int
	// MigrationDataStore specifies datastore which is set as default datastore in legacy cloud-config
	// and hence should be used as default datastore.
	MigrationDataStoreURL string
	// when ReloadVCConfigForNewClient is set to true it forces re-read config secret when
	// new vc client needs to be created
	ReloadVCConfigForNewClient bool
}

VirtualCenterConfig represents virtual center configuration.

func GetVirtualCenterConfig

func GetVirtualCenterConfig(ctx context.Context, cfg *config.Config) (*VirtualCenterConfig, error)

GetVirtualCenterConfig returns VirtualCenterConfig Object created using vSphere Configuration specified in the argument.

func GetVirtualCenterConfigs

func GetVirtualCenterConfigs(ctx context.Context, cfg *config.Config) ([]*VirtualCenterConfig, error)

GetVirtualCenterConfigs returns VirtualCenterConfig Objects created using vSphere Configuration specified in the argument.

type VirtualCenterManager

type VirtualCenterManager interface {
	// GetVirtualCenter returns the VirtualCenter instance given the host.
	GetVirtualCenter(ctx context.Context, host string) (*VirtualCenter, error)
	// GetAllVirtualCenters returns all VirtualCenter instances. If virtual
	// centers are added or removed concurrently, they may or may not be
	// reflected in the result of a call to this method.
	GetAllVirtualCenters() []*VirtualCenter
	// RegisterVirtualCenter registers a virtual center, but doesn't initiate
	// the connection to the host.
	RegisterVirtualCenter(ctx context.Context, config *VirtualCenterConfig) (*VirtualCenter, error)
	// UnregisterVirtualCenter disconnects and unregisters the virtual center
	// given it's host.
	UnregisterVirtualCenter(ctx context.Context, host string) error
	// UnregisterAllVirtualCenters disconnects and unregisters all virtual centers.
	UnregisterAllVirtualCenters(ctx context.Context) error
	// IsvSANFileServicesSupported checks if vSAN file services is supported or not.
	IsvSANFileServicesSupported(ctx context.Context, host string) (bool, error)
	// IsOnlineExtendVolumeSupported checks if online extend volume is supported
	// or not on the vCenter Host.
	IsOnlineExtendVolumeSupported(ctx context.Context, host string) (bool, error)
	// IsCnsSnapshotSupported checks if cns volume snapshot is supported
	// or not on the vCenter Host.
	IsCnsSnapshotSupported(ctx context.Context, host string) (bool, error)
}

VirtualCenterManager provides functionality to manage virtual centers.

func GetVirtualCenterManager

func GetVirtualCenterManager(ctx context.Context) VirtualCenterManager

GetVirtualCenterManager returns the VirtualCenterManager singleton.

type VirtualMachine

type VirtualMachine struct {
	// VirtualCenterHost represents the virtual machine's vCenter host.
	VirtualCenterHost string
	// UUID represents the virtual machine's UUID.
	UUID string
	// VirtualMachine represents the virtual machine.
	*object.VirtualMachine
	// Datacenter represents the datacenter to which the virtual machine belongs.
	Datacenter *Datacenter
}

VirtualMachine holds details of a virtual machine instance.

func GetVirtualMachineByUUID

func GetVirtualMachineByUUID(ctx context.Context, uuid string, instanceUUID bool) (*VirtualMachine, error)

GetVirtualMachineByUUID returns virtual machine given its UUID in entire VC. If instanceUuid is set to true, then UUID is an instance UUID. In this case, this function searches for virtual machines whose instance UUID matches the given uuid. If instanceUuid is set to false, then UUID is BIOS UUID. In this case, this function searches for virtual machines whose BIOS UUID matches the given uuid.

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) GetAncestors

func (vm *VirtualMachine) GetAncestors(ctx context.Context) ([]mo.ManagedEntity, error)

GetAncestors returns ancestors of VM. Example result: "Folder", "Datacenter", "Cluster".

func (*VirtualMachine) GetHostSystem

func (vm *VirtualMachine) GetHostSystem(ctx context.Context) (*object.HostSystem, error)

GetHostSystem returns HostSystem object of the virtual machine.

func (*VirtualMachine) GetTagManager

func (vm *VirtualMachine) GetTagManager(ctx context.Context) (*tags.Manager, error)

GetTagManager returns tagManager using vm client.

func (*VirtualMachine) GetTopologyLabels

func (vm *VirtualMachine) GetTopologyLabels(ctx context.Context, tagManager *tags.Manager,
	topologyCategories map[string]string) error

GetTopologyLabels populates the topology labels of the nodeVM in topologyCategories parameter given the category names.

func (*VirtualMachine) GetZoneRegion

func (vm *VirtualMachine) GetZoneRegion(ctx context.Context, zoneCategoryName string,
	regionCategoryName string, tagManager *tags.Manager) (zone string, region string, err error)

GetZoneRegion returns zone and region of the node vm.

func (*VirtualMachine) IsActive

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

IsActive returns true if Virtual Machine is powered on, else returns false.

func (*VirtualMachine) IsInZoneRegion

func (vm *VirtualMachine) IsInZoneRegion(ctx context.Context, zoneCategoryName string, regionCategoryName string,
	zoneValue string, regionValue string, tagManager *tags.Manager) (bool, error)

IsInZoneRegion checks if VM belongs to specified zone and region. This function returns true if yes, false otherwise.

func (*VirtualMachine) Renew

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

Renew renews the virtual machine and datacenter information. If reconnect is set to true, the virtual center connection is also renewed.

func (*VirtualMachine) String

func (vm *VirtualMachine) String() string

type VsanHostCapacity

type VsanHostCapacity struct {
	Capacity         int64
	CapacityReserved int64
	CapacityUsed     int64
	HostMoID         string
}

VsanHostCapacity captures the capacity info of a host. It exists to support the API within this Go helper module.

type VsanPhysicalDisk

type VsanPhysicalDisk struct {
	IsSSD            int        `json:"isSsd,omitempty"`
	SsdUUID          string     `json:"ssdUuid,omitempty"`
	Capacity         int64      `json:"capacity,omitempty"`
	CapacityReserved int64      `json:"capacityReserved,omitempty"`
	CapacityUsed     int64      `json:"capacityUsed,omitempty"`
	IsAllFlash       int        `json:"isAllFlash,omitempty"`
	Disk_Health      DiskHealth `json:"disk_health,omitempty"`
}

VsanPhysicalDisk reflects the fields of JSON structure emitted by the VsanInternalSystem.QueryPhysicalVsanDisks API that we care about.

type VsanPhysicalDiskMap

type VsanPhysicalDiskMap map[string]VsanPhysicalDisk

VsanPhysicalDiskMap is what VsanInternalSystem.QueryPhysicalVsanDisks returns

Jump to

Keyboard shortcuts

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