model

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0, Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HYPER_INIT    = ""
	HYPER_CREATED = "created"
	HYPER_ACTIVE  = "active"
)

Variables

View Source
var (
	HyperStatusValues = map[int32]string{
		0: HYPER_CREATED,
		1: HYPER_ACTIVE,
	}
	HyperStatusNames = map[string]int32{
		HYPER_INIT:    0,
		HYPER_CREATED: 0,
		HYPER_ACTIVE:  1,
	}
)

Functions

This section is empty.

Types

type Address

type Address struct {
	Model
	Address   string `gorm:"type:varchar(64)"`
	Netmask   string `gorm:"type:varchar(64)"`
	Type      string `gorm:"type:varchar(20);default:'native'"`
	Allocated bool   `gorm:"default:false"`
	Reserved  bool   `gorm:"default:false"`
	SubnetID  int64
	Subnet    *Subnet `gorm:"foreignkey:SubnetID"`
	Interface int64
}

type Authorize

type Authorize struct {
	Model
	ResourceType string `gorm:"type:varchar(32)"`
	ResourceID   uint
	User         uint
	Project      uint
}

type Callback

type Callback struct {
	gorm.Model
	Status  int32
	Control string `gorm:"type:varchar(256)"`
	Command string `gorm:"type:varchar(65536)"`
	Extra   int32
	Job     Job `gorm:"ForeignKey:JobID"`
	JobID   uint
}

func (*Callback) BeforeCreate

func (cb *Callback) BeforeCreate() (err error)

func (*Callback) LoadRequest

func (cb *Callback) LoadRequest(p *jobs.Job) (err error)

func (*Callback) ToJob

func (cb *Callback) ToJob() (job *Job)

type Console

type Console struct {
	Model
	Instance   int64
	HashSecret string `gorm:"type:varchar(256)"`
	Type       string
}

type Flavor

type Flavor struct {
	Model
	Name      string `gorm:"type:varchar(128)"`
	Cpu       int32
	Memory    int32
	Disk      int32
	Swap      int32
	Ephemeral int32
}

type FloatingIp

type FloatingIp struct {
	Model
	FipAddress string `gorm:"type:varchar(64)"`
	IntAddress string `gorm:"type:varchar(64)"`
	Type       string `gorm:"type:varchar(20)"`
	InstanceID int64
	Instance   *Instance  `gorm:"foreignkey:InstanceID"`
	Interface  *Interface `gorm:"foreignkey:FloatingIp"`
	GatewayID  int64
	Gateway    *Gateway `gorm:"foreignkey:GatewayID"`
	IPAddress  string
}

type Gateway

type Gateway struct {
	Model
	Name       string `gorm:"type:varchar(32)"`
	Status     string `gorm:"type:varchar(32)"`
	Type       string `gorm:"type:varchar(32)"`
	Hyper      int32  `gorm:"default:-1"`
	Peer       int32  `gorm:"default:-1"`
	VrrpVni    int64
	VrrpAddr   string       `gorm:"type:varchar(64)"`
	PeerAddr   string       `gorm:"type:varchar(64)"`
	Interfaces []*Interface `gorm:"foreignkey:Device"`
	Subnets    []*Subnet    `gorm:"many2many:subnet_routers;"`
	ZoneID     int64
	Zone       *Zone `gorm:"foreignkey:ZoneID"`
}

type Glusterfs

type Glusterfs struct {
	Model
	Name      string `gorm:"type:varchar(128)"`
	Endpoint  string `gorm:"type:varchar(256)"`
	Status    string `gorm:"type:varchar(32)"`
	WorkerNum int32
	Flavor    int64
	Key       int64
	HeketiKey int64
	SubnetID  int64
	Subnet    *Subnet `gorm:"foreignkey:SubnetID"`
	ClusterID int64
	ZoneID    int64
}

type Hyper

type Hyper struct {
	ID        int64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	Hostid    int32  `gorm:"unique_index"`
	Hostname  string `gorm:"type:varchar(64)"`
	Status    int32
	Parentid  int32
	Children  int32
	Duration  int64
	HostIP    string
	VirtType  string
	ZoneID    int64
	Zone      *Zone     `gorm:"foreignkey:ZoneID"`
	Resource  *Resource `gorm:"foreignkey:Hostid;AssociationForeignKey:Hostid"`
}

