paradrop.lib.misc package

Submodules

paradrop.lib.misc.pdinstall module

sendCommand(command, data)[source]

Send a command to the pdinstall service.

Commands: install - Install snaps from a file path or http(s) URL.

Required data fields: sources - List with at least one snap file path or URL. The snaps

are installed in order until one succeeds or all fail.

Returns True/False for success. Currently, we cannot check whether the call succeeded, only whether it was delived. A return value of False means we could not deliver the command to pdinstall.

paradrop.lib.misc.procmon module

The ProcessMonitor class ensures that a service is running and that its pid file is consistent.

This addresses an issue we have had with Docker on Ubuntu Snappy, where its pid file sometimes persists and prevents the service from starting.

class ProcessMonitor(service, cmdstring=None, pidfile=None, action='restart')[source]

Bases: object

allowedActions = set(['reboot', 'restart'])
check()[source]

Check that the service is running and consistent with pid file(s).

Returns True or False.

ensureReady(delay=5, tries=3)[source]

Look through checking and restarting the service until it is ready or the maximum number of tries has been reached.

delay: time delay (seconds) between retries. tries: maximum number of restart-wait-check cycles.

restart()[source]

Restart the service.

paradrop.lib.misc.resopt module

Resource optimization functions.

allocate(reservations, total=1.0)[source]

Allocate resources among slices with specified and unspecified reservations.

Returns a new list of values with the following properties: - Every value is >= the corresponding input value. - The result sums to total.

Examples: allocate([0.25, None, None]) -> [0.5, 0.25, 0.25] allocate([0.4, None, None]) -> [0.6, 0.2, 0.2] allocate([0.2, 0.2, 0.2]) -> [0.33, 0.33, 0.33] allocate([None, None, None]) -> [0.33, 0.33, 0.33] allocate([0.5, 0.5, 0.5]) -> ERROR

paradrop.lib.misc.snapd module

class SnapdClient(logging=True, wait_async=False)[source]

Bases: object

Client for interacting with the snapd API to manage installed snaps.

connect(plug_snap=None, plug=None, slot_snap='core', slot=None)[source]

Connect an interface.

get_change(change_id)[source]

Get the current status of a change.

installSnap(snapName)[source]

Install a snap from the store.

listSnaps()[source]

Get a list of installed snaps.

updateSnap(snapName, data)[source]

Post an update to a snap.

Valid actions are: install, refresh, remove, revert, enable, disable.

Example: updateSnap(“paradrop-daemon”, {“action”: “refresh”}

paradrop.lib.misc.ssh_keys module

addAuthorizedKey(key, user='paradrop')[source]
getAuthorizedKeys(user='paradrop')[source]
writeAuthorizedKeys(keys, user='paradrop')[source]

Module contents