Skip to content
GitLab
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
f3aa3ef6
Commit
f3aa3ef6
authored
Dec 03, 2018
by
Andrea Manzi
Browse files
Resolve
FTS-1324
parent
7e3301f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/fts3rest/fts3rest/controllers/banning.py
View file @
f3aa3ef6
...
...
@@ -282,9 +282,8 @@ class BanningController(BaseController):
if
not
storage
:
raise
HTTPBadRequest
(
'Missing storage parameter'
)
vo_name
=
input_dict
.
get
(
'vo_name'
,
'*'
)
if
vo_name
is
None
or
vo_name
==
''
:
raise
HTTPBadRequest
(
'vo_name can not be null'
)
user
=
request
.
environ
[
'fts3.User.Credentials'
]
vo_name
=
user
.
vos
[
0
]
allow_submit
=
bool
(
input_dict
.
get
(
'allow_submit'
,
False
))
status
=
input_dict
.
get
(
'status'
,
'cancel'
).
upper
()
...
...
@@ -355,8 +354,10 @@ class BanningController(BaseController):
raise
HTTPBadRequest
(
'Missing storage parameter'
)
job_ids
=
[]
try
:
Session
.
query
(
BannedSE
).
filter
(
BannedSE
.
se
==
storage
).
delete
()
job_ids
=
_reenter_queue
(
storage
,
'*'
)
user
=
request
.
environ
[
'fts3.User.Credentials'
]
vo_name
=
user
.
vos
[
0
]
Session
.
query
(
BannedSE
).
filter
(
BannedSE
.
se
==
storage
,
BannedSE
.
vo
==
vo_name
).
delete
()
job_ids
=
_reenter_queue
(
storage
,
vo_name
)
Session
.
commit
()
except
Exception
:
Session
.
rollback
()
...
...
src/fts3rest/fts3rest/tests/functional/test_banning.py
View file @
f3aa3ef6
...
...
@@ -100,13 +100,13 @@ class TestBanning(TestController):
"""
jobs
=
list
()
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
,
user_dn
=
'/DC=cern/CN=someone'
)
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
,
user_dn
=
'/DC=cern/CN=someone'
)
)
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
,
user_dn
=
'/DC=cern/CN=someone'
)
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
,
user_dn
=
'/DC=cern/CN=someone'
)
)
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
,
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
,
user_dn
=
'/DC=cern/CN=someone'
)
)
...
...
@@ -148,16 +148,13 @@ class TestBanning(TestController):
status
=
200
).
json
self
.
assertEqual
(
0
,
len
(
canceled
))
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'*'
))
banned
=
Session
.
query
(
BannedSE
).
filter
(
BannedSE
.
se
==
'gsiftp://nowhere'
).
first
()
self
.
assertNotEqual
(
None
,
banned
)
self
.
assertEqual
(
self
.
get_user_credentials
().
user_dn
,
banned
.
admin_dn
)
self
.
assertEqual
(
'CANCEL'
,
banned
.
status
)
self
.
assertEqual
(
'*'
,
banned
.
vo
)
self
.
assertEqual
(
'TEST BAN 42'
,
banned
.
message
)
self
.
app
.
delete
(
url
=
"/ban/se?storage=%s"
%
urllib
.
quote
(
'gsiftp://nowhere'
),
status
=
204
)
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'*'
)
)
banned
=
Session
.
query
(
BannedSE
).
filter
(
BannedSE
.
se
==
'gsiftp://nowhere'
).
first
(
)
self
.
assertEqual
(
None
,
banned
)
def
test_list_banned_ses
(
self
):
...
...
@@ -185,19 +182,19 @@ class TestBanning(TestController):
"""
canceled
=
self
.
app
.
post
(
url
=
"/ban/se"
,
params
=
{
'storage'
:
'gsiftp://nowhere'
,
'vo_name'
:
'
d
te
am
'
},
params
=
{
'storage'
:
'gsiftp://nowhere'
,
'vo_name'
:
'te
stvo
'
},
status
=
200
).
json
self
.
assertEqual
(
0
,
len
(
canceled
))
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'
d
te
am
'
))
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'te
stvo
'
))
self
.
assertNotEqual
(
None
,
banned
)
self
.
assertEqual
(
self
.
get_user_credentials
().
user_dn
,
banned
.
admin_dn
)
self
.
assertEqual
(
'CANCEL'
,
banned
.
status
)
self
.
assertEqual
(
'
d
te
am
'
,
banned
.
vo
)
self
.
assertEqual
(
'te
stvo
'
,
banned
.
vo
)
self
.
app
.
delete
(
url
=
"/ban/se?storage=%s&vo_name=
d
te
am
"
%
urllib
.
quote
(
'gsiftp://nowhere'
),
status
=
204
)
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'
dteam
'
))
self
.
app
.
delete
(
url
=
"/ban/se?storage=%s&vo_name=te
stvo
"
%
urllib
.
quote
(
'gsiftp://nowhere'
),
status
=
204
)
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://nowhere'
,
'
someone
'
))
self
.
assertEqual
(
None
,
banned
)
def
test_ban_se_cancel
(
self
):
...
...
@@ -205,9 +202,9 @@ class TestBanning(TestController):
Ban a SE that has files queued, make sure they are canceled
"""
jobs
=
list
()
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
))
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
))
canceled_ids
=
self
.
app
.
post
(
url
=
"/ban/se"
,
...
...
@@ -241,7 +238,7 @@ class TestBanning(TestController):
Ban a SE that has files queued. If a job has other pairs, the job must remain!
"""
job_id
=
insert_job
(
'
d
te
am
'
,
'te
stvo
'
,
multiple
=
[(
'gsiftp://source'
,
'gsiftp://destination'
),
(
'gsiftp://other'
,
'gsiftp://destination'
)]
)
canceled_ids
=
self
.
app
.
post
(
...
...
@@ -270,13 +267,13 @@ class TestBanning(TestController):
Cancel a SE that has files queued, make sure they are canceled (with VO)
"""
jobs
=
list
()
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'atlas'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'atlas'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'SUBMITTED'
))
canceled_ids
=
self
.
app
.
post
(
url
=
"/ban/se"
,
params
=
{
'storage'
:
'gsiftp://source'
,
'status'
:
'cancel'
,
'vo_name'
:
'
d
te
am
'
},
params
=
{
'storage'
:
'gsiftp://source'
,
'status'
:
'cancel'
,
'vo_name'
:
'te
stvo
'
},
status
=
200
).
json
...
...
@@ -302,9 +299,9 @@ class TestBanning(TestController):
Ban a SE, but instead of canceling, give jobs some time to finish
"""
jobs
=
list
()
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
))
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'ACTIVE'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'FAILED'
,
duration
=
10
,
queued
=
20
))
waiting_ids
=
self
.
app
.
post
(
url
=
"/ban/se"
,
...
...
@@ -332,7 +329,7 @@ class TestBanning(TestController):
for
f
in
files
:
self
.
assertEqual
(
'FAILED'
,
f
.
file_state
)
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://source'
,
'
*
'
))
banned
=
Session
.
query
(
BannedSE
).
get
((
'gsiftp://source'
,
'
testvo
'
))
self
.
assertEqual
(
'WAIT'
,
banned
.
status
)
def
test_ban_se_wait_vo
(
self
):
...
...
@@ -340,13 +337,13 @@ class TestBanning(TestController):
Ban a SE, but instead of canceling, give jobs some time to finish (with VO)
"""
jobs
=
list
()
jobs
.
append
(
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'atlas'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
))
jobs
.
append
(
insert_job
(
'atlas'
,
'gsiftp://source'
,
'gsiftp://destination2'
,
'SUBMITTED'
))
waiting_ids
=
self
.
app
.
post
(
url
=
"/ban/se"
,
params
=
{
'storage'
:
'gsiftp://source'
,
'status'
:
'wait'
,
'vo_name'
:
'
d
te
am
'
,
'timeout'
:
33
},
params
=
{
'storage'
:
'gsiftp://source'
,
'status'
:
'wait'
,
'vo_name'
:
'te
stvo
'
,
'timeout'
:
33
},
status
=
200
).
json
...
...
@@ -440,7 +437,7 @@ class TestBanning(TestController):
Regression for FTS-297
When unbanning a storage, if any file was left on wait, they must re-enter the queue
"""
job_id
=
insert_job
(
'
d
te
am
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
,
user_dn
=
'/DC=cern/CN=someone'
)
job_id
=
insert_job
(
'te
stvo
'
,
'gsiftp://source'
,
'gsiftp://destination'
,
'SUBMITTED'
,
user_dn
=
'/DC=cern/CN=someone'
)
self
.
app
.
post
(
url
=
"/ban/se"
,
params
=
{
'storage'
:
'gsiftp://source'
,
'status'
:
'wait'
,
'allow_submit'
:
True
},
status
=
200
...
...
@@ -506,7 +503,7 @@ class TestBanning(TestController):
"""
self
.
push_delegation
()
pre_job_id
=
insert_job
(
'
d
te
am
'
,
'srm://source'
,
'srm://destination'
,
'STAGING'
,
user_dn
=
'/DC=cern/CN=someone'
)
pre_job_id
=
insert_job
(
'te
stvo
'
,
'srm://source'
,
'srm://destination'
,
'STAGING'
,
user_dn
=
'/DC=cern/CN=someone'
)
self
.
app
.
post
(
url
=
"/ban/se"
,
params
=
{
'storage'
:
'srm://source'
,
'status'
:
'wait'
,
'allow_submit'
:
True
},
status
=
200
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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