Documentation ¶
Index ¶
- Constants
- Variables
- func CheckControllerSupported(ctrlType string) bool
- func CheckDiskFormatSupported(diskFormat string) bool
- func DiskformatValidOptions() string
- func RecordCreateVolumeMetric(volumeOptions *VolumeOptions, requestTime time.Time, err error)
- func RecordvSphereMetric(actionName string, requestTime time.Time, err error)
- func RegisterMetrics()
- func RemoveClusterFromVDiskPath(vDiskPath string) string
- func SCSIControllerTypeValidOptions() string
- type Datacenter
- func (dc *Datacenter) GetDatastoreByName(ctx context.Context, name string) (*Datastore, error)
- func (dc *Datacenter) GetDatastoreByPath(ctx context.Context, vmDiskPath string) (*Datastore, error)
- func (dc *Datacenter) GetDatastoreMoList(ctx context.Context, dsObjList []*Datastore, properties []string) ([]mo.Datastore, error)
- func (dc *Datacenter) GetFolderByPath(ctx context.Context, folderPath string) (*Folder, error)
- func (dc *Datacenter) GetVMByPath(ctx context.Context, vmPath string) (*VirtualMachine, error)
- func (dc *Datacenter) GetVMByUUID(ctx context.Context, vmUUID string) (*VirtualMachine, error)
- func (dc *Datacenter) GetVMMoList(ctx context.Context, vmObjList []*VirtualMachine, properties []string) ([]mo.VirtualMachine, error)
- type Datastore
- type Folder
- type PbmClient
- func (pbmClient *PbmClient) GetCompatibleDatastores(ctx context.Context, storagePolicyID string, datastores []*Datastore) ([]*Datastore, string, error)
- func (pbmClient *PbmClient) GetPlacementCompatibilityResult(ctx context.Context, storagePolicyID string, datastore []*Datastore) (pbm.PlacementCompatibilityResult, error)
- func (pbmClient *PbmClient) IsDatastoreCompatible(ctx context.Context, storagePolicyID string, datastore *Datastore) (bool, string, error)
- type VMOptions
- type VSphereConnection
- type VirtualMachine
- func (vm *VirtualMachine) AttachDisk(ctx context.Context, vmDiskPath string, volumeOptions *VolumeOptions) (string, error)
- func (vm *VirtualMachine) CreateDiskSpec(ctx context.Context, diskPath string, dsObj *Datastore, ...) (*types.VirtualDisk, types.BaseVirtualDevice, error)
- func (vm *VirtualMachine) DeleteVM(ctx context.Context) error
- func (vm *VirtualMachine) DetachDisk(ctx context.Context, vmDiskPath string) error
- func (vm *VirtualMachine) Exists(ctx context.Context) (bool, error)
- func (vm *VirtualMachine) GetAllAccessibleDatastores(ctx context.Context) ([]*Datastore, error)
- func (vm *VirtualMachine) GetResourcePool(ctx context.Context) (*object.ResourcePool, error)
- func (vm *VirtualMachine) GetVirtualDiskPage83Data(ctx context.Context, diskPath string) (string, error)
- func (vm *VirtualMachine) IsDiskAttached(ctx context.Context, diskPath string) (bool, error)
- type VolumeOptions
Constants ¶
const ( ThinDiskType = "thin" PreallocatedDiskType = "preallocated" EagerZeroedThickDiskType = "eagerZeroedThick" ZeroedThickDiskType = "zeroedThick" )
Volume Constnts
const ( SCSIControllerLimit = 4 SCSIControllerDeviceLimit = 15 SCSIDeviceSlots = 16 SCSIReservedSlot = 7 SCSIControllerType = "scsi" LSILogicControllerType = "lsiLogic" BusLogicControllerType = "busLogic" LSILogicSASControllerType = "lsiLogic-sas" PVSCSIControllerType = "pvscsi" )
Controller Constants
const ( LogLevel = 4 DatastoreProperty = "datastore" ResourcePoolProperty = "resourcePool" DatastoreInfoProperty = "info" VirtualMachineType = "VirtualMachine" RoundTripperDefaultCount = 3 VSANDatastoreType = "vsan" DummyVMPrefixName = "vsphere-k8s" ActivePowerState = "poweredOn" )
Other Constants
const ( FileAlreadyExistErrMsg = "File requested already exist" NoDiskUUIDFoundErrMsg = "No disk UUID found" NoDevicesFoundErrMsg = "No devices found" DiskNotFoundErrMsg = "No vSphere disk ID found" InvalidVolumeOptionsErrMsg = "VolumeOptions verification failed" )
Error Messages
const ( APICreateVolume = "CreateVolume" APIDeleteVolume = "DeleteVolume" APIAttachVolume = "AttachVolume" APIDetachVolume = "DetachVolume" )
Cloud Provider API constants
const ( OperationDeleteVolume = "DeleteVolumeOperation" OperationAttachVolume = "AttachVolumeOperation" OperationDetachVolume = "DetachVolumeOperation" OperationDiskIsAttached = "DiskIsAttachedOperation" OperationDisksAreAttached = "DisksAreAttachedOperation" OperationCreateVolume = "CreateVolumeOperation" OperationCreateVolumeWithPolicy = "CreateVolumeWithPolicyOperation" OperationCreateVolumeWithRawVSANPolicy = "CreateVolumeWithRawVSANPolicyOperation" )
Cloud Provider Operation constants
Variables ¶
var ( ErrFileAlreadyExist = errors.New(FileAlreadyExistErrMsg) ErrNoDiskUUIDFound = errors.New(NoDiskUUIDFoundErrMsg) ErrNoDevicesFound = errors.New(NoDevicesFoundErrMsg) ErrNoDiskIDFound = errors.New(DiskNotFoundErrMsg) ErrInvalidVolumeOptions = errors.New(InvalidVolumeOptionsErrMsg) )
Error constants
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 ¶
CheckControllerSupported checks if the given controller type is valid
func CheckDiskFormatSupported ¶
CheckDiskFormatSupported checks if the diskFormat is valid
func DiskformatValidOptions ¶
func DiskformatValidOptions() string
DiskformatValidOptions generates Valid Options for Diskformat
func RecordCreateVolumeMetric ¶
func RecordCreateVolumeMetric(volumeOptions *VolumeOptions, requestTime time.Time, err error)
RecordCreateVolumeMetric records the Create Volume metric
func RecordvSphereMetric ¶
RecordvSphereMetric records the vSphere API and Operation metrics
func RegisterMetrics ¶
func RegisterMetrics()
RegisterMetrics registers all the API and Operation metrics
func RemoveClusterFromVDiskPath ¶
RemoveClusterFromVDiskPath 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
Types ¶
type Datacenter ¶
type Datacenter struct {
*object.Datacenter
}
Datacenter extends the govmomi Datacenter object
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) GetDatastoreByName ¶
GetDatastoreByName gets the Datastore object for the given datastore name
func (*Datacenter) GetDatastoreByPath ¶
func (dc *Datacenter) GetDatastoreByPath(ctx context.Context, vmDiskPath string) (*Datastore, error)
GetDatastoreByPath gets the Datastore object from the given vmDiskPath
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) GetFolderByPath ¶
GetFolderByPath gets the Folder Object from the given folder path folderPath should be the full path to folder
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
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) 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
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 PbmClient ¶
PbmClient is extending govmomi pbm, and provides functions to get compatible list of datastore for given policy
func NewPbmClient ¶
NewPbmClient returns a new PBM Client object
func (*PbmClient) GetCompatibleDatastores ¶
func (pbmClient *PbmClient) GetCompatibleDatastores(ctx context.Context, storagePolicyID string, datastores []*Datastore) ([]*Datastore, 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 []*Datastore) (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 VMOptions ¶
type VMOptions struct { VMFolder *Folder VMResourcePool *object.ResourcePool }
VMOptions provides helper objects for provisioning volume with SPBM Policy
type VSphereConnection ¶
type VSphereConnection struct { GoVmomiClient *govmomi.Client Username string Password string Hostname string Port string Insecure bool RoundTripperCount uint }
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.GoVmomiClient. If connection.GoVmomiClient is already set, it obtains the existing user session. if user session is not valid, connection.GoVmomiClient will be set to the new client.
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 ¶
func (vm *VirtualMachine) Exists(ctx context.Context) (bool, error)
Exists checks if the VM exists. Returns false if VM doesn't exist or VM is in powerOff state.
func (*VirtualMachine) GetAllAccessibleDatastores ¶
func (vm *VirtualMachine) GetAllAccessibleDatastores(ctx context.Context) ([]*Datastore, 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) GetVirtualDiskPage83Data ¶
func (vm *VirtualMachine) GetVirtualDiskPage83Data(ctx context.Context, diskPath string) (string, error)
GetVirtualDiskPage83Data gets the virtual disk UUID by diskPath
func (*VirtualMachine) IsDiskAttached ¶
IsDiskAttached checks if disk is attached to the VM.
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