Hs2Py constants: SSL, job queue, and locks
authorJose A. Lopes <jabolopes@google.com>
Fri, 4 Oct 2013 17:21:17 +0000 (19:21 +0200)
committerJose A. Lopes <jabolopes@google.com>
Tue, 8 Oct 2013 12:57:29 +0000 (14:57 +0200)
Add SSL, job queue, and locks related constants to the Haskell to Python constant generation.

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

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

index 9b7b9a7..075ae8f 100644 (file)
@@ -1116,9 +1116,8 @@ NR_DRAINED = _constants.NR_DRAINED
 NR_OFFLINE = _constants.NR_OFFLINE
 NR_ALL = _constants.NR_ALL
 
-# SSL certificate check constants (in days)
-SSL_CERT_EXPIRATION_WARN = 30
-SSL_CERT_EXPIRATION_ERROR = 7
+SSL_CERT_EXPIRATION_WARN = _constants.SSL_CERT_EXPIRATION_WARN
+SSL_CERT_EXPIRATION_ERROR = _constants.SSL_CERT_EXPIRATION_ERROR
 
 # Allocator framework constants
 IALLOCATOR_VERSION = _constants.IALLOCATOR_VERSION
@@ -1142,16 +1141,14 @@ NODE_EVAC_SEC = _constants.NODE_EVAC_SEC
 NODE_EVAC_ALL = _constants.NODE_EVAC_ALL
 NODE_EVAC_MODES = _constants.NODE_EVAC_MODES
 
-# Job queue
-JOB_QUEUE_VERSION = 1
-JOB_QUEUE_SIZE_HARD_LIMIT = 5000
-JOB_QUEUE_FILES_PERMS = 0640
+JOB_QUEUE_VERSION = _constants.JOB_QUEUE_VERSION
+JOB_QUEUE_SIZE_HARD_LIMIT = _constants.JOB_QUEUE_SIZE_HARD_LIMIT
+JOB_QUEUE_FILES_PERMS = _constants.JOB_QUEUE_FILES_PERMS
 
 JOB_ID_TEMPLATE = r"\d+"
 JOB_FILE_RE = re.compile(r"^job-(%s)$" % JOB_ID_TEMPLATE)
 
-# unchanged job return
-JOB_NOTCHANGED = "nochange"
+JOB_NOTCHANGED = _constants.JOB_NOTCHANGED
 
 # Job status
 JOB_STATUS_QUEUED = _constants.JOB_STATUS_QUEUED
@@ -1186,18 +1183,12 @@ OP_PRIO_HIGH = _constants.OP_PRIO_HIGH
 OP_PRIO_SUBMIT_VALID = _constants.OP_PRIO_SUBMIT_VALID
 OP_PRIO_DEFAULT = _constants.OP_PRIO_DEFAULT
 
-# Lock recalculate mode
-LOCKS_REPLACE = "replace"
-LOCKS_APPEND = "append"
-
-# Lock timeout (sum) before we should go into blocking acquire (still
-# can be reset by priority change); computed as max time (10 hours)
-# before we should actually go into blocking acquire given that we
-# start from default priority level; in seconds
-# TODO
-LOCK_ATTEMPTS_TIMEOUT = 10 * 3600 / (OP_PRIO_DEFAULT - OP_PRIO_HIGHEST)
-LOCK_ATTEMPTS_MAXWAIT = 15.0
-LOCK_ATTEMPTS_MINWAIT = 1.0
+LOCKS_REPLACE = _constants.LOCKS_REPLACE
+LOCKS_APPEND = _constants.LOCKS_APPEND
+
+LOCK_ATTEMPTS_TIMEOUT = _constants.LOCK_ATTEMPTS_TIMEOUT
+LOCK_ATTEMPTS_MAXWAIT = _constants.LOCK_ATTEMPTS_MAXWAIT
+LOCK_ATTEMPTS_MINWAIT = _constants.LOCK_ATTEMPTS_MINWAIT
 
 # Execution log types
 ELOG_MESSAGE = _constants.ELOG_MESSAGE
index ee476a4..7848b7d 100644 (file)
@@ -2701,6 +2701,14 @@ nrRegular = Types.nodeRoleToRaw NRRegular
 nrAll :: FrozenSet String
 nrAll = ConstantUtils.mkSet $ map Types.nodeRoleToRaw [minBound..]
 
+-- * SSL certificate check constants (in days)
+
+sslCertExpirationError :: Int
+sslCertExpirationError = 7
+
+sslCertExpirationWarn :: Int
+sslCertExpirationWarn = 30
+
 -- * Allocator framework constants
 
 iallocatorVersion :: Int
@@ -2755,6 +2763,22 @@ nodeEvacAll = Types.evacModeToRaw ChangeAll
 nodeEvacModes :: FrozenSet String
 nodeEvacModes = ConstantUtils.mkSet $ map Types.evacModeToRaw [minBound..]
 
+-- * Job queue
+
+jobQueueVersion :: Int
+jobQueueVersion = 1
+
+jobQueueSizeHardLimit :: Int
+jobQueueSizeHardLimit = 5000
+
+jobQueueFilesPerms :: Int
+jobQueueFilesPerms = 0o640
+
+-- * Unchanged job return
+
+jobNotchanged :: String
+jobNotchanged = "nochange"
+
 -- * Job status
 
 jobStatusQueued :: String
@@ -2843,6 +2867,30 @@ opPrioSubmitValid = ConstantUtils.mkSet [opPrioLow, opPrioNormal, opPrioHigh]
 opPrioDefault :: Int
 opPrioDefault = opPrioNormal
 
+-- * Lock recalculate mode
+
+locksAppend :: String
+locksAppend = "append"
+
+locksReplace :: String
+locksReplace = "replace"
+
+-- * Lock timeout
+--
+-- The lock timeout (sum) before we transition into blocking acquire
+-- (this can still be reset by priority change).  Computed as max time
+-- (10 hours) before we should actually go into blocking acquire,
+-- given that we start from the default priority level.
+
+lockAttemptsMaxwait :: Double
+lockAttemptsMaxwait = 15.0
+
+lockAttemptsMinwait :: Double
+lockAttemptsMinwait = 1.0
+
+lockAttemptsTimeout :: Int
+lockAttemptsTimeout = (10 * 3600) `div` (opPrioDefault - opPrioHighest)
+
 -- * Execution log types
 
 elogMessage :: String