paradrop.core.config package


paradrop.core.config.airshark module

class AirsharkInterfaceManager[source]

Bases: object


Configure an Airshark interface.

paradrop.core.config.configservice module

configservice module:
This module is responsible for “poking” the proper host OS services to change the host OS config. This would include things like changing the networking, DHCP server settings, wifi, etc..

Reload pdconf configuration files.


This function successfully does nothing.

It serves as a placeholder so that we can attach an abort function to a specific point in the update pipeline.

paradrop.core.config.devices module

Detect physical devices that can be used by chutes.

This module detects physical devices (for now just network interfaces) that can be used by chutes. This includes WAN interfaces for Internet connectivity and WiFi interfaces which can host APs.

It also makes sure certain entries exist in the system UCI files for these devices, for example “wifi-device” sections. These are shared between chutes, so they only need to be added when missing.

class SysReader(phy)[source]

Bases: object

PCI_BUS_ID = <_sre.SRE_Pattern object>
USB_BUS_ID = <_sre.SRE_Pattern object>

Return the device ID for the device.

This is a four-digit hexadecimal number. For example, our Qualcomm 802.11n chips have device ID 002a.


Return the PCI/USB slot name for the device.

Example: “pci/0000:04:00.0” or “usb/1-1:1.0”


Return the vendor ID for the device.

This is a four-digit hexadecimal number. For example, our Qualcomm 802.11n chips have vendor ID 168c.


Read the device uevent file and return the contents as a dictionary.

class UCIBuilder[source]

Bases: object

UCIBuilder helps aggregate UCI configuration sections for writing to files.

FILES = ['dhcp', 'network', 'firewall', 'wireless', 'qos']
add(file_, type_, options, name=None)[source]

Add a new configuration section.


Get sections associated with a single file.

Returns: list of tuples, [(config, options)]


Write all of the configuration sections to files.


Check whether expected devices are present.

This may reboot the machine if devices are missing and the host config is set to do that.


Detect devices on the system.

The result is three lists stored in a dictionary. The three lists are indexed by ‘wan’, ‘wifi’, and ‘lan’. Other devices may be supported by adding additional lists.

Within each list, a device is represented by a dictionary. For all devices, the ‘name’ and ‘mac’ fields are defined. For WiFi devices, the ‘phy’ is defined in addition. Later, we may fill in more device information (e.g. what channels a WiFi card supports).


Remove all virtual interfaces associated with a wireless device.

This should be used before giving a chute exclusive access to a device (e.g. monitor mode), so that it does not inherit unexpected interfaces.


Detect devices on the system.

Store device information in cache key “networkDevices” as well as “networkDevicesByName”.


Get hardware serial number.

The most reliable way we have that works across many hardware platforms is to check the eth0 MAC address.

Returns a numeric serial number.


Return unique machine identifier.

This is software-based but fairly standardized from the /etc/machine-id file. We can potentially rely on this for uniquely identifying a node.


Take appropriate action in response to missing WiFi devices.

Depending on the host configuration, we may either emit a warning or reboot the system.


Test if an interface is a virtual one.

FIXME: This just tests for the presence of certain strings in the interface name, so it is not very robust.


Test if an interface is a WAN interface.


Test if an interface is a wireless device.


Detect devices on the system.

The result is a single list of dictionaries, each containing information about a network device.

readHostconfigVlan(vlanInterfaces, builder)[source]
readHostconfigWifi(wifi, networkDevices, builder)[source]
readHostconfigWifiInterfaces(wifiInterfaces, networkDevices, builder)[source]
resetWirelessDevice(phy, primary_interface)[source]

Reset a wireless device’s interfaces to clean state.

This will rename, delete, or add an interface as necessary to make sure only the primary interface exists, e.g. “wlan0” for a wireless device, e.g. phy0.

resolveWirelessDevRef(name, networkDevices)[source]

Resolve a WiFi device reference (wlan0, phy0, 00:11:22:33:44:55, etc.) to the name of the device section as used by pdconf (wifiXXXXXXXXXXXX).

Unambiguous naming is preferred going forward (either wifiXX or the MAC address), but to maintain backward compatibility, we attempt to resolve either wlanX or phyX to the MAC address of the device that currently uses that name.


