Revision d605e261

b/src/Ganeti/HTools/Backend/Luxi.hs
272 272
         -> IO (Result JSValue, Result JSValue, Result JSValue, Result JSValue)
273 273
readData master =
274 274
  E.bracket
275
       (L.getClient master)
275
       (L.getLuxiClient master)
276 276
       L.closeClient
277 277
       (\s -> do
278 278
          nodes <- queryNodes s
b/src/Ganeti/HTools/Program/Harep.hs
463 463
  iniData <- exitIfBad "when parsing auto-repair tags" iniDataRes
464 464

  
465 465
  -- First step: check all pending repairs, see if they are completed.
466
  iniData' <- bracket (L.getClient master) L.closeClient $
466
  iniData' <- bracket (L.getLuxiClient master) L.closeClient $
467 467
              forM iniData . processPending
468 468

  
469 469
  -- Second step: detect any problems.
......
476 476
                            ArHealthy _ -> doRepair c jobDelay i
477 477
                            _           -> const (return i)
478 478

  
479
  repairDone <- bracket (L.getClient master) L.closeClient $
479
  repairDone <- bracket (L.getLuxiClient master) L.closeClient $
480 480
                forM (zip iniData' repairs) . maybeRepair
481 481

  
482 482
  -- Print some stats and exit.
b/src/Ganeti/HTools/Program/Hbal.hs
192 192
      descr = map (\(_, idx, _, _) -> Container.nameOf il idx) js
193 193
      logfn = putStrLn . ("Got job IDs" ++) . commaJoin . map (show . fromJobId)
194 194
  putStrLn $ "Executing jobset for instances " ++ commaJoin descr
195
  jrs <- bracket (L.getClient master) L.closeClient $
195
  jrs <- bracket (L.getLuxiClient master) L.closeClient $
196 196
         Jobs.execJobsWait jobs logfn
197 197
  case jrs of
198 198
    Bad x -> return $ Bad x
b/src/Ganeti/JQueue.hs
444 444
startJobs :: [QueuedJob] -> IO ()
445 445
startJobs jobs = do
446 446
  socketpath <- defaultMasterSocket
447
  client <- getClient socketpath
447
  client <- getLuxiClient socketpath
448 448
  pickupResults <- mapM (flip callMethod client . PickupJob . qjId) jobs
449 449
  let failures = map show $ justBad pickupResults
450 450
  unless (null failures)
b/src/Ganeti/Luxi.hs
34 34
  , makeJobId
35 35
  , RecvResult(..)
36 36
  , strOfOp
37
  , getClient
38
  , getServer
37
  , getLuxiClient
38
  , getLuxiServer
39 39
  , acceptClient
40 40
  , closeClient
41 41
  , closeServer
b/src/Ganeti/Query/Server.hs
369 369
  socket_path <- Path.defaultQuerySocket
370 370
  cleanupSocket socket_path
371 371
  s <- describeError "binding to the Luxi socket"
372
         Nothing (Just socket_path) $ getServer True socket_path
372
         Nothing (Just socket_path) $ getLuxiServer True socket_path
373 373
  cref <- newIORef (Bad "Configuration not yet loaded")
374 374
  jq <- emptyJQStatus 
375 375
  return (socket_path, s, cref, jq)
b/src/Ganeti/UDSServer.hs
30 30
  , RecvResult(..)
31 31
  , MsgKeys(..)
32 32
  , strOfKey
33
  , getClient
34
  , getServer
33
  , getLuxiClient
34
  , getLuxiServer
35 35
  , acceptClient
36 36
  , closeClient
37 37
  , closeServer
......
107 107
                     }
108 108

  
109 109
-- | Connects to the master daemon and returns a luxi Client.
110
getClient :: String -> IO Client
111
getClient path = do
110
getLuxiClient :: String -> IO Client
111
getLuxiClient path = do
112 112
  s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
113 113
  withTimeout luxiDefCtmo "creating luxi connection" $
114 114
              S.connect s (S.SockAddrUnix path)
......
117 117
  return Client { socket=h, rbuf=rf }
118 118

  
119 119
-- | Creates and returns a server endpoint.
120
getServer :: Bool -> FilePath -> IO S.Socket
121
getServer setOwner path = do
120
getLuxiServer :: Bool -> FilePath -> IO S.Socket
121
getLuxiServer setOwner path = do
122 122
  s <- S.socket S.AF_UNIX S.Stream S.defaultProtocol
123 123
  S.bindSocket s (S.SockAddrUnix path)
124 124
  when setOwner . setOwnerAndGroupFromNames path GanetiLuxid $
b/test/hs/Test/Ganeti/Luxi.hs
131 131
  -- we need to create the server first, otherwise (if we do it in the
132 132
  -- forked thread) the client could try to connect to it before it's
133 133
  -- ready
134
  server <- run $ Luxi.getServer False fpath
134
  server <- run $ Luxi.getLuxiServer False fpath
135 135
  -- fork the server responder
136 136
  _ <- run . forkIO $
137 137
    bracket
......
140 140
      luxiServerPong
141 141
  replies <- run $
142 142
    bracket
143
      (Luxi.getClient fpath)
143
      (Luxi.getLuxiClient fpath)
144 144
      Luxi.closeClient
145 145
      (`luxiClientPong` msgs)
146 146
  stop $ replies ==? msgs

Also available in: Unified diff