func (*Hyper) LoadCommand

func (hyper *Hyper) LoadCommand(command string)

func (*Hyper) LoadControl

func (hyper *Hyper) LoadControl(control string)

func (*Hyper) LoadRequest

func (hyper *Hyper) LoadRequest(h *hypers.Hyper)

func (*Hyper) ToReply

func (hyper *Hyper) ToReply() (h *hypers.Hyper)

func (*Hyper) Updates

func (hyper *Hyper) Updates(ctx context.Context, values *Hyper) (err error)

type Image

type Image struct {
	Model
	Name         string `gorm:"type:varchar(128)"`
	OSCode       string `gorm:"type:varchar(128)"`
	Format       string `gorm:"type:varchar(128)"`
	Architecture string `gorm:"type:varchar(256)"`
	Status       string `gorm:"type:varchar(128)"`
	Href         string `gorm:"type:varchar(256)"`
	Checksum     string `gorm:"type:varchar(36)"`
	OsHashAlgo   string `gorm:"type:varchar(36)"`
	OsHashValue  string `gorm:"type:varchar(36)"`
	Holder       string `gorm:"type:varchar(36)"`
	Protected    bool
	OpenShiftLB  bool   `gorm:"default:false"`
	Visibility   string `gorm:"type:varchar(36)"`
	MiniDisk     int32
	MiniMem      int32
	Size         int64
	OsVersion    string `gorm:"type:varchar(128)"`
	DiskType     string `gorm:"type:varchar(128)"`
	VirtType     string `gorm:"type:varchar(36)"`
	UserName     string `gorm:"type:varchar(128)"`
}

type Instance

type Instance struct {
	Model
	Hostname    string        `gorm:"type:varchar(128)"`
	Domain      string        `gorm:"type:varchar(128)"`
	Status      string        `gorm:"type:varchar(32)"`
	Reason      string        `gorm:"type:text"`
	FloatingIps []*FloatingIp `gorm:"PRELOAD:false"`
	Volumes     []*Volume     `gorm:"PRELOAD:false"`
	Interfaces  []*Interface  `gorm:"foreignkey:Instance"`
	Portmaps    []*Portmap    `gorm:"foreignkey:instanceID"`
	FlavorID    int64
	Flavor      *Flavor `gorm:"foreignkey:FlavorID"`
	ImageID     int64
	Image       *Image `gorm:"foreignkey:ImageID"`
	ClusterID   int64
	Cluster     *Openshift `gorm:"PRELOAD:false"`
	Keys        []*Key     `gorm:"many2many:InstanceKeys;"`
	Userdata    string     `gorm:"type:text"`
	Hyper       int32      `gorm:"default:-1"`
	ZoneID      int64
	Zone        *Zone `gorm:"foreignkey:ZoneID"`
}

type Interface

type Interface struct {
	Model
	Name       string `gorm:"type:varchar(32)"`
	MacAddr    string `gorm:"type:varchar(32)"`
	Instance   int64
	Device     int64
	Dhcp       int64
	FloatingIp int64
	Subnet     int64
	ZoneID     int64
	Address    *Address `gorm:"foreignkey:Interface"`
	Hyper      int32    `gorm:"default:-1"`
	PrimaryIf  bool     `gorm:"default:false"`
	Type       string   `gorm:"type:varchar(20)"`
	Mtu        int32
	Secgroups  []*SecurityGroup `gorm:"many2many:secgroup_ifaces;"`
	AddrPairs  string           `gorm:"type:varchar(256)"`
}

type Job

type Job struct {
	gorm.Model
	Status     int32
	Control    string `gorm:"type:varchar(256)"`
	Command    string `gorm:"type:text"`
	Extra      int32
	Hooks      string `gorm:"type:varchar(256)"`
	EchoNumber int32
}

func (*Job) BeforeCreate

func (job *Job) BeforeCreate() (err error)

func (*Job) LoadRequest

func (job *Job) LoadRequest(p *jobs.Job)

func (*Job) ToReply

func (job *Job) ToReply() (p *jobs.Job)

type Key

