Hs2Py constants: add Luxi constants
authorJose A. Lopes <jabolopes@google.com>
Fri, 4 Oct 2013 12:11:47 +0000 (14:11 +0200)
committerJose A. Lopes <jabolopes@google.com>
Tue, 8 Oct 2013 12:57:26 +0000 (14:57 +0200)
Add Luxi related constants to the Haskell to Python constant
generation.  A new Haskell type is added 'Ganeti.Types.PythonChar' to
wrap the Python character type.

Signed-off-by: Jose A. Lopes <jabolopes@google.com>
Reviewed-by: Thomas Thrainer <thomasth@google.com>

lib/constants.py
src/Ganeti/ConstantUtils.hs
src/Ganeti/HsConstants.hs

index ca99f07..1d5e19d 100644 (file)
@@ -169,14 +169,11 @@ DEV_CONSOLE = _constants.DEV_CONSOLE
 
 PROC_MOUNTS = "/proc/mounts"
 
-# Local UniX Interface related constants
-LUXI_EOM = chr(3)
-LUXI_VERSION = CONFIG_VERSION
-#: Environment variable for the luxi override socket
-LUXI_OVERRIDE = "FORCE_LUXI_SOCKET"
-LUXI_OVERRIDE_MASTER = "master"
-LUXI_OVERRIDE_QUERY = "query"
-
+LUXI_EOM = _constants.LUXI_EOM
+LUXI_VERSION = _constants.LUXI_VERSION
+LUXI_OVERRIDE = _constants.LUXI_OVERRIDE
+LUXI_OVERRIDE_MASTER = _constants.LUXI_OVERRIDE_MASTER
+LUXI_OVERRIDE_QUERY = _constants.LUXI_OVERRIDE_QUERY
 # one of "no", "yes", "only"
 SYSLOG_USAGE = _constants.SYSLOG_USAGE
 SYSLOG_NO = _constants.SYSLOG_NO
index 62285dc..f6ea748 100644 (file)
@@ -28,12 +28,20 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 -}
 module Ganeti.ConstantUtils where
 
+import Data.Char (ord)
 import Data.Set (Set)
 import qualified Data.Set as Set (fromList, toList)
 
 import Ganeti.THH (PyValue(..))
 import Ganeti.PyValueInstances ()
 
+-- | PythonChar wraps a Python 'char'
+newtype PythonChar = PythonChar { unPythonChar :: Char }
+  deriving (Show)
+
+instance PyValue PythonChar where
+  showValue c = "chr(" ++ show (ord (unPythonChar c)) ++ ")"
+
 -- | FrozenSet wraps a Haskell 'Set'
 --
 -- See 'PyValue' instance for 'FrozenSet'.
index 5e5b243..4bd9139 100644 (file)
@@ -41,7 +41,8 @@ import Data.Map (Map)
 import qualified Data.Map as Map (fromList, keys, insert)
 
 import AutoConf
-import Ganeti.ConstantUtils (FrozenSet, Protocol(..), buildVersion)
+import Ganeti.ConstantUtils (PythonChar(..), FrozenSet, Protocol(..),
+                             buildVersion)
 import qualified Ganeti.ConstantUtils as ConstantUtils
 import Ganeti.Runtime (GanetiDaemon(..), MiscGroup(..), GanetiGroup(..),
                        ExtraLogReason(..))
@@ -341,6 +342,24 @@ extraLogreasonError = Runtime.daemonsExtraLogbase GanetiMond ErrorLog
 devConsole :: String
 devConsole = ConstantUtils.devConsole
 
+-- * Luxi (Local UniX Interface) related constants
+
+luxiEom :: PythonChar
+luxiEom = PythonChar '\x03'
+
+-- | Environment variable for the luxi override socket
+luxiOverride :: String
+luxiOverride = "FORCE_LUXI_SOCKET"
+
+luxiOverrideMaster :: String
+luxiOverrideMaster = "master"
+
+luxiOverrideQuery :: String
+luxiOverrideQuery = "query"
+
+luxiVersion :: Int
+luxiVersion = configVersion
+
 -- * Syslog
 
 syslogUsage :: String