Commit c09a8bd1 authored by Maria Arsuaga Rios's avatar Maria Arsuaga Rios
Browse files

FTS-372:Eliminate ClientError raise and use HTTPBadRequest

parent 95edbcfa
...@@ -104,7 +104,8 @@ def new_job(transfers=None, deletion=None, verify_checksum=True, reuse=False, ov ...@@ -104,7 +104,8 @@ def new_job(transfers=None, deletion=None, verify_checksum=True, reuse=False, ov
retry: Number of retries: <0 is no retries, 0 is server default, >0 is whatever value is passed retry: Number of retries: <0 is no retries, 0 is server default, >0 is whatever value is passed
metadata: Metadata to bind to the job metadata: Metadata to bind to the job
priority: Job priority priority: Job priority
id_generator: Job generator id algorithm
sid: Specific id given by the client
Returns: Returns:
An initialized dictionary representing a job An initialized dictionary representing a job
...@@ -137,7 +138,7 @@ def new_job(transfers=None, deletion=None, verify_checksum=True, reuse=False, ov ...@@ -137,7 +138,7 @@ def new_job(transfers=None, deletion=None, verify_checksum=True, reuse=False, ov
) )
return job return job
def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spacetoken=None, spacetoken=None, metadata=None, priority=None): def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spacetoken=None, spacetoken=None, metadata=None, priority=None, id_generator=JobIdGenerator.standard, sid=None):
""" """
Creates a new dictionary representing a staging job Creates a new dictionary representing a staging job
...@@ -149,6 +150,8 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa ...@@ -149,6 +150,8 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa
spacetoken: Deletion spacetoken spacetoken: Deletion spacetoken
metadata: Metadata to bind to the job metadata: Metadata to bind to the job
priority: Job priority priority: Job priority
id_generator: Job generator id algorithm
sid: Specific id given by the client
Returns: Returns:
An initialized dictionary representing a staging job An initialized dictionary representing a staging job
...@@ -176,6 +179,8 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa ...@@ -176,6 +179,8 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa
copy_pin_lifetime=copy_pin_lifetime, copy_pin_lifetime=copy_pin_lifetime,
job_metadata=metadata, job_metadata=metadata,
priority=priority, priority=priority,
id_generator=id_generator,
sid=sid
) )
job = dict( job = dict(
files=transfers, files=transfers,
...@@ -183,7 +188,7 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa ...@@ -183,7 +188,7 @@ def new_staging_job(files, bring_online=None, copy_pin_lifetime=None, source_spa
) )
return job return job
def new_delete_job(files, spacetoken=None, metadata=None, priority=None): def new_delete_job(files, spacetoken=None, metadata=None, priority=None, id_generator=JobIdGenerator.standard, sid=None):
""" """
Creates a new dictionary representing a deletion job Creates a new dictionary representing a deletion job
...@@ -191,14 +196,17 @@ def new_delete_job(files, spacetoken=None, metadata=None, priority=None): ...@@ -191,14 +196,17 @@ def new_delete_job(files, spacetoken=None, metadata=None, priority=None):
files: Array of surls to delete. Each item can be either a string or a dictionary with keys surl and metadata files: Array of surls to delete. Each item can be either a string or a dictionary with keys surl and metadata
spacetoken: Deletion spacetoken spacetoken: Deletion spacetoken
metadata: Metadata to bind to the job metadata: Metadata to bind to the job
id_generator: Job generator id algorithm
sid: Specific id given by the client
Return Return
An initialized dictionary representing a deletion job An initialized dictionary representing a deletion job
""" """
params = dict( params = dict(
source_spacetoken=spacetoken, source_spacetoken=spacetoken,
job_metadata=metadata, job_metadata=metadata,
priority=priority priority=priority,
id_generator=id_generator,
sid=sid
) )
job = dict( job = dict(
delete=files, delete=files,
......
...@@ -30,7 +30,7 @@ from fts3rest.lib.http_exceptions import * ...@@ -30,7 +30,7 @@ from fts3rest.lib.http_exceptions import *
from fts3rest.lib.scheduler.schd import Scheduler from fts3rest.lib.scheduler.schd import Scheduler
from fts3rest.lib.scheduler.db import Database from fts3rest.lib.scheduler.db import Database
from fts3rest.lib.scheduler.Cache import ThreadLocalCache from fts3rest.lib.scheduler.Cache import ThreadLocalCache
from fts3.rest.client.exceptions import ClientError
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -561,9 +561,8 @@ class JobBuilder(object): ...@@ -561,9 +561,8 @@ class JobBuilder(object):
vo_id = uuid.uuid5(BASE_ID, self.user.vos[0]) vo_id = uuid.uuid5(BASE_ID, self.user.vos[0])
self.job_id = str(uuid.uuid5(vo_id, str(sid))) self.job_id = str(uuid.uuid5(vo_id, str(sid)))
else: else:
raise ClientError("Need sid for deterministic job id generation") raise HTTPBadRequest("Need sid for deterministic job id generation")
else: else:
log.debug("Standard")
self.job_id = str(uuid.uuid1()) self.job_id = str(uuid.uuid1())
self.files = list() self.files = list()
self.datamanagement = list() self.datamanagement = list()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment