vsphere

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 33 Imported by: 3

Documentation

Index

Constants

View Source
const (
	KeepAliveIntervalInMinute = 10
	DatacenterTagCategory     = "k8s-region"
	ComputeClusterTagCategory = "k8s-zone"
)

Variables

View Source
var IsAdminAccount = isAdminAccount

Functions

func ClearCache

func ClearCache(sessionKey string)

func ConfigureSSOClient added in v0.0.25

func ConfigureSSOClient(ctx context.Context, driver *VSphereCloudDriver) (*ssoadmin.Client, error)

func GetVmwareUserPrivileges

func GetVmwareUserPrivileges(ctx context.Context, userPrincipal string, groupPrincipals []string, authManager *object.AuthorizationManager) (map[string]bool, error)

Types

type AdditionalDisk added in v0.0.23

type AdditionalDisk struct {
	Name      string
	Device    string
	Capacity  string
	Used      string
	Available string
	Usage     string
}

type Datastore added in v0.0.23

type Datastore struct {
	Name string
	Id   string
}

type HostDateInfo

type HostDateInfo struct {
	HostName   string
	NtpServers []string
	types.HostDateTimeInfo
	Service       *types.HostService
	Current       *time.Time
	ClientStatus  string
	ServiceStatus string
}

type LibvirtVmInfo added in v0.0.23

type LibvirtVmInfo struct {
	ImagePool string
	DataPool  string
}

type Metrics added in v0.0.23

type Metrics struct {
	CpuCores        string
	CpuUsage        string
	MemoryBytes     string
	MemoryUsage     string
	DiskUsage       string
	DiskProvisioned string
}

func ToVmMetrics added in v0.0.23

func ToVmMetrics(name string, metrics []performance.EntityMetric) Metrics

func ToVsphereMetrics added in v0.0.23

func ToVsphereMetrics(metric performance.EntityMetric) Metrics

type MockVsphereDriver added in v0.0.23

type MockVsphereDriver struct {
	Datacenters        []string
	Clusters           []string
	VMs                []VSphereVM
	VMFolders          []string
	HostSystems        map[string][]VSphereHostSystem
	VApps              []mo.VirtualApp
	ResourcePools      []*object.ResourcePool
	HostClusterMapping map[string]string
	ResourceTags       map[string]tags.AttachedTags
}

func (MockVsphereDriver) GetHostClusterMapping added in v0.0.23

func (d MockVsphereDriver) GetHostClusterMapping(ctx context.Context) (map[string]string, error)

func (MockVsphereDriver) GetResourcePools added in v0.0.23

func (d MockVsphereDriver) GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error)

func (MockVsphereDriver) GetResourceTags added in v0.0.23

func (d MockVsphereDriver) GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error)

func (MockVsphereDriver) GetVSphereClusters added in v0.0.23

func (d MockVsphereDriver) GetVSphereClusters(ctx context.Context, datacenter string) ([]string, error)

func (MockVsphereDriver) GetVSphereDatacenters added in v0.0.23

func (d MockVsphereDriver) GetVSphereDatacenters(ctx context.Context) ([]string, error)

func (MockVsphereDriver) GetVSphereHostSystems added in v0.0.23

func (d MockVsphereDriver) GetVSphereHostSystems(ctx context.Context, datacenter, cluster string) ([]VSphereHostSystem, error)

func (MockVsphereDriver) GetVSphereVMFolders added in v0.0.23

func (d MockVsphereDriver) GetVSphereVMFolders(ctx context.Context, datacenter string) ([]string, error)

func (MockVsphereDriver) GetVSphereVms added in v0.0.23

func (d MockVsphereDriver) GetVSphereVms(ctx context.Context, dcName string) ([]VSphereVM, error)

func (MockVsphereDriver) GetVapps added in v0.0.23

func (d MockVsphereDriver) GetVapps(ctx context.Context) ([]mo.VirtualApp, error)

func (MockVsphereDriver) IsAdminAccount added in v0.0.26

func (d MockVsphereDriver) IsAdminAccount(ctx context.Context) (bool, error)

func (MockVsphereDriver) IsValidVSphereCredentials added in v0.0.23

func (d MockVsphereDriver) IsValidVSphereCredentials(ctx context.Context) (bool, error)

func (MockVsphereDriver) ValidateVsphereVersion added in v0.0.23

func (d MockVsphereDriver) ValidateVsphereVersion(constraint string) error

type Session

type Session struct {
	GovmomiClient *govmomi.Client
	RestClient    *rest.Client
}

