maimok

package
v0.0.0-...-37a8257 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateVM

func CreateVM(state *globalState, createVM CreateVMStruct) error

CreateVM createds a virtual machine

func ForceRestartVM

func ForceRestartVM(state *globalState, name string) error

ForceRestartVM forcefully restarts/resets a VM, like pressing the reset button on a real PC

func ForceStopVM

func ForceStopVM(state *globalState, name string) error

ForceStopVM forcefully stops a VM, like pressing the power button on a real PC

func GetRouter

func GetRouter(state *globalState) chi.Router

GetRouter returns the router configuration

func RestartVM

func RestartVM(state *globalState, name string) error

RestartVM tries to gracefully restart a VM, which might fail

func Run

func Run()

Run is the main entry point

func StartVM

func StartVM(state *globalState, name string) error

StartVM starts a virtual machine with the given name

func StopVM

func StopVM(state *globalState, name string) error

StopVM tries to gracefully stop a VM, which might fail

Types

type Config

type Config struct {
	LibvirtURL string
	Image      string
	SSHKey     string
	Gateway    string
	Netmask    string
}

Config is the structure of the config file on disk

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads configuration from file or environment variables

type CreateVMStruct

type CreateVMStruct struct {
	// Generated
	ID         string
	MACAddress string
	// Provided by API
	Name        string
	Hostname    string
	RAMMB       uint
	DiskSpaceGB uint
	Image       string
	IPAddress   string
	// Set in config file
	SSHKey  string
	Gateway string
	Netmask string
}

CreateVMStruct struct for the CreateVM call

type VM

type VM struct {
	ID      uint   `json:"id"`
	Name    string `json:"name"`
	Memory  uint64 `json:"memory"`
	Running bool   `json:"running"`
}

VM data model

func ListVMs

func ListVMs(state *globalState) []*VM

ListVMs returns a list of all virtual machines

func (*VM) Render

func (rd *VM) Render(w http.ResponseWriter, r *http.Request) error

Render a VM

Jump to

Keyboard shortcuts

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