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.
-
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