case confdRqQuery req of
PlainQuery str -> return str
_ -> fail $ "Invalid query type " ++ show (confdRqQuery req)
+ inst <- lookupContainer (Bad $ "unknown instance: " ++ inst_uuid)
+ inst_uuid $ configInstances cfg
case getInstDisks cfg inst_uuid of
- Ok disks -> return (ReplyStatusOk, J.showJSON disks)
+ Ok disks -> return (ReplyStatusOk, J.showJSON disks, instSerial inst)
Bad e -> fail $ "Could not retrieve disks: " ++ show e
+-- | Return arbitrary configuration value given by a path.
+buildResponse cdata req@(ConfdRequest { confdRqType = ReqConfigQuery
+ , confdRqQuery = pathQ }) = do
+ let cfg = fst cdata
+ path <-
+ case pathQ of
+ PlainQuery path -> return path
+ _ -> fail $ "Invalid query type " ++ show (confdRqQuery req)
+ let configValue = extractJSONPath path cfg
+ case configValue of
- J.Ok jsvalue -> return (ReplyStatusOk, jsvalue)
++ J.Ok jsvalue -> return (ReplyStatusOk, jsvalue,
++ clusterSerial $ configCluster cfg)
+ J.Error _ -> return queryArgumentError
+
+-- | Return activation state of data collectors
+buildResponse (cdata,_) (ConfdRequest { confdRqType = ReqDataCollectors }) = do
+ let mkConfig col =
+ (dName col, DataCollectorConfig
+ (dActive col (dName col) cdata)
+ (dInterval col (dName col) cdata))
+ datacollectors = containerFromList $ map mkConfig collectors
- return (ReplyStatusOk, J.showJSON datacollectors)
++ return (ReplyStatusOk, J.showJSON datacollectors,
++ clusterSerial . configCluster $ cdata)
+
-- | Creates a ConfdReply from a given answer.
serializeResponse :: Result StatusAnswer -> ConfdReply
serializeResponse r =