paradrop.core.config package¶
Submodules¶
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..
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>¶
-
getDeviceId
(default='????')[source]¶ 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.
-
getSlotName
(default='????')[source]¶ Return the PCI/USB slot name for the device.
Example: “pci/0000:04:00.0” or “usb/1-1:1.0”
-
-
class
UCIBuilder
[source]¶ Bases:
object
UCIBuilder helps aggregate UCI configuration sections for writing to files.
-
FILES
= ['dhcp', 'network', 'firewall', 'wireless', 'qos']¶
-
-
checkSystemDevices
(update)[source]¶ Check whether expected devices are present.
This may reboot the machine if devices are missing and the host config is set to do that.
-
detectSystemDevices
()[source]¶ 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).
-
flushWirelessInterfaces
(phy)[source]¶ 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.
-
getSystemDevices
(update)[source]¶ Detect devices on the system.
Store device information in cache key “networkDevices” as well as “networkDevicesByName”.
-
handleMissingWiFi
(hostConfig)[source]¶ Take appropriate action in response to missing WiFi devices.
Depending on the host configuration, we may either emit a warning or reboot the system.
-
isVirtual
(ifname)[source]¶ 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.
-
listSystemDevices
()[source]¶ Detect devices on the system.
The result is a single list of dictionaries, each containing information about a network device.
-
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_brlan_address
(hostConfig)[source]¶ 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 10.0.0.0 or 192.168.0.1 to avoid conflict. Otherwise, when proto is set to ‘static’, we use the specified address.
paradrop.core.config.dhcp module¶
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.
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 ?).
-
getDeveloperFirewallRules
(update)[source]¶ Generate other firewall rules requested by the developer such as redirects. The object returned is a list of tuples (config, options).
paradrop.core.config.haproxy module¶
This module is responsible for configuration haproxy.
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.
-
generateHostConfig
(devices)[source]¶ Scan for devices on the machine and generate a working configuration.
-
getHostConfig
(update)[source]¶ Load host configuration.
Read device information from networkDevices. Store host configuration in hostConfig.
-
load
(path=None)[source]¶ 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.
-
revertHostConfig
(update)[source]¶ Restore host configuration from before update.
Uses oldHostConfig cache entry.
paradrop.core.config.network module¶
-
fulfillDeviceRequest
(update, cfg, devices)[source]¶ Find a physical device that matches the requested device type.
Raises an exception if one cannot be found.
-
getExtraOptions
(cfg)[source]¶ 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.
-
getInterfaceDict
(chute)[source]¶ Return interfaces from a chute as a dict with interface names as the keys. Returns an empty dict if chute is None or it had no interfaces.
-
getNetworkConfig
(update)[source]¶ 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.
-
getOSNetworkConfig
(update)[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.
-
reclaimNetworkResources
(chute)[source]¶ 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_chute_subnet_pool
(host_config)[source]¶ 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 10.128.0.0/9 or 192.168.128.0/17 to avoid conflict. Otherwise, we used the specified subnet.
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.
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.
-
getDeviceReservations
(exclude=None)[source]¶ 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
paradrop.core.config.resource module¶
paradrop.core.config.services module¶
Configure optional additional services such as telemetry.