From 4648c918b6db762b045542d3e51a048fb49159ba Mon Sep 17 00:00:00 2001 From: Raf Lopez Date: Fri, 30 Sep 2022 11:43:51 +1000 Subject: [PATCH] M #-: Fix the snapshot schemas (GOCA) The schema for vm and snapshots does not correctly deserialize the raw xml because the snapshot field in VM struct is not an array. This change fixes the snapshot field, and adds DiskID to DiskSnapshot struct so that after unmarshalling the snapshots are grouped by disk Signed-off-by: Rafael Lopez (cherry picked from commit 278b14930bf1409f4dc5c844bad47e359240f3ca) (cherry picked from commit 647a4851b8fe16590c7d9badec399992fc9f5253) --- .../go/src/goca/schemas/shared/snapshot.go | 1 + src/oca/go/src/goca/schemas/vm/vm.go | 44 +++++++++---------- 2 files changed, 23 insertions(+), 22 deletions(-) diff --git a/src/oca/go/src/goca/schemas/shared/snapshot.go b/src/oca/go/src/goca/schemas/shared/snapshot.go index 63c99a7457..35fb89d61e 100644 --- a/src/oca/go/src/goca/schemas/shared/snapshot.go +++ b/src/oca/go/src/goca/schemas/shared/snapshot.go @@ -33,6 +33,7 @@ type Snapshot struct { type DiskSnapshot struct { AllowOrphans string `xml:"ALLOW_ORPHANS"` CurrentBase int `xml:"CURRENT_BASE"` + DiskID int `xml:"DISK_ID"` NextSnapshot int `xml:"NEXT_SNAPSHOT"` Snapshots []Snapshot `xml:"SNAPSHOT"` } diff --git a/src/oca/go/src/goca/schemas/vm/vm.go b/src/oca/go/src/goca/schemas/vm/vm.go index 6b834e8dfa..1753f2338f 100644 --- a/src/oca/go/src/goca/schemas/vm/vm.go +++ b/src/oca/go/src/goca/schemas/vm/vm.go @@ -38,28 +38,28 @@ type PoolMonitoring struct { // VM represents an OpenNebula Virtual Machine type VM struct { - XMLName xml.Name `xml:"VM"` - ID int `xml:"ID,omitempty"` - UID int `xml:"UID,omitempty"` - GID int `xml:"GID,omitempty"` - UName string `xml:"UNAME,omitempty"` - GName string `xml:"GNAME,omitempty"` - Name string `xml:"NAME,omitempty"` - Permissions *shared.Permissions `xml:"PERMISSIONS,omitempty"` - LastPoll int `xml:"LAST_POLL,omitempty"` - StateRaw int `xml:"STATE,omitempty"` - LCMStateRaw int `xml:"LCM_STATE,omitempty"` - PrevStateRaw int `xml:"PREV_STATE,omitempty"` - PrevLCMStateRaw int `xml:"PREV_LCM_STATE,omitempty"` - ReschedValue int `xml:"RESCHED,omitempty"` - STime int `xml:"STIME,omitempty"` - ETime int `xml:"ETIME,omitempty"` - DeployID string `xml:"DEPLOY_ID,omitempty"` - MonitoringInfos dyn.Template `xml:"MONITORING,omitempty"` - Template Template `xml:"TEMPLATE,omitempty"` - UserTemplate UserTemplate `xml:"USER_TEMPLATE,omitempty"` - HistoryRecords []HistoryRecord `xml:"HISTORY_RECORDS>HISTORY,omitempty"` - Snapshots shared.DiskSnapshot `xml:"SNAPSHOTS,omitempty"` + XMLName xml.Name `xml:"VM"` + ID int `xml:"ID,omitempty"` + UID int `xml:"UID,omitempty"` + GID int `xml:"GID,omitempty"` + UName string `xml:"UNAME,omitempty"` + GName string `xml:"GNAME,omitempty"` + Name string `xml:"NAME,omitempty"` + Permissions *shared.Permissions `xml:"PERMISSIONS,omitempty"` + LastPoll int `xml:"LAST_POLL,omitempty"` + StateRaw int `xml:"STATE,omitempty"` + LCMStateRaw int `xml:"LCM_STATE,omitempty"` + PrevStateRaw int `xml:"PREV_STATE,omitempty"` + PrevLCMStateRaw int `xml:"PREV_LCM_STATE,omitempty"` + ReschedValue int `xml:"RESCHED,omitempty"` + STime int `xml:"STIME,omitempty"` + ETime int `xml:"ETIME,omitempty"` + DeployID string `xml:"DEPLOY_ID,omitempty"` + MonitoringInfos dyn.Template `xml:"MONITORING,omitempty"` + Template Template `xml:"TEMPLATE,omitempty"` + UserTemplate UserTemplate `xml:"USER_TEMPLATE,omitempty"` + HistoryRecords []HistoryRecord `xml:"HISTORY_RECORDS>HISTORY,omitempty"` + Snapshots []shared.DiskSnapshot `xml:"SNAPSHOTS,omitempty"` // Not filled with NewUserPool call LockInfos *shared.Lock `xml:"LOCK"`