Select IP address and netmask to use for LAN bridge.

Behavior depends on the proto field, which can either be ‘auto’ or ‘static’. When proto is set to ‘auto’, we check the WAN interface address and choose either or to avoid conflict. Otherwise, when proto is set to ‘static’, we use the specified address.

setConfig(chuteName, sections, filepath)[source]

Initialize system configuration files.

This section should only be run for host configuration updates.

Creates basic sections that all chutes require such as the “wan” interface.

paradrop.core.config.dhcp module


Looks at the runtime rules the developer defined to see if they want a dhcp server. If so it generates the data and stores it into the chute cache key:virtDHCPSettings.


Takes a list of tuples (config, opts) and saves it to the dhcp config file.

paradrop.core.config.dockerconfig module

dockerconfig module:
This module contains all of the knowledge of how to take internal pdfcd representation of configurations of chutes and translate them into specifically what docker needs to function properly, whether that be in the form of dockerfiles or the HostConfig JSON object known at init time of the chute.

Create directories required by the chute.


Prepare various settings for Docker containers.

paradrop.core.config.firewall module

findMatchingInterface(iface_name, interfaces)[source]

Search an interface list for one matching a given name.

iface_name can contain shell-style wildcards (* and ?).


Generate other firewall rules requested by the developer such as redirects. The object returned is a list of tuples (config, options).


There is a set of default things that must exist just for the chute to function at all, generate those here.

Stored in key: osFirewallRules


Takes a list of tuples (config, opts) and saves it to the firewall config file.

paradrop.core.config.haproxy module

This module is responsible for configuration haproxy.


Reconfigure haproxy with forwarding and redirect rules.


paradrop.core.config.hostconfig module

The host configuration controls system settings of the host OS.

This module operates as follows:

1. The first time, we try to detect all devices and auto-generate a reasonable configuration, which we store to a persistent file.

2. (TODO) We present the configuration to the owner sometime around provisioning or first chute creation and allow him to change settings.

3. (TODO) We have some kind of update operation that can manipulate settings.


Scan for devices on the machine and generate a working configuration.


Load host configuration.

Read device information from networkDevices. Store host configuration in hostConfig.


Load host configuration.

Tries to load host configuration from persistent file. If that does not work, it will try to automatically generate a working configuration.

Returns a host config object on success or None on failure.

prepareHostConfig(devices=None, hostConfigPath=None, write=True)[source]

Load an existing host configuration or generate one.

Tries to load host configuration from persistent file. If that does not work, it will try to automatically generate a working configuration.

write: if True and host config was automatically generated, then write the new host config to a file.


Restore host configuration from before update.

Uses oldHostConfig cache entry.

save(config, path=None)[source]

Save host configuration.

May raise exception if unable to write the configuration file.


Write host configuration to persistent storage.

Read host configuration from hostConfig. module


Release resources claimed by chute network configuration.

chooseExternalIntf(update, iface)[source]
chooseSubnet(update, cfg, iface)[source]
fulfillDeviceRequest(update, cfg, devices)[source]

Find a physical device that matches the requested device type.

Raises an exception if one cannot be found.


Get dictionary of extra wifi-iface options that we are not interpreting but just passing on to pdconf.

getInterfaceAddress(update, name, cfg, iface)[source]

Dynamically select IP address for the chute interface.

This function will use a subnet from the chute subnet pool and assign IP addresses to the external (in host) and internal (in chute) interfaces.

The addresses are stored in the iface object.


Creates configuration sections for layer 3 bridging.


For the Chute provided, return the dict object of a 100% filled out configuration set of network configuration. This would include determining what the IP addresses, interfaces names, etc…

Store configuration in networkInterfaces cache entry.

getNetworkConfigLan(update, name, cfg, iface)[source]
getNetworkConfigVlan(update, name, cfg, iface)[source]
getNetworkConfigWifi(update, name, cfg, iface)[source]

Takes the network interface obj created by NetworkManager.getNetworkConfiguration and returns a properly formatted object to be passed to the UCIConfig class. The object returned is a list of tuples (config, options).

getWifiKeySettings(cfg, iface)[source]

