3.8. Sessions

Todo

Intro to SAGA Session

3.8.1. Session – saga.session

class saga.session.Session(default=True)[source]

Bases: saga.base.SimpleBase

A SAGA Session object as defined in GFD.90.

A SAGA session has the purpose of scoping the use of security credentials for remote operations. In other words, a session instance acts as a container for security Context instances – SAGA objects (such as job.Service or filesystem.File) created in that session will then use exactly the security contexts from that session (and no others).

That way, the session serves two purposes: (1) it helps SAGA to decide which security mechanism should be used for what interaction, and (2) it helps SAGA to find security credentials which would be difficult to pick up automatically.

The use of a session is as follows:

Example:

# define an ssh context
c = saga.Context('ssh')
c.user_cert = '$HOME/.ssh/special_id_rsa.pub'
c.user_key  = '$HOME/.ssh/special_id_rsa'

# add it to a session
s = saga.Session
s.add_context(c)

# create a job service in this session -- that job service can now
# *only* use that ssh context. 
j = saga.job.Service('ssh://remote.host.net/', s)

The session argument to the L{job.Service} constructor is fully optional – if left out, SAGA will use default session, which picks up some default contexts as described above – that will suffice for the majority of use cases.

A session instance exposes a context property, which is a list of authentication contexts managed by this session. As the contexts and the session are stateless, it is safe to modify this list as needed.

add_context(ctx)[source]

ctx: saga.Context ret: None

Add a security L{Context} to the session. It is encouraged to use the L{contexts} property instead.

remove_context(ctx)[source]

ctx: saga.Context ret: None

Remove a security L{Context} from the session. It is encouraged to use the L{contexts} property instead.

list_contexts()[source]

ret: list[saga.Context]

Retrieve all L{Context} objects attached to the session. It is encouraged to use the L{contexts} property instead.

get_config(section='')[source]

ret: radical.utils.Configuration

Return the session configuration (optional a specific section).

class saga.session.DefaultSession[source]

Bases: saga.session.Session