juju: github.com/juju/juju/provider/vsphere/internal/vsphereclient Index | Files

package vsphereclient

import "github.com/juju/juju/provider/vsphere/internal/vsphereclient"

Index

Package Files

client.go createvm.go ovf_ubuntu.go status.go

Constants

const UbuntuOVF = "" /* 10168 byte string literal not displayed */

func GenerateMAC Uses

func GenerateMAC() (string, error)

GenerateMAC generates a random hardware address that meets VMWare requirements for MAC address: 00:50:56:XX:YY:ZZ where XX is between 00 and 3f. https://pubs.vmware.com/vsphere-4-esx-vcenter/index.jsp?topic=/com.vmware.vsphere.server_configclassic.doc_41/esx_server_config/advanced_networking/c_setting_up_mac_addresses.html

func IsExtendDiskError Uses

func IsExtendDiskError(err error) bool

IsExtendDiskError returns whether the cause of this error was a failure to extend a VM disk.

func VerifyMAC Uses

func VerifyMAC(mac string) bool

VerifyMAC verifies that the MAC is valid for VMWare.

type Client Uses

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

Client encapsulates a vSphere client, exposing the subset of functionality that we require in the Juju provider.

func Dial Uses

func Dial(
    ctx context.Context,
    u *url.URL,
    datacenter string,
    logger loggo.Logger,
) (*Client, error)

Dial dials a new vSphere client connection using the given URL, scoped to the specified datacenter. The resulting Client's Close method must be called in order to release resources allocated by Dial.

func (*Client) Close Uses

func (c *Client) Close(ctx context.Context) error

Close logs out and closes the client connection.

func (*Client) ComputeResources Uses

func (c *Client) ComputeResources(ctx context.Context) ([]*mo.ComputeResource, error)

ComputeResources returns list of all root compute resources in the system.

func (*Client) CreateVirtualMachine Uses

func (c *Client) CreateVirtualMachine(
    ctx context.Context,
    args CreateVirtualMachineParams,
) (_ *mo.VirtualMachine, err error)

CreateVirtualMachine creates and powers on a new VM.

The creation process makes use of a vSphere feature called template VMs. If it doesn't already exist, a template VM will be created within args.VMDKDirectory based off of the OVA data provided by args.ReadOVA.

Once the template VM is available, a new instance will be cloned from it. Configuration settings from args.Constraints are then applied through a reconfigure step. Once the constraints are applied, the newly cloned VM will be powered on.

func (*Client) Datastores Uses

func (c *Client) Datastores(ctx context.Context) ([]*mo.Datastore, error)

Datastores returns list of all datastores in the system.

func (*Client) DeleteDatastoreFile Uses

func (c *Client) DeleteDatastoreFile(ctx context.Context, datastorePath string) error

DeleteDatastoreFile deletes a file or directory in the datastore.

func (*Client) DestroyVMFolder Uses

func (c *Client) DestroyVMFolder(ctx context.Context, folderPath string) error

DestroyVMFolder destroys a folder rooted at the datacenter's base VM folder.

func (*Client) EnsureVMFolder Uses

func (c *Client) EnsureVMFolder(ctx context.Context, folderPath string) (*object.Folder, error)

EnsureVMFolder creates the a VM folder with the given path if it doesn't already exist.

func (*Client) MoveVMFolderInto Uses

func (c *Client) MoveVMFolderInto(ctx context.Context, parentPath, childPath string) error

MoveVMFolderInto moves one VM folder into another.

func (*Client) MoveVMsInto Uses

func (c *Client) MoveVMsInto(
    ctx context.Context,
    folderPath string,
    vms ...types.ManagedObjectReference,
) error

MoveVMsInto moves a set of VMs into a folder.

func (*Client) RemoveVirtualMachines Uses

func (c *Client) RemoveVirtualMachines(ctx context.Context, path string) error

RemoveVirtualMachines removes VMs matching the given path from the system. The path may include wildcards, to match multiple VMs.

