mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-16 22:50:10 +03:00
* Less restrictive parameter * Fix quota structs marshalling * Fix omitempty for consistency Signed-off-by: Pierre Lafievre <pierre.lafievre@iguanesolutions.com> (cherry picked from commit 211617bfe3171ce7af07ba137d86477bf1c9a7c8)
This commit is contained in:
parent
56d8f2f5d7
commit
8962ed144f
@ -37,6 +37,6 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds an cluster template key, value pair
|
||||
func (n *Template) Add(key keys.Template, value string) {
|
||||
func (n *Template) Add(key keys.Template, value interface{}) {
|
||||
n.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds an datastore key, value pair
|
||||
func (n *Template) Add(key keys.Template, value string) {
|
||||
func (n *Template) Add(key keys.Template, value interface{}) {
|
||||
n.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,6 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds an hook template key, value pair
|
||||
func (n *Template) Add(key keys.Template, value string) {
|
||||
func (n *Template) Add(key keys.Template, value interface{}) {
|
||||
n.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -42,6 +42,6 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a host template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -59,7 +59,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds an image template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -44,6 +44,6 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a marketplace Template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a marketplace app template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,6 @@ func (t *Rule) Get(key keys.Rule) (string, error) {
|
||||
}
|
||||
|
||||
// Add adds a security group rule template key, value pair
|
||||
func (t *Rule) Add(key keys.Rule, value string) {
|
||||
func (t *Rule) Add(key keys.Rule, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -46,6 +46,6 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a security group Template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -54,6 +54,6 @@ func (d *Disk) GetI(key DiskKeys) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a disk key, value pair
|
||||
func (d *Disk) Add(key DiskKeys, value string) {
|
||||
func (d *Disk) Add(key DiskKeys, value interface{}) {
|
||||
d.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -71,6 +71,6 @@ func (n *NIC) GetI(key NICKeys) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a NIC key, value pair
|
||||
func (n *NIC) Add(key NICKeys, value string) {
|
||||
func (n *NIC) Add(key NICKeys, value interface{}) {
|
||||
n.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -16,9 +16,12 @@
|
||||
|
||||
package shared
|
||||
|
||||
import "encoding/xml"
|
||||
|
||||
// Quotas keeps quota value per User or Group
|
||||
type Quotas struct {
|
||||
ID int `xml:"ID"`
|
||||
XMLName xml.Name `xml:"QUOTAS"`
|
||||
ID int `xml:"ID"`
|
||||
QuotasList
|
||||
}
|
||||
|
||||
@ -34,16 +37,16 @@ type QuotasList struct {
|
||||
type DatastoreQuota struct {
|
||||
ID int `xml:"ID"`
|
||||
Images int `xml:"IMAGES"`
|
||||
ImagesUsed int `xml:"IMAGES_USED"`
|
||||
ImagesUsed int `xml:"IMAGES_USED,omitempty"`
|
||||
Size int `xml:"SIZE"`
|
||||
SizeUsed int `xml:"SIZE_USED"`
|
||||
SizeUsed int `xml:"SIZE_USED,omitempty"`
|
||||
}
|
||||
|
||||
// NetworkQuota keeps quota for a network
|
||||
type NetworkQuota struct {
|
||||
ID int `xml:"ID"`
|
||||
Leases int `xml:"LEASES"`
|
||||
LeasesUsed int `xml:"LEASES_USED"`
|
||||
LeasesUsed int `xml:"LEASES_USED,omitempty"`
|
||||
}
|
||||
|
||||
// VMQuota keeps quota for all VMs in the group
|
||||
@ -55,18 +58,18 @@ type VMQuota struct {
|
||||
RunningCPU float32 `xml:"RUNNING_CPU"`
|
||||
RunningCPUUsed float32 `xml:"RUNNING_CPU_USED,omitempty"`
|
||||
RunningMemory int `xml:"RUNNING_MEMORY"`
|
||||
RunningMemoryUsed int `xml:"RUNNING_MEMORY_USED"`
|
||||
RunningMemoryUsed int `xml:"RUNNING_MEMORY_USED,omitempty"`
|
||||
RunningVMs int `xml:"RUNNING_VMS"`
|
||||
RunningVMsUsed int `xml:"RUNNING_VMS_USED,omitempty"`
|
||||
SystemDiskSize int64 `xml:"SYSTEM_DISK_SIZE"`
|
||||
SystemDiskSizeUsed int64 `xml:"SYSTEM_DISK_SIZE_USED,omitempty"`
|
||||
VMs int `xml:"VMS"`
|
||||
VMsUsed int `xml:"VMS_USED"`
|
||||
VMsUsed int `xml:"VMS_USED,omitempty"`
|
||||
}
|
||||
|
||||
// ImageQuota keeps quota for an image
|
||||
type ImageQuota struct {
|
||||
ID int `xml:"ID"`
|
||||
RVMs int `xml:"RVMS"`
|
||||
RVMsUsed int `xml:"RVMS_USED"`
|
||||
RVMsUsed int `xml:"RVMS_USED,omitempty"`
|
||||
}
|
||||
|
@ -53,6 +53,6 @@ func (n *AddressRange) GetI(key keys.AddressRange) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds an address range key, value pair.
|
||||
func (n *AddressRange) Add(key keys.AddressRange, value string) {
|
||||
func (n *AddressRange) Add(key keys.AddressRange, value interface{}) {
|
||||
n.AddPair(string(key), value)
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a virtual network template key, value pair.
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -32,12 +32,12 @@ type Pool struct {
|
||||
type VirtualNetwork struct {
|
||||
XMLName xml.Name `xml:"VNET"`
|
||||
ID int `xml:"ID,omitempty"`
|
||||
UID int `xml:"UID"`
|
||||
GID int `xml:"GID"`
|
||||
UName string `xml:"UNAME"`
|
||||
GName string `xml:"GNAME"`
|
||||
UID int `xml:"UID,omitempty"`
|
||||
GID int `xml:"GID,omitempty"`
|
||||
UName string `xml:"UNAME,omitempty"`
|
||||
GName string `xml:"GNAME,omitempty"`
|
||||
Name string `xml:"NAME"`
|
||||
Permissions *shared.Permissions `xml:"PERMISSIONS"`
|
||||
Permissions *shared.Permissions `xml:"PERMISSIONS,omitempty"`
|
||||
Clusters shared.EntitiesID `xml:"CLUSTERS,omitempty"`
|
||||
Bridge string `xml:"BRIDGE,omitempty"`
|
||||
BridgeType string `xml:"BRIDGE_TYPE,omitempty"` // minOccurs=0
|
||||
|
@ -47,7 +47,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a virtual router template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ func (n *Template) GetI(key keys.Template) (int, error) {
|
||||
}
|
||||
|
||||
// Add adds a vm template key, value pair
|
||||
func (t *Template) Add(key keys.Template, value string) {
|
||||
func (t *Template) Add(key keys.Template, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
@ -173,7 +173,7 @@ func (t *Template) AddNIC() *shared.NIC {
|
||||
|
||||
// Show back template part
|
||||
|
||||
func (t *Template) Showback(key keys.Showback, value string) *Template {
|
||||
func (t *Template) Showback(key keys.Showback, value interface{}) *Template {
|
||||
|
||||
t.Template.Del(string(key))
|
||||
t.Template.AddPair(string(key), value)
|
||||
@ -227,7 +227,7 @@ func (t *Template) GetFeature(key keys.Feature) (string, error) {
|
||||
|
||||
// I/O devices template part
|
||||
|
||||
func (t *Template) AddIOGraphic(key keys.IOGraphics, value string) error {
|
||||
func (t *Template) AddIOGraphic(key keys.IOGraphics, value interface{}) error {
|
||||
return t.Template.AddPairToVec(keys.IOGraphicsVec, string(key), value)
|
||||
}
|
||||
|
||||
@ -251,20 +251,21 @@ func (t *Template) GetCtx(key keys.Context) (string, error) {
|
||||
}
|
||||
|
||||
// Add adds a context key, value pair
|
||||
func (t *Template) AddCtx(key keys.Context, value string) error {
|
||||
func (t *Template) AddCtx(key keys.Context, value interface{}) error {
|
||||
return t.AddPairToVec(keys.ContextVec, string(key), value)
|
||||
}
|
||||
|
||||
// Add adds a context key, value pair. It will convert value to base64
|
||||
func (t *Template) AddB64Ctx(key keys.ContextB64, value string) error {
|
||||
valueB64 := base64.StdEncoding.EncodeToString([]byte(value))
|
||||
func (t *Template) AddB64Ctx(key keys.ContextB64, value interface{}) error {
|
||||
valueBytes := []byte(fmt.Sprint(value))
|
||||
valueB64 := base64.StdEncoding.EncodeToString(valueBytes)
|
||||
return t.AddPairToVec(keys.ContextVec, string(key), valueB64)
|
||||
}
|
||||
|
||||
// Placement Template part
|
||||
|
||||
// Placement set once a placement attribute
|
||||
func (t *Template) Placement(key keys.Placement, value string) *Template {
|
||||
func (t *Template) Placement(key keys.Placement, value interface{}) *Template {
|
||||
|
||||
t.Template.Del(string(key))
|
||||
t.Template.AddPair(string(key), value)
|
||||
@ -294,7 +295,7 @@ func (t *Template) AddSchedAction() *SchedAction {
|
||||
}
|
||||
|
||||
// Add adds a SchedAction key, value pair
|
||||
func (t *SchedAction) Add(key keys.SchedAction, value string) {
|
||||
func (t *SchedAction) Add(key keys.SchedAction, value interface{}) {
|
||||
t.AddPair(string(key), value)
|
||||
}
|
||||
|
||||
|
@ -32,20 +32,20 @@ type Pool struct {
|
||||
// VMGroup represents an OpenNebula VM group
|
||||
type VMGroup struct {
|
||||
XMLName xml.Name `xml:"VM_GROUP"`
|
||||
ID int `xml:"ID"`
|
||||
UID int `xml:"UID"`
|
||||
GID int `xml:"GID"`
|
||||
UName string `xml:"UNAME"`
|
||||
GName string `xml:"GNAME"`
|
||||
ID int `xml:"ID,omitemtpy"`
|
||||
UID int `xml:"UID,omitempty"`
|
||||
GID int `xml:"GID,omitempty"`
|
||||
UName string `xml:"UNAME,omitempty"`
|
||||
GName string `xml:"GNAME,omitempty"`
|
||||
Name string `xml:"NAME"`
|
||||
Permissions *shared.Permissions `xml:"PERMISSIONS"`
|
||||
LockInfos *shared.Lock `xml:"LOCK"`
|
||||
Roles []Role `xml:"ROLES>ROLE"`
|
||||
Template dyn.Template `xml:"TEMPLATE"`
|
||||
Permissions *shared.Permissions `xml:"PERMISSIONS,omitempty"`
|
||||
LockInfos *shared.Lock `xml:"LOCK,omitempty"`
|
||||
Roles []Role `xml:"ROLES>ROLE,omitempty"`
|
||||
Template dyn.Template `xml:"TEMPLATE,omitempty"`
|
||||
}
|
||||
|
||||
type Role struct {
|
||||
ID int `xml:"ID"`
|
||||
ID int `xml:"ID,omitempty"`
|
||||
Name string `xml:"NAME"`
|
||||
HostAffined string `xml:"HOST_AFFINED,omitempty"` // minOccurs=0
|
||||
HostAntiAffined string `xml:"HOST_ANTI_AFFINED,omitempty"` // minOccurs=0
|
||||
|
Loading…
x
Reference in New Issue
Block a user