db

package
v0.0.0-...-41fedb6 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NetworkIDWAN       = "wan"
	NetworkIDBootstrap = "entanglement-bootstrap-network"
)

Variables

This section is empty.

Functions

func Migrate

func Migrate() error

func NullString

func NullString(s string) sql.NullString

Types

type AddNetworkParams

type AddNetworkParams struct {
	ID   string
	Vlan int64
}

type AddNodeParams

type AddNodeParams struct {
	ID        string
	Hostname  string
	Available bool
}

type AddTrunkNetworkParams

type AddTrunkNetworkParams struct {
	Nic     string
	Network string
}

type AssignInstanceToNodeParams

type AssignInstanceToNodeParams struct {
	Node sql.NullString
	ID   string
}

type AssignVolumeToNodeParams

type AssignVolumeToNodeParams struct {
	Node sql.NullString
	ID   string
}

type AttachVolumeToInstanceParams

type AttachVolumeToInstanceParams struct {
	AttachedInstance sql.NullString
	ID               string
}

type CreateInstanceParams

type CreateInstanceParams struct {
	ID         string
	Tenant     string
	Name       string
	Memory     int64
	Cpu        int64
	UserData   []byte
	RootVolume string
	BiosData   sql.NullString
}

type CreateNICParams

type CreateNICParams struct {
	ID       string
	Instance string
	Mac      string
	Ip       string
	Network  string
	Trunk    bool
}

type CreateVolumeParams

type CreateVolumeParams struct {
	ID               string
	Tenant           string
	SourceImage      sql.NullString
	SourceImageQcow2 sql.NullString
	Size             int64
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type DeleteNICParams

type DeleteNICParams struct {
	Instance string
	ID       string
}

type Instance

type Instance struct {
	ID         string
	Tenant     string
	Name       string
	Memory     int64
	Cpu        int64
	Node       sql.NullString
	State      int64
	UserData   []byte
	RootVolume string
	BiosData   sql.NullString
}

func (Instance) GetGRPC

func (i Instance) GetGRPC(ctx context.Context, queries *Queries) (*protos.Instance, error)

func (Instance) GetOpenAPI

func (i Instance) GetOpenAPI(ctx context.Context, queries *Queries) (*openapi.Instance, error)

type InstanceNic

type InstanceNic struct {
	ID       string
	Instance string
	Mac      string
	Ip       string
	Network  string
	Trunk    bool
}

type Network

type Network struct {
	ID   string
	Vlan int64
}

type Node

type Node struct {
	ID        string
	Hostname  string
	Available bool
}

type Queries

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

func Get

func Get() (*Queries, *sql.DB, error)

Get the database and closable DB object example usage:

  queries, dbConn, err := db.Get()
  if err != nil {
	   return err
  }
  defer dbConn.Close()

func New

func New(db DBTX) *Queries

func (*Queries) AddNetwork

func (q *Queries) AddNetwork(ctx context.Context, arg AddNetworkParams) error

func (*Queries) AddNode

func (q *Queries) AddNode(ctx context.Context, arg AddNodeParams) (Node, error)

func (*Queries) AddTrunkNetwork

func (q *Queries) AddTrunkNetwork(ctx context.Context, arg AddTrunkNetworkParams) error

func (*Queries) AssignInstanceToNode

func (q *Queries) AssignInstanceToNode(ctx context.Context, arg AssignInstanceToNodeParams) error

func (*Queries) AssignVolumeToNode

func (q *Queries) AssignVolumeToNode(ctx context.Context, arg AssignVolumeToNodeParams) error

func (*Queries) AttachVolumeToInstance

func (q *Queries) AttachVolumeToInstance(ctx context.Context, arg AttachVolumeToInstanceParams) (int64, error)

func (*Queries) CreateInstance

func (q *Queries) CreateInstance(ctx context.Context, arg CreateInstanceParams) (Instance, error)

Copyright 2021 Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) CreateNIC

func (q *Queries) CreateNIC(ctx context.Context, arg CreateNICParams) error

Copyright 2021 Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) CreateVolume

func (q *Queries) CreateVolume(ctx context.Context, arg CreateVolumeParams) error

Copyright 2021 Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) DeleteInstance

func (q *Queries) DeleteInstance(ctx context.Context, id string) error

func (*Queries) DeleteNIC

func (q *Queries) DeleteNIC(ctx context.Context, arg DeleteNICParams) error

func (*Queries) DeleteNICsByInstance

func (q *Queries) DeleteNICsByInstance(ctx context.Context, instance string) error

func (*Queries) DeleteNode

func (q *Queries) DeleteNode(ctx context.Context, id string) (int64, error)

func (*Queries) DeleteSpecialCases

func (q *Queries) DeleteSpecialCases(ctx context.Context, instance string) error

func (*Queries) DeleteVolume

func (q *Queries) DeleteVolume(ctx context.Context, id string) error

func (*Queries) DetachVolume

func (q *Queries) DetachVolume(ctx context.Context, id string) (int64, error)

func (*Queries) GetAvailableNodes