func GetOrCreateSession

func GetOrCreateSession(
	ctx context.Context,
	server, username, password string, refreshRestClient bool) (Session, error)

type SshInfo added in v0.0.23

type SshInfo struct {
	Username   string
	Password   string
	PublicKey  []string
	PrivateKey []string
}

type VSphereCloudDriver

type VSphereCloudDriver struct {
	VCenterServer   string
	VCenterUsername string
	VCenterPassword string
	Datacenter      string
	Client          *govmomi.Client
	RestClient      *rest.Client
}

func NewVSphereDriver

func NewVSphereDriver(VCenterServer, VCenterUsername, VCenterPassword, datacenter string) (*VSphereCloudDriver, error)

func (*VSphereCloudDriver) CreateVSphereVMFolder

func (v *VSphereCloudDriver) CreateVSphereVMFolder(ctx context.Context, datacenter string, folders []string) error

func (*VSphereCloudDriver) FolderExists

func (v *VSphereCloudDriver) FolderExists(ctx context.Context, finder *find.Finder, datacenter, folderName string) (bool, error)

func (*VSphereCloudDriver) GetClusterIfExists

func (v *VSphereCloudDriver) GetClusterIfExists(ctx context.Context, finder *find.Finder, datacenter, clusterName string) (bool, *object.ClusterComputeResource, error)

func (*VSphereCloudDriver) GetCurrentVmwareUser

func (v *VSphereCloudDriver) GetCurrentVmwareUser(ctx context.Context) (string, error)

func (*VSphereCloudDriver) GetDatacenterIfExists

func (v *VSphereCloudDriver) GetDatacenterIfExists(ctx context.Context, finder *find.Finder, datacenter string) (bool, *object.Datacenter, error)

func (*VSphereCloudDriver) GetFinderWithDatacenter

func (v *VSphereCloudDriver) GetFinderWithDatacenter(ctx context.Context, datacenter string) (*find.Finder, string, error)

func (*VSphereCloudDriver) GetFolderIfExists

func (v *VSphereCloudDriver) GetFolderIfExists(ctx context.Context, finder *find.Finder, datacenter, folderName string) (bool, *object.Folder, error)

func (*VSphereCloudDriver) GetFolderNameByID

func (v *VSphereCloudDriver) GetFolderNameByID(ctx context.Context, datacenter, id string) (string, error)

func (*VSphereCloudDriver) GetHostClusterMapping added in v0.0.23

func (v *VSphereCloudDriver) GetHostClusterMapping(ctx context.Context) (map[string]string, error)

func (*VSphereCloudDriver) GetHostIfExists

func (v *VSphereCloudDriver) GetHostIfExists(ctx context.Context, finder *find.Finder, datacenter, clusterName, hostName string) (bool, *object.HostSystem, error)

func (*VSphereCloudDriver) GetMetrics added in v0.0.23

func (*VSphereCloudDriver) GetResourcePoolIfExists

func (v *VSphereCloudDriver) GetResourcePoolIfExists(ctx context.Context, finder *find.Finder, datacenter, cluster, resourcePoolName string) (bool, *object.ResourcePool, error)

func (*VSphereCloudDriver) GetResourcePools added in v0.0.23

func (v *VSphereCloudDriver) GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error)

func (*VSphereCloudDriver) GetResourceTags added in v0.0.23

func (v *VSphereCloudDriver) GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error)

func (*VSphereCloudDriver) GetVAppIfExists

func (v *VSphereCloudDriver) GetVAppIfExists(ctx context.Context, finder *find.Finder, datacenter, vAppName string) (bool, *object.VirtualApp, error)

func (*VSphereCloudDriver) GetVMIfExists

func (v *VSphereCloudDriver) GetVMIfExists(ctx context.Context, finder *find.Finder, datacenter, cluster, vmName string) (bool, *object.VirtualMachine, error)

func (*VSphereCloudDriver) GetVSphereClusters added in v0.0.23

func (v *VSphereCloudDriver) GetVSphereClusters(ctx context.Context, datacenter string) ([]string, error)

func (*VSphereCloudDriver) GetVSphereDatacenters added in v0.0.23

func (v *VSphereCloudDriver) GetVSphereDatacenters(ctx context.Context) ([]string, error)

func (*VSphereCloudDriver) GetVSphereHostSystems added in v0.0.23

func (v *VSphereCloudDriver) GetVSphereHostSystems(ctx context.Context, datacenter, cluster string) ([]VSphereHostSystem, error)

func (*VSphereCloudDriver) GetVSphereResourcePools

