summaryrefslogtreecommitdiffstats
path: root/chrome/test/pyautolib/chromeos
diff options
context:
space:
mode:
authordtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 22:07:15 +0000
committerdtu@chromium.org <dtu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-06 22:07:15 +0000
commit2831638398f9ab2b991009c1e380395758c98e60 (patch)
tree327d974ef60426b8182c52e3d434b5e34b89bf4a /chrome/test/pyautolib/chromeos
parent9cb31511cb8ba57c36157c5a509ffd3fe4568437 (diff)
downloadchromium_src-2831638398f9ab2b991009c1e380395758c98e60.zip
chromium_src-2831638398f9ab2b991009c1e380395758c98e60.tar.gz
chromium_src-2831638398f9ab2b991009c1e380395758c98e60.tar.bz2
Initial inclusion of power_strip code.
Including WifiRouterStrip code that is used for power_strips that exclusively have Wifi routers attached to them. Added first connect test case using the power strip. BUG= TEST=run chromeos_wifi.py Review URL: http://codereview.chromium.org/6764022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@80704 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/pyautolib/chromeos')
-rw-r--r--chrome/test/pyautolib/chromeos/__init__.py0
-rw-r--r--chrome/test/pyautolib/chromeos/power_strip.py78
2 files changed, 78 insertions, 0 deletions
diff --git a/chrome/test/pyautolib/chromeos/__init__.py b/chrome/test/pyautolib/chromeos/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/chrome/test/pyautolib/chromeos/__init__.py
diff --git a/chrome/test/pyautolib/chromeos/power_strip.py b/chrome/test/pyautolib/chromeos/power_strip.py
new file mode 100644
index 0000000..50d7b19
--- /dev/null
+++ b/chrome/test/pyautolib/chromeos/power_strip.py
@@ -0,0 +1,78 @@
+# Copyright (c) 2011 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import telnetlib
+
+
+class PowerStrip(object):
+ """Controls Server Technology CW-16V1-C20M switched CDUs.
+ (Cabinet Power Distribution Unit)
+
+ This class is used to control the CW-16V1-C20M unit which
+ is a 16 port remote power strip. The strip supports AC devices
+ using 100-120V 50/60Hz input voltages. The commands in this
+ class are supported by switches that use Sentry Switched CDU Version 6.0g.
+
+ Opens a new connection for every command.
+ """
+
+ def __init__(self, host, user='admn', password='admn'):
+ self._host = host
+ self._user = user
+ self._password = password
+
+ def PowerOff(self, outlet):
+ """Powers off the device that is plugged into the specified outlet.
+
+ Args:
+ outlet: The outlet ID defined on the switch (eg. .a14).
+ """
+ self._DoCommand('off', outlet)
+
+ def PowerOn(self, outlet):
+ """Powers on the device that is plugged into the specified outlet.
+
+ Args:
+ outlet: The outlet ID defined on the switch (eg. .a14).
+ """
+ self._DoCommand('on', outlet)
+
+ def _DoCommand(self, command, outlet):
+ """Performs power strip commands on the specified outlet.
+
+ Sample telnet interaction:
+ Escape character is '^]'.
+
+ Sentry Switched CDU Version 6.0g
+
+ Username: admn
+ Password: < password hidden from view >
+
+ Location:
+
+ Switched CDU: on .a1
+
+ Outlet Outlet Outlet Control
+ ID Name Status State
+
+ .A1 TowerA_Outlet1 On On
+
+ Command successful
+
+ Switched CDU: < cdu cmd >
+
+ Args:
+ command: A valid CW-16V1-C20M command that follows the format
+ <command> <outlet>.
+ outlet: The outlet ID defined on the switch (eg. .a14).
+ """
+ tn = telnetlib.Telnet(self._host)
+ tn.read_until('Username: ')
+ tn.write(self._user + '\n')
+ tn.read_until('Password: ')
+ tn.write(self._password + '\n')
+ tn.read_until('Switched CDU: ')
+ tn.write('%s %s\n' % (command, outlet))
+ tn.read_some()
+ tn.close()