toxiccommon package¶
Submodules¶
toxiccommon.client module¶
- class toxiccommon.client.HoleClient(requester, *args, hole_token=None, **kwargs)[source]¶
Bases:
BaseToxicClient,LoggerMixinClient for the master’s hole.
- async request2server(action, body)[source]¶
Performs a request to a hole server.
- Parameters:
action – The action to perform on the server.
body – The body of the request, with the actions parameters.
- settings = None¶
toxiccommon.coordination module¶
toxiccommon.exceptions module¶
toxiccommon.exchange module¶
- class toxiccommon.exchange.AmqpConnection(**conn_kwargs)[source]¶
Bases:
LoggerMixinA connection for a broker. We can have many channels over one connection.
- async connect(**conn_kwargs)[source]¶
Connects to the Rabbitmq server.
- Parameters:
conn_kwargs – Named arguments passed to
asyncamqp.connect()
- property reconn_lock¶
- class toxiccommon.exchange.Consumer(channel, queue, consumer_tag, nowait=False, timeout=0)[source]¶
Bases:
Consumer,LoggerMixin
- class toxiccommon.exchange.Exchange(name, connection, exchange_type, durable=False, bind_publisher=True, exclusive_consumer_queue=False)[source]¶
Bases:
LoggerMixinA simple abstraction for an amqp exchange.
- async bind(routing_key, queue_name=None, channel=None)[source]¶
Binds the queue to the exchange.
- Parameters:
routing_key – Routing key to bind the queue.
queue_name – The name of the queue to be bound. If not self.queue_name will be used.
channel – Optional channel to use in the communication. A new one will be used.
- async consume(wait_message=True, timeout=0, routing_key='', no_ack=False)[source]¶
Consumes a message from a Rabbitmq queue.
- Parameters:
wait_message – Should we wait for new messages in the queue?
timeout – Timeout for waiting messages.
no_ack – Indicates if we should send a ack response to the server. The ack must be sent by the consumer.
- async declare(queue_name=None)[source]¶
Declares the exchange and queue.
- Parameters:
queue_name – The name for the queue to be declared. If None, self.queue_name will be used.
- async publish(message, routing_key='')[source]¶
Publishes a message to a Rabbitmq exchange
- Parameters:
message – The message that will be published in the exchange. Must be something that can be serialized into a json.
routing_key – The routing key to publish the message.
toxiccommon.exchanges module¶
toxiccommon.interfaces module¶
Module with base models that are populated using a remote api.
- class toxiccommon.interfaces.BaseHoleInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseInterface
- class toxiccommon.interfaces.BaseInterface(requester, ordered_kwargs)[source]¶
Bases:
object- references = {}¶
- settings = None¶
- class toxiccommon.interfaces.BuildInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface- async classmethod get(requester, uuid)[source]¶
Returns information about abuild. :param uuid: The uuid of the build.
- references = {'builder': <class 'toxiccommon.interfaces.BuilderInterface'>, 'steps': <class 'toxiccommon.interfaces.StepInterface'>}¶
- class toxiccommon.interfaces.BuildSetInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface- async classmethod get(requester, buildset_id)[source]¶
Returns an instance of BuildSetInterface.
- Parameters:
buildset_id – The id of the buildset to get.
- async classmethod list(requester, repo_name_or_id=None, summary=True, branch=None)[source]¶
Lists buildsets. If
repo_name_or_idonly builds of this repsitory will be listed.- Parameters:
repo_name – Name of a repository.
summary – If True, no builds information will be returned.
branch – List buildsets for this branch. If None list buildsets from all branches.
- references = {'builds': <class 'toxiccommon.interfaces.BuildInterface'>, 'repository': <class 'toxiccommon.interfaces.RepositoryInterface'>}¶
- class toxiccommon.interfaces.BuilderInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface
- class toxiccommon.interfaces.NotificationInterface(ordered_kwargs)[source]¶
Bases:
BaseInterfaceIntegration with the notifications api.
- async classmethod disable(repo_id, notif_name)[source]¶
Disables a notification for a given repository.
- Parameters:
repo_id – The id of the repository to enable the notification.
notif_name – The name of the notification.
- async classmethod enable(repo_id, notif_name, **config)[source]¶
Enables a notification for a given repository.
- Parameters:
repo_id – The id of the repository to enable the notification.
notif_name – The name of the notification.
config – A dictionary with the config values for the notification.
- async classmethod list(obj_id=None)[source]¶
Lists all the notifications available.
- Parameters:
obj_id – The of of an repository. If not None, the notifications will return the values of the configuration for that repository.
- async classmethod update(repo_id, notif_name, **config)[source]¶
Updates a notification for a given repository.
- Parameters:
repo_id – The id of the repository to enable the notification.
notif_name – The name of the notification.
config – A dictionary with the new config values for the notification.
- class toxiccommon.interfaces.RepositoryInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterfaceInterface for a repository.
- async classmethod add(requester, name, url, owner, vcs_type, update_seconds=300, slaves=None, parallel_builds=None, schedule_poller=True, branches=None, external_id=None, external_full_name=None, fetch_url=None, envvars=None)[source]¶
Adds a new repository.
- Parameters:
requester – The user who is requesting the operation.
name – Repository’s name.
url – Repository’s url.
owner – The repository owner
vcs_type – VCS type used on the repository.
update_seconds – Interval to update the repository code.
slaves – List with slave names for this reporitory.
schedule_poller – Should this repository be scheduled for polling? If this repository comes from an integration (with github, gitlab, etc…) this should be False.
branches – A list of branches configuration that trigger builds.
external_id – The id of the repository in an external service.
external_full_name – The full name in an external service.
fetch_url – If the repository uses a differente url to fetch code (ie: it has an auth token url) this is the fetch_url.
envvars – Environment variables that will be used in every build in this repository.
- Params parallel_builds:
How many paralles builds this repository executes. If None, there is no limit.
- async add_branch(branch_name, notify_only_latest)[source]¶
Adds a branch config to a repositoiry.
- Parameters:
branch_name – The name of the branch.
notify_only_latest – If we should create builds for all revisions or only for the lastest one.
- async add_envvars(**envvars)[source]¶
Adds environment variables to use in the builds of this repository.
- Parameters:
envvars – Environment variables in the format {var: val, …}
- async add_or_update_secret(key, value)[source]¶
Adds a new secret to be used in builds. Note that secrets are not used in builds from external sources.
- async add_slave(slave)[source]¶
Adds a slave to the repository.
- Parameters:
slave – A Slave instance.
- async cancel_build(build_uuid)[source]¶
Cancels a build from the repository.
- Parameters:
build_uuid – The uuid of the build.
- async classmethod get(requester, **kwargs)[source]¶
Returns a repository.
- Parameters:
requester – The user who is requesting the operation.
kwargs – kwargs to get the repository.
- async classmethod list(requester, **kwargs)[source]¶
Lists all repositories.
- Parameters:
requester – The user who is requesting the operation.
- references = {'last_buildset': 'toxiccommon.interfaces.BuildSetInterface', 'slaves': <class 'toxiccommon.interfaces.SlaveInterface'>}¶
- async remove_branch(branch_name)[source]¶
Removes a branch config from a repository.
- Parameters:
branch_name – The name of the branch.
- async remove_slave(slave)[source]¶
Removes a slave from the repository.
- Parameters:
slave – A Slave instance.
- async replace_envvars(**envvars)[source]¶
Replaces environment variables of this repository.
- Parameters:
envvars – Environment variables in the format {var: val, …}
- async request_code_update(repo_branches=None, external=None)[source]¶
Request the code update of the repository.
- Parameters:
repo_branches –
A dictionary with information about the branches to be updated. If no
repo_branchesall branches in the repo config will be updated.The dictionary has the following format.
{'branch-name': {'notify_only_latest': True}}
external – If we should update code from an external (not the origin) repository, external is the information about this remote repo.
- async rm_envvars(**envvars)[source]¶
Removes environment variables from this repository.
- Parameters:
envvars – Environment variables in the format {var: val, …}
- async start_build(branch, builder_name_or_id=None, named_tree=None)[source]¶
Starts a (some) build(s) for a repository.
- Parameters:
branch – The name of the branch.
builder_name_or_id – The name of the builder that will execute the build
named_tree – The named_tree that will be builded. If no named_tree the last one will be used.
- class toxiccommon.interfaces.SlaveInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface- async classmethod add(requester, name, port, token, owner, use_ssl=True, validate_cert=True, on_demand=False, host=None, instance_type=None, instance_confs=None)[source]¶
Adds a new slave.
- Parameters:
name – Slave name.
host – Slave host.
port – Slave port.
token – Authentication token.
owner – The slave owner
use_ssl – Indicates if the slave uses a ssl connection.
on_demand – Does this slave have an on-demand instance?
instance_type – Type of the on-demand instance.
instance_confs – Configuration parameters for the on-demand instance.
- Pram validate_cert:
Should the slave certificate be validated?
- async classmethod get(requester, **kwargs)[source]¶
Returns a slave.
- Parameters:
requester – The user who is requesting the operation.
kwargs – kwargs to get the slave.
- class toxiccommon.interfaces.StepInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface
- class toxiccommon.interfaces.UserInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterfaceA user created in the master
- async classmethod change_password_with_token(token, password)[source]¶
Changes the user password using a token. The token was generated when
request_password_resetwas called and a link with the token was sent to the user email.
- async classmethod exists(**kwargs)[source]¶
Checks if a user with some given information exists.
- Parameters:
kwargs – Named arguments to match the user
- class toxiccommon.interfaces.WaterfallInterface(requester, ordered_kwargs)[source]¶
Bases:
BaseHoleInterface- async classmethod get(requester, repo_name_or_id, branch=None)[source]¶
Returns an instance of WaterfallInterface.
- Parameters:
buildset_id – The name or id of a repository
branch – A branch name to filter the waterfall
- references = {'builders': <class 'toxiccommon.interfaces.BuilderInterface'>, 'buildsets': <class 'toxiccommon.interfaces.BuildSetInterface'>}¶
toxiccommon.utils module¶
- toxiccommon.utils.format_datetime(dt, dtformat, tzname=None)[source]¶
Formats a datetime object according to the timezone and format specified in the config file.
- Parameters:
dt – A datetime object.
dtformat – The format for the datetime.
tzname – A timezone name.