Read encryption settings from cfg and transfer them to iface.

get_current_phy_conf(update, device_id)[source]

Lookup current configuration for a network device.

This includes information such as the Wi-Fi channel.

Returns a dictionary, which may be empty if no configuration was found.


Reclaim network resources for a previously running chute.

This function only applies to the special case in which pd starts up and loads a list of chutes that were running. This function marks their IP addresses and interface names as taken so that new chutes will not use the same values.

satisfies_requirements(obj, requirements)[source]

Checks that an object satifies given requirements.

Every key-value pair in the requirements object must be present in the target object for it to be considered satisfied.

Returns True/False.


Select IP subnet to use as pool for chutes.

Behavior depends on whether a static subnet is configured or auto configuration is requested. If the chuteSubnetPool option is set to ‘auto’, then we check the WAN interface address and choose either or to avoid conflict. Otherwise, we used the specified subnet.


Apply configuration for layer 3 bridging.


Takes a list of tuples (config, opts) and saves it to the network config file.


paradrop.core.config.osconfig module

osconfig module:
This module is in charge of changing configuration files for pdfcd on the host OS. This relates to things like network, dhcp, wifi, firewall changes. Pdfcd should be able to make simple abstracted calls into this module so that if we need to change what type of OS config we need to support only this module would change.
revertConfig(update, theType)[source]

Tell the UCI module to revert changes to the old state of the chute.

paradrop.core.config.power module


Reboot the node.


Power down the node.

paradrop.core.config.reservations module

Module for checking resource reservations by chutes.

One idea motivating this design is to reduce the amount of state in memory for resource reservations. We have the chute list, which contains information about what devices the chute is using. If we also maintain a separate list of devices used by chutes, we need to keep them synchronized. This becomes messy when a chute fails to install or uninstall correctly. The getDeviceReservations function iterates over the chute list and returns an up-to-date view of device usage. This can be called as needed.

class DeviceReservations[source]

Bases: object

add(chute, dtype, mode=None)[source]
count(dtype=None, mode=None)[source]

Return the number of reservations matching the given criteria.

None is used as a wildcard, so if no arguments are passed, the count returned is the total number of reservations.

class InterfaceReservationSet[source]

Bases: object

class SubnetReservationSet[source]

Bases: object


Produce a dictionary mapping device names to DeviceReservations objects that describe the current usage of the device.

The returned type is a defaultdict, so there is no need to check if a key exists before accessing it.

exclude: name of chute whose device reservations should be excluded


Get current set of interface reservations.

Returns an instance of InterfaceReservationSet.

exclude: name of chute whose interfaces should be excluded


Get device and resource reservations claimed by other users.


Get current set of subnet reservations.

Returns an instance of SubnetReservationSet.

exclude: name of chute whose reservations should be excluded

paradrop.core.config.resource module


Allocate compute resources for chutes.

Sets cache variables “newResourceAllocation” and “oldResourceAllocation”. module

Configure optional additional services such as telemetry.


paradrop.core.config.snap module


paradrop.core.config.state module


Save information about the chute to the filesystem.

paradrop.core.config.uciutils module

restoreConfigFile(chute, configname)[source]

Restore a system config file from backup.

This can only be used during a chute update operation to revert changes that were made during that update operation.

configname: name of configuration file (“network”, “wireless”, etc.)

setConfig(update, cacheKeys, filepath)[source]

Helper function used to modify config file of each various setting in /etc/config/ Returns:

True: if it modified a file False: if it did NOT cause any modifications

Raises exception if an error occurs.

paradrop.core.config.wifi module


Read settings from networkInterfaces for wireless interfaces. Store wireless configuration settings in osWirelessConfig.


Write settings from osWirelessConfig out to UCI files.

paradrop.core.config.zerotier module


Return the zerotier address for this device or None if unavailable.


Return the zerotier auth token for accessing its API or None if unavailable.


Get list of active ZeroTier networks.

manage_network(nwid, action='join')[source]

Join or leave a ZeroTier network.

nwid: ZeroTier network ID, e.g. “e5cd7a9e1c8a5e83” action: either “join” or “leave”


Wait for ZeroTier to start up and create the authtoken file.

Module contents