From d4de2ea8b5ad38675c283789ffc8abd5125fce00 Mon Sep 17 00:00:00 2001 From: Michele Tartara <mtartara@google.com> Date: Thu, 25 Apr 2013 14:36:10 +0000 Subject: [PATCH] Export the actual instance state Compute the actual state of the instance and export it. Signed-off-by: Michele Tartara <mtartara@google.com> Reviewed-by: Klaus Aehlig <aehlig@google.com> --- src/Ganeti/DataCollectors/InstStatus.hs | 11 +++++++++++ src/Ganeti/DataCollectors/InstStatusTypes.hs | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/Ganeti/DataCollectors/InstStatus.hs b/src/Ganeti/DataCollectors/InstStatus.hs index 3209f750c..acd459bcd 100644 --- a/src/Ganeti/DataCollectors/InstStatus.hs +++ b/src/Ganeti/DataCollectors/InstStatus.hs @@ -42,6 +42,7 @@ import Ganeti.Common import Ganeti.DataCollectors.CLI import Ganeti.DataCollectors.InstStatusTypes import Ganeti.Hypervisor.Xen +import Ganeti.Hypervisor.Xen.Types import Ganeti.Objects import Ganeti.Utils @@ -89,11 +90,21 @@ buildStatus domains uptimes inst = do currUInfo = idNum >>= (`Map.lookup` uptimes) uptime = fmap uInfoUptime currUInfo adminState = instAdminState inst + actualState = + if adminState == AdminDown && isNothing currDomain + then ActualShutdown + else case currDomain of + (Just dom@(Domain _ _ _ _ (Just isHung))) -> + if isHung + then ActualHung + else domState dom + _ -> ActualUnknown return $ InstStatus name (instUuid inst) adminState + actualState uptime (instMtime inst) diff --git a/src/Ganeti/DataCollectors/InstStatusTypes.hs b/src/Ganeti/DataCollectors/InstStatusTypes.hs index 5eabd3c30..b26578c41 100644 --- a/src/Ganeti/DataCollectors/InstStatusTypes.hs +++ b/src/Ganeti/DataCollectors/InstStatusTypes.hs @@ -29,6 +29,7 @@ module Ganeti.DataCollectors.InstStatusTypes ) where +import Ganeti.Hypervisor.Xen.Types import Ganeti.Objects import Ganeti.THH @@ -37,6 +38,7 @@ $(buildObject "InstStatus" "iStat" [ simpleField "name" [t| String |] , simpleField "uuid" [t| String |] , simpleField "adminState" [t| AdminState |] + , simpleField "actualState" [t| ActualState |] , optionalNullSerField $ simpleField "uptime" [t| String |] , simpleField "mtime" [t| Double |] -- GitLab