icslib

package
v0.0.0-...-718960f Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

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"
	NoZoneRegionFoundErrMsg        = "Unable to find the Zone/Region pair"
	NoDatastoreFoundErrMsg         = "Datastore not found"
	NoDatacenterFoundErrMsg        = "Datacenter not found"
	NoDataStoreClustersFoundErrMsg = "No DatastoreClusters Found"
)

Error Messages

Variables

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

Error constants

Functions

func GetNumberOfDatacenters

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

GetNumberOfDatacenters returns the number of DataCenters in this vCenter

Types

type Common

type Common struct {
	Con *icsgo.ICSConnection
}

Common contains the fields and functions common to all objects.

func NewCommon

func NewCommon(con *icsgo.ICSConnection) Common

func (Common) Client

func (c Common) Client() *client.Client

type Datacenter

type Datacenter struct {
	Common
	*types.Datacenter
}

Datacenter extends the govmomi Datacenter object

func GetAllDatacenter

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

GetAllDatacenter returns all the DataCenter Objects

func GetDatacenter

func GetDatacenter(ctx context.Context, connection *icsgo.ICSConnection, 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) 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) DoesFirstClassDiskExist

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

DoesFirstClassDiskExist returns information about an FCD if it exists.

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

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

type Datastore

type Datastore struct {
	Common
	*types.Storage
	Datacenter *Datacenter
}

Datastore extends the govmomi Datastore object

type DatastoreInfo

type DatastoreInfo struct {
	*Datastore
}

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

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 {
	ID         string
	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 HostSystem

type HostSystem struct {
	Common
	*types.Host
}

func GetHostSystemListByDC

func GetHostSystemListByDC(ctx context.Context, connection *icsgo.ICSConnection, datacenterPath string) ([]*HostSystem, 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

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 StoragePod

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

StoragePod extends the govmomi StoragePod object

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.

type VirtualMachine

type VirtualMachine struct {
	Common
	*types.VirtualMachine
	Datacenter *Datacenter
}

VirtualMachine extends the govmomi VirtualMachine object

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.

Jump to

Keyboard shortcuts

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