| module: | bastio.cli |
|---|---|
| synopsis: | A module responsible for the CLI of the agent. |
| author: | Amr Ali <amr@databracket.com> |
| module: | bastio.ssh |
|---|---|
| synopsis: | A Package for SSH management and communication. |
| author: | Amr Ali <amr@databracket.com> |
| module: | bastio.ssh.client |
|---|---|
| synopsis: | A module for SSH client implementations. |
| author: | Amr Ali <amr@databracket.com> |
A singleton to establish and maintain a secure connection with the backend over a specific subsystem channel. This connector supports registering of endpoints where processors can register their endpoint to communicate with the backend. It is guaranteed that the messages will be delivered ASAP but the actual ETA is chaotic.
EndPoint(ingress, egress)
Alias for field number 1
Alias for field number 0
Register an endpoint to this connector to so that it can communicate with the backend. The endpoint is a tuple of one ingress queue as first argument and egress as the second argument.
| Parameters: | endpoint (BackendConnector.EndPoint) – A tuple of two queues; ingress and egress. |
|---|
| module: | bastio.ssh.api |
|---|---|
| synopsis: | A module responsible for the API between the backend and the agent. |
| author: | Amr Ali <amr@databracket.com> |
A class to handle action messages coming from the backend and send back a feedback to indicate success or failure of the action requested. This class is a kind-singleton which means you cannot instantiate more than one copy per application life time.
Return an ingress and an egress points to communicate with this processor.
| Returns: | bastio.ssh.client.BackendConnector.EndPoint |
|---|
Process a message and return a feedback.
| Parameters: | message (A subclass of bastio.ssh.protocol.ActionMessage) – A message to be processed. |
|---|---|
| Returns: | bastio.ssh.protocol.FeedbackMessage |
| module: | bastio.ssh.protocol |
|---|---|
| synopsis: | A module containing protocol messages. |
| author: | Amr Ali <amr@databracket.com> |
A class to help parsing and composing Netstring formatted messages.
This class takes a sock and an optional message length limit argument through its constructor for operating on data as it is received. The limit parameter is in KiB, so passing limit=32 means that the message length limit will be 32768 bytes. The socket passed must return a zero-sized string as an indication of EOF.
There are two class methods, compose to compose Netstring formatted messages and parse to parse Netstring messages.
Compose a Netstring formatted message.
| Parameters: | data (str) – The data to be wrapped in a Netstring message. |
|---|---|
| Returns: | A Netstring formatted message for the data passed in. |
A protocol message base class.
Check protocol message fields and validate them.
Return a new object of type cls containing the validated feedback object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated protocol message object. |
A protocol action message base class. Use this class as a base for all other action messages.
Check action message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
A protocol message parser for JSON strings.
Note that this class acts as a router for the type of messages you can handle, so in order to add support for another message you will have to edit the class dictionary SupportedMessages to include the message type you wish to support.
A protocol action message parser.
Note that this class acts as a router for the actions that you can carry out, so in order to add support for a particular action you will have to edit the class dictionary SupportedActions to include the action type you wish to support.
Parse an action-type and return the relevant action object that represents the action-type of this message.
| Parameters: | obj (bastio.mixin.Json) – A JSON object for an action. |
|---|---|
| Returns: | A parsed and validated action message. |
A protocol feedback message.
Check feedback message fields and validate them.
Return a new object of type cls containing the validated feedback object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated feedback object. |
An add-user action message.
Check add-user message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
A remove-user action message.
Check remove-user message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
A update-user action message.
Check update-user message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
A add-key action message.
Check add-key message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
A remove-key action message.
Check remove-key message fields and validate them.
Return a new object of type cls containing the validated action object.
| Parameters: |
|
|---|---|
| Returns: | A new object of type cls containing the validated action object. |
| module: | bastio.ssh.crypto |
|---|---|
| synopsis: | A module for miscellaneous cryptographic facilities. |
| author: | Amr Ali <amr@databracket.com> |
A class to add a few helper functions to paramiko.RSAKey.
Load an instance of this class with public_key.
| Parameters: | public_key (str) – An OpenSSH formatted public key. |
|---|---|
| Returns: | RSAKey |
A wrapper around paramiko’s RSAKey generation interface to add this class’s methods to it.
| Parameters: | size (int) – The size of the RSA key pair in bits you wish to generate. |
|---|---|
| Returns: | RSAKey |
Validate private key data.
| Parameters: | data (str) – A PEM formatted private key content. |
|---|---|
| Returns: | Whether the key data is valid. |
| module: | bastio.account |
|---|---|
| synopsis: | A module responsible for communicating account details. |
| author: | Amr Ali <amr@databracket.com> |
Get Bastio’s backend SSH host key.
| Returns: | bastio.ssh.crypto.RSAKey |
|---|---|
| Raises : | bastio.excepts.BastioAccountError |
Upload agent’s public key to Bastio on the account specified by api_key.
This action will create a new server when old_public_key is not specified and it is the first time we see this public_key. However the public key we store that identifies this server will be replaced IFF we already have old_public_key in our records and public_key does not exist in our database.
| Parameters: |
|
|---|---|
| Raises : |
| module: | bastio.configs |
|---|---|
| synopsis: | Configurations memory and file system store. |
| author: | Amr Ali <amr@databracket.com> |
An in-memory configuration store that inherits defaultdict behavior. This store is a singleton so only one object is created. Please see bastio.mixin.UniqueSingletonMeta.
The in-memory store takes precedence over the configuration file. If key was not found in the memory store we’ll try to get it from the configuration file, if all fails we will simply return the default value of the default_factory assigned in the constructor.
There’s only one case where precedence is reversed in favor of the configuration file; when one of the [method]s below are present right before the <option name>. This and once the value is retrieved successfully it will be set in the memory store so that you can access it later without having to consult the configuration file again.
| Parameters: | attr (str) – The syntax is [method]_[section]_<option name> where [method] and [section] are optional, and <option name> is required. Note that if you wish not to supply [method] you need to remove [section] and _ as well. Also if [section] was not supplied the default section name that was supplied to the constructor will be used. [method] could be one of a few possibilities. Either get, getint, getfloat, or getboolean that correspond to the methods available through the ConfigParser interface. e.g., get_alpha_name will try to get the option name from the configuration file, similarly in the case of get_name we will try to get the option’s value from the configuration file but from under the section that was supplied to the constructor. |
|---|---|
| Returns: | The option’s value or default_factory if no value was set. |
| Raises : | bastio.excepts.BastioConfigError |
| Parameters: |
|
|---|
alias of UniqueSingletonMeta
list of weak references to the object (if defined)
Load a configuration file using ConfigParser into memory.
| Parameters: | filename (str) – The absolute path of the configuration file. |
|---|---|
| Raises : | bastio.excepts.BastioConfigError |
| module: | bastio.concurrency |
|---|---|
| synopsis: | Concurrency utilities. |
| author: | Amr Ali <amr@databracket.com> |
A class to wrap an exception info to pass to the failure callback registered on a task to handle it.
This class must only be instantiated from under an except clause.
A class to describe a task to be used by the thread pool.
An infinite or a blocking task will have to take a kill threading.Event as the first argument to the function to be able to end operations gracefully in case a stop event was triggered.
This class takes two callbacks as keyword arguments to handle the cases where a task succeeds or fails, called success and failure respectively.
Calling the Task.stop() method will signal the worker in the thread pool to stop execution and exit gracefully.
An adaptive thread pool.
This thread pool adapts to the threads consumption rate by making sure that the available number of workers to process tasks is always above the minimum number of workers that should be always available.
Add worker(s) to the thread pool.
| Parameters: | num (int) – The number of workers to add to the pool. |
|---|
Remove all workers from the pool.
Remove all active workers from the pool and wait wait seconds until last worker ends, or wait forever if wait is None. This action will also signal all running tasks to stop as soon as possible.
| Parameters: | wait (float) – Number of seconds to wait or None to wait forever. |
|---|
A singleton of bastio.concurrency.ThreadPool.
Add worker(s) to the thread pool.
| Parameters: | num (int) – The number of workers to add to the pool. |
|---|
Remove all workers from the pool.
Remove all active workers from the pool and wait wait seconds until last worker ends, or wait forever if wait is None. This action will also signal all running tasks to stop as soon as possible.
| Parameters: | wait (float) – Number of seconds to wait or None to wait forever. |
|---|
| module: | bastio.log |
|---|---|
| synopsis: | Logging facilities for this project. |
| author: | Amr Ali <amr@databracket.com> |
| module: | bastio.mixin |
|---|---|
| synopsis: | Mixins utilities used across the project. |
| author: | Amr Ali <amr@databracket.com> |
A Singleton pattern abstract metaclass.
A mixin to give objects the ability to serialize and deserialize to/from JSON formatted string.
| module: | bastio.version |
|---|---|
| synopsis: | A module that contain version details for the package. |
| author: | Amr Ali <amr@databracket.com> |
Update version information here only. There’s no need to update any other file in the package.
Release of a hotfix/bugfix: - Increment version’s BUILD field.
Release of an update that modifies the API but maintains backward compatibility: - Increment version’s MINOR field and reset the BUILD field.
Release of an update that that modifies the API and breaks backward compatibility: - Increment version’s MAJOR field and reset both the MINOR and BUILD fields.
| module: | bastio.excepts |
|---|---|
| synopsis: | Exception classes used by this project. |
| author: | Amr Ali <amr@databracket.com> |
Reraise the exception last happened with the original traceback.
| Parameters: |
|
|---|---|
| Raises : | ex |