LGTM, thanks.
On 11/02/2015 01:35 PM, Klaus Aehlig wrote:
On Mon, Nov 02, 2015 at 01:22:29PM +0100, Oleg Ponomarev wrote:
Please add a comment describing what is "sor" somewhere in the
Luxi.hs because it's not clear.
Rest LGTM.
I propose to include the following interdiff.
commit 986df14d101691a5c828a7ea4a37ebcdd6c687f2
Author: Klaus Aehlig <[email protected]>
Date: Mon Nov 2 13:34:06 2015 +0100
Interdiff [PATCH master 3/4] Honor the --state-of-record option in the
luxi backend
diff --git a/src/Ganeti/HTools/Backend/Luxi.hs
b/src/Ganeti/HTools/Backend/Luxi.hs
index 215fd5c..08fe2a3 100644
--- a/src/Ganeti/HTools/Backend/Luxi.hs
+++ b/src/Ganeti/HTools/Backend/Luxi.hs
@@ -135,14 +135,14 @@ queryGroups :: L.Client -> IO (Result JSValue)
queryGroups = liftM errToResult . L.callMethod queryGroupsMsg
-- | Parse a instance list in JSON format.
-getInstances :: Bool
+getInstances :: Bool -- ^ use only state-of-record (SoR) data
-> NameAssoc
-> JSValue
-> Result [(String, Instance.Instance)]
getInstances sor ktn arr = L.extractArray arr >>= mapM (parseInstance sor ktn)
-- | Construct an instance from a JSON object.
-parseInstance :: Bool
+parseInstance :: Bool -- ^ use only state-of-record (SoR) data
-> NameAssoc
-> [(JSValue, JSValue)]
-> Result (String, Instance.Instance)
@@ -154,6 +154,8 @@ parseInstance sor ktn
xdisk <- convert "disk_usage" disk
xmem <- case (sor, oram) of -- FIXME: remove the "guessing"
(False, (_, JSRational _ _)) -> convert "oper_ram" oram
+ -- Note: "oper_ram" is live data; we only use it if not told
+ -- to restrict to state-of-record data
_ -> convert "be/memory" mem
xvcpus <- convert "be/vcpus" vcpus
xpnode <- convert "pnode" pnode >>= lookupNode ktn xname
@@ -277,7 +279,7 @@ readData master =
-- | Converts the output of 'readData' into the internal cluster
-- representation.
-parseData :: Bool
+parseData :: Bool -- ^ use only state-of-record (SoR) data
-> (Result JSValue, Result JSValue, Result JSValue, Result JSValue)
-> Result ClusterData
parseData sor (groups, nodes, instances, cinfo) = do
@@ -292,7 +294,7 @@ parseData sor (groups, nodes, instances, cinfo) = do
return (ClusterData group_idx node_idx' inst_idx ctags cpol)
-- | Top level function for data loading.
-loadData :: Bool -- ^ use only state-of-record data
+loadData :: Bool -- ^ use only state-of-record (SoR) data
-> String -- ^ Unix socket to use as source
-> IO (Result ClusterData)
loadData sor = fmap (parseData sor) . readData