func (*Client) ResourcePools Uses

func (c *Client) ResourcePools(ctx context.Context, path string) ([]*object.ResourcePool, error)

ResourcePools returns a list of all of the resource pools (possibly nested) under the given path.

func (*Client) UpdateVirtualMachineExtraConfig Uses

func (c *Client) UpdateVirtualMachineExtraConfig(
    ctx context.Context,
    vmInfo *mo.VirtualMachine,
    metadata map[string]string,
) error

UpdateVirtualMachineExtraConfig updates the "ExtraConfig" attributes of the specified virtual machine. Keys with empty values will be removed from the config; existing keys that are unspecified in the map will be untouched.

func (*Client) UserHasRootLevelPrivilege Uses

func (c *Client) UserHasRootLevelPrivilege(ctx context.Context, privilege string) (bool, error)

UserHasRootLevelPrivilege returns whether the connected user has the specified privilege on the root-level object.

func (*Client) VirtualMachines Uses

func (c *Client) VirtualMachines(ctx context.Context, path string) ([]*mo.VirtualMachine, error)

VirtualMachines return list of all VMs in the system matching the given path.

type CreateVirtualMachineParams Uses

type CreateVirtualMachineParams struct {
    // Name is the name to give the virtual machine. The VM name is used
    // for its hostname also.
    Name string

    // Folder is the path of the VM folder, relative to the root VM folder,
    // in which to create the VM.
    Folder string

    // VMDKDirectory is the datastore path in which VMDKs are stored for
    // this controller. Within this directory there will be subdirectories
    // for each series, and within those the VMDKs will be stored.
    VMDKDirectory string

    // Series is the name of the OS series that the image will run.
    Series string

    // ReadOVA returns the location of, and an io.ReadCloser for,
    // the OVA from which to extract the VMDK. The location may be
    // used for reporting progress. The ReadCloser must be closed
    // by the caller when it is finished with it.
    ReadOVA func() (location string, _ io.ReadCloser, _ error)

    // OVASHA256 is the expected SHA-256 hash of the OVA.
    OVASHA256 string

    // UserData is the cloud-init user-data.
    UserData string

    // ComputeResource is the compute resource (host or cluster) to be used
    // to create the VM.
    ComputeResource *mo.ComputeResource

    // ResourcePool is a reference to the pool the VM should be
    // created in.
    ResourcePool types.ManagedObjectReference

    // Metadata are metadata key/value pairs to apply to the VM as
    // "extra config".
    Metadata map[string]string

    // Constraints contains the resource constraints for the virtual machine.
    Constraints constraints.Value

    // Networks contain a list of network devices the VM should have.
    NetworkDevices []NetworkDevice

    // UpdateProgress is a function that should be called before/during
    // long-running operations to provide a progress reporting.
    UpdateProgress func(string)

    // UpdateProgressInterval is the amount of time to wait between calls
    // to UpdateProgress. This should be lower when the operation is
    // interactive (bootstrap), and higher when non-interactive.
    UpdateProgressInterval time.Duration

    // Clock is used for controlling the timing of progress updates.
    Clock clock.Clock

    // EnableDiskUUID controls whether the VMware disk should expose a
    // consistent UUID to the guest OS.
    EnableDiskUUID bool

    // IsBootstrap indicates whether the requested instance will be a
    // newly bootstrapped controller.
    IsBootstrap bool
}

CreateVirtualMachineParams contains the parameters required for creating a new virtual machine.

type NetworkDevice Uses

type NetworkDevice struct {
    // Network is the name of the network the device should be connected to.
    // If empty it will be connected to the default "VM Network" network.
    Network string
    // MAC is the hardware address of the network device.
    MAC string
}

NetworkDevice defines a single network device attached to a newly created VM.

Package vsphereclient imports 32 packages (graph) and is imported by 3 packages. Updated 2019-10-18. Refresh now. Tools for package owners.