func (v *VSphereCloudDriver) GetVSphereResourcePools(ctx context.Context, datacenter string, cluster string) (resourcePools []string, err error)

func (*VSphereCloudDriver) GetVSphereVMFolders added in v0.0.23

func (v *VSphereCloudDriver) GetVSphereVMFolders(ctx context.Context, datacenter string) ([]string, error)

func (*VSphereCloudDriver) GetVSphereVms added in v0.0.23

func (v *VSphereCloudDriver) GetVSphereVms(ctx context.Context, dcName string) ([]VSphereVM, error)

func (*VSphereCloudDriver) GetVapps added in v0.0.23

func (v *VSphereCloudDriver) GetVapps(ctx context.Context) ([]mo.VirtualApp, error)

func (*VSphereCloudDriver) IsAdminAccount added in v0.0.26

func (v *VSphereCloudDriver) IsAdminAccount(ctx context.Context) (bool, error)

func (*VSphereCloudDriver) IsValidVSphereCredentials added in v0.0.23

func (v *VSphereCloudDriver) IsValidVSphereCredentials(ctx context.Context) (bool, error)

func (*VSphereCloudDriver) ValidateHostNTPSettings

func (v *VSphereCloudDriver) ValidateHostNTPSettings(ctx context.Context, finder *find.Finder, datacenter, clusterName string, hosts []string) (bool, []string, error)

func (*VSphereCloudDriver) ValidateUserPrivilegeOnEntities

func (v *VSphereCloudDriver) ValidateUserPrivilegeOnEntities(ctx context.Context, authManager *object.AuthorizationManager, datacenter string, finder *find.Finder, entityName, entityType string, privileges []string, userName, clusterName string) (isValid bool, failures []string, err error)

func (*VSphereCloudDriver) ValidateVsphereVersion added in v0.0.23

func (v *VSphereCloudDriver) ValidateVsphereVersion(constraint string) error

type VSphereHostSystem added in v0.0.23

type VSphereHostSystem struct {
	Name      string
	Reference string
}

type VSphereNetwork added in v0.0.23

type VSphereNetwork struct {
	Type      string
	Ip        string
	Interface string
}

type VSphereVM added in v0.0.23

type VSphereVM struct {
	Name           string
	Type           string
	Status         string
	IpAddress      string
	Host           string
	Cpu            int32
	Memory         int32
	RootDiskSize   int32
	Network        []VSphereNetwork
	LibvirtVmInfo  LibvirtVmInfo
	VSphereVmInfo  VSphereVmInfo
	SshInfo        SshInfo
	AdditionalDisk []AdditionalDisk
	Metrics        Metrics
	Storage        []Datastore
}

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) 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) []VSphereVM

type VSphereVmInfo added in v0.0.23

type VSphereVmInfo struct {
	Folder    string
	Cluster   string
	Datastore string
	Network   string
}

type VsphereCloudAccount

type VsphereCloudAccount struct {
	// Insecure is a flag that controls whether to validate the vSphere server's certificate.
	Insecure bool `json:"insecure" yaml:"insecure"`

	// password
	// Required: true
	Password string `json:"password" yaml:"password"`

	// username
	// Required: true
	Username string `json:"username" yaml:"username"`

	// VcenterServer is the address of the vSphere endpoint
	// Required: true
	VcenterServer string `json:"vcenterServer" yaml:"vcenterServer"`
}

type VsphereDriver added in v0.0.23

type VsphereDriver interface {
	GetVSphereVMFolders(ctx context.Context, datacenter string) ([]string, error)
	GetVSphereDatacenters(ctx context.Context) ([]string, error)
	GetVSphereClusters(ctx context.Context, datacenter string) ([]string, error)
	GetVSphereHostSystems(ctx context.Context, datacenter, cluster string) ([]VSphereHostSystem, error)
	IsValidVSphereCredentials(ctx context.Context) (bool, error)
	ValidateVsphereVersion(constraint string) error
	GetHostClusterMapping(ctx context.Context) (map[string]string, error)
	GetVSphereVms(ctx context.Context, dcName string) ([]VSphereVM, error)
	GetResourcePools(ctx context.Context, datacenter string, cluster string) ([]*object.ResourcePool, error)
	GetVapps(ctx context.Context) ([]mo.VirtualApp, error)
	GetResourceTags(ctx context.Context, resourceType string) (map[string]tags.AttachedTags, error)
	IsAdminAccount(ctx context.Context) (bool, error)
}

Jump to

Keyboard shortcuts

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