Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request qca#1 from qca/master
Browse files Browse the repository at this point in the history
Update to latest
  • Loading branch information
wwahammy committed May 24, 2016
2 parents a6b2c97 + 8352bc6 commit ee59516
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ The simplest tests consist of commands to type expected output. These tests use

Test suites are located in `testsuites.cfg` and are simply lists of test names. Results of running a test suite are stored in a nicely formated html file that can be emailed to interested parties or sent to a database.

Getting involved
--------------
Have a question about BoardFarm? Want to know the best way to get involved? Found a bug? Here are the BoardFarm communication channels:

* Mailing List at [email protected] (sign up at http://lists.prplfoundation.org/cgi-bin/mailman/listinfo/boardfarm). Use this for general discussion or questions.
* IRC at #boardfarm on Freenode. Use this for quick answers if someone is available (Sometimes no one is there)
* Issue tracker at https://github.com/qca/boardfarm/issues. Use this for clear feature requests or bug reports. It's okay to also initially discuss a feature request on the mailing lists
* Pull requests at https://github.com/qca/boardfarm. When you want to submit a change to Boardfarm!

Software Setup
--------------

Expand Down
23 changes: 12 additions & 11 deletions devices/power.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
# This file is distributed under the Clear BSD license.
# The full text can be found in LICENSE in the root directory.

try:
from urllib.request import urlopen
from urllib.error import HTTPError
except:
from urllib2 import urlopen, HTTPError

import pexpect
import dlipower

Expand All @@ -17,23 +23,18 @@ def get_power_device(ip_address, username=None, password=None, outlet=None):
'''
if ip_address is None:
return HumanButtonPusher()
p = pexpect.spawn('curl -L %s' % ip_address)
try:
t = p.expect_exact(['<title>Power Controller </title>',
'Sentry Switched CDU',
'<title>APC | Log On</title>'], timeout=90)
except pexpect.EOF as e:
if hasattr(p, "before"):
print(p.before)
raise Exception("Unable to connect to %s." % ip_address)
data = urlopen("http://" + ip_address).read().decode()
except HTTPError as e:
data = e.read().decode()
except Exception as e:
print(e)
raise Exception("\nError connecting to %s" % ip_address)
if t == 0:
if '<title>Power Controller' in data:
return DLIPowerSwitch(ip_address, outlet=outlet, username=username, password=password)
elif t == 1:
if 'Sentry Switched CDU' in data:
return SentrySwitchedCDU(ip_address, outlet=outlet)
elif t == 2:
if '<title>APC ' in data:
return APCPower(ip_address, outlet=outlet)
else:
raise Exception("No code written to handle power device found at %s" % ip_address)
Expand Down

0 comments on commit ee59516

Please sign in to comment.