paradrop.core.chute package


paradrop.core.chute.chute module

class Chute(description=None, name=None, owner=None, state='running', version=None, config=NOTHING, environment=NOTHING, services=NOTHING, web=NOTHING, cache=NOTHING)[source]

Bases: object

This Chute class provides the internal representation of a Paradrop chute.

This class encapsulates the complex configuration details of a chute and provides a stable interface for the execution path even as the chute specification language evolves over time.

The Chute class has minimal external dependencies, e.g. no dependency on the Docker API. Chute objects should be immutable, since they describe a desired software state at a fixed point in time.

name (str): The name of the chute. description (str): The human-friendly description of the chute. state (str): Desired run state of the chute (“running”, “stopped”). version (str): The version of the chute. config (dict): Configuration settings for the chute. environment (dict): Environment variables to set for all chute services.
STATE_DISABLED = 'disabled'
STATE_FROZEN = 'frozen'
STATE_INVALID = 'invalid'
STATE_RUNNING = 'running'
STATE_STOPPED = 'stopped'

Add a service to the chute.


Create a new chute specification from the existing chute.

This is a completely clean copy of all information necessary to rebuild the Chute object. It should contain only primitive types, which can easily be serialized as JSON or YAML.


Get a value from the cache or None if it does not exist.


Get the contents of the cache as a dictionary.


Get the chute’s configuration object.


Get the chute’s host_config options for Docker.

Returns an empty dictionary if there is no host_config setting.


Get the port configured for the chute’s web server.

Returns port (int) or None if no port is configured.


Get one of the chute’s services designated as the default one.

This is more for convenience with existing API functions where the caller did not need to specify a service because prior to 0.12.0, chutes could only have one Docker container. We use some heuristics such as the service’s name is “main” to identify one of the services as the default.


Get the chute environment variables.

These are defined by the developer or administrator and passed to all services that belong to the chute.


Get the name of the user who owns this installed chute.


Get a service by name.


Get a list of services installed by this chute.


Get the port and Service object that provides this chutes web service.

Returns a tuple containing the port number and Service object. Both values will be None if a web service is not configured.


Inherit attributes from another version of the chute.

If any settings are None or missing in this chute but present in the other version, they will be copied over. The return value is a dictionary containing changes that were applied.


Check if the chute is supposed to be running.


Return True only if the Chute object we have has all the proper things defined to be in a valid state.

setCache(key, value)[source]

Set a value in the cache.

Deprecated: Most of the cache functionality has been moved to the Update object because they are values that are used as temporary storage between one update step and the following steps. However, there are a few instances of cache values that we do still read from chute storage. Any calls to the getCache method throughout the project are still depending on this functionality, so we have corresponding calls to setCache that ensure the required information is present in the chute cache and not just in the update cache. Eventually, we should remove this dependency either by using a less stateful design or by formalizing the process for storing persistent chute state, such as the networkInterfaces list.


Update the chute cache from another dictionary.

paradrop.core.chute.chute_storage module

class ChuteStorage(filename=None, save_timer=0)[source]

Bases: paradrop.lib.utils.pd_storage.PDStorage

ChuteStorage class.

This class holds onto the list of Chutes on this AP.

It implements the PDStorage class which allows us to save the chuteList to disk transparently


Returns True if we should save the ChuteList, otherwise False.

chuteList = {}

Deletes a chute from the chute storage. Can be sent the chute object, or the chute name.


Get our attr (as class variable for all to see)


Returns a reference to a chute we have in our cache, or None.


Return a list of the names of the chutes we know of.

classmethod get_chute(name)[source]

Saves the chute provided in our internal chuteList. Also since we just received a new chute to hold onto we should save our ChuteList to disk.


Save our attr however we want (as class variable for all to see)

paradrop.core.chute.restart module

Contains the functions required to restart chutes properly on power cycle of device. Checks with pdconfd to make sure it was able to properly bring up all interfaces before starting chutes.


Get update objects to chutes that should be running at startup.

This function is called to restart any chutes that were running prior to the system being restarted. It waits for pdconfd to come up and report whether or not it failed to bring up any of the interfaces that existed before the power cycle. If pdconfd indicates something failed we then force a stop update in order to bring down all interfaces associated with that chute and mark it with a warning. If the stop fails we mark the chute with a warning manually and change its state to stopped and save to storage this isn’t great as it could mean our system still has interfaces up associated with that chute. If pdconfd doesn’t report failure we attempt to start the chute and if this fails we trust the abort process to restore the system to a consistent state and we manually mark the chute as stopped and add a warning to it.

Returns:(list) A list of UpdateChute objects that should be run before accepting new updates.

This function is a callback for the updates we do upon restarting the system. It checks whether or not the update completed successfully and if not it changes the state of the chute to stopped and adds a warning. :param update: The update object containing information about the chute that was created and whether it was successful or not. :type update: obj :returns: None

Module contents