Giter VIP home page Giter VIP logo

apc9606's Introduction

APC Network Power Management Controller

Build Status

Controls rebooting of APC network PDU switches with 'telnet' network interface. Tested with the AP7900, but likely works with other models.

This handles locking of the device so that parallel calls will block, since APC has a single telnet session.

Requirements

  • Python 2.x or Python 3.x
  • Python Expect (pexpect) library. To install: 'pip install pexpect'
  • APC with telnet network interface (tested on AP7900)

Installation

$ pip install git+https://github.com/Makr91/APC9606

or

Download source and run

$ python setup.py install

The APC needs to be set up with telnet enabled, and using a fixed IP address. If a DHCP address is used, it may change, and you will have trouble connecting.

Usage

Display help

$ apc --help
usage: apc [-h] [--host HOST] [--user USER] [--password PASSWORD] [-v]
           [--quiet] [--debug] [--reboot OUTLET] [--off OUTLET] [--on OUTLET]
           [--cli CLI] [--delay DELAY] [--duration DURATION] [--status]

APC Python CLI

optional arguments:
  -h, --help           show this help message and exit
  --host HOST          Override the host
  --user USER          Override the username
  --password PASSWORD  Override the password
  -v, --verbose        Verbose messages
  --quiet              Quiet
  --debug              Debug mode
  --reboot OUTLET      Reboot an outlet
  --off OUTLET         Turn off an outlet
  --on OUTLET          Turn on an outlet
  --cli CLI            command line to execute 'ssh {user}@{host}' or 'telnet
                       {host}
  --delay DELAY        delay before on/off (-1 to 7200 sec, where -1=Never)
  --duration DURATION  reboot duration (5 to 60 sec)
  --status             Status of outlets

Outlet status

$ apc --status
Acquiring lock /tmp/apc.lock
Connecting to APC @ 10.8.0.142
Logged in as user apc, version 3.9.2
Outlet 1 NAS             ON
Outlet 2                 OFF
Outlet 3                 ON
Outlet 4                 ON
Outlet 5                 ON
Outlet 6                 ON
Outlet 7                 ON
Outlet 8                 ON
DISCONNECTED from 10.8.0.142

Power cycle (reboot) a single port

Immediate

$ apc --reboot PORT

Example: reboot power port 8

$ apc --reboot 8
Acquiring lock /tmp/apc.lock
Connecting to APC @ 10.8.0.142
Logged in as user apc, version 3.9.2
APC 10.8.0.142: Outlet #8 Rebooted
DISCONNECTED from 10.8.0.142

Delayed reboot with duration

Example: reboot power port 4

$ apc --reboot 4 --delay 30 --duration 10

Power off a single port

Immediate

Example: power off port 4

$ apc --off 4

Delayed power off

Example: power off port 4 30 seconds later

$ apc --off 4 --delay 30

Environment Variables

The following environment variables will override the APC connection:

  • $APC_HOST
  • $APC_USER
  • $APC_PASSWORD

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.