Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: client/common_lib/power_strip.py

Issue 3465002: Add Sentry power strip control and cryptohome/sync stress test (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/autotest.git
Patch Set: Mistake: iterations is already an autotest parameter for run_tests() Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | client/site_tests/platform_CryptohomeSyncStress/control » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/common_lib/power_strip.py
diff --git a/client/common_lib/power_strip.py b/client/common_lib/power_strip.py
new file mode 100644
index 0000000000000000000000000000000000000000..b21ddcad9d60ec45308a3d7f59467d0b843e5db7
--- /dev/null
+++ b/client/common_lib/power_strip.py
@@ -0,0 +1,41 @@
+# Copyright (c) 2010 The Chromium OS 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, threading, time
+
+# Controls Server Technology CW-16V1-C20M switched CDUs over Telnet
+# Opens a new connection for every command to
+# avoid threading and address space conflicts
+
+class PowerStrip():
+ def __init__(self, host, user='admn', password='admn'):
+ self.host = host
+ self.user = user
+ self.password = password
+
+ def reboot(self, outlet, delay=0):
+ self.command('reboot', outlet, delay)
+
+ def off(self, outlet, delay=0):
+ self.command('off', outlet, delay)
+
+ def on(self, outlet, delay=0):
+ self.command('on', outlet, delay)
+
+ def command(self, command, outlet=1, delay=0):
+ if delay == 0:
+ self._do_command(command, outlet)
+ else:
+ threading.Timer(delay, self._do_command, (command, outlet)).start()
+
+ def _do_command(self, command, outlet=1):
+ 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 .a%d\n' % (command, outlet))
+ tn.read_some()
+ tn.close()
« no previous file with comments | « no previous file | client/site_tests/platform_CryptohomeSyncStress/control » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698