From e5d8774beb203ea8580defe9893eca1bdb2192d2 Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Thu, 2 Sep 2010 18:28:30 +0200 Subject: [PATCH] Add job priority constants Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/constants.py | 10 ++++++++++ test/ganeti.constants_unittest.py | 9 +++++++++ 2 files changed, 19 insertions(+) diff --git a/lib/constants.py b/lib/constants.py index 402549859..51783416c 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -841,6 +841,16 @@ OPS_FINALIZED = frozenset([OP_STATUS_CANCELED, OP_STATUS_SUCCESS, OP_STATUS_ERROR]) +# OpCode priority +OP_PRIO_LOWEST = +19 +OP_PRIO_HIGHEST = -20 + +OP_PRIO_LOW = +10 +OP_PRIO_NORMAL = 0 +OP_PRIO_HIGH = -10 + +OP_PRIO_DEFAULT = OP_PRIO_NORMAL + # Execution log types ELOG_MESSAGE = "message" ELOG_PROGRESS = "progress" diff --git a/test/ganeti.constants_unittest.py b/test/ganeti.constants_unittest.py index d73d6503c..9aab10fa1 100755 --- a/test/ganeti.constants_unittest.py +++ b/test/ganeti.constants_unittest.py @@ -26,6 +26,7 @@ import unittest import re from ganeti import constants +from ganeti import locking import testutils @@ -68,6 +69,14 @@ class TestConstants(unittest.TestCase): self.failUnless(constants.SSL_CERT_EXPIRATION_ERROR < constants.SSL_CERT_EXPIRATION_WARN) + def testOpCodePriority(self): + self.failUnless(constants.OP_PRIO_LOWEST > constants.OP_PRIO_LOW) + self.failUnless(constants.OP_PRIO_LOW > constants.OP_PRIO_NORMAL) + self.failUnlessEqual(constants.OP_PRIO_NORMAL, locking._DEFAULT_PRIORITY) + self.failUnlessEqual(constants.OP_PRIO_DEFAULT, locking._DEFAULT_PRIORITY) + self.failUnless(constants.OP_PRIO_NORMAL > constants.OP_PRIO_HIGH) + self.failUnless(constants.OP_PRIO_HIGH > constants.OP_PRIO_HIGHEST) + class TestParameterNames(unittest.TestCase): """HV/BE parameter tests""" -- GitLab