diff --git a/Makefile.am b/Makefile.am index 4dec77fb9060c52b23a628494c80b7b2d3d25a37..d3103abe5ebbe22e3e7b3b050d2395f734fc8355 100644 --- a/Makefile.am +++ b/Makefile.am @@ -685,7 +685,7 @@ dist_tools_SCRIPTS = \ $(python_scripts) \ tools/kvm-console-wrapper \ tools/master-ip-setup \ - tools/xm-console-wrapper + tools/xen-console-wrapper nodist_tools_SCRIPTS = \ tools/vcluster-setup diff --git a/htest/Test/Ganeti/HTools/Cluster.hs b/htest/Test/Ganeti/HTools/Cluster.hs index 8261c06e16ef649020480709cafaa54257b8811a..fdc49240b03fa32f9f119173527798422e932bd4 100644 --- a/htest/Test/Ganeti/HTools/Cluster.hs +++ b/htest/Test/Ganeti/HTools/Cluster.hs @@ -326,7 +326,8 @@ prop_AllocBalance = forAll (choose (3, 5)) $ \count -> not (Node.offline node) && not (Node.failN1 node) ==> let nl = makeSmallCluster node count - (hnode, nl') = IntMap.deleteFindMax nl + hnode = snd $ IntMap.findMax nl + nl' = IntMap.deleteMax nl il = Container.empty allocnodes = Cluster.genAllocNodes defGroupList nl' 2 True i_templ = createInstance Types.unitMem Types.unitDsk Types.unitCpu diff --git a/htools/Ganeti/Confd/Server.hs b/htools/Ganeti/Confd/Server.hs index 2306c20b16670d5bd26a2d034a373edbe4bdd052..ae571d6e6af30c04f27a560bb2c176da3215f477 100644 --- a/htools/Ganeti/Confd/Server.hs +++ b/htools/Ganeti/Confd/Server.hs @@ -37,7 +37,6 @@ import Data.List import qualified Data.Map as M import Data.Maybe (fromMaybe) import qualified Network.Socket as S -import Prelude hiding (catch) import System.Posix.Files import System.Posix.Types import System.Time @@ -294,7 +293,8 @@ updateConfig path r = do -- | Wrapper over 'updateConfig' that handles IO errors. safeUpdateConfig :: FilePath -> FStat -> CRef -> IO (FStat, ConfigReload) safeUpdateConfig path oldfstat cref = - catch (do + Control.Exception.catch + (do nt <- needsReload oldfstat path case nt of Nothing -> return (oldfstat, ConfigToDate) @@ -418,7 +418,8 @@ onReloadInner inotiaction path cref -- it will return False. addNotifier :: INotify -> FilePath -> CRef -> MVar ServerState -> IO Bool addNotifier inotify path cref mstate = - catch (addWatch inotify [CloseWrite] path + Control.Exception.catch + (addWatch inotify [CloseWrite] path (onInotify inotify path cref mstate) >> return True) (\e -> const (return False) (e::IOError)) diff --git a/htools/Ganeti/Daemon.hs b/htools/Ganeti/Daemon.hs index 94676ad1544bca819d4e0bcda3250f2ca36ab8c2..3be311429cb83c5101aa655abc1fe84397cb3f1b 100644 --- a/htools/Ganeti/Daemon.hs +++ b/htools/Ganeti/Daemon.hs @@ -48,7 +48,6 @@ import Data.Maybe (fromMaybe) import Data.Word import GHC.IO.Handle (hDuplicateTo) import qualified Network.Socket as Socket -import Prelude hiding (catch) import System.Console.GetOpt import System.Exit import System.Environment @@ -200,7 +199,8 @@ formatIOError msg err = msg ++ ": " ++ show err -- 'Bad' value. writePidFile :: FilePath -> IO (Result Fd) writePidFile path = - catch (fmap Ok $ _writePidFile path) + Control.Exception.catch + (fmap Ok $ _writePidFile path) (return . Bad . formatIOError "Failure during writing of the pid file") -- | Helper function to ensure a socket doesn't exist. Should only be @@ -271,8 +271,9 @@ parseAddress opts defport = do def_family <- Ssconf.getPrimaryIPFamily Nothing case optBindAddress opts of Nothing -> return (def_family >>= defaultBindAddr port) - Just saddr -> catch (resolveAddr port saddr) - (annotateIOError $ "Invalid address " ++ saddr) + Just saddr -> Control.Exception.catch + (resolveAddr port saddr) + (annotateIOError $ "Invalid address " ++ saddr) -- | Run an I/O action as a daemon. -- diff --git a/htools/Ganeti/HTools/Backend/Rapi.hs b/htools/Ganeti/HTools/Backend/Rapi.hs index 28593450a3fe91a353fd78080eaf1bf98745cf25..005cfdbf17554b73774c152dd3caead885c1ae6a 100644 --- a/htools/Ganeti/HTools/Backend/Rapi.hs +++ b/htools/Ganeti/HTools/Backend/Rapi.hs @@ -38,7 +38,6 @@ import Network.Curl import Network.Curl.Types () #endif import Control.Monad -import Prelude hiding (catch) import Text.JSON (JSObject, fromJSObject, decodeStrict) import Text.JSON.Types (JSValue(..)) import Text.Printf (printf) @@ -94,8 +93,8 @@ getUrl url = do -- | Helper to convert I/O errors in 'Bad' values. ioErrToResult :: IO a -> IO (Result a) ioErrToResult ioaction = - catch (liftM Ok ioaction) - (\e -> return . Bad . show $ (e::IOException)) + Control.Exception.catch (liftM Ok ioaction) + (\e -> return . Bad . show $ (e::IOException)) -- | Append the default port if not passed in. formatHost :: String -> String diff --git a/htools/Ganeti/HTools/ExtLoader.hs b/htools/Ganeti/HTools/ExtLoader.hs index eb8121092b42e287ed13b1ff10fc68141740a478..89b147843293f8182e53e7c89d011e0871c4c55e 100644 --- a/htools/Ganeti/HTools/ExtLoader.hs +++ b/htools/Ganeti/HTools/ExtLoader.hs @@ -36,7 +36,6 @@ module Ganeti.HTools.ExtLoader import Control.Monad import Control.Exception import Data.Maybe (isJust, fromJust) -import Prelude hiding (catch) import System.FilePath import System.IO import Text.Printf (hPrintf) diff --git a/htools/Ganeti/Ssconf.hs b/htools/Ganeti/Ssconf.hs index bf3713bfbd40f323ea367a884bc3c2fc0a6a6816..192e925ae958ba5add87c9601ee2599d8f33fa81 100644 --- a/htools/Ganeti/Ssconf.hs +++ b/htools/Ganeti/Ssconf.hs @@ -40,7 +40,6 @@ import Control.Exception import Control.Monad (liftM) import Data.Char (isSpace) import Data.Maybe (fromMaybe) -import Prelude hiding (catch) import qualified Network.Socket as Socket import System.FilePath ((</>)) import System.IO.Error (isDoesNotExistError) @@ -97,7 +96,8 @@ catchIOErrors :: Maybe a -- ^ Optional default -> IO a -- ^ Action to run -> IO (Result a) catchIOErrors def action = - catch (do + Control.Exception.catch + (do result <- action return (Ok result) ) (\err -> let bad_result = Bad (show err) diff --git a/htools/htools.hs b/htools/htools.hs index cec4aa39dbe3157b1d7be8205423994ba50cfeba..35dc99d74a0cf896357750e08d5959753c902f73 100644 --- a/htools/htools.hs +++ b/htools/htools.hs @@ -28,7 +28,6 @@ module Main (main) where import Control.Exception import Control.Monad (guard) import Data.Char (toLower) -import Prelude hiding (catch) import System.Environment import System.IO import System.IO.Error (isDoesNotExistError) diff --git a/lib/hypervisor/hv_xen.py b/lib/hypervisor/hv_xen.py index 9be1a0e90e16a39df93c8efe2c4f2c04f8301134..37ca7b518492328d107634bb309097ab88d3ca0d 100644 --- a/lib/hypervisor/hv_xen.py +++ b/lib/hypervisor/hv_xen.py @@ -423,8 +423,8 @@ class XenHypervisor(hv_base.BaseHypervisor): kind=constants.CONS_SSH, host=instance.primary_node, user=constants.SSH_CONSOLE_USER, - command=[pathutils.XM_CONSOLE_WRAPPER, - instance.name]) + command=[pathutils.XEN_CONSOLE_WRAPPER, + constants.XEN_CMD, instance.name]) def Verify(self): """Verify the hypervisor. diff --git a/lib/pathutils.py b/lib/pathutils.py index bab240911b4ce4c875314fab91fa5ad2ab1846e7..ca78ea8c45f257271bf16a2c34ea9fab51bd6582 100644 --- a/lib/pathutils.py +++ b/lib/pathutils.py @@ -44,7 +44,7 @@ IMPORT_EXPORT_DAEMON = _autoconf.PKGLIBDIR + "/import-export" KVM_CONSOLE_WRAPPER = _autoconf.PKGLIBDIR + "/tools/kvm-console-wrapper" KVM_IFUP = _autoconf.PKGLIBDIR + "/kvm-ifup" 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 # Top-level paths diff --git a/tools/xm-console-wrapper b/tools/xen-console-wrapper similarity index 95% rename from tools/xm-console-wrapper rename to tools/xen-console-wrapper index d6fd556637f4fa324009fd5349bc7885c411b146..f3d015a4a62f41d4d843f0a0ed3238581e2d836f 100755 --- a/tools/xm-console-wrapper +++ b/tools/xen-console-wrapper @@ -18,7 +18,8 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA. -INSTANCE="$1" +XEN_CMD="$1" +INSTANCE="$2" unpause() { ispaused=$(xm list -l "$INSTANCE" 2>/dev/null | @@ -35,4 +36,4 @@ unpause() { } unpause & -exec xm console "$INSTANCE" +exec $XEN_CMD console "$INSTANCE"