Add request type to Confd server for getting instance list
authorMichele Tartara <mtartara@google.com>
Thu, 10 Jan 2013 08:22:57 +0000 (09:22 +0100)
committerMichele Tartara <mtartara@google.com>
Mon, 18 Feb 2013 15:34:47 +0000 (15:34 +0000)
Add to Confd server a new request type (and its implementation) to ask for
the list of instances in a node.

Signed-off-by: Michele Tartara <mtartara@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

lib/constants.py
src/Ganeti/Confd/Server.hs
src/Ganeti/Confd/Types.hs

index 0e4f471..db84892 100644 (file)
@@ -2144,6 +2144,7 @@ CONFD_REQ_NODE_PIP_LIST = 4
 CONFD_REQ_MC_PIP_LIST = 5
 CONFD_REQ_INSTANCES_IPS_LIST = 6
 CONFD_REQ_NODE_DRBD = 7
+CONFD_REQ_NODE_INSTANCES = 8
 
 # Confd request query fields. These are used to narrow down queries.
 # These must be strings rather than integers, because json-encoding
index f737326..4339ce2 100644 (file)
@@ -242,6 +242,14 @@ buildResponse cdata req@(ConfdRequest { confdRqType = ReqNodeDrbd }) = do
                  (a, b, c, d, e, f) <- minors]
   return (ReplyStatusOk, J.showJSON encoded)
 
+buildResponse cdata req@(ConfdRequest { confdRqType = ReqNodeInstances }) = do
+  let cfg = fst cdata
+  node_name <- case confdRqQuery req of
+                PlainQuery str -> return str
+                _ -> fail $ "Invalid query type " ++ show (confdRqQuery req)
+  let instances = getNodeInstances cfg node_name
+  return (ReplyStatusOk, J.showJSON instances)
+
 -- | Creates a ConfdReply from a given answer.
 serializeResponse :: Result StatusAnswer -> ConfdReply
 serializeResponse r =
index 5439fbe..f503c3d 100644 (file)
@@ -78,6 +78,7 @@ $(declareIADT "ConfdRequestType"
   , ("ReqMcPipList",        'C.confdReqMcPipList )
   , ("ReqInstIpsList",      'C.confdReqInstancesIpsList )
   , ("ReqNodeDrbd",         'C.confdReqNodeDrbd )
+  , ("ReqNodeInstances",    'C.confdReqNodeInstances)
   ])
 $(makeJSONInstance ''ConfdRequestType)