A simple package to control PDUs
Project description
from selenium.webdriver.common.devtools.v117.web_authn import get_credentials
pducontrol
pducontrol is a Python library to control a wide variety of PDUs Currently we support the following models:
- SWH-1023J-08N1 (Dexlan, seems to be just an OEM rebadged unit)
- PDU81003 (CyberPower)
- NetIO 4C
Installation
You can install pducontrol from source:
make pip
pip install /dist/pducontrol-*.tar.gz
or just call the refresh_package.sh script
Usage
This package provides both Python and CLI interfaces, here is how you can use them:
In Python
You can either instantiate the class targeting your PDU, for instance for a Dexlan unit:
from pducontrol import PDUControlREST
pdu = PDUControlREST("192.168.0.23")
print(pdu.get_all_names())
Or for more flexibility, you can let pducontrol choose the class to instantiate:
from types import SimpleNamespace
from pducontrol import choose_pdu
pdu = choose_pdu(SimpleNamespace(ip_address="192.168.1.23"), {}, 5)
print(pdu.get_all_names())
In CLI
pducontrol 192.168.1.23 get_name all
More information can be found using the -h argument. Some arguments even
have submenus, for instance:
pducontrol 192.168.1.23 set -h
usage: pducontrol ip_address set [-h] outlets {on,off,reboot}
positional arguments:
outlets comma-separated list of outlets
{on,off,reboot} state to set the outlets to, can be one of [on, off,
reboot]
A configuration file named pdu_settings.cfg, containing IP addresses and
credentials can be added in~/.config/pducontrol/ for ease of use and
autocompletion.
An example file is available in config.
Contributing
Bug reports and comments are warmly welcome, but contributions, such as pull requests and patches, are not, for legal reasons only. If that's bothering you, don't hesitate to tell, with enough pressure, we could reconsider our position.
License
pducontrol is released under LGPL v3
Hacking
Execute the program from the source directory
python3 -m pducontrol
Generate a debian package
make debian
Execute the unit tests
They are located in tests/.
make test
Coding style
All python files should respect the PEP 8 coding style and shell scripts, the shellcheck coding style.
How to publish a release
- put the repository on the release's revision
make piptwine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file pducontrol-1.7.0.tar.gz.
File metadata
- Download URL: pducontrol-1.7.0.tar.gz
- Upload date:
- Size: 28.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.66.4 urllib3/1.26.5 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4192c18ebd1fbce5e5bb2725ca233fc38dc4afa1683ea88b9c0212305b555509
|
|
| MD5 |
5026bcb95b551bbfb3ff1d672ba20213
|
|
| BLAKE2b-256 |
d75bb24df3efbbe5d5e37cacf0d52cb8151a122bd78932bec097947387eec369
|