Documentation ¶
Index ¶
- Constants
- Variables
- func Backends() ([]string, error)
- func BindPort(netType, protocol, port string) (string, string, error)
- func BridgedDevices() ([]string, error)
- func CheckNameExistsHyperV(name string) (bool, error)
- func CheckNameExistsVirtualBox(name string) (bool, error)
- func GetExecutable(virtualizer string) (string, error)
- func HostDevices() ([]string, error)
- func Register(vtype string, allocator VirtualizerAllocator)
- func RegisteredVirtualizers() map[string]VirtualizerAllocator
- func VSwitches() ([]string, error)
- type ListTuple
- type LogChunk
- type Manager
- func (mgr *Manager) Close() error
- func (mgr *Manager) CreateVirtualizer(name, ptype string, data []byte) error
- func (mgr *Manager) DeleteVirtualizer(name string) error
- func (mgr *Manager) DiskAlignment(name string) (vcfg.Bytes, error)
- func (mgr *Manager) DiskFormat(name string) (vdisk.Format, error)
- func (mgr *Manager) List() ([]ListTuple, error)
- func (mgr *Manager) Prepare(name string, args *PrepareArgs) (*VirtualizeOperation, error)
- func (mgr *Manager) ReturnData(name string) ([]byte, error)
- func (mgr *Manager) ValidateArgs(name string) error
- type ManagerArgs
- type NIC
- type NetworkInterface
- type NetworkProtocol
- type NetworkProtocolPorts
- type NetworkRoute
- type PrepareArgs
- type ProgramSummaries
- type RouteMap
- type Routes
- type Source
- type VState
- type VirtualMachine
- type VirtualizeOperation
- type Virtualizer
- type VirtualizerAllocator
Constants ¶
const ( Ready = "ready" Alive = "alive" Broken = "broken" Deleted = "deleted" Changing = "changing" )
Different states for the virtualizer
Variables ¶
var ActiveVMs *syncmap.Map
ActiveVMs is a global sync map that contains current running vms
var IPRegex = regexp.MustCompile(`(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$`)
IPRegex is the regexp to capture an ip address from ip output of a vm
var Powershell string
Powershell is the path to exec from
Functions ¶
func BridgedDevices ¶
BridgedDevices is a virtualbox only function which returns an array of available bridged devices
func CheckNameExistsHyperV ¶
CheckNameExistsHyperV checks the hyperv driver to see if a vm with the same name already exists
func CheckNameExistsVirtualBox ¶
CheckNameExistsVirtualBox checks the virtualbox list to see if a vm with the same name has already been created
func GetExecutable ¶
GetExecutable returns the name of the executable for the virtualizer.
func HostDevices ¶
HostDevices is a virtualbox only function which returns a list of available host devices
func Register ¶
func Register(vtype string, allocator VirtualizerAllocator)
Register Adds a allocator to the map depending on what virtualizer was created
func RegisteredVirtualizers ¶
func RegisteredVirtualizers() map[string]VirtualizerAllocator
RegisteredVirtualizers returns the map purely for testing the register function
Types ¶
type LogChunk ¶
type LogChunk struct { Cursor string `json:"cursor"` More bool `json:"more"` Data string `json:"data"` }
LogChunk is struct to control the Serial Logger output
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is main object which the daemon will interact with
func New ¶
func New(args *ManagerArgs) (*Manager, error)
New creates a new manager the daemon can communicate with.
func (*Manager) Close ¶
Close loops through the current active vms to close them as the manager is closing.
func (*Manager) CreateVirtualizer ¶
CreateVirtualizer creates a virtualizer from the name, type and data required
func (*Manager) DeleteVirtualizer ¶
DeleteVirtualizer removes a virtualizer from the database with the appropriate name
func (*Manager) DiskAlignment ¶
DiskAlignment returns the alignment the disk needs to be for the virtualizer
func (*Manager) DiskFormat ¶
DiskFormat returns the imageformat required for this virtualizer.
func (*Manager) Prepare ¶
func (mgr *Manager) Prepare(name string, args *PrepareArgs) (*VirtualizeOperation, error)
Prepare calls the prepare function of a virtualizer which sets up the ability to spawn a VM.
func (*Manager) ReturnData ¶
ReturnData returns data related to the virtualizer to show a user.
func (*Manager) ValidateArgs ¶
ValidateArgs validates the arguments provided to see if the virtualizer is
type ManagerArgs ¶
type ManagerArgs struct { Logger func(format string, v ...interface{}) DatabaseAddress string FirecrackerPath string // path to folder for vmlinux binaries Passphrase string VMDrive string // path to store vms will be /tmp if not provided }
ManagerArgs are the arguments required to create Virtualizer Manager
type NIC ¶
type NIC struct {
Protocol map[NetworkProtocol]*NetworkProtocolPorts
}
NIC contains information pertaining to a specific network card for the virtual machine.
type NetworkInterface ¶
type NetworkInterface struct { Name string `json:"name"` IP string `json:"ip"` Mask string `json:"mask"` Gateway string `json:"gateway"` UDP []RouteMap `json:"udp"` TCP []RouteMap `json:"tcp"` HTTP []RouteMap `json:"http"` HTTPS []RouteMap `json:"https"` }
NetworkInterface is the routes for the machine
type NetworkProtocol ¶
type NetworkProtocol string
NetworkProtocol is related to the API returning state
type NetworkProtocolPorts ¶
type NetworkProtocolPorts struct {
Port map[string]*NetworkRoute
}
NetworkProtocolPorts contains mappings from the internal ports in use by a Vorteil VM to the network address that can be used to reach them externally.
type NetworkRoute ¶
type NetworkRoute struct {
Address string
}
NetworkRoute contains information representing the valid and complete information needed to connected to a NetworkPort, regardless of NAT or proxying. Standard ports may be omitted, such as port 80 on HTTP, or 443 on HTTPS.
Examples:
NetworkRoute.Address = "192.168.1.1:80" NetworkRoute.Address = "localhost:8080" NetworkRoute.Address = "http://myapp.vorteil.io"
type PrepareArgs ¶
type PrepareArgs struct { Name string // name of the vm PName string // name of virtualizer spawned from Logger elog.View FCPath string // used for firecracker to find vmlinux binaries Context context.Context Start bool // to control whether its to start automatically Config *vcfg.VCFG // the vcfg attached to the VM Source interface{} ImagePath string VMDrive string // path to store disks for vms }
PrepareArgs is a struct that contains what the VM needs to be able to act accordingly.
type ProgramSummaries ¶
type ProgramSummaries struct { Binary string `json:"binary,omitempty"` Args string `json:"args,omitempty"` Env []string `json:"env,omitempty"` }
ProgramSummaries contains the programs that the machine will run
type Routes ¶
type Routes struct {
NIC [4]NIC
}
Routes contains comprehensive information about the network interfaces on a live virtual machine, and how to connect to them. A common example of their use would be as follows.
addr := Routes.NIC[0].Protocol[NetworkProtocolHTTP].Port["80"].Address
type Source ¶
type Source struct { Name string `json:"name"` Type string `json:"type"` Checksum string `json:"checksum"` Icon string `json:"icon"` FileSystem []string `json:"filesystem"` Job string `json:"job"` }
Source is a struct that contains the contents of the virtual machine
type VState ¶
type VState string
VState a type to call for the virtualizers. (ready, alive, broken, deleted, changing)
type VirtualMachine ¶
type VirtualMachine struct { ID string `json:"id"` Instance string `json:"instance"` LogFile string `json:"logFile"` StateLog string `json:"stateLog"` Created time.Time `json:"created"` Status string `json:"status"` State string `json:"state"` Platform string `json:"platform"` Source Source `json:"source"` // build-determined fields Kernel string `json:"kernel"` CPUs int `json:"cpus"` RAM vcfg.Bytes `json:"ram"` Disk vcfg.Bytes `json:"disk"` Programs []ProgramSummaries `json:"programs"` Name string `json:"name"` Author string `json:"author"` Summary string `json:"summary"` URL string `json:"url"` Version string `json:"version"` Date time.Time `json:"date"` // dynamic or semi-dynamic fields Hostname string `json:"hostname"` Networks []NetworkInterface `json:"networks"` // Logs Serial LogChunk `json:"serial"` }
VirtualMachine is a struct that contains details about the virtual machine
type VirtualizeOperation ¶
VirtualizeOperation is a struct that contains ways to log for the operation As it is normally go routined which can't return the error through normal means.
type Virtualizer ¶
type Virtualizer interface { Type() string // Returns what type of virtualizer it is as each virtualizer is actually a VM. I still need the type Initialize(data []byte) error // Initialize the virtualizer using the data provided from the alloc Prepare(args *PrepareArgs) *VirtualizeOperation // Prepare the vm setup args etc State() string // Return the state the vm is currently in Download() (vio.File, error) // Download the disk of the vm Details() (string, string, string, []NetworkInterface, time.Time, *vcfg.VCFG, interface{}) // fetch details relating to the machine Start() error // Start the vm Stop() error // Stop the vm Serial() *logger.Logger // Return the serial output of the vm Close(bool) error // Close the vm is deleting the vm and removing its contents as its not needed anymore. }
Virtualizer is an interface which each virtualzier needs to implement
type VirtualizerAllocator ¶
type VirtualizerAllocator interface { Alloc() Virtualizer // Return the virtualizer ValidateArgs(data []byte) error // Validates the data provided to the virtualizer DiskAlignment() vcfg.Bytes // Returns the appropriate disk alignment required for the virtualizer DiskFormat() vdisk.Format // Returns the appropriate disk format required for the virtualizer IsAvailable() bool // Check if the virtualizer is available on the host's system }
VirtualizerAllocator is an interface which each virtualizer allocator needs to implement