Correct properties of the cluster's file storage dir
[ganeti-local] / src / Ganeti / Luxi.hs
index 9e5b337..570992f 100644 (file)
@@ -77,8 +77,10 @@ import Ganeti.JSON
 import Ganeti.OpParams (pTagsObject)
 import Ganeti.OpCodes
 import qualified Ganeti.Query.Language as Qlang
+import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..))
 import Ganeti.THH
 import Ganeti.Types
+import Ganeti.Utils
 
 -- * Utility functions
 
@@ -119,6 +121,11 @@ $(genLuxiOp "LuxiOp"
      , simpleField "fields" [t| [String] |]
      , simpleField "lock"   [t| Bool     |]
      ])
+  , (luxiReqQueryNetworks,
+     [ simpleField "names"  [t| [String] |]
+     , simpleField "fields" [t| [String] |]
+     , simpleField "lock"   [t| Bool     |]
+     ])
   , (luxiReqQueryInstances,
      [ simpleField "names"  [t| [String] |]
      , simpleField "fields" [t| [String] |]
@@ -137,10 +144,15 @@ $(genLuxiOp "LuxiOp"
     )
   , (luxiReqQueryClusterInfo, [])
   , (luxiReqQueryTags,
-     [ pTagsObject ])
+     [ pTagsObject 
+     , simpleField "name" [t| String |]
+     ])
   , (luxiReqSubmitJob,
      [ simpleField "job" [t| [MetaOpCode] |] ]
     )
+  , (luxiReqSubmitJobToDrainedQueue,
+     [ simpleField "job" [t| [MetaOpCode] |] ]
+    )
   , (luxiReqSubmitManyJobs,
      [ simpleField "ops" [t| [[MetaOpCode]] |] ]
     )
@@ -217,10 +229,12 @@ getClient path = do
   return Client { socket=h, rbuf=rf }
 
 -- | Creates and returns a server endpoint.
-getServer :: FilePath -> IO S.Socket
-getServer path = do
+getServer :: Bool -> FilePath -> IO S.Socket
+getServer setOwner path = do
   s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
   S.bindSocket s (S.SockAddrUnix path)
+  when setOwner . setOwnerAndGroupFromNames path GanetiLuxid $
+    ExtraGroup DaemonsGroup
   S.listen s 5 -- 5 is the max backlog
   return s
 
@@ -341,6 +355,9 @@ decodeCall (LuxiCall call args) =
               return $ QueryGroups names fields locking
     ReqQueryClusterInfo ->
               return QueryClusterInfo
+    ReqQueryNetworks -> do
+              (names, fields, locking) <- fromJVal args
+              return $ QueryNetworks names fields locking
     ReqQuery -> do
               (what, fields, qfilter) <- fromJVal args
               return $ Query what fields qfilter
@@ -354,6 +371,10 @@ decodeCall (LuxiCall call args) =
               [ops1] <- fromJVal args
               ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
               return $ SubmitJob ops2
+    ReqSubmitJobToDrainedQueue -> do
+              [ops1] <- fromJVal args
+              ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
+              return $ SubmitJobToDrainedQueue ops2
     ReqSubmitManyJobs -> do
               [ops1] <- fromJVal args
               ops2 <- mapM (fromJResult (luxiReqToRaw call) . J.readJSON) ops1
@@ -387,8 +408,7 @@ decodeCall (LuxiCall call args) =
               return $ QueryConfigValues fields
     ReqQueryTags -> do
               (kind, name) <- fromJVal args
-              item <- tagObjectFrom kind name
-              return $ QueryTags item
+              return $ QueryTags kind name
     ReqCancelJob -> do
               [jid] <- fromJVal args
               return $ CancelJob jid