Metadata-Version: 2.0
Name: manage-server-power
Version: 0.0.2
Summary: Small library for shutting down and starting up local server
Home-page: https://github.com/ojarva/python-manage-server-power
Author: Olli Jarva
Author-email: olli@jarva.fi
License: BSD
Keywords: wol wake-on-lan
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: BSD License
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.2
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: PyPy
Requires-Dist: wakeonlan
Requires-Dist: paramiko
Provides-Extra: dev
Requires-Dist: twine; extra == 'dev'
Requires-Dist: wheel; extra == 'dev'

Home server remote power management
===================================

This library handles rather specific remote power management scenario.

- Server can be woken up with wake-on-lan (WOL)
- There's SSH access 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 <https://github.com/ojarva/python-manage-server-power>`_ 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"


