From 1eaddbc67496099f5f0789ff691c97cca85033cf Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Fri, 12 Oct 2012 11:35:54 +0200 Subject: [PATCH] Add new constant for pending job status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This constant contains the job status' βqueuedβ, βwaitingβ and βcancelledβ. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- lib/constants.py | 10 ++++++---- lib/rapi/client.py | 10 ++++++---- test/ganeti.constants_unittest.py | 5 +++++ test/ganeti.rapi.client_unittest.py | 1 + 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/lib/constants.py b/lib/constants.py index 9738033bb..0342ddf1a 100644 --- a/lib/constants.py +++ b/lib/constants.py @@ -1498,17 +1498,19 @@ JOB_STATUS_RUNNING = "running" JOB_STATUS_CANCELED = "canceled" JOB_STATUS_SUCCESS = "success" JOB_STATUS_ERROR = "error" +JOBS_PENDING = frozenset([ + JOB_STATUS_QUEUED, + JOB_STATUS_WAITING, + JOB_STATUS_CANCELING, + ]) JOBS_FINALIZED = frozenset([ JOB_STATUS_CANCELED, JOB_STATUS_SUCCESS, JOB_STATUS_ERROR, ]) JOB_STATUS_ALL = frozenset([ - JOB_STATUS_QUEUED, - JOB_STATUS_WAITING, - JOB_STATUS_CANCELING, JOB_STATUS_RUNNING, - ]) | JOBS_FINALIZED + ]) | JOBS_PENDING | JOBS_FINALIZED # OpCode status # not yet finalized diff --git a/lib/rapi/client.py b/lib/rapi/client.py index da552fd7d..67fa6026c 100644 --- a/lib/rapi/client.py +++ b/lib/rapi/client.py @@ -80,17 +80,19 @@ JOB_STATUS_RUNNING = "running" JOB_STATUS_CANCELED = "canceled" JOB_STATUS_SUCCESS = "success" JOB_STATUS_ERROR = "error" +JOB_STATUS_PENDING = frozenset([ + JOB_STATUS_QUEUED, + JOB_STATUS_WAITING, + JOB_STATUS_CANCELING, + ]) JOB_STATUS_FINALIZED = frozenset([ JOB_STATUS_CANCELED, JOB_STATUS_SUCCESS, JOB_STATUS_ERROR, ]) JOB_STATUS_ALL = frozenset([ - JOB_STATUS_QUEUED, - JOB_STATUS_WAITING, - JOB_STATUS_CANCELING, JOB_STATUS_RUNNING, - ]) | JOB_STATUS_FINALIZED + ]) | JOB_STATUS_PENDING | JOB_STATUS_FINALIZED # Legacy name JOB_STATUS_WAITLOCK = JOB_STATUS_WAITING diff --git a/test/ganeti.constants_unittest.py b/test/ganeti.constants_unittest.py index 0b7736ce3..105a4d372 100755 --- a/test/ganeti.constants_unittest.py +++ b/test/ganeti.constants_unittest.py @@ -85,6 +85,11 @@ class TestConstants(unittest.TestCase): self.failUnless(set(constants.DISK_DT_DEFAULTS.keys()) == constants.DISK_TEMPLATES) + def testJobStatus(self): + self.assertFalse(constants.JOBS_PENDING & constants.JOBS_FINALIZED) + self.assertFalse(constants.JOBS_PENDING - constants.JOB_STATUS_ALL) + self.assertFalse(constants.JOBS_FINALIZED - constants.JOB_STATUS_ALL) + class TestExportedNames(unittest.TestCase): _VALID_NAME_RE = re.compile(r"^[A-Z][A-Z0-9_]+$") diff --git a/test/ganeti.rapi.client_unittest.py b/test/ganeti.rapi.client_unittest.py index 98f117ab5..89c1b3ac2 100755 --- a/test/ganeti.rapi.client_unittest.py +++ b/test/ganeti.rapi.client_unittest.py @@ -114,6 +114,7 @@ class TestConstants(unittest.TestCase): self.assertEqual(client.JOB_STATUS_CANCELED, constants.JOB_STATUS_CANCELED) self.assertEqual(client.JOB_STATUS_SUCCESS, constants.JOB_STATUS_SUCCESS) self.assertEqual(client.JOB_STATUS_ERROR, constants.JOB_STATUS_ERROR) + self.assertEqual(client.JOB_STATUS_PENDING, constants.JOBS_PENDING) self.assertEqual(client.JOB_STATUS_FINALIZED, constants.JOBS_FINALIZED) self.assertEqual(client.JOB_STATUS_ALL, constants.JOB_STATUS_ALL) -- GitLab