models

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewIPOption

func NewIPOption(t layers.DHCPOpt, v net.IP) layers.DHCPOption

func NewInt32Option

func NewInt32Option(t layers.DHCPOpt, v int) layers.DHCPOption

func NewStringOption

func NewStringOption(t layers.DHCPOpt, v string) layers.DHCPOption

func NewUint16Option

func NewUint16Option(t layers.DHCPOpt, v int) layers.DHCPOption

func NewUint32Option

func NewUint32Option(t layers.DHCPOpt, v int) layers.DHCPOption

Types

type APIError

type APIError struct {
	ErrorStatus  int    `json:"error_status"`
	ErrorMessage string `json:"error_message"`
}

type Address

type Address struct {
	ID int `json:"id" gorm:"primary_key"`

	Pool  Pool  `json:"pool" gorm:"foreignkey:PoolID"`
	Group Group `json:"group" gorm:"foreignkey:GroupID"`

	AddressForm

	FirstSeen time.Time `json:"first_seen"`
	LastSeen  time.Time `json:"last_seen"`

	// DHCP parameters
	LastSeenRelay  string    `json:"last_seen_relay" gorm:"type:varchar(15)"`
	MissingOptions string    `json:"missing_options" gorm:"type:varchar(255)"`
	Expires        time.Time `json:"expires_at"`

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

type AddressForm

type AddressForm struct {
	IP           string    `json:"ip" gorm:"type:varchar(15);not null;index:uniqIp,unique"`
	Mac          string    `json:"mac" gorm:"type:varchar(17);not null"`
	Hostname     string    `json:"hostname" gorm:"type:varchar(255)"`
	Domain       string    `json:"domain" gorm:"type:varchar(255)"`
	Reimage      bool      `json:"reimage" gorm:"type:bool;index:uniqIp,unique"`
	PoolID       NullInt32 `json:"pool_id" gorm:"type:BIGINT" swaggertype:"integer"`
	GroupID      NullInt32 `json:"group_id" gorm:"type:BIGINT" swaggertype:"integer"`
	Progress     int       `json:"progress" gorm:"type:INT"`
	Progresstext string    `json:"progresstext" gorm:"type:varchar(255)"`
	Ks           string    `json:"ks" gorm:"type:text"`
}

type DeviceClass

type DeviceClass struct {
	ID int `json:"id" gorm:"primary_key"`

	DeviceClassForm

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

type DeviceClassForm

type DeviceClassForm struct {
	Name        string `json:"name" gorm:"type:varchar(255)"`
	VendorClass string `json:"vendor_class" gorm:"type:varchar(255)"`
}

type Group

type Group struct {
	ID int `json:"id" gorm:"primary_key"`

	GroupForm

	Pool    *Pool     `json:"pool,omitempty" gorm:"foreignkey:PoolID"`
	Option  []Option  `json:"option,omitempty" gorm:"foreignkey:PoolID"`
	Address []Address `json:"address,omitempty" gorm:"foreignkey:GroupID"`

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

type GroupForm

type GroupForm struct {
	PoolID      int            `json:"pool_id" gorm:"type:BIGINT"`
	Name        string         `json:"name" gorm:"type:varchar(255)"`
	DNS         string         `json:"dns" gorm:"type:varchar(255)"`
	NTP         string         `json:"ntp" gorm:"type:varchar(255)"`
	Password    string         `json:"password" gorm:"type:varchar(255)"`
	ImageID     int            `json:"image_id" gorm:"type:INT"`
	Ks          string         `json:"ks" gorm:"type:text"`
	Syslog      string         `json:"syslog" gorm:"type:varchar(255)"`
	Vlan        string         `json:"vlan" gorm:"type:INT"`
	CallbackURL string         `json:"callbackurl"`
	BootDisk    string         `json:"bootdisk" gorm:"type:varchar(255)"`
	Options     datatypes.JSON `json:"options" sql:"type:JSONB" swaggertype:"object,string"`
}

type GroupOptions

type GroupOptions struct {
	SSH                  bool `json:"ssh"`
	SuppressShellWarning bool `json:"suppressshellwarning"`
	EraseDisks           bool `json:"erasedisks"`
	AllowLegacyCPU       bool `json:"allowlegacycpu"`
	Certificate          bool `json:"certificate"`
	CreateVMFS           bool `json:"createvmfs"`
}

type Image

type Image struct {
	ID int `json:"id" gorm:"primary_key"`

	ImageForm

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

type ImageForm

type ImageForm struct {
	ISOImage    string `json:"iso_image" gorm:"type:varchar(255)"`
	Path        string `json:"path" gorm:"type:varchar(255)"`
	Size        int64  `json:"size" gorm:"type:BIGINT"`
	Hash        string `json:"hash" gorm:"type:varchar(255)"`
	Description string `json:"description" gorm:"type:text"`
}

type NoPWGroup added in v0.3.20

type NoPWGroup struct {
	ID int `json:"id" gorm:"primary_key"`

	NoPWGroupForm

	Pool    *Pool     `json:"pool,omitempty" gorm:"foreignkey:PoolID"`
	Option  []Option  `json:"option,omitempty" gorm:"foreignkey:PoolID"`
	Address []Address `json:"address,omitempty" gorm:"foreignkey:GroupID"`

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (NoPWGroup) TableName added in v0.3.20

func (NoPWGroup) TableName() string

type NoPWGroupForm added in v0.3.20

type NoPWGroupForm struct {
	PoolID      int            `json:"pool_id" gorm:"type:BIGINT"`
	Name        string         `json:"name" gorm:"type:varchar(255)"`
	DNS         string         `json:"dns" gorm:"type:varchar(255)"`
	NTP         string         `json:"ntp" gorm:"type:varchar(255)"`
	ImageID     int            `json:"image_id" gorm:"type:INT"`
	Ks          string         `json:"ks" gorm:"type:text"`
	Syslog      string         `json:"syslog" gorm:"type:varchar(255)"`
	Vlan        string         `json:"vlan" gorm:"type:INT"`
	CallbackURL string         `json:"callbackurl"`
	BootDisk    string         `json:"bootdisk" gorm:"type:varchar(255)"`
	Options     datatypes.JSON `json:"options" sql:"type:JSONB" swaggertype:"object,string"`
}

type NullInt32

type NullInt32 struct {
	sql.NullInt32
}

func (NullInt32) MarshalJSON

func (r NullInt32) MarshalJSON() ([]byte, error)

NullInt64 MarshalJSON interface redefinition

func (*NullInt32) UnmarshalJSON

func (ns *NullInt32) UnmarshalJSON(text []byte) error

type Option

type Option struct {
	ID int `json:"id" gorm:"primary_key"`

	OptionForm

	Pool    *Pool    `json:"pool,omitempty" gorm:"foreignkey:PoolID"`
	Address *Address `json:"address,omitempty" gorm:"foreignkey:AddressID"`

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (Option) Level

func (o Option) Level() int

func (Option) ToDHCPOption

func (o Option) ToDHCPOption() (opt layers.DHCPOption, merge bool, err error)

type OptionForm

type OptionForm struct {
	PoolID        int    `json:"pool_id" gorm:"type:BIGINT"`
	AddressID     int    `json:"address_id" gorm:"type:BIGINT"`
	DeviceClassID int    `json:"device_class_id" gorm:"type:BIGINT"`
	OpCode        byte   `json:"opcode" gorm:"type:SMALLINT;unsigned;not null" binding:"required" `
	Data          string `json:"data" gorm:"type:varchar(255);not null" binding:"required" `
	Priority      int    `json:"priority" gorm:"type:SMALLINT;not null" binding:"required" `
}

type Pool

type Pool struct {
	ID int `json:"id" gorm:"primary_key"`

	NetAddress string `json:"net_address" gorm:"type:varchar(15);not null"`
	PoolForm

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

func (*Pool) BeforeCreate

func (p *Pool) BeforeCreate(tx *gorm.DB) error

func (*Pool) BeforeSave

func (p *Pool) BeforeSave(tx *gorm.DB) error

func (*Pool) LastAddr

func (p *Pool) LastAddr() (net.IP, error)

Credit to Mikio Hara and pnovotnak https://stackoverflow.com/questions/36166791/how-to-get-broadcast-address-of-ipv4-net-ipnet

type PoolForm

type PoolForm struct {
	Name             string `json:"name" gorm:"type:varchar(255);not null" binding:"required" `
	StartAddress     string `json:"start_address" gorm:"type:varchar(15);not null" binding:"required" `
	EndAddress       string `json:"end_address" gorm:"type:varchar(15);not null" binding:"required" `
	Netmask          int    `json:"netmask" gorm:"type:integer;not null" binding:"required" `
	LeaseTime        int    `json:"lease_time" gorm:"type:bigint" binding:"required" `
	Gateway          string `json:"gateway" gorm:"type:varchar(15)" binding:"required" `
	OnlyServeReimage bool   `json:"only_serve_reimage" gorm:"type:boolean"`

	AuthorizedVlan int    `json:"authorized_vlan" gorm:"type:bigint"`
	ManagedRef     string `json:"managed_reference"`
}

type PoolWithAddresses

type PoolWithAddresses struct {
	Pool
	Addresses []Address `json:"address,omitempty" gorm:"foreignkey:PoolID"`
}

func (*PoolWithAddresses) Contains

func (p *PoolWithAddresses) Contains(ip net.IP) (bool, error)

func (*PoolWithAddresses) IsAvailable

func (p *PoolWithAddresses) IsAvailable(ip net.IP) error

func (*PoolWithAddresses) IsAvailableExcept

func (p *PoolWithAddresses) IsAvailableExcept(ip net.IP, exclude string) error

func (*PoolWithAddresses) Next

func (p *PoolWithAddresses) Next() (ip net.IP, err error)

Next returns the next free address in the pool (that is not reserved nor already leased)

type User

type User struct {
	ID int `json:"id" gorm:"primary_key"`

	UserForm

	CreatedAt time.Time  `json:"created_at"`
	UpdatedAt time.Time  `json:"updated_at"`
	DeletedAt *time.Time `json:"deleted_at,omitempty"`
}

type UserForm

type UserForm struct {
	Username string `json:"username" gorm:"type:varchar(255)"`
	Password string `json:"password" gorm:"type:varchar(255)"`
	Email    string `json:"email" gorm:"type:varchar(255)"`
	Comment  string `json:"comment" gorm:"type:varchar(255)"`
}

Jump to

Keyboard shortcuts

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