x2gobroker.agent module¶
Add a public key hash to the user’s authorized_keys file.
Parameters: - username (
str
) – run the query on behalf of this username - pubkey_hash (
str
) – the public key hash as found in SSH authorized_keys files - authorized_keys_file (
str
) – the full path to the remote X2Go server’s authorized_keys file - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, [])
, a tuple with the <success> flag as first itemReturn type: tuple
- username (
-
x2gobroker.agent.
call_broker_agent
(username, task, cmdline_args=[], remote_agent=None, logger=None, **kwargs)[source]¶ Launch X2Go Broker Agent and process its output.
Parameters: - username (
str
) – run the broker agent for this user - task (
str
) – task name to execute via the broker agent (listsessions, getservers, etc.) - cmdline_args (
list
) – additional command line parameters for the broker agent - remote_agent (
dict
) – if notNone
call a remote broker agent via SSH - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Raises: X2GoBrokerAgentException – if the call to the remote broker agents fails.
Returns: (<success>, <data>)
, a tuple with the <success> flag as first item and the data retrieved from the broker agent as second itemReturn type: tuple
- username (
-
x2gobroker.agent.
check_load
(remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent for a summary of system load specific parameters.
Parameters: - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <load-factor>)
, a tuple with the <success> flag as first item and the queried server’s load factor as second itemReturn type: tuple
- remote_agent (
Remove a public key hash from the user’s authorized_keys file.
Parameters: - username (
str
) – run the query on behalf of this username - pubkey_hash (
str
) – the public key hash as found in SSH authorized_keys files - authorized_keys_file (
str
) – the full path to the remote X2Go server’s authorized_keys file - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, [])
, a tuple with the <success> flag as first itemReturn type: tuple
- username (
-
x2gobroker.agent.
find_busy_servers
(username, remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent for a list of servers with running and/or suspended sessions and a percentage that tells about the busy-state of the server.
The result is independent from the username given.
Parameters: - username (
str
) – run the query on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <server-usage>)
, a tuple with the <success> flag as first item and a dict reflecting the relative server usageReturn type: tuple
- username (
-
x2gobroker.agent.
genkeypair
(local_username, client_address, key_type='RSA', logger=None)[source]¶ Generate an SSH pub/priv key pair without writing the private key to file.
Parameters: - local_username (
str
) – the key is for this user - client_address (
str
) – the key is only valid for this client - key_type (
str
) – either of: RSA, DSA - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: two-item tuple:
(<pubkey>, <privkey>)
Return type: tuple
- local_username (
-
x2gobroker.agent.
get_servers
(username, remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent for the list of currently used servers.
The result is independent from the username given.
Parameters: - username (
str
) – run the query on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <server-list>)
, a tuple with the <success> flag as first item and the list of used X2Go Servers as second itemReturn type: tuple
- username (
-
x2gobroker.agent.
has_remote_broker_agent_setup
()[source]¶ Peform some integrity checks that may indicate that a remote broker agent setup is available.
- Check for available SSH private keys.
- Nothing else, so far…
Returns: True
, if the broker supports remote broker agent callsReturn type: bool
-
x2gobroker.agent.
has_sessions
(username, remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent to detect running/suspended sessions on the remote X2Go Server (farm).
Parameters: - username (
str
) – run the query on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <has-running-sessions>, <has-suspended-session>)
, a tuple of two Boolean valuesReturn type: tuple
- username (
-
x2gobroker.agent.
list_sessions
(username, remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent for a session list for a given username.
Parameters: - username (
str
) – run the query on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <list-of-sessions>)
, a tuple with the <success> flag as first item and a sessionlist
as second itemReturn type: tuple
- username (
-
x2gobroker.agent.
ping
(remote_agent=None, logger=None, **kwargs)[source]¶ Ping X2Go Broker Agent.
Parameters: - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: True
if broker agent respondsReturn type: bool
- remote_agent (
-
x2gobroker.agent.
suspend_session
(username, session_name, remote_agent=None, logger=None, **kwargs)[source]¶ Trigger a session suspensions via the X2Go Broker Agent.
Parameters: - username (
str
) – suspend the session on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, [])
, a tuple with the <success> flag as first itemReturn type: tuple
- username (
-
x2gobroker.agent.
tasks_available
(username, remote_agent=None, logger=None, **kwargs)[source]¶ Query X2Go Broker Agent for the list of available tasks.
Depending on the remove broker agent’s version, the result of this query can vary tremendously from X2Go Server to X2Go Server.
Parameters: - username (
str
) – run the query on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, <server-list>)
, a tuple with the <success> flag as first item and a list of available broker agent tasks as second itemReturn type: tuple
- username (
-
x2gobroker.agent.
terminate_session
(username, session_name, remote_agent=None, logger=None, **kwargs)[source]¶ Trigger a session termination via the X2Go Broker Agent.
Parameters: - username (
str
) – terminate the session on behalf of this username - remote_agent (
dict
) – information about the remote agent that is to be called - logger (
logging.<Some>Logger
) – logger instance to report log messages to
Returns: (<success>, [])
, a tuple with the <success> flag as first itemReturn type: tuple
- username (