Documentation ¶
Index ¶
- Constants
- Variables
- func NewVmrest(ctx context.Context, vmrestPath string, logger hclog.Logger) (v *vmrest, err error)
- type AdvancedDriver
- func (a *AdvancedDriver) AddPortFwd(pfwds []*PortFwd) error
- func (a *AdvancedDriver) AddVmnet(vmnet *Vmnet) error
- func (a *AdvancedDriver) DeletePortFwd(pfwds []*PortFwd) error
- func (a *AdvancedDriver) DeleteVmnet(vmnet *Vmnet) error
- func (a *AdvancedDriver) LookupDhcpAddress(device, mac string) (addr string, err error)
- func (a *AdvancedDriver) ReserveDhcpAddress(slot int, mac, ip string) error
- func (a *AdvancedDriver) UpdateVmnet(vmnet *Vmnet) error
- type BaseDriver
- func (b *BaseDriver) AddInternalPortForward(fwd *PortFwd) (err error)
- func (b *BaseDriver) DeleteInternalPortForward(fwd *PortFwd) (err error)
- func (b *BaseDriver) EnableInternalPortForwarding() (err error)
- func (b *BaseDriver) InternalPortForwarding() bool
- func (b *BaseDriver) InternalPortFwds() (fwds []*PortFwd, err error)
- func (b *BaseDriver) LoadNatFile(device string) (*utility.VMWareNatFile, error)
- func (b *BaseDriver) LoadNetworkingFile() (utility.NetworkingFile, error)
- func (b *BaseDriver) Path() (*string, error)
- func (b *BaseDriver) PortFwds(device string) (pfwds *PortFwds, err error)
- func (b *BaseDriver) PrunePortFwds(pfwds func(string) (*PortFwds, error), deleter func([]*PortFwd) error) error
- func (b *BaseDriver) Settings() *settings.Settings
- func (b *BaseDriver) Validate() bool
- func (b *BaseDriver) Validated() bool
- func (b *BaseDriver) ValidationReason() string
- func (b *BaseDriver) VerifyVmnet() (err error)
- func (b *BaseDriver) Vmnets() (*Vmnets, error)
- func (b *BaseDriver) VmwareInfo() (*VmwareInfo, error)
- func (b *BaseDriver) VmwarePaths() *utility.VmwarePaths
- type Client
- type Driver
- type MacToIp
- type MacToIps
- type MockDriver
- func (t *MockDriver) AddPortFwd(fwds []*PortFwd) (err error)
- func (t *MockDriver) AddVmnet(v *Vmnet) (err error)
- func (t *MockDriver) DeletePortFwd(fwds []*PortFwd) (err error)
- func (t *MockDriver) DeleteVmnet(v *Vmnet) (err error)
- func (t *MockDriver) LoadNetworkingFile() (f utility.NetworkingFile, err error)
- func (t *MockDriver) LookupDhcpAddress(device, mac string) (ip string, err error)
- func (t *MockDriver) Path() (p *string, err error)
- func (t *MockDriver) PortFwds(device string) (fwds *PortFwds, err error)
- func (t *MockDriver) PrunePortFwds(fwds func(string) (*PortFwds, error), deleter func([]*PortFwd) error) (err error)
- func (t *MockDriver) ReserveDhcpAddress(slot int, mac, ip string) (err error)
- func (t *MockDriver) UpdateVmnet(v *Vmnet) (err error)
- func (t *MockDriver) Validate() bool
- func (t *MockDriver) Validated() bool
- func (t *MockDriver) ValidationReason() (r string)
- func (t *MockDriver) VerifyVmnet() (err error)
- func (t *MockDriver) Vmnets() (v *Vmnets, err error)
- func (t *MockDriver) VmwareInfo() (info *VmwareInfo, err error)
- func (t *MockDriver) VmwarePaths() (p *utility.VmwarePaths)
- type PortFwd
- type PortFwdGuest
- type PortFwds
- type SimpleDriver
- func (s *SimpleDriver) AddPortFwd(pfwds []*PortFwd) error
- func (s *SimpleDriver) AddVmnet(vmnet *Vmnet) error
- func (s *SimpleDriver) DeletePortFwd(pfwds []*PortFwd) error
- func (s *SimpleDriver) DeleteVmnet(vmnet *Vmnet) error
- func (s *SimpleDriver) LookupDhcpAddress(device, mac string) (addr string, err error)
- func (s *SimpleDriver) ReserveDhcpAddress(slot int, mac, ip string) error
- func (s *SimpleDriver) UpdateVmnet(vmnet *Vmnet) error
- type Vmnet
- type Vmnets
- type VmrestDriver
- func (v *VmrestDriver) AddPortFwd(pfwds []*PortFwd) (err error)
- func (v *VmrestDriver) AddVmnet(vnet *Vmnet) (err error)
- func (v *VmrestDriver) DeletePortFwd(pfwds []*PortFwd) (err error)
- func (v *VmrestDriver) DeleteVmnet(vnet *Vmnet) (err error)
- func (v *VmrestDriver) Do(method, path string, body io.Reader) (r []byte, err error)
- func (v *VmrestDriver) LoadNetworkingFile() (utility.NetworkingFile, error)
- func (v *VmrestDriver) LookupDhcpAddress(device string, mac string) (addr string, err error)
- func (v *VmrestDriver) PortFwds(slot string) (*PortFwds, error)
- func (v *VmrestDriver) ReserveDhcpAddress(slot int, mac string, ip string) (err error)
- func (v *VmrestDriver) UpdateVmnet(vnet *Vmnet) (err error)
- func (v *VmrestDriver) VerifyVmnet() error
- func (v *VmrestDriver) Vmnets() (vmns *Vmnets, err error)
- type VmwareInfo
Constants ¶
const APIPA_CIDR = "169.254.0.0/16"
const FUSION_ADVANCED_MAJOR_MIN = 10
const HOME_DIR_ENV = "HOME"
const PORTFWD_PREFIX = "vagrant: "
const VAGRANT_NETDEV_PREFIX = "vgtnet"
const VMREST_CONFIG = ".vmrestCfg"
const VMREST_CONTENT_TYPE = "application/vnd.vmware.vmw.rest-v1+json"
const VMREST_KEEPALIVE_SECONDS = 300
const VMREST_URL = "http://localhost:%d/api"
const VMREST_VAGRANT_DESC = "vagrant: managed port"
const VMREST_VERSION_CONSTRAINT = ">= 1.2.0"
const VMWARE_NETDEV_PREFIX = "vmnet"
const VMWARE_VERSION_PATTERN = `(?i)VMware\s+(?P<product>[A-Za-z0-9-]+)\s+(?P<version>[\d.]+|e.x.p)\s*(?P<build>\S+)?\s*(?P<type>[A-Za-z0-9-]+)?`
const WINDOWS_VMREST_CONFIG = "vmrest.cfg"
Variables ¶
var Shutdown sync.Cond
Functions ¶
Types ¶
type AdvancedDriver ¶
type AdvancedDriver struct { BaseDriver // contains filtered or unexported fields }
func NewAdvancedDriver ¶
func NewAdvancedDriver(vmxPath *string, b *BaseDriver, logger hclog.Logger) (a *AdvancedDriver, err error)
func (*AdvancedDriver) AddPortFwd ¶
func (a *AdvancedDriver) AddPortFwd(pfwds []*PortFwd) error
When adding a port forward we use the networking file utility to write the new rules directly into the file. The vnetlib CLI does not support custom descriptions used for forward rules, so we just do it manually.
func (*AdvancedDriver) AddVmnet ¶
func (a *AdvancedDriver) AddVmnet(vmnet *Vmnet) error
func (*AdvancedDriver) DeletePortFwd ¶
func (a *AdvancedDriver) DeletePortFwd(pfwds []*PortFwd) error
For deletion of the port forward we can just use the vnetlib CLI directly as we no longer care about the description
func (*AdvancedDriver) DeleteVmnet ¶
func (a *AdvancedDriver) DeleteVmnet(vmnet *Vmnet) error
func (*AdvancedDriver) LookupDhcpAddress ¶
func (a *AdvancedDriver) LookupDhcpAddress(device, mac string) (addr string, err error)
Lookup reserved DHCP address for MAC
func (*AdvancedDriver) ReserveDhcpAddress ¶
func (a *AdvancedDriver) ReserveDhcpAddress(slot int, mac, ip string) error
func (*AdvancedDriver) UpdateVmnet ¶
func (a *AdvancedDriver) UpdateVmnet(vmnet *Vmnet) error
type BaseDriver ¶
type BaseDriver struct { Natfile func(string) (*utility.VMWareNatFile, error) Networkingfile func() (utility.NetworkingFile, error) Vmrun service.Vmrun VmwareServices service.VmwareServices // contains filtered or unexported fields }
func NewBaseDriver ¶
func NewBaseDriverMock ¶
func NewBaseDriverMock() *BaseDriver
func (*BaseDriver) AddInternalPortForward ¶
func (b *BaseDriver) AddInternalPortForward(fwd *PortFwd) (err error)
func (*BaseDriver) DeleteInternalPortForward ¶
func (b *BaseDriver) DeleteInternalPortForward(fwd *PortFwd) (err error)
func (*BaseDriver) EnableInternalPortForwarding ¶
func (b *BaseDriver) EnableInternalPortForwarding() (err error)
func (*BaseDriver) InternalPortForwarding ¶
func (b *BaseDriver) InternalPortForwarding() bool
func (*BaseDriver) InternalPortFwds ¶
func (b *BaseDriver) InternalPortFwds() (fwds []*PortFwd, err error)
func (*BaseDriver) LoadNatFile ¶
func (b *BaseDriver) LoadNatFile(device string) (*utility.VMWareNatFile, error)
func (*BaseDriver) LoadNetworkingFile ¶
func (b *BaseDriver) LoadNetworkingFile() (utility.NetworkingFile, error)
func (*BaseDriver) Path ¶
func (b *BaseDriver) Path() (*string, error)
func (*BaseDriver) PortFwds ¶
func (b *BaseDriver) PortFwds(device string) (pfwds *PortFwds, err error)
Generate current list of port forwards for given device
func (*BaseDriver) PrunePortFwds ¶
func (b *BaseDriver) PrunePortFwds(pfwds func(string) (*PortFwds, error), deleter func([]*PortFwd) error) error
Prune any port
func (*BaseDriver) Settings ¶
func (b *BaseDriver) Settings() *settings.Settings
func (*BaseDriver) Validated ¶
func (b *BaseDriver) Validated() bool
func (*BaseDriver) ValidationReason ¶
func (b *BaseDriver) ValidationReason() string
func (*BaseDriver) VerifyVmnet ¶
func (b *BaseDriver) VerifyVmnet() (err error)
Verify the VMware networking services are up and healthy
func (*BaseDriver) Vmnets ¶
func (b *BaseDriver) Vmnets() (*Vmnets, error)
Generate current list of vmnets
func (*BaseDriver) VmwareInfo ¶
func (b *BaseDriver) VmwareInfo() (*VmwareInfo, error)
Find installed VMware product information
func (*BaseDriver) VmwarePaths ¶
func (b *BaseDriver) VmwarePaths() *utility.VmwarePaths
type Driver ¶
type Driver interface { AddInternalPortForward(fwd *PortFwd) error AddPortFwd(fwds []*PortFwd) error AddVmnet(v *Vmnet) error DeleteInternalPortForward(fwd *PortFwd) error DeletePortFwd(fwds []*PortFwd) error DeleteVmnet(v *Vmnet) error EnableInternalPortForwarding() error InternalPortFwds() (fwds []*PortFwd, err error) LoadNetworkingFile() (f utility.NetworkingFile, err error) LookupDhcpAddress(device, mac string) (addr string, err error) Path() (path *string, err error) PortFwds(device string) (fwds *PortFwds, err error) PrunePortFwds(fwds func(string) (*PortFwds, error), deleter func([]*PortFwd) error) error ReserveDhcpAddress(slot int, mac, ip string) error Settings() *settings.Settings UpdateVmnet(v *Vmnet) error Validated() bool Validate() bool ValidationReason() string VerifyVmnet() error Vmnets() (v *Vmnets, err error) VmwareInfo() (info *VmwareInfo, err error) VmwarePaths() *utility.VmwarePaths }
func CreateDriver ¶
type MockDriver ¶
type MockDriver struct{}
func (*MockDriver) AddPortFwd ¶
func (t *MockDriver) AddPortFwd(fwds []*PortFwd) (err error)
func (*MockDriver) AddVmnet ¶
func (t *MockDriver) AddVmnet(v *Vmnet) (err error)
func (*MockDriver) DeletePortFwd ¶
func (t *MockDriver) DeletePortFwd(fwds []*PortFwd) (err error)
func (*MockDriver) DeleteVmnet ¶
func (t *MockDriver) DeleteVmnet(v *Vmnet) (err error)
func (*MockDriver) LoadNetworkingFile ¶
func (t *MockDriver) LoadNetworkingFile() (f utility.NetworkingFile, err error)
func (*MockDriver) LookupDhcpAddress ¶
func (t *MockDriver) LookupDhcpAddress(device, mac string) (ip string, err error)
func (*MockDriver) Path ¶
func (t *MockDriver) Path() (p *string, err error)
func (*MockDriver) PortFwds ¶
func (t *MockDriver) PortFwds(device string) (fwds *PortFwds, err error)
func (*MockDriver) PrunePortFwds ¶
func (*MockDriver) ReserveDhcpAddress ¶
func (t *MockDriver) ReserveDhcpAddress(slot int, mac, ip string) (err error)
func (*MockDriver) UpdateVmnet ¶
func (t *MockDriver) UpdateVmnet(v *Vmnet) (err error)
func (*MockDriver) Validate ¶
func (t *MockDriver) Validate() bool
func (*MockDriver) Validated ¶
func (t *MockDriver) Validated() bool
func (*MockDriver) ValidationReason ¶
func (t *MockDriver) ValidationReason() (r string)
func (*MockDriver) VerifyVmnet ¶
func (t *MockDriver) VerifyVmnet() (err error)
func (*MockDriver) Vmnets ¶
func (t *MockDriver) Vmnets() (v *Vmnets, err error)
func (*MockDriver) VmwareInfo ¶
func (t *MockDriver) VmwareInfo() (info *VmwareInfo, err error)
func (*MockDriver) VmwarePaths ¶
func (t *MockDriver) VmwarePaths() (p *utility.VmwarePaths)
type PortFwd ¶
type PortFwd struct { Port int `json:"port"` Protocol string `json:"protocol"` Description string `json:"description"` Guest *PortFwdGuest `json:"guest"` SlotNumber int `json:"-"` }
type PortFwdGuest ¶
type SimpleDriver ¶
type SimpleDriver struct {
BaseDriver
}
Simple driver is used where the vnet lib is not public requiring full network service modifications (Workstation Linux)
func NewSimpleDriver ¶
func NewSimpleDriver(vmxPath *string, b *BaseDriver, logger hclog.Logger) (s *SimpleDriver, err error)
func (*SimpleDriver) AddPortFwd ¶
func (s *SimpleDriver) AddPortFwd(pfwds []*PortFwd) error
func (*SimpleDriver) AddVmnet ¶
func (s *SimpleDriver) AddVmnet(vmnet *Vmnet) error
func (*SimpleDriver) DeletePortFwd ¶
func (s *SimpleDriver) DeletePortFwd(pfwds []*PortFwd) error
func (*SimpleDriver) DeleteVmnet ¶
func (s *SimpleDriver) DeleteVmnet(vmnet *Vmnet) error
func (*SimpleDriver) LookupDhcpAddress ¶
func (s *SimpleDriver) LookupDhcpAddress(device, mac string) (addr string, err error)
Lookup reserved DHCP address for MAC
func (*SimpleDriver) ReserveDhcpAddress ¶
func (s *SimpleDriver) ReserveDhcpAddress(slot int, mac, ip string) error
func (*SimpleDriver) UpdateVmnet ¶
func (s *SimpleDriver) UpdateVmnet(vmnet *Vmnet) error
type VmrestDriver ¶
type VmrestDriver struct { BaseDriver // contains filtered or unexported fields }
func (*VmrestDriver) AddPortFwd ¶
func (v *VmrestDriver) AddPortFwd(pfwds []*PortFwd) (err error)
func (*VmrestDriver) AddVmnet ¶
func (v *VmrestDriver) AddVmnet(vnet *Vmnet) (err error)
func (*VmrestDriver) DeletePortFwd ¶
func (v *VmrestDriver) DeletePortFwd(pfwds []*PortFwd) (err error)
func (*VmrestDriver) DeleteVmnet ¶
func (v *VmrestDriver) DeleteVmnet(vnet *Vmnet) (err error)
func (*VmrestDriver) LoadNetworkingFile ¶
func (v *VmrestDriver) LoadNetworkingFile() (utility.NetworkingFile, error)
func (*VmrestDriver) LookupDhcpAddress ¶
func (v *VmrestDriver) LookupDhcpAddress(device string, mac string) (addr string, err error)
func (*VmrestDriver) ReserveDhcpAddress ¶
func (v *VmrestDriver) ReserveDhcpAddress(slot int, mac string, ip string) (err error)
func (*VmrestDriver) UpdateVmnet ¶
func (v *VmrestDriver) UpdateVmnet(vnet *Vmnet) (err error)
func (*VmrestDriver) VerifyVmnet ¶
func (v *VmrestDriver) VerifyVmnet() error
func (*VmrestDriver) Vmnets ¶
func (v *VmrestDriver) Vmnets() (vmns *Vmnets, err error)
type VmwareInfo ¶
type VmwareInfo struct { Product string `json:"product"` Version string `json:"version"` Build string `json:"build"` Type string `json:"type"` License string `json:"license"` }
func (*VmwareInfo) IsProfessional ¶
func (v *VmwareInfo) IsProfessional() bool
func (*VmwareInfo) IsStandard ¶
func (v *VmwareInfo) IsStandard() bool
func (*VmwareInfo) Normalize ¶
func (v *VmwareInfo) Normalize()