Change in vdsm[master]: jobs: By default jobs do not support abort

Nir Soffer nsoffer at redhat.com
Mon Nov 30 19:32:44 UTC 2015


Hello Adam Litke,

I'd like you to do a code review.  Please visit

    https://gerrit.ovirt.org/49449

to review the following change.

Change subject: jobs: By default jobs do not support abort
......................................................................

jobs: By default jobs do not support abort

Change-Id: I9084a32a99e8252b1526d86aae7994c2bebc7a96
Signed-off-by: Adam Litke <alitke at redhat.com>
---
M lib/vdsm/define.py
M lib/vdsm/jobs.py
M tests/jobsTests.py
3 files changed, 15 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/49/49449/1

diff --git a/lib/vdsm/define.py b/lib/vdsm/define.py
index 0943939..4670bfa 100644
--- a/lib/vdsm/define.py
+++ b/lib/vdsm/define.py
@@ -193,6 +193,9 @@
     'destVolumeTooSmall': {'status': {
         'code': 79,
         'message': 'Destination volume is too small'}},
+    'AbortNotSupported': {'status': {
+        'code': 80,
+        'message': 'Job does not support aborting'}},
     'recovery': {'status': {
         'code': 99,
         'message': 'Recovering from crash or Initializing'}},
diff --git a/lib/vdsm/jobs.py b/lib/vdsm/jobs.py
index 5949084..8c7c30e 100644
--- a/lib/vdsm/jobs.py
+++ b/lib/vdsm/jobs.py
@@ -60,6 +60,11 @@
     name = 'JobNotDone'
 
 
+class AbortNotSupported(ClientError):
+    ''' This type of job does not support aborting '''
+    name = 'AbortNotSupported'
+
+
 class Job(object):
     _JOB_TYPE = None
 
@@ -113,6 +118,7 @@
         """
         May be implemented by child class
         """
+        raise AbortNotSupported()
 
 
 # This helper should only be called by test code.  Everything else should be
diff --git a/tests/jobsTests.py b/tests/jobsTests.py
index 373c916..0c83e5b 100644
--- a/tests/jobsTests.py
+++ b/tests/jobsTests.py
@@ -115,6 +115,12 @@
         self.assertEqual(response.error(jobs.NoSuchJob.name),
                          jobs.abort('foo'))
 
+    def test_abort_not_supported(self):
+        job = jobs.Job(str(uuid.uuid4()))
+        jobs.add(job)
+        self.assertEqual(response.error(jobs.AbortNotSupported.name),
+                         jobs.abort(job.id))
+
     @permutations([
         [jobs.STATUS.ABORTED],
         [jobs.STATUS.DONE],


-- 
To view, visit https://gerrit.ovirt.org/49449
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9084a32a99e8252b1526d86aae7994c2bebc7a96
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Adam Litke <alitke at redhat.com>
Gerrit-Reviewer: Nir Soffer <nsoffer at redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation at ovirt.org>


More information about the vdsm-patches mailing list