diff --git a/src/oca/go/src/goca/schemas/cluster/template.go b/src/oca/go/src/goca/schemas/cluster/template.go index 4c32cab4e4..7c5e60fe0f 100644 --- a/src/oca/go/src/goca/schemas/cluster/template.go +++ b/src/oca/go/src/goca/schemas/cluster/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/datastore/template.go b/src/oca/go/src/goca/schemas/datastore/template.go index f89a4e8eff..2179c8d3e1 100644 --- a/src/oca/go/src/goca/schemas/datastore/template.go +++ b/src/oca/go/src/goca/schemas/datastore/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/hook/template.go b/src/oca/go/src/goca/schemas/hook/template.go index 8df69bd8a9..e99ab23ab7 100644 --- a/src/oca/go/src/goca/schemas/hook/template.go +++ b/src/oca/go/src/goca/schemas/hook/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/host/template.go b/src/oca/go/src/goca/schemas/host/template.go index 8d1f1f139a..f77efad2a4 100644 --- a/src/oca/go/src/goca/schemas/host/template.go +++ b/src/oca/go/src/goca/schemas/host/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/image/template.go b/src/oca/go/src/goca/schemas/image/template.go index 95ab26484d..bb20314a0c 100644 --- a/src/oca/go/src/goca/schemas/image/template.go +++ b/src/oca/go/src/goca/schemas/image/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/marketplace/template.go b/src/oca/go/src/goca/schemas/marketplace/template.go index 6e805ad199..598343b4b3 100644 --- a/src/oca/go/src/goca/schemas/marketplace/template.go +++ b/src/oca/go/src/goca/schemas/marketplace/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/marketplaceapp/template.go b/src/oca/go/src/goca/schemas/marketplaceapp/template.go index 93a26dbf6a..12bbc1aae1 100644 --- a/src/oca/go/src/goca/schemas/marketplaceapp/template.go +++ b/src/oca/go/src/goca/schemas/marketplaceapp/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/securitygroup/rules.go b/src/oca/go/src/goca/schemas/securitygroup/rules.go index 2b3f7fc81b..23b45a5fe0 100644 --- a/src/oca/go/src/goca/schemas/securitygroup/rules.go +++ b/src/oca/go/src/goca/schemas/securitygroup/rules.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/securitygroup/template.go b/src/oca/go/src/goca/schemas/securitygroup/template.go index 719ee874ce..5af302ed39 100644 --- a/src/oca/go/src/goca/schemas/securitygroup/template.go +++ b/src/oca/go/src/goca/schemas/securitygroup/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/shared/disk.go b/src/oca/go/src/goca/schemas/shared/disk.go index ed5329eae1..5038bc976b 100644 --- a/src/oca/go/src/goca/schemas/shared/disk.go +++ b/src/oca/go/src/goca/schemas/shared/disk.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/shared/nic.go b/src/oca/go/src/goca/schemas/shared/nic.go index 978524f502..ba5e1c7d49 100644 --- a/src/oca/go/src/goca/schemas/shared/nic.go +++ b/src/oca/go/src/goca/schemas/shared/nic.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/shared/quota.go b/src/oca/go/src/goca/schemas/shared/quota.go index afc8106df8..90444d2df7 100644 --- a/src/oca/go/src/goca/schemas/shared/quota.go +++ b/src/oca/go/src/goca/schemas/shared/quota.go @@ -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"` } diff --git a/src/oca/go/src/goca/schemas/virtualnetwork/addressrange.go b/src/oca/go/src/goca/schemas/virtualnetwork/addressrange.go index ffd50af18b..2153206a67 100644 --- a/src/oca/go/src/goca/schemas/virtualnetwork/addressrange.go +++ b/src/oca/go/src/goca/schemas/virtualnetwork/addressrange.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/virtualnetwork/template.go b/src/oca/go/src/goca/schemas/virtualnetwork/template.go index 74e532c3a5..9913646efa 100644 --- a/src/oca/go/src/goca/schemas/virtualnetwork/template.go +++ b/src/oca/go/src/goca/schemas/virtualnetwork/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/virtualnetwork/virtualnetwork.go b/src/oca/go/src/goca/schemas/virtualnetwork/virtualnetwork.go index 11daefe6b4..a9b559ba55 100644 --- a/src/oca/go/src/goca/schemas/virtualnetwork/virtualnetwork.go +++ b/src/oca/go/src/goca/schemas/virtualnetwork/virtualnetwork.go @@ -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 diff --git a/src/oca/go/src/goca/schemas/virtualrouter/template.go b/src/oca/go/src/goca/schemas/virtualrouter/template.go index 1724f3071f..877929e269 100644 --- a/src/oca/go/src/goca/schemas/virtualrouter/template.go +++ b/src/oca/go/src/goca/schemas/virtualrouter/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/vm/template.go b/src/oca/go/src/goca/schemas/vm/template.go index 184660f544..c3f23663fa 100644 --- a/src/oca/go/src/goca/schemas/vm/template.go +++ b/src/oca/go/src/goca/schemas/vm/template.go @@ -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) } diff --git a/src/oca/go/src/goca/schemas/vmgroup/vmgroup.go b/src/oca/go/src/goca/schemas/vmgroup/vmgroup.go index aa9d6d4f6e..552615cd15 100644 --- a/src/oca/go/src/goca/schemas/vmgroup/vmgroup.go +++ b/src/oca/go/src/goca/schemas/vmgroup/vmgroup.go @@ -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