Revision ecff332f

b/src/Ganeti/Daemon.hs
47 47

  
48 48
import Control.Exception
49 49
import Control.Monad
50
import Data.Maybe (fromMaybe)
50
import Data.Maybe (fromMaybe, listToMaybe)
51 51
import Data.Word
52 52
import GHC.IO.Handle (hDuplicateTo)
53 53
import Network.BSD (getHostName)
......
297 297
vClusterHostNameEnvVar :: String
298 298
vClusterHostNameEnvVar = "GANETI_HOSTNAME"
299 299

  
300
getFQDN :: IO String
301
getFQDN = do
302
  hostname <- getHostName
303
  addrInfos <- Socket.getAddrInfo Nothing (Just hostname) Nothing
304
  let address = listToMaybe addrInfos >>= (Just . Socket.addrAddress)
305
  case address of
306
    Just a -> do
307
      fqdn <- liftM fst $ Socket.getNameInfo [] True False a
308
      return (fromMaybe hostname fqdn)
309
    Nothing -> return hostname
310

  
300 311
-- | Returns if the current node is the master node.
301 312
isMaster :: IO Bool
302 313
isMaster = do
......
307 318
                     ioErrorToNothing
308 319
  curNode <- case vcluster_node of
309 320
    Just node_name -> return node_name
310
    Nothing -> getHostName
321
    Nothing -> getFQDN
311 322
  masterNode <- Ssconf.getMasterNode Nothing
312 323
  case masterNode of
313 324
    Ok n -> return (curNode == n)

Also available in: Unified diff