mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
F #5682: GOCA - schemas
- vms monitoring schemas - hosts monitoring schemas Signed-off-by: Pierre Lafievre <pierre.lafievre@iguanesolutions.com> (cherry picked from commit 2d251749a0c04f5ea5a65a81af468a134d6ea8e9)
This commit is contained in:
parent
2ea36e9988
commit
430d81bc3d
@ -113,12 +113,19 @@ func (hc *HostsController) Create(name, im, vm string, clusterID int) (int, erro
|
||||
// Monitoring Returns the Hosts monitoring records
|
||||
// num: Retrieve monitor records in the last num seconds.
|
||||
// 0 just the last record, -1 all records
|
||||
func (hc *HostsController) Monitoring(num int) (string, error) {
|
||||
func (hc *HostsController) Monitoring(num int) (*host.PoolMonitoring, error) {
|
||||
monitorData, err := hc.c.Client.Call("one.hostpool.monitoring", num)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return monitorData.Body(), nil
|
||||
|
||||
hostsMon := &host.PoolMonitoring{}
|
||||
err = xml.Unmarshal([]byte(monitorData.Body()), &hostsMon)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return hostsMon, nil
|
||||
}
|
||||
|
||||
// Delete deletes the given host from the pool
|
||||
@ -151,10 +158,17 @@ func (hc *HostController) Rename(newName string) error {
|
||||
}
|
||||
|
||||
// Monitoring returns the host monitoring records.
|
||||
func (hc *HostController) Monitoring() (string, error) {
|
||||
func (hc *HostController) Monitoring() (*host.Monitoring, error) {
|
||||
monitorData, err := hc.c.Client.Call("one.host.monitoring", hc.ID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return monitorData.Body(), nil
|
||||
|
||||
hostMon := &host.Monitoring{}
|
||||
err = xml.Unmarshal([]byte(monitorData.Body()), &hostMon)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return hostMon, nil
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ type Pool struct {
|
||||
Hosts []Host `xml:"HOST"`
|
||||
}
|
||||
|
||||
// PoolMonitoring contains the monitoring records of the hosts
|
||||
type PoolMonitoring struct {
|
||||
XMLName xml.Name `xml:"MONITORING_DATA"`
|
||||
Records []dyn.Template `xml:"MONITORING"`
|
||||
}
|
||||
|
||||
// Host represents an OpenNebula Host
|
||||
type Host struct {
|
||||
XMLName xml.Name `xml:"HOST"`
|
||||
@ -41,12 +47,14 @@ type Host struct {
|
||||
Cluster string `xml:"CLUSTER,omitempty"`
|
||||
Share Share `xml:"HOST_SHARE,omitempty"`
|
||||
VMs shared.EntitiesID `xml:"VMS,omitempty"`
|
||||
MonitoringInfos Monitoring `xml:"MONITORING,omitempty"`
|
||||
MonitoringInfos dyn.Template `xml:"MONITORING,omitempty"`
|
||||
Template Template `xml:"TEMPLATE,omitempty"`
|
||||
}
|
||||
|
||||
// Monitoring contains the monitoring records of a host
|
||||
type Monitoring struct {
|
||||
dyn.Template
|
||||
XMLName xml.Name `xml:"MONITORING_DATA"`
|
||||
Records []dyn.Template `xml:"MONITORING"`
|
||||
}
|
||||
|
||||
type Share struct {
|
||||
|
@ -30,6 +30,12 @@ type Pool struct {
|
||||
VMs []VM `xml:"VM"`
|
||||
}
|
||||
|
||||
// PoolMonitoring contains the monitoring records of the VMs
|
||||
type PoolMonitoring struct {
|
||||
XMLName xml.Name `xml:"MONITORING_DATA"`
|
||||
VMs []dyn.Template `xml:"MONITORING"`
|
||||
}
|
||||
|
||||
// VM represents an OpenNebula Virtual Machine
|
||||
type VM struct {
|
||||
XMLName xml.Name `xml:"VM"`
|
||||
@ -49,7 +55,7 @@ type VM struct {
|
||||
STime int `xml:"STIME,omitempty"`
|
||||
ETime int `xml:"ETIME,omitempty"`
|
||||
DeployID string `xml:"DEPLOY_ID,omitempty"`
|
||||
MonitoringInfos Monitoring `xml:"MONITORING,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"`
|
||||
@ -59,9 +65,10 @@ type VM struct {
|
||||
LockInfos *shared.Lock `xml:"LOCK"`
|
||||
}
|
||||
|
||||
// Monitoring is a dynamic VM part containing metrics
|
||||
// Monitoring contains the monitoring records of a VM
|
||||
type Monitoring struct {
|
||||
dyn.Template
|
||||
XMLName xml.Name `xml:"MONITORING_DATA"`
|
||||
Records []dyn.Template `xml:"MONITORING"`
|
||||
}
|
||||
|
||||
// History records
|
||||
|
@ -197,12 +197,19 @@ func (vc *VMController) Info(decrypt bool) (*vm.VM, error) {
|
||||
// >= 0: UID User's Resources
|
||||
// num: Retrieve monitor records in the last num seconds.
|
||||
// 0 just the last record, -1 all records
|
||||
func (vc *VMsController) Monitoring(filter, num int) (string, error) {
|
||||
func (vc *VMsController) Monitoring(filter, num int) (*vm.PoolMonitoring, error) {
|
||||
monitorData, err := vc.c.Client.Call("one.vmpool.monitoring", filter, num)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return monitorData.Body(), nil
|
||||
|
||||
vmsMon := &vm.PoolMonitoring{}
|
||||
err = xml.Unmarshal([]byte(monitorData.Body()), &vmsMon)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vmsMon, nil
|
||||
}
|
||||
|
||||
// Accounting returns the virtual machine history records
|
||||
@ -285,12 +292,19 @@ func (vc *VMController) UpdateConf(tpl string) error {
|
||||
}
|
||||
|
||||
// Monitoring Returns the virtual machine monitoring records
|
||||
func (vc *VMController) Monitoring() (string, error) {
|
||||
func (vc *VMController) Monitoring() (*vm.Monitoring, error) {
|
||||
monitorData, err := vc.c.Client.Call("one.vm.monitoring", vc.ID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
return nil, err
|
||||
}
|
||||
return monitorData.Body(), nil
|
||||
|
||||
vmMon := &vm.Monitoring{}
|
||||
err = xml.Unmarshal([]byte(monitorData.Body()), &vmMon)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return vmMon, nil
|
||||
}
|
||||
|
||||
// Chown changes the owner/group of a VM. If uid or gid is -1 it will not
|
||||
|
Loading…
x
Reference in New Issue
Block a user