Documentation ¶
Overview ¶
Package vsphere is used to interact with vSphere
Index ¶
- Constants
- func ClearCache(sessionKey string)
- func ToVMMetrics(name string, metrics []performance.EntityMetric) vcenter.Metrics
- func ToVSphereVM(param mo.VirtualMachine, metrics []performance.EntityMetric, ...) vcenter.VM
- func ToVSphereVMs(params []mo.VirtualMachine, metrics []performance.EntityMetric, ...) []vcenter.VM
- func ToVsphereMetrics(metric performance.EntityMetric) vcenter.Metrics
- type Driver
- type MockVsphereDriver
- func (d MockVsphereDriver) GetClusters(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetClustersByTag(_ context.Context, _, _ string) ([]string, error)
- func (d MockVsphereDriver) GetDatacenters(_ context.Context) ([]string, error)
- func (d MockVsphereDriver) GetDatacentersByTag(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetDatastores(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetDistributedVirtualPortgroups(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetDistributedVirtualSwitches(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetHostClusterMapping(_ context.Context) (map[string]string, error)
- func (d MockVsphereDriver) GetHostSystems(_ context.Context, datacenter, cluster string) ([]vcenter.HostSystem, error)
- func (d MockVsphereDriver) GetNetworks(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetResourcePools(_ context.Context, _ string, _ string) ([]*object.ResourcePool, error)
- func (d MockVsphereDriver) GetResourceTags(_ context.Context, _ string) (map[string]tags.AttachedTags, error)
- func (d MockVsphereDriver) GetVApps(_ context.Context) ([]mo.VirtualApp, error)
- func (d MockVsphereDriver) GetVMFolders(_ context.Context, _ string) ([]string, error)
- func (d MockVsphereDriver) GetVMs(_ context.Context, _ string) ([]vcenter.VM, error)
- func (d MockVsphereDriver) ValidateCredentials() (bool, error)
- func (d MockVsphereDriver) ValidateVersion(_ string) error
- type Session
- type VCenterDriver
- func (v *VCenterDriver) CurrentDomains(ctx context.Context) ([]string, error)
- func (v *VCenterDriver) CurrentUser(ctx context.Context) (string, error)
- func (v *VCenterDriver) FolderExists(ctx context.Context, finder *find.Finder, name string) bool
- func (v *VCenterDriver) GetCluster(ctx context.Context, finder *find.Finder, datacenter, clusterName string) (*object.ClusterComputeResource, error)
- func (v *VCenterDriver) GetClusters(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetClustersByTag(ctx context.Context, datacenter, tagCategory string) ([]string, error)
- func (v *VCenterDriver) GetDatacenter(ctx context.Context, finder *find.Finder, datacenter string) (*object.Datacenter, error)
- func (v *VCenterDriver) GetDatacenters(ctx context.Context) ([]string, error)
- func (v *VCenterDriver) GetDatacentersByTag(ctx context.Context, tagCategory string) ([]string, error)
- func (v *VCenterDriver) GetDatastore(ctx context.Context, finder *find.Finder, datastore string) (*object.Datastore, error)
- func (v *VCenterDriver) GetDatastores(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetDistributedVirtualPortgroup(ctx context.Context, finder *find.Finder, path string) (*object.DistributedVirtualPortgroup, error)
- func (v *VCenterDriver) GetDistributedVirtualPortgroups(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetDistributedVirtualSwitch(ctx context.Context, finder *find.Finder, path string) (*object.DistributedVirtualSwitch, error)
- func (v *VCenterDriver) GetDistributedVirtualSwitchNameFromPortGroup(ctx context.Context, dvp *object.DistributedVirtualPortgroup) (string, error)
- func (v *VCenterDriver) GetDistributedVirtualSwitches(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetFinderWithDatacenter(ctx context.Context, datacenter string) (*find.Finder, string, error)
- func (v *VCenterDriver) GetFolder(ctx context.Context, datacenter, name string) (*object.Folder, error)
- func (v *VCenterDriver) GetHost(ctx context.Context, finder *find.Finder, ...) (*object.HostSystem, error)
- func (v *VCenterDriver) GetHostClusterMapping(ctx context.Context) (map[string]string, error)
- func (v *VCenterDriver) GetHostSystems(ctx context.Context, datacenter, cluster string) ([]vcenter.HostSystem, error)
- func (v *VCenterDriver) GetMetrics(ctx context.Context, c *vim25.Client) ([]performance.EntityMetric, error)
- func (v *VCenterDriver) GetNetwork(ctx context.Context, finder *find.Finder, path string) (*object.Network, error)
- func (v *VCenterDriver) GetNetworkTypeByName(ctx context.Context, datacenter, name string) (string, error)
- func (v *VCenterDriver) GetNetworks(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetOpaqueNetwork(ctx context.Context, finder *find.Finder, path string) (*object.OpaqueNetwork, error)
- func (v *VCenterDriver) GetOpaqueNetworks(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetResourcePool(ctx context.Context, finder *find.Finder, ...) (*object.ResourcePool, error)
- func (v *VCenterDriver) GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error)
- func (v *VCenterDriver) GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error)
- func (v *VCenterDriver) GetVApp(ctx context.Context, finder *find.Finder, vAppName string) (*object.VirtualApp, error)
- func (v *VCenterDriver) GetVApps(ctx context.Context) ([]mo.VirtualApp, error)
- func (v *VCenterDriver) GetVM(ctx context.Context, finder *find.Finder, vmName string) (*object.VirtualMachine, error)
- func (v *VCenterDriver) GetVMFolders(ctx context.Context, datacenter string) ([]string, error)
- func (v *VCenterDriver) GetVMs(ctx context.Context, datacenter string) ([]vcenter.VM, error)
- func (v *VCenterDriver) GetVSphereResourcePools(ctx context.Context, datacenter string, cluster string) (resourcePools []string, err error)
- func (v *VCenterDriver) ValidateCredentials() (bool, error)
- func (v *VCenterDriver) ValidateHostNTPSettings(ctx context.Context, finder *find.Finder, datacenter, clusterName string, ...) (bool, []string, error)
- func (v *VCenterDriver) ValidateUserPrivilegeOnEntities(ctx context.Context, authManager *object.AuthorizationManager, ...) ([]string, error)
- func (v *VCenterDriver) ValidateVersion(constraint string) error
Constants ¶
const ( // KeepAliveIntervalInMinute is the interval in minutes for keep alive in the govmomi vim25 client KeepAliveIntervalInMinute = 10 // K8sDatacenterTagCategory is the tag category for kubernetes-enabled datacenters K8sDatacenterTagCategory = "k8s-region" // K8sComputeClusterTagCategory is the tag category for kubernetes-enabled compute clusters K8sComputeClusterTagCategory = "k8s-zone" )
Variables ¶
This section is empty.
Functions ¶
func ClearCache ¶
func ClearCache(sessionKey string)
ClearCache deletes the session from the session cache
func ToVMMetrics ¶ added in v0.0.27
func ToVMMetrics(name string, metrics []performance.EntityMetric) vcenter.Metrics
ToVMMetrics finds the EntityMetric with the provided name and converts it to Metrics
func ToVSphereVM ¶ added in v0.0.23
func ToVSphereVM(param mo.VirtualMachine, metrics []performance.EntityMetric, networks []object.NetworkReference, dsNames []*object.Datastore, folders []*object.Folder, hostSystems []mo.HostSystem, ccrs []*object.ClusterComputeResource, parentsRef []mo.VirtualMachine) vcenter.VM
ToVSphereVM converts a VirtualMachine to a VSphereVM
func ToVSphereVMs ¶ added in v0.0.23
func ToVSphereVMs(params []mo.VirtualMachine, metrics []performance.EntityMetric, networks []object.NetworkReference, dsNames []*object.Datastore, folders []*object.Folder, hostSystems []mo.HostSystem, ccrs []*object.ClusterComputeResource, parentsRef []mo.VirtualMachine) []vcenter.VM
ToVSphereVMs converts a list of VirtualMachines to a list of VSphereVMs
func ToVsphereMetrics ¶ added in v0.0.23
func ToVsphereMetrics(metric performance.EntityMetric) vcenter.Metrics
ToVsphereMetrics converts the EntityMetric to Metrics
Types ¶
type Driver ¶ added in v0.0.27
type Driver interface { GetClusters(ctx context.Context, datacenter string) ([]string, error) GetClustersByTag(ctx context.Context, datacenter, tagCategory string) ([]string, error) GetDatacenters(ctx context.Context) ([]string, error) GetDatacentersByTag(ctx context.Context, tagCategory string) ([]string, error) GetDatastores(ctx context.Context, datacenter string) ([]string, error) GetDistributedVirtualPortgroups(ctx context.Context, datacenter string) ([]string, error) GetDistributedVirtualSwitches(ctx context.Context, datacenter string) ([]string, error) GetHostClusterMapping(ctx context.Context) (map[string]string, error) GetHostSystems(ctx context.Context, datacenter, cluster string) ([]vcenter.HostSystem, error) GetNetworks(ctx context.Context, datacenter string) ([]string, error) GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error) GetVApps(ctx context.Context) ([]mo.VirtualApp, error) GetVMFolders(ctx context.Context, datacenter string) ([]string, error) GetVMs(ctx context.Context, dcName string) ([]vcenter.VM, error) GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error) ValidateCredentials() (bool, error) ValidateVersion(constraint string) error }
Driver is an interface that defines the functions to interact with vSphere
type MockVsphereDriver ¶ added in v0.0.23
type MockVsphereDriver struct { Clusters []string Datacenters []string Datastores []string DistributedVirtualPortgroups []string DistributedVirtualSwitches []string HostClusterMapping map[string]string HostSystems map[string][]vcenter.HostSystem Networks []string ResourcePools []*object.ResourcePool ResourceTags map[string]tags.AttachedTags VApps []mo.VirtualApp VMFolders []string VMs []vcenter.VM }
MockVsphereDriver is a mock implementation of the Driver interface
func (MockVsphereDriver) GetClusters ¶ added in v0.1.0
GetClusters returns a mocked response
func (MockVsphereDriver) GetClustersByTag ¶ added in v0.1.0
GetClustersByTag returns a mocked response
func (MockVsphereDriver) GetDatacenters ¶ added in v0.1.0
func (d MockVsphereDriver) GetDatacenters(_ context.Context) ([]string, error)
GetDatacenters returns a mocked response
func (MockVsphereDriver) GetDatacentersByTag ¶ added in v0.1.0
GetDatacentersByTag returns a mocked response
func (MockVsphereDriver) GetDatastores ¶ added in v0.1.0
GetDatastores returns a mocked response
func (MockVsphereDriver) GetDistributedVirtualPortgroups ¶ added in v0.1.0
func (d MockVsphereDriver) GetDistributedVirtualPortgroups(_ context.Context, _ string) ([]string, error)
GetDistributedVirtualPortgroups returns a mocked response
func (MockVsphereDriver) GetDistributedVirtualSwitches ¶ added in v0.1.0
func (d MockVsphereDriver) GetDistributedVirtualSwitches(_ context.Context, _ string) ([]string, error)
GetDistributedVirtualSwitches returns a mocked response
func (MockVsphereDriver) GetHostClusterMapping ¶ added in v0.0.23
GetHostClusterMapping returns a mocked response
func (MockVsphereDriver) GetHostSystems ¶ added in v0.1.0
func (d MockVsphereDriver) GetHostSystems(_ context.Context, datacenter, cluster string) ([]vcenter.HostSystem, error)
GetHostSystems returns a mocked response
func (MockVsphereDriver) GetNetworks ¶ added in v0.1.0
GetNetworks returns a mocked response
func (MockVsphereDriver) GetResourcePools ¶ added in v0.0.23
func (d MockVsphereDriver) GetResourcePools(_ context.Context, _ string, _ string) ([]*object.ResourcePool, error)
GetResourcePools returns a mocked response
func (MockVsphereDriver) GetResourceTags ¶ added in v0.0.23
func (d MockVsphereDriver) GetResourceTags(_ context.Context, _ string) (map[string]tags.AttachedTags, error)
GetResourceTags returns a mocked response
func (MockVsphereDriver) GetVApps ¶ added in v0.1.0
func (d MockVsphereDriver) GetVApps(_ context.Context) ([]mo.VirtualApp, error)
GetVApps returns a mocked response
func (MockVsphereDriver) GetVMFolders ¶ added in v0.1.0
GetVMFolders returns a mocked response
func (MockVsphereDriver) ValidateCredentials ¶ added in v0.1.0
func (d MockVsphereDriver) ValidateCredentials() (bool, error)
ValidateCredentials returns a mocked response
func (MockVsphereDriver) ValidateVersion ¶ added in v0.1.0
func (d MockVsphereDriver) ValidateVersion(_ string) error
ValidateVersion returns a mocked response
type VCenterDriver ¶ added in v0.1.0
type VCenterDriver struct { Account vcenter.Account Datacenter string Client *govmomi.Client RestClient *rest.Client // contains filtered or unexported fields }
VCenterDriver is a struct that implements the Driver interface
func NewVCenterDriver ¶ added in v0.1.0
func NewVCenterDriver(account vcenter.Account, datacenter string, log logr.Logger) (*VCenterDriver, error)
NewVCenterDriver creates a new VCenterDriver
func (*VCenterDriver) CurrentDomains ¶ added in v0.1.0
func (v *VCenterDriver) CurrentDomains(ctx context.Context) ([]string, error)
CurrentDomains returns the current domains for the user the vCenter driver is currently authenticated as.
func (*VCenterDriver) CurrentUser ¶ added in v0.1.0
func (v *VCenterDriver) CurrentUser(ctx context.Context) (string, error)
CurrentUser returns the username of the user the vCenter driver is currently authenticated as.
func (*VCenterDriver) FolderExists ¶ added in v0.1.0
FolderExists checks if a folder exists in the vCenter inventory
func (*VCenterDriver) GetCluster ¶ added in v0.1.0
func (v *VCenterDriver) GetCluster(ctx context.Context, finder *find.Finder, datacenter, clusterName string) (*object.ClusterComputeResource, error)
GetCluster returns the cluster if it exists
func (*VCenterDriver) GetClusters ¶ added in v0.1.0
GetClusters returns a sorted list of all vCenter clusters within a datacenter.
func (*VCenterDriver) GetClustersByTag ¶ added in v0.1.0
func (v *VCenterDriver) GetClustersByTag(ctx context.Context, datacenter, tagCategory string) ([]string, error)
GetClustersByTag returns a sorted list of vCenter clusters within a datacenter, filtered by a tag category.
func (*VCenterDriver) GetDatacenter ¶ added in v0.1.0
func (v *VCenterDriver) GetDatacenter(ctx context.Context, finder *find.Finder, datacenter string) (*object.Datacenter, error)
GetDatacenter returns a datacenter object if it exists
func (*VCenterDriver) GetDatacenters ¶ added in v0.1.0
func (v *VCenterDriver) GetDatacenters(ctx context.Context) ([]string, error)
GetDatacenters returns a sorted list of datacenters in the vCenter environment.
func (*VCenterDriver) GetDatacentersByTag ¶ added in v0.1.0
func (v *VCenterDriver) GetDatacentersByTag(ctx context.Context, tagCategory string) ([]string, error)
GetDatacentersByTag returns a sorted list of datacenters in the vCenter environment having a specific tag.
func (*VCenterDriver) GetDatastore ¶ added in v0.1.0
func (v *VCenterDriver) GetDatastore(ctx context.Context, finder *find.Finder, datastore string) (*object.Datastore, error)
GetDatastore returns a datastore object if it exists
func (*VCenterDriver) GetDatastores ¶ added in v0.1.0
GetDatastores returns a sorted list of all vCenter datastores within a datacenter.
func (*VCenterDriver) GetDistributedVirtualPortgroup ¶ added in v0.1.0
func (v *VCenterDriver) GetDistributedVirtualPortgroup(ctx context.Context, finder *find.Finder, path string) (*object.DistributedVirtualPortgroup, error)
GetDistributedVirtualPortgroup returns a distributed virtual port group object if it exists
func (*VCenterDriver) GetDistributedVirtualPortgroups ¶ added in v0.1.0
func (v *VCenterDriver) GetDistributedVirtualPortgroups(ctx context.Context, datacenter string) ([]string, error)
GetDistributedVirtualPortgroups returns a sorted list of all vCenter distributed port groups.
func (*VCenterDriver) GetDistributedVirtualSwitch ¶ added in v0.1.0
func (v *VCenterDriver) GetDistributedVirtualSwitch(ctx context.Context, finder *find.Finder, path string) (*object.DistributedVirtualSwitch, error)
GetDistributedVirtualSwitch returns a distributed virtual switch object if it exists
func (*VCenterDriver) GetDistributedVirtualSwitchNameFromPortGroup ¶ added in v0.1.3
func (v *VCenterDriver) GetDistributedVirtualSwitchNameFromPortGroup(ctx context.Context, dvp *object.DistributedVirtualPortgroup) (string, error)
GetDistributedVirtualSwitchNameFromPortGroup returns the name of a distributed port group's distributed switch
func (*VCenterDriver) GetDistributedVirtualSwitches ¶ added in v0.1.0
func (v *VCenterDriver) GetDistributedVirtualSwitches(ctx context.Context, datacenter string) ([]string, error)
GetDistributedVirtualSwitches returns a sorted list of all vCenter distributed switches.
func (*VCenterDriver) GetFinderWithDatacenter ¶ added in v0.1.0
func (v *VCenterDriver) GetFinderWithDatacenter(ctx context.Context, datacenter string) (*find.Finder, string, error)
GetFinderWithDatacenter returns a finder and the datacenter name
func (*VCenterDriver) GetFolder ¶ added in v0.1.0
func (v *VCenterDriver) GetFolder(ctx context.Context, datacenter, name string) (*object.Folder, error)
GetFolder returns the vCenter VM folder if it exists
func (*VCenterDriver) GetHost ¶ added in v0.1.0
func (v *VCenterDriver) GetHost(ctx context.Context, finder *find.Finder, datacenter, clusterName, hostName string) (*object.HostSystem, error)
GetHost returns the host system if it exists
func (*VCenterDriver) GetHostClusterMapping ¶ added in v0.1.0
GetHostClusterMapping returns the host cluster mapping
func (*VCenterDriver) GetHostSystems ¶ added in v0.1.0
func (v *VCenterDriver) GetHostSystems(ctx context.Context, datacenter, cluster string) ([]vcenter.HostSystem, error)
GetHostSystems returns vCenter host systems
func (*VCenterDriver) GetMetrics ¶ added in v0.1.0
func (v *VCenterDriver) GetMetrics(ctx context.Context, c *vim25.Client) ([]performance.EntityMetric, error)
GetMetrics returns the metrics for the given VMs
func (*VCenterDriver) GetNetwork ¶ added in v0.1.0
func (v *VCenterDriver) GetNetwork(ctx context.Context, finder *find.Finder, path string) (*object.Network, error)
GetNetwork returns a network object if it exists
func (*VCenterDriver) GetNetworkTypeByName ¶ added in v0.1.0
func (v *VCenterDriver) GetNetworkTypeByName(ctx context.Context, datacenter, name string) (string, error)
GetNetworkTypeByName determines the type of a network given its datacenter and name.
func (*VCenterDriver) GetNetworks ¶ added in v0.1.0
GetNetworks returns a sorted list of all vCenter networks.
func (*VCenterDriver) GetOpaqueNetwork ¶ added in v0.1.0
func (v *VCenterDriver) GetOpaqueNetwork(ctx context.Context, finder *find.Finder, path string) (*object.OpaqueNetwork, error)
GetOpaqueNetwork returns an opaque network object if it exists
func (*VCenterDriver) GetOpaqueNetworks ¶ added in v0.1.0
GetOpaqueNetworks returns a sorted list of all vCenter opaque networks.
func (*VCenterDriver) GetResourcePool ¶ added in v0.1.0
func (v *VCenterDriver) GetResourcePool(ctx context.Context, finder *find.Finder, datacenter, cluster, resourcePoolName string) (*object.ResourcePool, error)
GetResourcePool returns the resource pool if it exists
func (*VCenterDriver) GetResourcePools ¶ added in v0.1.0
func (v *VCenterDriver) GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error)
GetResourcePools returns a list of resource pools
func (*VCenterDriver) GetResourceTags ¶ added in v0.1.0
func (v *VCenterDriver) GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error)
GetResourceTags returns a map of resource tags
func (*VCenterDriver) GetVApp ¶ added in v0.1.0
func (v *VCenterDriver) GetVApp(ctx context.Context, finder *find.Finder, vAppName string) (*object.VirtualApp, error)
GetVApp returns the virtual app if it exists
func (*VCenterDriver) GetVApps ¶ added in v0.1.0
func (v *VCenterDriver) GetVApps(ctx context.Context) ([]mo.VirtualApp, error)
GetVApps returns a list of virtual apps
func (*VCenterDriver) GetVM ¶ added in v0.1.0
func (v *VCenterDriver) GetVM(ctx context.Context, finder *find.Finder, vmName string) (*object.VirtualMachine, error)
GetVM returns the vCenter VM if it exists
func (*VCenterDriver) GetVMFolders ¶ added in v0.1.0
GetVMFolders returns a list of vCenter VM folders
func (*VCenterDriver) GetVSphereResourcePools ¶ added in v0.1.0
func (v *VCenterDriver) GetVSphereResourcePools(ctx context.Context, datacenter string, cluster string) (resourcePools []string, err error)
GetVSphereResourcePools returns a sorted list of resource pool paths
func (*VCenterDriver) ValidateCredentials ¶ added in v0.1.0
func (v *VCenterDriver) ValidateCredentials() (bool, error)
ValidateCredentials ensures that vCenter account credentials are valid
func (*VCenterDriver) ValidateHostNTPSettings ¶ added in v0.1.0
func (v *VCenterDriver) ValidateHostNTPSettings(ctx context.Context, finder *find.Finder, datacenter, clusterName string, hosts []string) (bool, []string, error)
ValidateHostNTPSettings validates the NTP settings for the hosts
func (*VCenterDriver) ValidateUserPrivilegeOnEntities ¶ added in v0.1.0
func (v *VCenterDriver) ValidateUserPrivilegeOnEntities(ctx context.Context, authManager *object.AuthorizationManager, datacenter, username string, finder *find.Finder, rule v1alpha1.PrivilegeValidationRule) ([]string, error)
ValidateUserPrivilegeOnEntities validates the user's privileges and permissions on a specific entity.
func (*VCenterDriver) ValidateVersion ¶ added in v0.1.0
func (v *VCenterDriver) ValidateVersion(constraint string) error
ValidateVersion ensures that the vSphere version satisfies the given constraint