Commit 1ad13633 authored by Alejandro Alvarez Ayllon's avatar Alejandro Alvarez Ayllon
Browse files

FTS-76: Added FailedDependency NeedDelegation and TryAgain exceptions

parent b867f43f
......@@ -19,27 +19,37 @@ In the following code snippets, an import as above is assumed.
### Exceptions
#### FTS3ClientException
Base class for all other exceptions
Base class for all other exceptions.
#### BadEndpoint
Can not contact the given endpoint
Can not contact the given endpoint.
### Unauthorized
The user is not allowed to perform the operation
The user is not allowed to perform the operation.
#### Client error
The client tried to perform an invaild action (i.e. bad submission)
The client tried to perform an invaild action (i.e. bad submission).
#### NotFound
The resource has not been found.
#### NeedDelegation
The server needs new delegated credentials.
#### FailedDependency
Some step required to succeed a request failed, so the whole request was canceled. i.e. requesting adding voms
extensions.
#### Server error
Server side error (i.e. internal server error)
#### NotFound
The resource has not been found
#### TryAgain
The server could not fulfill the request now, but it may be able to do so later on.
### Context
In order to be able to do any operation, some state about the user credentials and remote endpoint need to be
kept.
That's the purpose of a Context
That's the purpose of a Context.
```python
context = fts3.Context(endpoint, ucert, ukey)
......@@ -60,7 +70,7 @@ Queries the server to see how does it see us
#### Returns:
Deserialized JSON message returned by the server with a representation of
the user credentials (as set in context)
#### Example:
```python
fts3.whoami(context)
......@@ -69,25 +79,25 @@ fts3.whoami(context)
```json
{
"dn": [
"/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=aalvarez/CN=678984/CN=Alejandro Alvarez Ayllon",
"/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=aalvarez/CN=678984/CN=Alejandro Alvarez Ayllon",
"/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=aalvarez/CN=678984/CN=Alejandro Alvarez Ayllon/CN=proxy"
],
],
"roles": [
"lcgadmin"
],
],
"level": {
"transfer": "vo",
"transfer": "vo",
"config": "all"
},
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=aalvarez/CN=678984/CN=Alejandro Alvarez Ayllon",
"delegation_id": "7e0863c6cf4e52dd",
},
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=aalvarez/CN=678984/CN=Alejandro Alvarez Ayllon",
"delegation_id": "7e0863c6cf4e52dd",
"vos": [
"dteam",
"dteam",
"dteam/cern"
],
],
"voms_cred": [
"/dteam/Role=lcgadmin/Capability=NULL",
"/dteam/Role=NULL/Capability=NULL",
"/dteam/Role=lcgadmin/Capability=NULL",
"/dteam/Role=NULL/Capability=NULL",
"/dteam/cern/Role=NULL/Capability=NULL"
]
}
......@@ -112,65 +122,65 @@ fts3.list_jobs(context. user_dn=None, vo=None)
```json
[
{
"cred_id": "1234",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/...",
"retry": 0,
"cred_id": "1234",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/...",
"retry": 0,
"job_id": "1234-5678-98765",
"cancel_job": false,
"job_finished": null,
"submit_host": "fts104.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"job_metadata": "",
"cancel_job": false,
"job_finished": null,
"submit_host": "fts104.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"job_metadata": "",
"source_se": "srm://source.cern.ch",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": -1,
"reason": null,
"space_token": "",
"submit_time": "2014-04-28T13:18:26",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": -1,
"reason": null,
"space_token": "",
"submit_time": "2014-04-28T13:18:26",
"dest_se": "srm://destination.cern.ch",
"internal_job_params": "",
"finish_time": null,
"verify_checksum": false,
"vo_name": "cms",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "SUBMITTED",
"internal_job_params": "",
"finish_time": null,
"verify_checksum": false,
"vo_name": "cms",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "SUBMITTED",
"overwrite_flag": true
},
},
{
"cred_id": "1234",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/...",
"retry": 0,
"cred_id": "1234",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/...",
"retry": 0,
"job_id": "1234-5678-987ab",
"cancel_job": false,
"job_finished": null,
"submit_host": "fts102.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"job_metadata": "",
"source_se": "gsiftp://source.cern.ch",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": -1,
"reason": null,
"space_token": "",
"submit_time": "2014-04-28T09:00:17",
"cancel_job": false,
"job_finished": null,
"submit_host": "fts102.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"job_metadata": "",
"source_se": "gsiftp://source.cern.ch",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": -1,
"reason": null,
"space_token": "",
"submit_time": "2014-04-28T09:00:17",
"dest_se": "srm://destination.cern.ch",
"internal_job_params": "",
"finish_time": null,
"verify_checksum": false,
"vo_name": "cms",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "SUBMITTED",
"internal_job_params": "",
"finish_time": null,
"verify_checksum": false,
"vo_name": "cms",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "SUBMITTED",
"overwrite_flag": true
}
]
......@@ -194,37 +204,37 @@ fts3.get_job_status(context, '1234-5678-abcdef', list_files=False)
```json
{
"cred_id": "0ef8fb17bc42a356",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=saketag/CN=678984/CN=Alejandro Alvarez Ayllon",
"retry": 0,
"job_id": "969bc54e-ca78-11e3-a6e2-02163e00a17a",
"cancel_job": false,
"job_finished": "2014-04-22T23:48:25",
"submit_host": "fts106.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"cred_id": "0ef8fb17bc42a356",
"user_dn": "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=saketag/CN=678984/CN=Alejandro Alvarez Ayllon",
"retry": 0,
"job_id": "969bc54e-ca78-11e3-a6e2-02163e00a17a",
"cancel_job": false,
"job_finished": "2014-04-22T23:48:25",
"submit_host": "fts106.cern.ch",
"priority": 3,
"source_space_token": "",
"max_time_in_queue": null,
"job_metadata": {
"test": "test_bring_online_only",
"test": "test_bring_online_only",
"label": "fts3-tests"
},
"source_se": "srm://hepgrid11.ph.liv.ac.uk",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": 120,
"reason": "",
"space_token": "",
"submit_time": "2014-04-22T23:48:22",
"dest_se": "srm://hepgrid11.ph.liv.ac.uk",
"internal_job_params": null,
"finish_time": "2014-04-22T23:48:25",
"verify_checksum": false,
"vo_name": "dteam",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "FINISHED",
},
"source_se": "srm://hepgrid11.ph.liv.ac.uk",
"user_cred": "",
"reuse_job": false,
"source_token_description": null,
"job_params": "",
"bring_online": 120,
"reason": "",
"space_token": "",
"submit_time": "2014-04-22T23:48:22",
"dest_se": "srm://hepgrid11.ph.liv.ac.uk",
"internal_job_params": null,
"finish_time": "2014-04-22T23:48:25",
"verify_checksum": false,
"vo_name": "dteam",
"copy_pin_lifetime": -1,
"agent_dn": null,
"job_state": "FINISHED",
"overwrite_flag": false
}
```
......
......@@ -25,6 +25,16 @@ class ClientError(FTS3ClientException):
return "Client error: %s" % self.reason
class NeedDelegation(ClientError):
def __str__(self):
return "Need to delegate credentials"
class FailedDependency(ClientError):
def __str__(self):
return "Failed dependency"
class ServerError(FTS3ClientException):
def __init__(self, reason):
self.reason = reason
......@@ -33,6 +43,11 @@ class ServerError(FTS3ClientException):
return "Server error: %s" % self.reason
class TryAgain(ServerError):
def __str__(self):
return "Try again: %s" % self.reason
class NotFound(FTS3ClientException):
def __init__(self, resource):
self.resource = resource
......
......@@ -29,8 +29,14 @@ class RequestFactory(object):
raise Unauthorized()
elif code == 404:
raise NotFound(url)
elif code == 419:
raise NeedDelegation()
elif code == 424:
raise FailedDependency()
elif code > 404 and code < 500:
raise ClientError(str(code))
elif code == 503:
raise TryAgain(str(code))
elif code >= 500:
raise ServerError(str(code))
......
Markdown is supported
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