vsphere

package
v8.0.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

README

To test vSphere

You will first need to have a vSphere environment and then provide details of the vcenter server and VM as below.

export VSPHERE_VCENTER=my-vc.demo.com
export VSPHERE_VCENTER_PORT=443
export VSPHERE_USER=administrator@vsphere.local
export VSPHERE_PASSWORD=my-vc-password
export VSPHERE_INSECURE=true

# To get VSPHERE_VM_UUID, go to https://<vcenter-ip>/mob/?moid=<VM-MOREF>&doPath=config and get the "uuid" field value
# To get the VM-MOREF, select the VM in vcenter server and you will see a string of format "VirtualMachine:vm-155" in the URL. vm-155 is the moref.

export VSPHERE_VM_UUID=42124a20-d049-9c0a-0094-1552b320fb18
export VSPHERE_TEST_DATASTORE=<test-datastore-to-use>

# VSPHERE_TEST_DATASTORE above can be a vSphere datastore or datastore cluster name. When testing changes, it is recommended to test with both.

go test -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStoragePodMoList

func GetStoragePodMoList(
	ctx context.Context,
	client *vim25.Client,
	storagePodRefs []types.ManagedObjectReference,
	properties []string) ([]mo.StoragePod, error)

GetStoragePodMoList fetches the managed storage pod objects for the given references

Only the properties is the given property list will be populated in the response

func GetVMObject

func GetVMObject(ctx context.Context, conn *vclib.VSphereConnection, vmUUID string) (*vclib.VirtualMachine, error)

GetVMObject fetches the VirtualMachine object corresponding to the given virtual machine uuid

func IsDevMode

func IsDevMode() bool

IsDevMode checks if requirement env variables are set to run the pkg outside vsphere in dev mode

func IsStoragePod

func IsStoragePod(ctx context.Context, vmObj *vclib.VirtualMachine, name string) (bool, *object.StoragePod, error)

IsStoragePod checks if the object with given name is a StoragePod (Datastore cluster)

func NewClient

func NewClient(cfg *VSphereConfig) (storageops.Ops, error)

NewClient creates a new vsphere storageops instance

Types

type VSphereConfig

type VSphereConfig struct {
	// User is the vCenter username.
	User string
	// Password is the vCenter password in clear text.
	Password string
	// VCenterIP is the vcenter IP to connect on
	VCenterIP string
	// VCenterPort is the vcenter port to connect on
	VCenterPort string
	// InsecureFlag True if vCenter uses self-signed cert.
	InsecureFlag bool
	// RoundTripperCount is the Soap round tripper count (retries = RoundTripper - 1)
	RoundTripperCount uint
	// VMUUID is the VM Instance UUID of virtual machine which can be retrieved from instanceUuid
	// property in VmConfigInfo, or also set as vc.uuid in VMX file.
	// If not set, will be fetched from the machine via sysfs (requires root)
	VMUUID string
}

derived from https://github.com/kubernetes/kubernetes/blob/release-1.9/pkg/cloudprovider/providers/vsphere/vsphere_util.go#L94 VSphereConfig represents the vsphere configuration

func ReadVSphereConfigFromEnv

func ReadVSphereConfigFromEnv() (*VSphereConfig, error)

type VSphereInstance

type VSphereInstance struct {
	// contains filtered or unexported fields
}

Represents a vSphere instance where one or more kubernetes nodes are running.

type VirtualCenterConfig

type VirtualCenterConfig struct {
	// vCenter username.
	User string
	// vCenter password in clear text.
	Password string
	// vCenter port
	VCenterPort string
	// Datacenter in which VMs are located.
	Datacenter string
	// Soap round tripper count (retries = RoundTripper - 1)
	RoundTripperCount uint
}

Structure that represents Virtual Center configuration

type VirtualDisk

type VirtualDisk struct {
	diskmanagers.VirtualDisk
	// DatastoreRef is the managed object reference of the datastore on which the disk belongs
	DatastoreRef types.ManagedObjectReference
}

VirtualDisk encapsulates the existing virtual disk object to add a managed object reference to the datastore of the disk

Jump to

Keyboard shortcuts

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