Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
File Transfer Service
fts-rest
Commits
23337969
Commit
23337969
authored
Jan 08, 2016
by
Maria Arsuaga Rios
Browse files
FTS-372
:Namespaced uuid version 5 for Atlas
parent
865d9a86
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/fts3/cli/whoami.py
View file @
23337969
...
...
@@ -52,4 +52,7 @@ class WhoAmI(Base):
self
.
logger
.
info
(
"User DN: %s"
%
whoami
[
'dn'
][
0
])
for
vo
in
whoami
[
'vos'
]:
self
.
logger
.
info
(
"VO: %s"
%
vo
)
for
vo_id
in
whoami
[
'vos_id'
]:
self
.
logger
.
info
(
"VO id: %s"
%
vo_id
)
self
.
logger
.
info
(
"Delegation id: %s"
%
whoami
[
'delegation_id'
])
self
.
logger
.
info
(
"Base id: %s"
%
whoami
[
'base_id'
])
src/fts3/rest/client/easy/submission.py
View file @
23337969
...
...
@@ -18,6 +18,10 @@ from fts3.rest.client import Submitter
from
delegate
import
delegate
from
fts3.rest.client
import
ClientError
class
JobIdGenerator
:
standard
=
'standard'
deterministic
=
'deterministic'
def
cancel
(
context
,
job_id
,
file_ids
=
None
):
"""
Cancels a job
...
...
@@ -81,7 +85,8 @@ def add_alternative_source(transfer, alt_source):
def
new_job
(
transfers
=
None
,
deletion
=
None
,
verify_checksum
=
True
,
reuse
=
False
,
overwrite
=
False
,
multihop
=
False
,
source_spacetoken
=
None
,
spacetoken
=
None
,
bring_online
=
None
,
copy_pin_lifetime
=
None
,
retry
=-
1
,
retry_delay
=
0
,
metadata
=
None
,
priority
=
None
,
strict_copy
=
False
):
retry
=-
1
,
retry_delay
=
0
,
metadata
=
None
,
priority
=
None
,
strict_copy
=
False
,
id_generator
=
JobIdGenerator
.
standard
,
sid
=
None
):
"""
Creates a new dictionary representing a job
...
...
@@ -99,6 +104,7 @@ 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
metadata: Metadata to bind to the job
priority: Job priority
Returns:
An initialized dictionary representing a job
...
...
@@ -120,7 +126,9 @@ def new_job(transfers=None, deletion=None, verify_checksum=True, reuse=False, ov
retry
=
retry
,
retry_delay
=
retry_delay
,
priority
=
priority
,
strict_copy
=
strict_copy
strict_copy
=
strict_copy
,
id_generator
=
id_generator
,
sid
=
sid
)
job
=
dict
(
files
=
transfers
,
...
...
@@ -216,3 +224,4 @@ def submit(context, job, delegation_lifetime=timedelta(hours=7), force_delegatio
submitter
=
Submitter
(
context
)
params
=
job
.
get
(
'params'
,
{})
return
submitter
.
submit
(
transfers
=
job
.
get
(
'files'
,
None
),
delete
=
job
.
get
(
'delete'
,
None
),
staging
=
job
.
get
(
'staging'
,
None
),
**
params
)
src/fts3/rest/client/submitter.py
View file @
23337969
...
...
@@ -19,8 +19,7 @@ try:
import
simplejson
as
json
except
:
import
json
class
Submitter
(
object
):
def
__init__
(
self
,
context
):
...
...
src/fts3rest/fts3rest/controllers/delegation.py
View file @
23337969
...
...
@@ -37,7 +37,7 @@ from fts3rest.lib.helpers import jsonify
from
fts3rest.lib.helpers
import
voms
from
fts3rest.lib.http_exceptions
import
HTTPMethodFailure
from
fts3rest.lib.middleware.fts3auth
import
require_certificate
from
fts3rest.lib.JobBuilder
import
get_base_id
,
get_vo_id
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -208,7 +208,11 @@ class DelegationController(BaseController):
"""
Returns the active credentials of the user
"""
return
request
.
environ
[
'fts3.User.Credentials'
]
whoami
=
request
.
environ
[
'fts3.User.Credentials'
]
whoami
.
base_id
=
get_base_id
()
for
vo
in
whoami
.
vos
:
whoami
.
vos_id
.
append
(
get_vo_id
(
vo
))
return
whoami
@
doc
.
return_type
(
'dateTime'
)
@
jsonify
...
...
src/fts3rest/fts3rest/lib/JobBuilder.py
View file @
23337969
...
...
@@ -30,9 +30,12 @@ from fts3rest.lib.http_exceptions import *
from
fts3rest.lib.scheduler.schd
import
Scheduler
from
fts3rest.lib.scheduler.db
import
Database
from
fts3rest.lib.scheduler.Cache
import
ThreadLocalCache
from
fts3.rest.client.exceptions
import
ClientError
log
=
logging
.
getLogger
(
__name__
)
BASE_ID
=
uuid
.
UUID
(
'urn:uuid:01874efb-4735-4595-bc9c-591aef8240c9'
)
DEFAULT_PARAMS
=
{
'bring_online'
:
-
1
,
'verify_checksum'
:
False
,
...
...
@@ -50,7 +53,12 @@ DEFAULT_PARAMS = {
'max_time_in_queue'
:
0
}
def
get_base_id
():
return
str
(
BASE_ID
)
def
get_vo_id
(
vo_name
):
return
str
(
uuid
.
uuid5
(
BASE_ID
,
vo_name
))
def
get_storage_element
(
uri
):
"""
Returns the storage element of the given uri, which is the scheme +
...
...
@@ -545,8 +553,18 @@ class JobBuilder(object):
raise
HTTPBadRequest
(
'Simultaneous transfer and namespace operations not supported'
)
if
files_list
is
None
and
datamg_list
is
None
:
raise
HTTPBadRequest
(
'No transfers or namespace operations specified'
)
self
.
job_id
=
str
(
uuid
.
uuid1
())
if
self
.
params
[
'id_generator'
]
==
'deterministic'
:
log
.
debug
(
"Deterministic"
)
sid
=
self
.
params
[
'sid'
]
if
sid
is
not
None
:
vo_id
=
uuid
.
uuid5
(
BASE_ID
,
self
.
user
.
vos
[
0
])
self
.
job_id
=
str
(
uuid
.
uuid5
(
vo_id
,
str
(
sid
)))
else
:
raise
ClientError
(
"Need sid for deterministic job id generation"
)
else
:
log
.
debug
(
"Standard"
)
self
.
job_id
=
str
(
uuid
.
uuid1
())
self
.
files
=
list
()
self
.
datamanagement
=
list
()
...
...
src/fts3rest/fts3rest/lib/middleware/fts3auth/credentials.py
View file @
23337969
...
...
@@ -114,8 +114,10 @@ class UserCredentials(object):
# Default
self
.
user_dn
=
None
self
.
dn
=
[]
self
.
base_id
=
[]
self
.
voms_cred
=
[]
self
.
vos
=
[]
self
.
vos_id
=
[]
self
.
roles
=
[]
self
.
level
=
[]
self
.
delegation_id
=
None
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment