core

package
v0.0.0-...-19b7e1b Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	DB *gorm.DB
}

func NewDB

func NewDB(path string) (*DB, error)

NewDB returns a new DB connection

func (*DB) AddThing

func (db *DB) AddThing(input thingInput) (*model.Thing, error)

func (*DB) CreateHostdevs

func (db *DB) CreateHostdevs(devices_str [][]string) error

func (*DB) Find_user

func (db *DB) Find_user(username string) (*model.User, error)

func (*DB) GetUserVms

func (db *DB) GetUserVms(id uint) ([]model.Vm, error)

GetUserVms gets vms associated with the user

func (*DB) SaveDev

func (db *DB) SaveDev(dev *model.Hostdev)

func (*DB) SaveThing

func (db *DB) SaveThing(thing *model.Thing)

func (*DB) Savevm

func (db *DB) Savevm(vm *model.Vm)

type DevResolver

type DevResolver struct {
	// contains filtered or unexported fields
}

DevResolver contains the db and the Hostdevice model for resolving

func (*DevResolver) Bus

func (d *DevResolver) Bus(ctx context.Context) *string

Bus resolves the bus field

func (*DevResolver) Device

func (d *DevResolver) Device(ctx context.Context) *string

Device resolves the device field

func (*DevResolver) ID

func (d *DevResolver) ID(ctx context.Context) *graphql.ID

ID resolves the ID for device

func (*DevResolver) Info

func (d *DevResolver) Info(ctx context.Context) *string

Info resolves the info field

type PageInfo

type PageInfo struct {
	// contains filtered or unexported fields
}

PageInfo gives page info for pagination

func (*PageInfo) EndCursor

func (u *PageInfo) EndCursor(ctx context.Context) *graphql.ID

EndCursor ...

func (*PageInfo) HasNextPage

func (u *PageInfo) HasNextPage(ctx context.Context) bool

HasNextPage returns true if there are more results to show

func (*PageInfo) HasPreviousPage

func (u *PageInfo) HasPreviousPage(ctx context.Context) bool

HasPreviousPage returns true if there are results behind the current cursor position

func (*PageInfo) StartCursor

func (u *PageInfo) StartCursor(ctx context.Context) *graphql.ID

StartCursor ...

type Resolver

type Resolver struct {
	Db         *DB
	Controller driver.Provider
}

func (*Resolver) AttachDevice

func (r *Resolver) AttachDevice(args struct{ DevID, VmID graphql.ID }) (*bool, error)

TODO: send udp request to bootstrap only if IP

func (*Resolver) AttachThing

func (r *Resolver) AttachThing(args struct{ ThingID, VmID graphql.ID }) (*bool, error)

TODO: send udp request to bootstrap only if IP

func (*Resolver) CreateThing

func (r *Resolver) CreateThing(ctx context.Context, args struct{ Thing thingInput }) (*ThingResolver, error)

func (*Resolver) CreateThingVm

func (r *Resolver) CreateThingVm(ctx context.Context, args struct {
	Thing thingInput
	VmID  graphql.ID
}) (*ThingResolver, error)

TODO: send udp request to bootstrap if have ip

func (*Resolver) CreateVm

func (r *Resolver) CreateVm(ctx context.Context, args struct{ Vm vmInput }) (*VmResolver, error)

ddVm Resolves the createvm mutation

func (*Resolver) DeleteVm

func (r *Resolver) DeleteVm(args struct{ UserID, VmID graphql.ID }) (*bool, error)

DeleteVm takes care of deleting a vm record

func (*Resolver) DestroyVM

func (r *Resolver) DestroyVM(args struct{ VmID graphql.ID }) (*bool, error)

TODO:

	ERASE VM FROM DATABASE
 DELETE DISK IN DRIVER OPERATION

func (*Resolver) DetachDevice

func (r *Resolver) DetachDevice(args struct{ DevID, VmID graphql.ID }) (*bool, error)

func (*Resolver) ForceOFF

func (r *Resolver) ForceOFF(args struct{ VmID graphql.ID }) (*bool, error)

func (*Resolver) GetDev

func (r *Resolver) GetDev(ctx context.Context, args struct{ ID graphql.ID }) (*DevResolver, error)

GetDev resolves the getDev query

func (*Resolver) GetThing

func (r *Resolver) GetThing(ctx context.Context, args struct{ ID graphql.ID }) (*ThingResolver, error)

func (*Resolver) GetUsb

func (r *Resolver) GetUsb(ctx context.Context) (*[]*DevResolver, error)

func (*Resolver) GetUser

func (r *Resolver) GetUser(ctx context.Context, args struct{ ID graphql.ID }) (*UserResolver, error)

GetUser resolves the getUser query

func (*Resolver) GetUsers

func (r *Resolver) GetUsers(ctx context.Context) (*[]*UserResolver, error)

func (*Resolver) GetVm

func (r *Resolver) GetVm(args struct{ ID graphql.ID }) (*VmResolver, error)

GetVm resolves the getVm query

func (*Resolver) GetVms

func (r *Resolver) GetVms(ctx context.Context) (*[]*VmResolver, error)

func (*Resolver) PowerOFF

func (r *Resolver) PowerOFF(args struct{ VmID graphql.ID }) (*VmResolver, error)

func (*Resolver) PowerON

func (r *Resolver) PowerON(args struct{ VmID graphql.ID }) (*VmResolver, error)

func (*Resolver) UpdateVm

func (r *Resolver) UpdateVm(args struct{ Vm vmInput }) (*VmResolver, error)

UpdateVm takes care of updating any field on the vm

type ThingResolver

type ThingResolver struct {
	// contains filtered or unexported fields
}

func (*ThingResolver) ID

func (t *ThingResolver) ID(ctx context.Context) *graphql.ID

ID resolves the ID for Thing

func (*ThingResolver) Info

func (t *ThingResolver) Info(ctx context.Context) *string

Info resolves the info field

func (*ThingResolver) Name

func (t *ThingResolver) Name(ctx context.Context) *string

Name resolves the name field

type UserResolver

type UserResolver struct {
	// contains filtered or unexported fields
}

UserResolver contains the database and the user model to resolve against

func (*UserResolver) ID

func (u *UserResolver) ID(ctx context.Context) *graphql.ID

ID resolves the user ID

func (*UserResolver) Name

func (u *UserResolver) Name(ctx context.Context) *string

Name resolves the Name field for User, it is all caps to avoid name clashes

func (*UserResolver) Vms

func (u *UserResolver) Vms(ctx context.Context) (*[]*VmResolver, error)

Vms resolves the Vms field for User

func (*UserResolver) VmsConnection

func (u *UserResolver) VmsConnection(ctx context.Context, args vmsConnArgs) (*UserVmsConnectionResolver, error)

VmsConnection returns nodes (vms) connected by edges (relationships)

type UserVmEdge

type UserVmEdge struct {
	// contains filtered or unexported fields
}

UserVmEdge is an edge (related node) that is returned in pagination

func (*UserVmEdge) Cursor

func (u *UserVmEdge) Cursor(ctx context.Context) graphql.ID

Cursor resolves the cursor for pagination

func (*UserVmEdge) Node

func (u *UserVmEdge) Node(ctx context.Context) *VmResolver

Node resolves the node for pagination

type UserVmsConnectionResolver

type UserVmsConnectionResolver struct {
	// contains filtered or unexported fields
}

UserVmsConnectionResolver is all the vms that are connected to a certain user

func (*UserVmsConnectionResolver) Edges

Edges gives a list of all the edges (related vms) that belong to a user

func (*UserVmsConnectionResolver) PageInfo

PageInfo resolves page info

func (UserVmsConnectionResolver) TotalCount

func (u UserVmsConnectionResolver) TotalCount(ctx context.Context) int32

TotalCount gives the total amount of vms in UserVmsConnection

type VmResolver

type VmResolver struct {
	// contains filtered or unexported fields
}

func (*VmResolver) Base

func (p *VmResolver) Base(ctx context.Context) *string

Base resolves the base field for Vm

func (*VmResolver) Dev

func (p *VmResolver) Dev(ctx context.Context) (*[]*DevResolver, error)

Dev resolves the vm devices

func (*VmResolver) ID

func (p *VmResolver) ID(ctx context.Context) *graphql.ID

ID resolves the ID field for Vm

func (*VmResolver) Ip

func (p *VmResolver) Ip(ctx context.Context) *string

func (*VmResolver) Memory

func (p *VmResolver) Memory(ctx context.Context) *int32

memory resolves the memory field for Vm

func (*VmResolver) Name

func (p *VmResolver) Name(ctx context.Context) *string

Name resolves the name field for Vm

func (*VmResolver) Owner

func (p *VmResolver) Owner() (*UserResolver, error)

Owner resolves the owner field for Vm

func (*VmResolver) Things

func (p *VmResolver) Things(ctx context.Context) (*[]*ThingResolver, error)

func (*VmResolver) Vcpu

func (p *VmResolver) Vcpu(ctx context.Context) *int32

vcpu resolves the vcpu field for Vm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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