driver

package
v0.0.0-...-66aed2d Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2024 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const APIPA_CIDR = "169.254.0.0/16"
View Source
const FUSION_ADVANCED_MAJOR_MIN = 10
View Source
const HOME_DIR_ENV = "HOME"
View Source
const PORTFWD_PREFIX = "vagrant: "
View Source
const VAGRANT_NETDEV_PREFIX = "vgtnet"
View Source
const VMREST_CONFIG = ".vmrestCfg"
View Source
const VMREST_CONTENT_TYPE = "application/vnd.vmware.vmw.rest-v1+json"
View Source
const VMREST_KEEPALIVE_SECONDS = 300
View Source
const VMREST_URL = "http://localhost:%d/api"
View Source
const VMREST_VAGRANT_DESC = "vagrant: managed port"
View Source
const VMREST_VERSION_CONSTRAINT = ">= 1.2.0"
View Source
const VMWARE_NETDEV_PREFIX = "vmnet"
View Source
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-]+)?`
View Source
const WINDOWS_VMREST_CONFIG = "vmrest.cfg"

Variables

View Source
var Shutdown sync.Cond

Functions

func NewVmrest

func NewVmrest(ctx context.Context, vmrestPath string, logger hclog.Logger) (v *vmrest, err error)

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 NewBaseDriver(vmxPath *string, licenseOverride string, logger hclog.Logger) (*BaseDriver, error)

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) Validate

func (b *BaseDriver) Validate() bool

Validate the VMware installation

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 Client

type Client interface {
	Do(req *http.Request) (r *http.Response, err error)
}

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

func CreateDriver(vmxPath *string, b *BaseDriver, logger hclog.Logger) (Driver, error)

func NewVmrestDriver

func NewVmrestDriver(ctx context.Context, f Driver, logger hclog.Logger) (d Driver, err error)

type MacToIp

type MacToIp struct {
	Vmnet string `json:"vmnet"`
	Mac   string `json:"mac"`
	Ip    string `json:"ip"`
}

type MacToIps

type MacToIps struct {
	Num      int        `json:"num"`
	MacToIps []*MacToIp `json:"mactoips"`
}

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 (t *MockDriver) PrunePortFwds(fwds func(string) (*PortFwds, error), deleter func([]*PortFwd) error) (err error)

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:"-"`
}

func (*PortFwd) Matches

func (p *PortFwd) Matches(fwd *PortFwd) bool

type PortFwdGuest

type PortFwdGuest struct {
	Ip   string `json:"ip"`
	Port int    `json:"port"`
}

type PortFwds

type PortFwds struct {
	Num          int        `json:"num"`
	PortForwards []*PortFwd `json:"port_forwards"`
}

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 Vmnet

type Vmnet struct {
	Name   string `json:"name"`
	Type   string `json:"type"`
	Dhcp   string `json:"dhcp"`
	Subnet string `json:"subnet"`
	Mask   string `json:"mask"`
}

type Vmnets

type Vmnets struct {
	Num    int      `json:"num"`
	Vmnets []*Vmnet `json:"vmnets"`
}

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) Do

func (v *VmrestDriver) Do(method, path string, body io.Reader) (r []byte, err error)

Sends a request to the vmrest service

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) PortFwds

func (v *VmrestDriver) PortFwds(slot string) (*PortFwds, 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()

Jump to

Keyboard shortcuts

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