controllers

package
v0.0.0-...-7c1aaf1 Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bridge

type Bridge struct {
	Mutex   sync.Mutex `json:"-" db:"-"`
	ID      uuid.UUID  `json:"id"`
	HV      uuid.UUID  `json:"hv" db:"hv_id"`
	Enabled bool       `json:"enabled"`
	Name    string     `json:"name"`
	Remarks string     `json:"remarks"`
}

type HV

type HV struct {
	ID         uuid.UUID              `json:"id"`
	Hostname   string                 `json:"hostname"`
	AutoUrl    string                 `json:"auto_url" db:"auto_url"`
	AutoSerial string                 `json:"auto_serial" db:"auto_serial"`
	Site       string                 `json:"site"`
	Created    time.Time              `json:"created"`
	Updated    time.Time              `json:"updated"`
	Remarks    string                 `json:"remarks"`
	Mutex      sync.Mutex             `json:"-" db:"-"`
	VMs        map[uuid.UUID]*VM      `json:"-" db:"-"`
	Storages   map[uuid.UUID]*Storage `json:"-" db:"-"` // storage places for VM disks, isos, backups
	Bridges    map[uuid.UUID]*Bridge  `json:"-" db:"-"` // bridges for VMs
	Auto       *auto.Auto             `json:"-" db:"-"` // auto conn details
	Specs      *models.HV             `json:"-" db:"-"` // specs fetched from auto
}

This is the HV struct that will be stored in the DB.

func (*HV) CreateVM

func (hv *HV) CreateVM(ctx context.Context, vm *util.VMCreateRequest, hvid uuid.UUID) (uuid.UUID, error)

func (*HV) DeleteVM

func (hv *HV) DeleteVM(ctx context.Context, vmid string) error

func (*HV) GetVMState

func (hv *HV) GetVMState(vm *VM) (models.VMState, error)

func (*HV) Init

func (hv *HV) Init() error

Initialize the HV Auto connection

func (*HV) InitVMs

func (hv *HV) InitVMs() error

Fetch VMs from the DB and Libvirt, marshall them into the HV struct, and check for inconsistencies

func (*HV) Refresh

func (hv *HV) Refresh() error

func (*HV) SetVMState

func (hv *HV) SetVMState(vm *VM, state string) (models.VMState, error)

type HVList

type HVList struct {
	Mutex sync.Mutex
	HVs   map[uuid.UUID]*HV `json:"hvs"`
}
var Cloud *HVList

The cloud struct that will be used by the rest of the app

func InitCloud

func InitCloud() *HVList

Initialize the cloud struct that will hold all of the hypervisors

type Storage

type Storage struct {
	Mutex      sync.Mutex `json:"-" db:"-"`
	ID         uuid.UUID  `json:"id"`
	HV         uuid.UUID  `json:"hv" db:"hv_id"`
	Enabeld    bool       `json:"enabled" db:"enabled"`
	Type       string     `json:"type" db:"type"`
	Path       string     `json:"path" db:"path"`
	Iso        bool       `json:"iso" db:"iso"`
	Disk       bool       `json:"disk" db:"disk"`
	CloudImage bool       `json:"cloud_image" db:"cloud_image"`
	Remarks    string     `json:"remarks" db:"remarks"`
}

type VM

type VM struct {
	Mutex    sync.Mutex           `json:"-" db:"-"`
	ID       uuid.UUID            `json:"id"`
	HV       uuid.UUID            `json:"hv" db:"hv_id"`
	Hostname string               `json:"hostname"`
	UserID   uuid.UUID            `json:"user" db:"profile_id"`
	CPU      int                  `json:"cpu"`
	Memory   int64                `json:"memory"`
	Nics     map[string]VMNic     `json:"nics" db:"-"`
	Storages map[string]VMStorage `json:"storages" db:"-"`
	Created  time.Time            `json:"created"`
	Updated  time.Time            `json:"updated"`
	Remarks  string               `json:"remarks"`
	Domain   models.VM            `json:"-" db:"-"` // data from libvirt
}

type VMNic

type VMNic struct {
	Mutex  sync.Mutex `db:"-" json:"-"`
	ID     uuid.UUID
	Bridge uuid.UUID

	MAC     string
	IP      []net.IP `db:"-"`
	Created time.Time
	Updated time.Time
	Remarks string
	State   string `db:"-"`
	// contains filtered or unexported fields
}

type VMStorage

type VMStorage struct {
	Mutex   sync.Mutex `db:"-" json:"-"`
	ID      uuid.UUID
	Storage uuid.UUID
	Size    int
	Created time.Time
	Updated time.Time
	Remarks string
}

Jump to

Keyboard shortcuts

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