Documentation
¶
Index ¶
- Variables
- func GetVMSizingPolicyByName(sizingPolicies []*govcd.VdcComputePolicyV2, policyName string) (*govcd.VdcComputePolicyV2, error)
- type ConnectConfig
- type Driver
- type MksTicket
- type NetworkInfo
- type TrustedPlatformModuleEdit
- type VCDDriver
- func (d *VCDDriver) Cleanup() error
- func (d *VCDDriver) CreateCatalogWithStorageProfile(name, description string, storageProfileRef *types.Reference) (*govcd.AdminCatalog, error)
- func (d *VCDDriver) CreateVApp(vdc *govcd.Vdc, name, description, networkName string) (*govcd.VApp, error)
- func (d *VCDDriver) DeleteCatalog(catalog *govcd.AdminCatalog) error
- func (d *VCDDriver) FindAvailableIP(vdc *govcd.Vdc, networkName string) (*NetworkInfo, error)
- func (d *VCDDriver) FindAvailableIPExcluding(vdc *govcd.Vdc, networkName string, excludeIPs []string) (*NetworkInfo, error)
- func (d *VCDDriver) FindVM(vdcName, vappName, vmName string) (VirtualMachine, error)
- func (d *VCDDriver) GetAdminOrg() (*govcd.AdminOrg, error)
- func (d *VCDDriver) GetCatalog(name string) (*govcd.Catalog, error)
- func (d *VCDDriver) GetClient() *govcd.VCDClient
- func (d *VCDDriver) GetNetworkInfo(vdc *govcd.Vdc, networkName string) (*NetworkInfo, error)
- func (d *VCDDriver) GetOrg() (*govcd.Org, error)
- func (d *VCDDriver) GetVApp(vdcName, vappName string) (*govcd.VApp, error)
- func (d *VCDDriver) GetVdc(name string) (*govcd.Vdc, error)
- func (d *VCDDriver) MakeTemplatePoliciesNonFinal(template *govcd.VAppTemplate) error
- func (d *VCDDriver) NewVM(ref *govcd.VM) VirtualMachine
- func (d *VCDDriver) UploadMediaImage(catalog *govcd.Catalog, name, description, filePath string) (*govcd.Media, error)
- type VirtualMachine
- type VirtualMachineDriver
- func (v *VirtualMachineDriver) ChangeCPU(cpuCount, coresPerSocket int) error
- func (v *VirtualMachineDriver) ChangeIPAddress(newIP string) error
- func (v *VirtualMachineDriver) ChangeMemory(memoryMB int64) error
- func (v *VirtualMachineDriver) EjectMedia(catalogName, mediaName string) error
- func (v *VirtualMachineDriver) GetIPAddress() (string, error)
- func (v *VirtualMachineDriver) GetName() string
- func (v *VirtualMachineDriver) GetStatus() (string, error)
- func (v *VirtualMachineDriver) GetVM() *govcd.VM
- func (v *VirtualMachineDriver) InsertMedia(catalogName, mediaName string) error
- func (v *VirtualMachineDriver) IsPoweredOff() (bool, error)
- func (v *VirtualMachineDriver) IsPoweredOn() (bool, error)
- func (v *VirtualMachineDriver) PowerOff() error
- func (v *VirtualMachineDriver) PowerOn() error
- func (v *VirtualMachineDriver) Refresh() error
- func (v *VirtualMachineDriver) SetBootOptions(bootDelayMs int, efiSecureBoot bool) error
- func (v *VirtualMachineDriver) SetTPM(enabled bool) error
- func (v *VirtualMachineDriver) Shutdown() error
- func (v *VirtualMachineDriver) WaitForIP(ctx context.Context, timeout time.Duration) (string, error)
- func (v *VirtualMachineDriver) WaitForPowerOff(ctx context.Context, timeout time.Duration) error
- type WMKSBootDriver
- type WMKSClient
- type WMKSOption
Constants ¶
This section is empty.
Variables ¶
var VScanCodes = map[string]int{
"ESCAPE": 1,
"1": 2,
"2": 3,
"3": 4,
"4": 5,
"5": 6,
"6": 7,
"7": 8,
"8": 9,
"9": 10,
"0": 11,
"MINUS": 12,
"EQUALS": 13,
"BACKSPACE": 14,
"TAB": 15,
"Q": 16,
"W": 17,
"E": 18,
"R": 19,
"T": 20,
"Y": 21,
"U": 22,
"I": 23,
"O": 24,
"P": 25,
"LBRACKET": 26,
"RBRACKET": 27,
"ENTER": 28,
"LCTRL": 29,
"A": 30,
"S": 31,
"D": 32,
"F": 33,
"G": 34,
"H": 35,
"J": 36,
"K": 37,
"L": 38,
"SEMICOLON": 39,
"QUOTE": 40,
"BACKTICK": 41,
"LSHIFT": 42,
"BACKSLASH": 43,
"Z": 44,
"X": 45,
"C": 46,
"V": 47,
"B": 48,
"N": 49,
"M": 50,
"COMMA": 51,
"PERIOD": 52,
"SLASH": 53,
"RSHIFT": 54,
"MULTIPLY": 55,
"LALT": 56,
"SPACE": 57,
"CAPSLOCK": 58,
"F1": 59,
"F2": 60,
"F3": 61,
"F4": 62,
"F5": 63,
"F6": 64,
"F7": 65,
"F8": 66,
"F9": 67,
"F10": 68,
"NUMLOCK": 69,
"SCROLLOCK": 70,
"KP7": 71,
"KP8": 72,
"KP9": 73,
"KPMINUS": 74,
"KP4": 75,
"KP5": 76,
"KP6": 77,
"KPPLUS": 78,
"KP1": 79,
"KP2": 80,
"KP3": 81,
"KP0": 82,
"KPDOT": 83,
"F11": 87,
"F12": 88,
"KPENTER": 0x11C,
"RCTRL": 0x11D,
"KPSLASH": 0x135,
"RALT": 0x138,
"HOME": 0x147,
"UP": 0x148,
"PAGEUP": 0x149,
"LEFT": 0x14B,
"RIGHT": 0x14D,
"END": 0x14F,
"DOWN": 0x150,
"PAGEDOWN": 0x151,
"INSERT": 0x152,
"DELETE": 0x153,
}
VScanCodes are PS/2 scan codes used by WMKS These are NOT USB HID codes - they're the legacy PC keyboard scan codes
Functions ¶
func GetVMSizingPolicyByName ¶ added in v0.0.11
func GetVMSizingPolicyByName(sizingPolicies []*govcd.VdcComputePolicyV2, policyName string) (*govcd.VdcComputePolicyV2, error)
GetVMSizingPolicyByName finds a VM sizing policy by name from a list of policies
Types ¶
type ConnectConfig ¶
type Driver ¶
type Driver interface {
// VM operations
NewVM(ref *govcd.VM) VirtualMachine
FindVM(vdcName, vappName, vmName string) (VirtualMachine, error)
// Org operations
GetOrg() (*govcd.Org, error)
GetAdminOrg() (*govcd.AdminOrg, error)
// VDC operations
GetVdc(name string) (*govcd.Vdc, error)
// vApp operations
GetVApp(vdcName, vappName string) (*govcd.VApp, error)
CreateVApp(vdc *govcd.Vdc, name, description, networkName string) (*govcd.VApp, error)
// Network operations
FindAvailableIP(vdc *govcd.Vdc, networkName string) (*NetworkInfo, error)
FindAvailableIPExcluding(vdc *govcd.Vdc, networkName string, excludeIPs []string) (*NetworkInfo, error)
GetNetworkInfo(vdc *govcd.Vdc, networkName string) (*NetworkInfo, error)
// Catalog operations
GetCatalog(name string) (*govcd.Catalog, error)
CreateCatalogWithStorageProfile(name, description string, storageProfileRef *types.Reference) (*govcd.AdminCatalog, error)
DeleteCatalog(catalog *govcd.AdminCatalog) error
UploadMediaImage(catalog *govcd.Catalog, name, description, filePath string) (*govcd.Media, error)
// Template operations
MakeTemplatePoliciesNonFinal(template *govcd.VAppTemplate) error
// Lifecycle
Cleanup() error
GetClient() *govcd.VCDClient
}
Driver defines the interface for VCD operations
func NewDriver ¶
func NewDriver(config *ConnectConfig) (Driver, error)
type MksTicket ¶
type MksTicket struct {
XMLName xml.Name `xml:"MksTicket"`
Xmlns string `xml:"xmlns,attr,omitempty"`
Host string `xml:"Host"`
Port int `xml:"Port"`
Ticket string `xml:"Ticket"`
Vmx string `xml:"Vmx,omitempty"`
}
MksTicket represents the response from acquireMksTicket API This is used to establish a WebMKS console connection to a VM
func AcquireMksTicket ¶
AcquireMksTicket gets a WebMKS ticket for console access to a VM The ticket is valid for 30 seconds
func AcquireMksTicketDirect ¶
AcquireMksTicketDirect gets an MKS ticket using the VM's HREF directly This is an alternative method when the link traversal doesn't work
func (*MksTicket) WebSocketURL ¶
WebSocketURL constructs the WebSocket URL for connecting to the VM console
type NetworkInfo ¶ added in v0.0.2
type NetworkInfo struct {
Gateway string
Netmask string
DNS1 string
DNS2 string
AvailableIP string // First available IP from pool
}
NetworkInfo contains information about a network's IP configuration
type TrustedPlatformModuleEdit ¶ added in v0.0.4
type TrustedPlatformModuleEdit struct {
XMLName xml.Name `xml:"root:TrustedPlatformModule"`
Xmlns string `xml:"xmlns:root,attr"`
TpmPresent bool `xml:"root:TpmPresent"`
}
TrustedPlatformModuleEdit is used to enable/disable TPM on a VM API: POST {vm}/action/editTrustedPlatformModule Content-Type: application/vnd.vmware.vcloud.TpmSection+xml
type VCDDriver ¶
type VCDDriver struct {
// contains filtered or unexported fields
}
func (*VCDDriver) CreateCatalogWithStorageProfile ¶
func (*VCDDriver) CreateVApp ¶
func (*VCDDriver) DeleteCatalog ¶
func (d *VCDDriver) DeleteCatalog(catalog *govcd.AdminCatalog) error
func (*VCDDriver) FindAvailableIP ¶ added in v0.0.2
func (*VCDDriver) FindAvailableIPExcluding ¶ added in v0.0.4
func (*VCDDriver) FindVM ¶
func (d *VCDDriver) FindVM(vdcName, vappName, vmName string) (VirtualMachine, error)
func (*VCDDriver) GetNetworkInfo ¶ added in v0.0.4
GetNetworkInfo returns network configuration (gateway, netmask, DNS) without finding an available IP
func (*VCDDriver) MakeTemplatePoliciesNonFinal ¶ added in v0.0.17
func (d *VCDDriver) MakeTemplatePoliciesNonFinal(template *govcd.VAppTemplate) error
MakeTemplatePoliciesNonFinal fetches the raw XML of a vApp template, sets VmSizingPolicyFinal and VmPlacementPolicyFinal to false via string replacement, and PUTs the modified XML back. This avoids Go struct marshaling issues with VCD's strict XML element ordering for template child VMs.
type VirtualMachine ¶
type VirtualMachine interface {
// Power operations
PowerOn() error
PowerOff() error
Shutdown() error
// Status
GetStatus() (string, error)
IsPoweredOn() (bool, error)
IsPoweredOff() (bool, error)
WaitForPowerOff(ctx context.Context, timeout time.Duration) error
// Network
GetIPAddress() (string, error)
WaitForIP(ctx context.Context, timeout time.Duration) (string, error)
ChangeIPAddress(newIP string) error
// Media operations
InsertMedia(catalogName, mediaName string) error
EjectMedia(catalogName, mediaName string) error
// Hardware configuration
ChangeCPU(cpuCount, coresPerSocket int) error
ChangeMemory(memoryMB int64) error
SetTPM(enabled bool) error
SetBootOptions(bootDelayMs int, efiSecureBoot bool) error
// Info
GetName() string
GetVM() *govcd.VM
Refresh() error
}
VirtualMachine defines the interface for VM operations
type VirtualMachineDriver ¶
type VirtualMachineDriver struct {
// contains filtered or unexported fields
}
func (*VirtualMachineDriver) ChangeCPU ¶
func (v *VirtualMachineDriver) ChangeCPU(cpuCount, coresPerSocket int) error
func (*VirtualMachineDriver) ChangeIPAddress ¶ added in v0.0.4
func (v *VirtualMachineDriver) ChangeIPAddress(newIP string) error
ChangeIPAddress updates the VM's primary NIC IP address
func (*VirtualMachineDriver) ChangeMemory ¶
func (v *VirtualMachineDriver) ChangeMemory(memoryMB int64) error
func (*VirtualMachineDriver) EjectMedia ¶
func (v *VirtualMachineDriver) EjectMedia(catalogName, mediaName string) error
func (*VirtualMachineDriver) GetIPAddress ¶
func (v *VirtualMachineDriver) GetIPAddress() (string, error)
GetIPAddress returns the IP address of the primary NIC
func (*VirtualMachineDriver) GetName ¶
func (v *VirtualMachineDriver) GetName() string
func (*VirtualMachineDriver) GetStatus ¶
func (v *VirtualMachineDriver) GetStatus() (string, error)
func (*VirtualMachineDriver) GetVM ¶
func (v *VirtualMachineDriver) GetVM() *govcd.VM
func (*VirtualMachineDriver) InsertMedia ¶
func (v *VirtualMachineDriver) InsertMedia(catalogName, mediaName string) error
func (*VirtualMachineDriver) IsPoweredOff ¶
func (v *VirtualMachineDriver) IsPoweredOff() (bool, error)
func (*VirtualMachineDriver) IsPoweredOn ¶
func (v *VirtualMachineDriver) IsPoweredOn() (bool, error)
func (*VirtualMachineDriver) PowerOff ¶
func (v *VirtualMachineDriver) PowerOff() error
func (*VirtualMachineDriver) PowerOn ¶
func (v *VirtualMachineDriver) PowerOn() error
func (*VirtualMachineDriver) Refresh ¶
func (v *VirtualMachineDriver) Refresh() error
func (*VirtualMachineDriver) SetBootOptions ¶ added in v0.0.4
func (v *VirtualMachineDriver) SetBootOptions(bootDelayMs int, efiSecureBoot bool) error
func (*VirtualMachineDriver) SetTPM ¶ added in v0.0.4
func (v *VirtualMachineDriver) SetTPM(enabled bool) error
func (*VirtualMachineDriver) Shutdown ¶
func (v *VirtualMachineDriver) Shutdown() error
func (*VirtualMachineDriver) WaitForIP ¶
func (v *VirtualMachineDriver) WaitForIP(ctx context.Context, timeout time.Duration) (string, error)
WaitForIP polls until the VM has an IP address or timeout
func (*VirtualMachineDriver) WaitForPowerOff ¶
type WMKSBootDriver ¶
type WMKSBootDriver struct {
// contains filtered or unexported fields
}
WMKSBootDriver implements bootcommand.BCDriver for WMKS console
func NewWMKSBootDriver ¶
func NewWMKSBootDriver(client *WMKSClient, interval time.Duration) *WMKSBootDriver
NewWMKSBootDriver creates a boot command driver that sends keystrokes via WMKS
func (*WMKSBootDriver) Flush ¶
func (d *WMKSBootDriver) Flush() error
Flush sends any buffered scancodes - WMKS sends immediately so this is a no-op
func (*WMKSBootDriver) SendKey ¶
func (d *WMKSBootDriver) SendKey(key rune, action bootcommand.KeyAction) error
SendKey sends a regular character key
func (*WMKSBootDriver) SendSpecial ¶
func (d *WMKSBootDriver) SendSpecial(special string, action bootcommand.KeyAction) error
SendSpecial sends a special key (like enter, esc, f1, etc.)
type WMKSClient ¶
type WMKSClient struct {
// contains filtered or unexported fields
}
WMKSClient provides console access to a VM via WebMKS protocol
func NewWMKSClient ¶
func NewWMKSClient(ticket *MksTicket, opts ...WMKSOption) *WMKSClient
NewWMKSClient creates a new WMKS client for the given ticket
func (*WMKSClient) Connect ¶
func (c *WMKSClient) Connect() error
Connect establishes the WebSocket connection to the VM console
func (*WMKSClient) SendKey ¶
func (c *WMKSClient) SendKey(scanCode int) error
SendKey sends a key press followed by release
func (*WMKSClient) SendKeyEvent ¶
func (c *WMKSClient) SendKeyEvent(scanCode int, down bool) error
SendKeyEvent sends a single key event (press or release)
func (*WMKSClient) SendSpecialKey ¶
func (c *WMKSClient) SendSpecialKey(keyName string) error
SendSpecialKey sends a special key by name (e.g., "ENTER", "F1", "ESCAPE")
func (*WMKSClient) SendString ¶
func (c *WMKSClient) SendString(s string) error
SendString types a string character by character
type WMKSOption ¶
type WMKSOption func(*WMKSClient)
WMKSOption configures the WMKS client
func WithAuth ¶
func WithAuth(token, header string) WMKSOption
WithAuth sets the VCD authentication token and header
func WithGroupDelay ¶
func WithGroupDelay(d time.Duration) WMKSOption
WithGroupDelay sets the delay after special key sequences
func WithInsecure ¶
func WithInsecure(insecure bool) WMKSOption
WithInsecure allows connecting to servers with invalid TLS certificates
func WithKeyDelay ¶
func WithKeyDelay(d time.Duration) WMKSOption
WithKeyDelay sets the delay between individual key presses