Skip to main content

This library handles rather specific remote power management scenario.

  • Server can be woken up with wake-on-lan (WOL)

  • SSH access with public key authentication to the server (for shutting it down)

  • Server responds to ping (checking whether the server is running)

Installation:

pip install manage_server_power

or clone the repository and use

python setup.py install

Configuration and notes

On the server side:

  • Enable WOL (from BIOS/… settings).

  • Take note of relevant MAC address.

  • Add new user to server (say, powermanagement).

  • Edit sudoers (visudo) and add powermanagement ALL=NOPASSWD: /sbin/poweroff

On the management computer:

  • Generate ssh public key pair (ssh-keygen)

  • Copy public key to powermanagement user on server (add it to .ssh/authorized_keys)

  • Connect to server to check that public key works properly and to add server host key to known_hosts.

Notes:

  • At least with some devices/networks, WOL won’t work if broadcast_ip is not set to local network’s broadcast, instead of 255.255.255.255.

Usage

import manage_server_power
sp = manage_server_power.ServerPower(server_hostname="example.com",
                                     server_mac="61:a3:18:1c:84:4b",
                                     server_port=22,  # optional, default is 22
                                     ssh_username="powermanagement",
                                     broadcast_ip="192.168.1.255",  # optional, default is 255.255.255.255
                                     socket_timeout=0.5,  # optional
                                     wol_port=9,  # optional, default is 9
                                     )
print sp.is_alive()
# SERVER_DOWN, SERVER_UP or SERVER_UP_NOT_RESPONDING
print sp.wake_up()  # send WOL packet
print sp.shutdown()  # ssh in and run "sudo poweroff"

Release files for manage_server_power 0.0.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for manage_server_power 0.0.6
File Size Uploaded
manage_server_power-0.0.6.tar.gz 3.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for manage_server_power 0.0.6
File Interpreter ABI Platform
manage_server_power-0.0.6-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 8.3 kB

Release files / manage_server_power-0.0.6.tar.gz

Download URL manage_server_power-0.0.6.tar.gz
Size 3.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8274382b6d8e4e9f398e2d040b750f31f65183db917d2e1f4cff4ea9b40ba2aa
BLAKE2b-256 checksum
How to use checksums
55c883aec0e525cd29042e3336d51a36ff059d4f6416c3973e144b099a13b3de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / manage_server_power-0.0.6-py2.py3-none-any.whl

Download URL manage_server_power-0.0.6-py2.py3-none-any.whl
Size 5.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
200579224181a4b219f8df4f0d5cad63bf804996a09ba82e7a1f62dda7cedb4b
BLAKE2b-256 checksum
How to use checksums
1401aa37a5570e9f8b1454d2b482ad3740d17bd7049b89920b08bc0053bd6d52
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.0.6 This release

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page