Commit b9612abb authored by Iustin Pop's avatar Iustin Pop
Browse files

Merge branch 'devel-2.6' into submit



* devel-2.6:
  Fix compatibility with newer Haskell libraries
  Fix gnt-instance console with xl

Conflicts:
        Makefile.am (reordering, fixed)
        htools/Ganeti/Confd/Server.hs (hlint fixes on master)
        htools/Ganeti/Daemon.hs (hlint)
        htools/Ganeti/HTools/Backend/Rapi.hs (hlint)
        htools/Ganeti/HTools/ExtLoader.hs (hlint)
        htools/Ganeti/HTools/QC.hs (file renamed/split in master, fixed)
        htools/test.hs (we don't use maxDiscards, ignored)
        lib/constants.py (move to pathutils)
        lib/hypervisor/hv_xen.py (move to pathutils)
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarGuido Trotter <ultrotter@google.com>
parents f9435bdc 27639c4e
...@@ -685,7 +685,7 @@ dist_tools_SCRIPTS = \ ...@@ -685,7 +685,7 @@ dist_tools_SCRIPTS = \
$(python_scripts) \ $(python_scripts) \
tools/kvm-console-wrapper \ tools/kvm-console-wrapper \
tools/master-ip-setup \ tools/master-ip-setup \
tools/xm-console-wrapper tools/xen-console-wrapper
nodist_tools_SCRIPTS = \ nodist_tools_SCRIPTS = \
tools/vcluster-setup tools/vcluster-setup
......
...@@ -326,7 +326,8 @@ prop_AllocBalance = ...@@ -326,7 +326,8 @@ prop_AllocBalance =
forAll (choose (3, 5)) $ \count -> forAll (choose (3, 5)) $ \count ->
not (Node.offline node) && not (Node.failN1 node) ==> not (Node.offline node) && not (Node.failN1 node) ==>
let nl = makeSmallCluster node count let nl = makeSmallCluster node count
(hnode, nl') = IntMap.deleteFindMax nl hnode = snd $ IntMap.findMax nl
nl' = IntMap.deleteMax nl
il = Container.empty il = Container.empty
allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True
i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu
......
...@@ -37,7 +37,6 @@ import Data.List ...@@ -37,7 +37,6 @@ import Data.List
import qualified Data.Map as M import qualified Data.Map as M
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import qualified Network.Socket as S import qualified Network.Socket as S
import Prelude hiding (catch)
import System.Posix.Files import System.Posix.Files
import System.Posix.Types import System.Posix.Types
import System.Time import System.Time
...@@ -294,7 +293,8 @@ updateConfig path r = do ...@@ -294,7 +293,8 @@ updateConfig path r = do
-- | Wrapper over 'updateConfig' that handles IO errors. -- | Wrapper over 'updateConfig' that handles IO errors.
safeUpdateConfig :: FilePath -> FStat -> CRef -> IO (FStat, ConfigReload) safeUpdateConfig :: FilePath -> FStat -> CRef -> IO (FStat, ConfigReload)
safeUpdateConfig path oldfstat cref = safeUpdateConfig path oldfstat cref =
catch (do Control.Exception.catch
(do
nt <- needsReload oldfstat path nt <- needsReload oldfstat path
case nt of case nt of
Nothing -> return (oldfstat, ConfigToDate) Nothing -> return (oldfstat, ConfigToDate)
...@@ -418,7 +418,8 @@ onReloadInner inotiaction path cref ...@@ -418,7 +418,8 @@ onReloadInner inotiaction path cref
-- it will return False. -- it will return False.
addNotifier :: INotify -> FilePath -> CRef -> MVar ServerState -> IO Bool addNotifier :: INotify -> FilePath -> CRef -> MVar ServerState -> IO Bool
addNotifier inotify path cref mstate = addNotifier inotify path cref mstate =
catch (addWatch inotify [CloseWrite] path Control.Exception.catch
(addWatch inotify [CloseWrite] path
(onInotify inotify path cref mstate) >> return True) (onInotify inotify path cref mstate) >> return True)
(\e -> const (return False) (e::IOError)) (\e -> const (return False) (e::IOError))
......
...@@ -48,7 +48,6 @@ import Data.Maybe (fromMaybe) ...@@ -48,7 +48,6 @@ import Data.Maybe (fromMaybe)
import Data.Word import Data.Word
import GHC.IO.Handle (hDuplicateTo) import GHC.IO.Handle (hDuplicateTo)
import qualified Network.Socket as Socket import qualified Network.Socket as Socket
import Prelude hiding (catch)
import System.Console.GetOpt import System.Console.GetOpt
import System.Exit import System.Exit
import System.Environment import System.Environment
...@@ -200,7 +199,8 @@ formatIOError msg err = msg ++ ": " ++ show err ...@@ -200,7 +199,8 @@ formatIOError msg err = msg ++ ": " ++ show err
-- 'Bad' value. -- 'Bad' value.
writePidFile :: FilePath -> IO (Result Fd) writePidFile :: FilePath -> IO (Result Fd)
writePidFile path = writePidFile path =
catch (fmap Ok $ _writePidFile path) Control.Exception.catch
(fmap Ok $ _writePidFile path)
(return . Bad . formatIOError "Failure during writing of the pid file") (return . Bad . formatIOError "Failure during writing of the pid file")
-- | Helper function to ensure a socket doesn't exist. Should only be -- | Helper function to ensure a socket doesn't exist. Should only be
...@@ -271,8 +271,9 @@ parseAddress opts defport = do ...@@ -271,8 +271,9 @@ parseAddress opts defport = do
def_family <- Ssconf.getPrimaryIPFamily Nothing def_family <- Ssconf.getPrimaryIPFamily Nothing
case optBindAddress opts of case optBindAddress opts of
Nothing -> return (def_family >>= defaultBindAddr port) Nothing -> return (def_family >>= defaultBindAddr port)
Just saddr -> catch (resolveAddr port saddr) Just saddr -> Control.Exception.catch
(annotateIOError $ "Invalid address " ++ saddr) (resolveAddr port saddr)
(annotateIOError $ "Invalid address " ++ saddr)
-- | Run an I/O action as a daemon. -- | Run an I/O action as a daemon.
-- --
......
...@@ -38,7 +38,6 @@ import Network.Curl ...@@ -38,7 +38,6 @@ import Network.Curl
import Network.Curl.Types () import Network.Curl.Types ()
#endif #endif
import Control.Monad import Control.Monad
import Prelude hiding (catch)
import Text.JSON (JSObject, fromJSObject, decodeStrict) import Text.JSON (JSObject, fromJSObject, decodeStrict)
import Text.JSON.Types (JSValue(..)) import Text.JSON.Types (JSValue(..))
import Text.Printf (printf) import Text.Printf (printf)
...@@ -94,8 +93,8 @@ getUrl url = do ...@@ -94,8 +93,8 @@ getUrl url = do
-- | Helper to convert I/O errors in 'Bad' values. -- | Helper to convert I/O errors in 'Bad' values.
ioErrToResult :: IO a -> IO (Result a) ioErrToResult :: IO a -> IO (Result a)
ioErrToResult ioaction = ioErrToResult ioaction =
catch (liftM Ok ioaction) Control.Exception.catch (liftM Ok ioaction)
(\e -> return . Bad . show $ (e::IOException)) (\e -> return . Bad . show $ (e::IOException))
-- | Append the default port if not passed in. -- | Append the default port if not passed in.
formatHost :: String -> String formatHost :: String -> String
......
...@@ -36,7 +36,6 @@ module Ganeti.HTools.ExtLoader ...@@ -36,7 +36,6 @@ module Ganeti.HTools.ExtLoader
import Control.Monad import Control.Monad
import Control.Exception import Control.Exception
import Data.Maybe (isJust, fromJust) import Data.Maybe (isJust, fromJust)
import Prelude hiding (catch)
import System.FilePath import System.FilePath
import System.IO import System.IO
import Text.Printf (hPrintf) import Text.Printf (hPrintf)
......
...@@ -40,7 +40,6 @@ import Control.Exception ...@@ -40,7 +40,6 @@ import Control.Exception
import Control.Monad (liftM) import Control.Monad (liftM)
import Data.Char (isSpace) import Data.Char (isSpace)
import Data.Maybe (fromMaybe) import Data.Maybe (fromMaybe)
import Prelude hiding (catch)
import qualified Network.Socket as Socket import qualified Network.Socket as Socket
import System.FilePath ((</>)) import System.FilePath ((</>))
import System.IO.Error (isDoesNotExistError) import System.IO.Error (isDoesNotExistError)
...@@ -97,7 +96,8 @@ catchIOErrors :: Maybe a -- ^ Optional default ...@@ -97,7 +96,8 @@ catchIOErrors :: Maybe a -- ^ Optional default
-> IO a -- ^ Action to run -> IO a -- ^ Action to run
-> IO (Result a) -> IO (Result a)
catchIOErrors def action = catchIOErrors def action =
catch (do Control.Exception.catch
(do
result <- action result <- action
return (Ok result) return (Ok result)
) (\err -> let bad_result = Bad (show err) ) (\err -> let bad_result = Bad (show err)
......
...@@ -28,7 +28,6 @@ module Main (main) where ...@@ -28,7 +28,6 @@ module Main (main) where
import Control.Exception import Control.Exception
import Control.Monad (guard) import Control.Monad (guard)
import Data.Char (toLower) import Data.Char (toLower)
import Prelude hiding (catch)
import System.Environment import System.Environment
import System.IO import System.IO
import System.IO.Error (isDoesNotExistError) import System.IO.Error (isDoesNotExistError)
......
...@@ -423,8 +423,8 @@ class XenHypervisor(hv_base.BaseHypervisor): ...@@ -423,8 +423,8 @@ class XenHypervisor(hv_base.BaseHypervisor):
kind=constants.CONS_SSH, kind=constants.CONS_SSH,
host=instance.primary_node, host=instance.primary_node,
user=constants.SSH_CONSOLE_USER, user=constants.SSH_CONSOLE_USER,
command=[pathutils.XM_CONSOLE_WRAPPER, command=[pathutils.XEN_CONSOLE_WRAPPER,
instance.name]) constants.XEN_CMD, instance.name])
def Verify(self): def Verify(self):
"""Verify the hypervisor. """Verify the hypervisor.
......
...@@ -44,7 +44,7 @@ IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export" ...@@ -44,7 +44,7 @@ IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export"
KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper" KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper"
KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup" KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup"
PREPARE_NODE_JOIN = _autoconf.PKGLIBDIR + "/prepare-node-join" PREPARE_NODE_JOIN = _autoconf.PKGLIBDIR + "/prepare-node-join"
XM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xm-console-wrapper" XEN_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/xen-console-wrapper"
ETC_HOSTS = vcluster.ETC_HOSTS ETC_HOSTS = vcluster.ETC_HOSTS
# Top-level paths # Top-level paths
......
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA. # 02110-1301, USA.
INSTANCE="$1" XEN_CMD="$1"
INSTANCE="$2"
unpause() { unpause() {
ispaused=$(xm list -l "$INSTANCE" 2>/dev/null | ispaused=$(xm list -l "$INSTANCE" 2>/dev/null |
...@@ -35,4 +36,4 @@ unpause() { ...@@ -35,4 +36,4 @@ unpause() {
} }
unpause & unpause &
exec xm console "$INSTANCE" exec $XEN_CMD console "$INSTANCE"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment