add proxmoxaas-common-lib dependency, update types and functions to use proxmoxaas-common-lib
This commit is contained in:
+15
-86
@@ -1,5 +1,7 @@
|
||||
package app
|
||||
|
||||
import paas "proxmoxaas-common-lib"
|
||||
|
||||
type Backend interface {
|
||||
NewPool(poolname string) (int, error)
|
||||
DelPool(poolname string) (int, error)
|
||||
@@ -13,89 +15,16 @@ type Backend interface {
|
||||
DelUserFromGroup(username Username, groupname Groupname) (int, error)
|
||||
}
|
||||
|
||||
type Pool struct {
|
||||
PoolID string `json:"poolid"`
|
||||
Path string `json:"-"` // typically /pool/poolid from proxmox, only used internally
|
||||
Groups []Group `json:"groups"`
|
||||
Resources map[string]any `json:"resources"`
|
||||
Templates Templates `json:"templates"`
|
||||
AllowedNodes map[string]bool `json:"nodes-allowed"`
|
||||
VMIDRange VMID `json:"vmid-allowed"`
|
||||
Backups Backups `json:"backups-allowed"` // measured in numbers
|
||||
}
|
||||
|
||||
// proxmox typically formats as gid-realm for non pve realms
|
||||
// proxmox realms are formatted without realm values
|
||||
// I assume that backends store groups by ID only and only proxmox will append the realm string
|
||||
type Groupname struct {
|
||||
GroupID string `json:"gid"`
|
||||
Realm string `json:"realm"`
|
||||
}
|
||||
|
||||
type Group struct {
|
||||
Groupname Groupname `json:"groupname"`
|
||||
Role string `json:"role"` // role in owner pool
|
||||
Users []User `json:"users"`
|
||||
}
|
||||
|
||||
type Username struct { // ie userid@realm
|
||||
UserID string `json:"uid"`
|
||||
Realm string `json:"realm"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
Username Username `json:"username"`
|
||||
CN string `json:"cn"` // aka first name
|
||||
SN string `json:"sn"` // aka last name
|
||||
Mail string `json:"mail"`
|
||||
Password string `json:"password"` // only used for POST requests
|
||||
}
|
||||
|
||||
type VMID struct {
|
||||
Min int `json:"min"`
|
||||
MAx int `json:"max"`
|
||||
}
|
||||
|
||||
type Backups struct {
|
||||
Max int `json:"max"`
|
||||
}
|
||||
|
||||
type Templates struct {
|
||||
Instances struct {
|
||||
LXC map[string]ResourceTemplate `json:"lxc"`
|
||||
QEMU map[string]ResourceTemplate `json:"qemu"`
|
||||
} `json:"instances"`
|
||||
}
|
||||
|
||||
type SimpleResource struct {
|
||||
Limits struct {
|
||||
Global SimpleLimit `json:"global"`
|
||||
Nodes map[string]SimpleLimit `json:"nodes"`
|
||||
} `json:"limits"`
|
||||
}
|
||||
|
||||
type SimpleLimit struct {
|
||||
Max int `json:"max"`
|
||||
}
|
||||
|
||||
type MatchResource struct {
|
||||
Limits struct {
|
||||
Global []MatchLimit `json:"global"`
|
||||
Nodes map[string][]MatchLimit `json:"nodes"`
|
||||
} `json:"limits"`
|
||||
}
|
||||
|
||||
type MatchLimit struct {
|
||||
Match string `json:"match"`
|
||||
Name string `json:"name"`
|
||||
Max int `json:"max"`
|
||||
}
|
||||
|
||||
type ResourceTemplate struct {
|
||||
Value string `json:"value"`
|
||||
Resource struct {
|
||||
Enabled bool `json:"enabled"`
|
||||
Name string `json:"name"`
|
||||
Amount int `json:"amount"`
|
||||
} `json:"resource"`
|
||||
}
|
||||
type Pool = paas.Pool
|
||||
type Groupname = paas.Groupname
|
||||
type Group = paas.Group
|
||||
type Username = paas.Username
|
||||
type User = paas.User
|
||||
type VMID = paas.VMID
|
||||
type Backups = paas.Backups
|
||||
type Templates = paas.Templates
|
||||
type SimpleResource = paas.SimpleResource
|
||||
type SimpleLimit = paas.SimpleLimit
|
||||
type MatchResource = paas.MatchResource
|
||||
type MatchLimit = paas.MatchLimit
|
||||
type ResourceTemplate = paas.ResourceTemplate
|
||||
|
||||
Reference in New Issue
Block a user