func (q *Queries) GetAvailableNodes(ctx context.Context) ([]string, error)

func (*Queries) GetImageForVolume

func (q *Queries) GetImageForVolume(ctx context.Context, id string) (sql.NullString, error)

func (*Queries) GetInstance

func (q *Queries) GetInstance(ctx context.Context, id string) (Instance, error)

func (*Queries) GetInstanceAttachedVolumes

func (q *Queries) GetInstanceAttachedVolumes(ctx context.Context, attachedInstance sql.NullString) ([]Volume, error)

func (*Queries) GetInstancesForNode

func (q *Queries) GetInstancesForNode(ctx context.Context, node sql.NullString) ([]Instance, error)

func (*Queries) GetNICsByInstance

func (q *Queries) GetNICsByInstance(ctx context.Context, instance string) ([]InstanceNic, error)

func (*Queries) GetNetworkByID

func (q *Queries) GetNetworkByID(ctx context.Context, id string) (Network, error)

func (*Queries) GetNetworkForVlan

func (q *Queries) GetNetworkForVlan(ctx context.Context, vlan int64) (string, error)

func (*Queries) GetNodeByHostname

func (q *Queries) GetNodeByHostname(ctx context.Context, hostname string) (Node, error)

func (*Queries) GetNodeForInstance

func (q *Queries) GetNodeForInstance(ctx context.Context, id string) (Node, error)

func (*Queries) GetNodes

func (q *Queries) GetNodes(ctx context.Context) ([]Node, error)

Copyright 2021 Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) GetSpecialCases

func (q *Queries) GetSpecialCases(ctx context.Context, instance string) ([]string, error)

func (*Queries) GetTrunkVlans

func (q *Queries) GetTrunkVlans(ctx context.Context, nic string) ([]int64, error)

func (*Queries) GetVlanForNetwork

func (q *Queries) GetVlanForNetwork(ctx context.Context, id string) (int64, error)

func (*Queries) GetVolumeByID

func (q *Queries) GetVolumeByID(ctx context.Context, id string) (Volume, error)

func (*Queries) GetVolumesForNode

func (q *Queries) GetVolumesForNode(ctx context.Context, node sql.NullString) ([]Volume, error)

func (*Queries) ListInstances

func (q *Queries) ListInstances(ctx context.Context, tenant string) ([]Instance, error)

func (*Queries) ListVolumes

func (q *Queries) ListVolumes(ctx context.Context, tenant string) ([]Volume, error)

func (*Queries) RemoveAllNicsOnNetwork

func (q *Queries) RemoveAllNicsOnNetwork(ctx context.Context, network string) ([]string, error)

func (*Queries) RemoveTrunkNetwork

func (q *Queries) RemoveTrunkNetwork(ctx context.Context, arg RemoveTrunkNetworkParams) error

func (*Queries) SetInstanceState

func (q *Queries) SetInstanceState(ctx context.Context, arg SetInstanceStateParams) error

func (*Queries) SetNodeAvailability

func (q *Queries) SetNodeAvailability(ctx context.Context, arg SetNodeAvailabilityParams) (int64, error)

func (*Queries) SetNodeForInstance

func (q *Queries) SetNodeForInstance(ctx context.Context, arg SetNodeForInstanceParams) (int64, error)

func (*Queries) SetNodeHostname

func (q *Queries) SetNodeHostname(ctx context.Context, arg SetNodeHostnameParams) (int64, error)

func (*Queries) SetSpecialCase

func (q *Queries) SetSpecialCase(ctx context.Context, arg SetSpecialCaseParams) error

func (*Queries) SetVolumeState

func (q *Queries) SetVolumeState(ctx context.Context, arg SetVolumeStateParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type RemoveTrunkNetworkParams

type RemoveTrunkNetworkParams struct {
	Nic     string
	Network string
}

type SetInstanceStateParams

type SetInstanceStateParams struct {
	State int64
	ID    string
}

type SetNodeAvailabilityParams

type SetNodeAvailabilityParams struct {
	Available bool
	Hostname  string
}

type SetNodeForInstanceParams

type SetNodeForInstanceParams struct {
	Node sql.NullString
	ID   string
}

type SetNodeHostnameParams

type SetNodeHostnameParams struct {
	Hostname string
	ID       string
}

type SetSpecialCaseParams

type SetSpecialCaseParams struct {
	Instance    string
	SpecialCase string
}

type SetVolumeStateParams

type SetVolumeStateParams struct {
	State int64
	ID    string
}

type SpecialCase

type SpecialCase struct {
	Instance    string
	SpecialCase string
}

type TrunkNetwork

type TrunkNetwork struct {
	Nic     string
	Network string
}

type Volume

type Volume struct {
	ID               string
	Tenant           string
	Node             sql.NullString
	Size             int64
	State            int64
	SourceImage      sql.NullString
	SourceImageQcow2 sql.NullString
	AttachedInstance sql.NullString
}

func (Volume) GetGRPC

func (v Volume) GetGRPC() *protos.Volume

Jump to

Keyboard shortcuts

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