Documentation ¶
Index ¶
- Constants
- type Client
- func (c *Client) AssignNote(vm *VirtualMachine, note string, overwrite bool) error
- func (c *Client) Clone(vm *VirtualMachine, name, destination, resourcePool string) (*VirtualMachine, error)
- func (c *Client) Configure(vm *VirtualMachine, vmc *VirtualMachineConfiguration) error
- func (c *Client) Destroy(vm *VirtualMachine) error
- func (c *Client) EnsureOff(vm *VirtualMachine) error
- func (c *Client) EnsureOn(vm *VirtualMachine) error
- func (c *Client) FindSnapshot(vm *VirtualMachine, name string, byRef bool) (*types.ManagedObjectReference, error)
- func (c *Client) FindVM(path string, pathIsRef bool, properties ...string) (*VirtualMachine, error)
- func (c *Client) GetPowerState(vm *VirtualMachine) (PowerState, error)
- func (c *Client) Relocate(vm *VirtualMachine, name, destination string) error
- func (c *Client) ReportSnapshot(mo *types.ManagedObjectReference) *Snapshot
- func (c *Client) ReportVM(vm *VirtualMachine) *VirtualMachineInfo
- func (c *Client) SnapshotCreate(vm *VirtualMachine, name string) (*types.ManagedObjectReference, error)
- func (c *Client) SnapshotList(vm *VirtualMachine) (*Snapshot, error)
- func (c *Client) SnapshotRemove(vm *VirtualMachine, moRef *types.ManagedObjectReference) error
- func (c *Client) SnapshotRemoveAll(vm *VirtualMachine) error
- func (c *Client) SnapshotRevert(vm *VirtualMachine) error
- func (c *Client) SnapshotRevertTo(vm *VirtualMachine, moRef *types.ManagedObjectReference) error
- func (c *Client) Suspend(vm *VirtualMachine) error
- type ConnectionError
- type ErrorCoder
- type NotFoundError
- type PowerState
- type Snapshot
- type TimeoutExceededError
- type VirtualMachine
- type VirtualMachineConfiguration
- type VirtualMachineInfo
Constants ¶
const Version = "0.7.0"
Version is the version of the application and API
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { Client *govmomi.Client Finder *find.Finder Verbose bool // contains filtered or unexported fields }
Client represents a connection to vSphere
func (*Client) AssignNote ¶
func (c *Client) AssignNote(vm *VirtualMachine, note string, overwrite bool) error
AssignNote adds a note to the VM, or overwrites the notes entirely
func (*Client) Clone ¶
func (c *Client) Clone(vm *VirtualMachine, name, destination, resourcePool string) (*VirtualMachine, error)
Clone clones the specified VM
func (*Client) Configure ¶
func (c *Client) Configure(vm *VirtualMachine, vmc *VirtualMachineConfiguration) error
Configure will change some of the virtual hardware that the specified VM uses
func (*Client) Destroy ¶
func (c *Client) Destroy(vm *VirtualMachine) error
Destroy will remove a VM from vSphere
func (*Client) EnsureOff ¶
func (c *Client) EnsureOff(vm *VirtualMachine) error
EnsureOff makes certain that the VM is off (not on or suspended)
func (*Client) EnsureOn ¶
func (c *Client) EnsureOn(vm *VirtualMachine) error
EnsureOn makes certain that the VM is on
func (*Client) FindSnapshot ¶
func (c *Client) FindSnapshot(vm *VirtualMachine, name string, byRef bool) (*types.ManagedObjectReference, error)
FindSnapshot will locate the Managed Object Reference for a snapshot, either by looking it up by name, or converting the provided ref into a MORef.
func (*Client) FindVM ¶
FindVM will fetch the Virtual Machine struct for use with this API. The VM can be identified by path (example, `/Engineering/Templates/Base Template`), or by the Managed Object Ref (example, `vm-139`). The struct can also be populated with the additional data as requested in the `properties` argument.
func (*Client) GetPowerState ¶
func (c *Client) GetPowerState(vm *VirtualMachine) (PowerState, error)
GetPowerState returns the current power state of the provided VM
func (*Client) Relocate ¶
func (c *Client) Relocate(vm *VirtualMachine, name, destination string) error
Relocate will move the VM into a new destination folder, and/or change its name
func (*Client) ReportSnapshot ¶
func (c *Client) ReportSnapshot(mo *types.ManagedObjectReference) *Snapshot
func (*Client) ReportVM ¶
func (c *Client) ReportVM(vm *VirtualMachine) *VirtualMachineInfo
ReportVM writes descriptive JSON data to the console
func (*Client) SnapshotCreate ¶
func (c *Client) SnapshotCreate(vm *VirtualMachine, name string) (*types.ManagedObjectReference, error)
SnapshotCreate will create a snapshot of the current VM. It is assumed that the VM is already powered off. Taking a snapshot of a powered-on or suspended VM _may_ be successful, but certain configurations will cause problems, and we are not snapshotting the current memory state or quiescing the file system. See https://docs.vmware.com/en/VMware-vSphere/6.5/com.vmware.vsphere.vm_admin.doc/GUID-53F65726-A23B-4CF0-A7D5-48E584B88613.html
func (*Client) SnapshotList ¶
func (c *Client) SnapshotList(vm *VirtualMachine) (*Snapshot, error)
SnapshotList retrieves all the snapshots for the provided VM, hierarchically
func (*Client) SnapshotRemove ¶
func (c *Client) SnapshotRemove(vm *VirtualMachine, moRef *types.ManagedObjectReference) error
SnapshotRemove removes a single snapshot from the provided VM
func (*Client) SnapshotRemoveAll ¶
func (c *Client) SnapshotRemoveAll(vm *VirtualMachine) error
SnapshotRemoveAll removes snapshots from the provided VM
func (*Client) SnapshotRevert ¶
func (c *Client) SnapshotRevert(vm *VirtualMachine) error
SnapshotRevert will revert the provided VM back the previous snapshot
func (*Client) SnapshotRevertTo ¶
func (c *Client) SnapshotRevertTo(vm *VirtualMachine, moRef *types.ManagedObjectReference) error
SnapshotRevertTo will revert the provided VM to the specified snapshot
func (*Client) Suspend ¶
func (c *Client) Suspend(vm *VirtualMachine) error
Suspend makes certain that the VM is suspended
type ConnectionError ¶
type ConnectionError struct{}
ConnectionError occurs when vcon fails to establish a connection to vSphere or the user has not provided a valid datacenter or datastore name
func (ConnectionError) Code ¶
func (ce ConnectionError) Code() int
func (ConnectionError) Error ¶
func (ce ConnectionError) Error() string
type ErrorCoder ¶
type ErrorCoder interface { // Code provides the integer error code to return Code() int }
ErrorCoder gives errors a code to return with os.Exit
type NotFoundError ¶
type NotFoundError struct {
Path string
}
func (NotFoundError) Code ¶
func (nfe NotFoundError) Code() int
func (NotFoundError) Error ¶
func (nfe NotFoundError) Error() string
type PowerState ¶
type PowerState string
PowerState describes whether a VM is on, off, or suspended
const ( // PoweredOff indicates that the VM is turned off PoweredOff PowerState = "powered_off" // PoweredOn indicates that the VM is running PoweredOn PowerState = "powered_on" // Suspended indicates that the VM is on but not running Suspended PowerState = "suspended" // Unknown indicates that the power state was not determined Unknown PowerState = "unknown" )
type Snapshot ¶
type Snapshot struct { Name string `json:"name"` Ref string `json:"ref"` Children []Snapshot `json:"children,omitempty"` }
Snapshot represents a node in a hierarchical list of VM snapshots
type TimeoutExceededError ¶
type TimeoutExceededError struct {
// contains filtered or unexported fields
}
TimeoutExceededError occurs when a collection of vSphere operations does not complete in the determined timeout
func (TimeoutExceededError) Cause ¶
func (tee TimeoutExceededError) Cause() error
Cause returns the root cause, which will always be context.DeadlineExceeded
func (TimeoutExceededError) Code ¶
func (tee TimeoutExceededError) Code() int
func (TimeoutExceededError) Error ¶
func (tee TimeoutExceededError) Error() string
type VirtualMachine ¶
type VirtualMachine struct { MO *mo.VirtualMachine Ref types.ManagedObjectReference VM *object.VirtualMachine }
VirtualMachine is a vSphere VM
type VirtualMachineConfiguration ¶
type VirtualMachineConfiguration struct { CPUs *int `json:"cpus,omitempty"` Memory *int `json:"memory,omitempty"` Network *string `json:"network,omitempty"` }
VirtualMachineConfiguration describes the virtual hardware assigned to a VM
type VirtualMachineInfo ¶
type VirtualMachineInfo struct { Configuration *VirtualMachineConfiguration `json:"configuration"` IPs []string `json:"ips"` IsRunning bool `json:"isRunning"` Path string `json:"path"` Ref string `json:"ref"` }
VirtualMachineInfo describes interesting information about a VM