type Key struct {
	Model
	Name        string `gorm:"type:varchar(100)"`
	PublicKey   string `gorm:"type:varchar(8192)"`
	Length      int32
	FingerPrint string `gorm:"type:varchar(100)"`
}

type Member

type Member struct {
	Model
	UserID   int64
	UserName string
	OrgID    int64
	OrgName  string
	Role     Role
}

type Model

type Model struct {
	ID        int64 `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time    `sql:"index"`
	UUID      string        `gorm:"type:varchar(64)"`
	Creater   int64         `gorm:"default:1"` /* The user ID of the resource */
	Owner     int64         `gorm:"default:1"` /* The organization ID of the resource */
	OwnerInfo *Organization `gorm:"PRELOAD:false","foreignkey:Owner"`
}

func (*Model) BeforeCreate

func (m *Model) BeforeCreate() (err error)

type Network

type Network struct {
	Model
	Name     string `gorm:"type:varchar(100)"`
	Hyper    int32  `gorm:"default:-1"`
	Peer     int32  `gorm:"default:-1"`
	Vlan     int64
	Type     string
	External bool      // external router
	Subnets  []*Subnet `gorm:"foreignkey:Vlan;AssociationForeignKey:Vlan;PRELOAD:false"`
}

type Openshift

type Openshift struct {
	Model
	ClusterName           string `gorm:"type:varchar(128)"`
	BaseDomain            string `gorm:"type:varchar(256)"`
	LoadBalancer          string `gorm:"type:varchar(128)"`
	Version               string `gorm:"type:varchar(32)"`
	Status                string `gorm:"type:varchar(32)"`
	Haflag                string
	Instances             []*Instance `gorm:"foreignkey:ClusterID"`
	SubnetID              int64
	Subnet                *Subnet `gorm:"foreignkey:subnetID"`
	WorkerNum             int32
	Flavor                int64
	MasterFlavor          int64
	WorkerFlavor          int64
	Key                   int64
	GlusterID             int64
	ZoneID                int64
	InfrastructureType    string `gorm:"type:varchar(256)"`
	StorageBackend        string `gorm:"type:varchar(256)"`
	AdditionalTrustBundle string `gorm:"type:varchar(256)"`
	ImageContentSources   string `gorm:"type:varchar(256)"`
}

type Organization

type Organization struct {
	Model
	Name      string `gorm:"size:255;unique_index" json:"name,omitempty"`
	DefaultSG int64
	Members   []*Member `gorm:"foreignkey:OrgID"`
	OwnerUser *User     `gorm:"foreignkey:ID";AssociationForeignKey:Owner`
}

func (Organization) TableName

func (Organization) TableName() string

type Portmap

type Portmap struct {
	Model
	Name          string `gorm:"type:varchar(32)"`
	Status        string `gorm:"type:varchar(32)"`
	LocalPort     int32
	LocalAddress  string `gorm:"type:varchar(64)"`
	RemotePort    int32
	RemoteAddress string `gorm:"type:varchar(64)"`
	GatewayID     int64
	Gateway       *Gateway `gorm:"foreignkey:GatewayID"`
	InstanceID    int64
}

type Quota

type Quota struct {
	Model
	Name      string `gorm:"type:varchar(128)"`
	Type      string `gorm:"type:varchar(32)"`
	Cpu       int32
	Memory    int32
	Disk      int32
	Subnet    int32
	PublicIp  int32
	PrivateIp int32
	Gateway   int32
	Volume    int32
	Secgroup  int32
	Secrule   int32
	Instance  int32
	Openshift int32
}

type Registry

type Registry struct {
	Model
	Label           string `gorm:"type:varchar(128)"`
	OcpVersion      string `gorm:"type:varchar(128)"`
	VirtType        string `gorm:"type:varchar(128)"`
	RegistryContent string `gorm:"type:varchar(20480)"`
	Initramfs       string `gorm:"type:varchar(1280)"`
	Kernel          string `gorm:"type:varchar(1280)"`
	Image           string `gorm:"type:varchar(1280)"`
	Installer       string `gorm:"type:varchar(1280)"`
	Cli             string `gorm:"type:varchar(1280)"`
}

type Resource

type Resource struct {
	ID          int64 `gorm:"primary_key"`
	CreatedAt   time.Time
	UpdatedAt   time.Time
	Hostid      int32 `gorm:"unique_index"`
	Cpu         int64
	CpuTotal    int64
	Memory      int64
	MemoryTotal int64
	Disk        int64
	DiskTotal   int64
}

type Role

type Role int
const (
	None   Role = iota /* No permissions  */
	Reader             /* Get List permissions */
	Writer             /* Create Edit Patch permission */
	Owner              /* Invite or Remove user to from org */
	Admin              /* Create user and org */
)

func (Role) String

func (r Role) String() string

type SecurityGroup

type SecurityGroup struct {
	Model
	Name       string       `gorm:"type:varchar(32)"`
	IsDefault  bool         `gorm:"default:false"`
	Interfaces []*Interface `gorm:"many2many:secgroup_ifaces;"`
}

type SecurityRule

type SecurityRule struct {
	Model
	Secgroup    int64
	RemoteIp    string `gorm:"type:varchar(32)"`
	RemoteGroup string `gorm:"type:varchar(36)"`
	Direction   string `gorm:"type:varchar(16)"`
	IpVersion   string `gorm:"type:varchar(12)"`
	Protocol    string `gorm:"type:varchar(20)"`
	PortMin     int32  `gorm:"default:-1"`
	PortMax     int32  `gorm:"default:-1"`
}

func GetSecurityRules

func GetSecurityRules(secGroups []*SecurityGroup) (securityRules []*SecurityRule, err error)

type Session

type Session struct {
	Key    string `gorm:"type:varchar(16);primary_key;not null"`
	Data   []byte
	Expiry int32 `gorm:"not null"`
}

func (Session) TableName

func (Session) TableName() string

type Subnet

type Subnet struct {
	Model
	Name         string `gorm:"type:varchar(32)"`
	Network      string `gorm:"type:varchar(64)"`
	Netmask      string `gorm:"type:varchar(64)"`
	Gateway      string `gorm:"type:varchar(64)"`
	Start        string `gorm:"type:varchar(64)"`
	End          string `gorm:"type:varchar(64)"`
	NameServer   string `gorm:"type:varchar(64)"`
	DomainSearch string `gorm:"type:varchar(256)"`
	Dhcp         string `gorm:"type:varchar(16)"`
	Vlan         int64
	Zones        []*Zone    `gorm:"many2many:subnet_zones;"`
	Routers      []*Gateway `gorm:"many2many:subnet_routers;"`
	Netlink      *Network   `gorm:"foreignkey:Vlan;AssociationForeignKey:Vlan"`
	Type         string     `gorm:"type:varchar(20);default:'internal'"`
	Router       int64
	Routes       string `gorm:"type:varchar(256)"`
	VSwitch      string `gorm:"type:varchar(256)"`
}

type User

type User struct {
	Model
	Username string    `gorm:"size:255;unique_index" json:"username,omitempty"`
	Password string    `gorm:"size:255" json:"password,omitempty"`
	Members  []*Member `gorm:"foreignkey:UserID"`
}

func (User) TableName

func (User) TableName() string

type Vnc

type Vnc struct {
	Model
	LocalAddress  string `gorm:"type:varchar(64)"`
	LocalPort     int32
	AccessAddress string `gorm:"type:varchar(64)"`
	AccessPort    int32
	Passwd        string `gorm:"type:varchar(32)"`
	InstanceID    int64
	Router        int64
	ExpiredAt     *time.Time
}

type Volume

type Volume struct {
	Model
	Name       string `gorm:"type:varchar(128)"`
	Path       string `gorm:"type:varchar(128)"`
	Size       int32
	Format     string `gorm:"type:varchar(32)"`
	Status     string `gorm:"type:varchar(32)"`
	Target     string `gorm:"type:varchar(32)"`
	Href       string `gorm:"type:varchar(256)"`
	InstanceID int64
	Instance   *Instance `gorm:"foreignkey:InstanceID"`
}

type Zone

type Zone struct {
	ID        int64 `gorm:"primary_key"`
	Name      string
	Default   bool
	Subnets   []*Subnet `gorm:"many2many:subnet_zones;"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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