x2gobroker.agent module¶
- x2gobroker.agent.add_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', remote_agent=None, logger=None, **kwargs)[source]¶
Add a public key hash to the user’s authorized_keys file.
- Parameters:
username (
str
) – run the query on behalf of this usernamepubkey_hash (
str
) – the public key hash as found in SSH authorized_keys filesauthorized_keys_file (
str
) – the full path to the remote X2Go server’s authorized_keys fileremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
(<success>, [])
, a tuple with the <success> flag as first item- Return type:
tuple
- 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 usertask (
str
) – task name to execute via the broker agent (listsessions, getservers, etc.)cmdline_args (
list
) – additional command line parameters for the broker agentremote_agent (
dict
) – if notNone
call a remote broker agent via SSHlogger (
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 item- Return type:
tuple
- 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 calledlogger (
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 item- Return type:
tuple
- x2gobroker.agent.delete_authorized_key(username, pubkey_hash, authorized_keys_file='%h/.x2go/authorized_keys', remote_agent=None, delay_deletion=0, logger=None, **kwargs)[source]¶
Remove a public key hash from the user’s authorized_keys file.
- Parameters:
username (
str
) – run the query on behalf of this usernamepubkey_hash (
str
) – the public key hash as found in SSH authorized_keys filesauthorized_keys_file (
str
) – the full path to the remote X2Go server’s authorized_keys fileremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
(<success>, [])
, a tuple with the <success> flag as first item- Return type:
tuple
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
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 usage- Return type:
tuple
- 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 userclient_address (
str
) – the key is only valid for this clientkey_type (
str
) – either of: RSA, DSAlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
two-item tuple:
(<pubkey>, <privkey>)
- Return type:
tuple
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
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 item- Return type:
tuple
- 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 calls- Return 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
(<success>, <has-running-sessions>, <has-suspended-session>)
, a tuple of two Boolean values- Return type:
tuple
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
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 item- Return type:
tuple
- 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 calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
True
if broker agent responds- Return type:
bool
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
(<success>, [])
, a tuple with the <success> flag as first item- Return type:
tuple
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
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 item- Return type:
tuple
- 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 usernameremote_agent (
dict
) – information about the remote agent that is to be calledlogger (
logging.<Some>Logger
) – logger instance to report log messages to
- Returns:
(<success>, [])
, a tuple with the <success> flag as first item- Return type:
tuple