From b56b3b3edc1e66f090ed4326152e1cdc5f15333a Mon Sep 17 00:00:00 2001 From: treywelsh Date: Mon, 10 Dec 2018 17:53:00 +0100 Subject: [PATCH] F #2662: GOCA - Add host state values and strings --- src/oca/go/src/goca/host.go | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/oca/go/src/goca/host.go b/src/oca/go/src/goca/host.go index 81394fa5af..76f9d6b52c 100644 --- a/src/oca/go/src/goca/host.go +++ b/src/oca/go/src/goca/host.go @@ -12,6 +12,52 @@ type HostPool struct { XMLResource } +// HostState is the state of an OpenNebula Host +type HostState int + +const ( + // HostInit host is in the initial state when enabled + HostInit = iota + + // HostMonitoringMonitored host is being monitored (from monitored state) + HostMonitoringMonitored + + // HostMonitored host has been successfully monitored + HostMonitored + + // HostError host has encountered an error ocurred while monitoring + HostError + + // HostDisabled host is disabled + HostDisabled + + // HostMonitoringError host is being monitored (from error state) + HostMonitoringError + + // HostMonitoringInit host is being monitored (from init state) + HostMonitoringInit + + // HostMonitoringDisabled host is being monitored (from disabled state) + HostMonitoringDisabled + + // HostOffline host is totally offline + HostOffline +) + +func (st HostState) String() string { + return [...]string{ + "INIT", + "MONITORING_MONITORED", + "MONITORED", + "ERROR", + "DISABLED", + "MONITORING_ERROR", + "MONITORING_INIT", + "MONITORING_DISABLED", + "OFFLINE", + }[st] +} + // NewHostPool returns a host pool. A connection to OpenNebula is // performed. func NewHostPool() (*HostPool, error) {