Merge branch 'stable-2.8' into stable-2.9
authorThomas Thrainer <thomasth@google.com>
Tue, 20 Aug 2013 12:20:52 +0000 (14:20 +0200)
committerThomas Thrainer <thomasth@google.com>
Tue, 20 Aug 2013 12:48:33 +0000 (14:48 +0200)
* stable-2.8
  Allow instance mods if only osparams are given
  Fix harep manpage title
  Use FQDN to check master node status

Signed-off-by: Thomas Thrainer <thomasth@google.com>
Reviewed-by: Klaus Aehlig <aehlig@google.com>

man/harep.rst
src/Ganeti/Daemon.hs

index e07b4db..70b5249 100644 (file)
@@ -1,5 +1,5 @@
 HAREP(1) Ganeti | Version @GANETI_VERSION@
-=========================================
+==========================================
 
 NAME
 ----
index 2de30dd..da0628d 100644 (file)
@@ -47,7 +47,7 @@ module Ganeti.Daemon
 
 import Control.Exception
 import Control.Monad
-import Data.Maybe (fromMaybe)
+import Data.Maybe (fromMaybe, listToMaybe)
 import Data.Word
 import GHC.IO.Handle (hDuplicateTo)
 import Network.BSD (getHostName)
@@ -283,6 +283,17 @@ parseAddress opts defport = do
 vClusterHostNameEnvVar :: String
 vClusterHostNameEnvVar = "GANETI_HOSTNAME"
 
+getFQDN :: IO String
+getFQDN = do
+  hostname <- getHostName
+  addrInfos <- Socket.getAddrInfo Nothing (Just hostname) Nothing
+  let address = listToMaybe addrInfos >>= (Just . Socket.addrAddress)
+  case address of
+    Just a -> do
+      fqdn <- liftM fst $ Socket.getNameInfo [] True False a
+      return (fromMaybe hostname fqdn)
+    Nothing -> return hostname
+
 -- | Returns if the current node is the master node.
 isMaster :: IO Bool
 isMaster = do
@@ -293,7 +304,7 @@ isMaster = do
                      ioErrorToNothing
   curNode <- case vcluster_node of
     Just node_name -> return node_name
-    Nothing -> getHostName
+    Nothing -> getFQDN
   masterNode <- Ssconf.getMasterNode Nothing
   case masterNode of
     Ok n -> return (curNode == n)