OLD | NEW |
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import telnetlib, threading, time | 5 import telnetlib, threading, time |
6 | 6 |
7 # Controls Server Technology CW-16V1-C20M switched CDUs over Telnet | 7 # Controls Server Technology CW-16V1-C20M switched CDUs over Telnet |
8 # Opens a new connection for every command to | 8 # Opens a new connection for every command to |
9 # avoid threading and address space conflicts | 9 # avoid threading and address space conflicts |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 def _do_command(self, command, outlet=1): | 32 def _do_command(self, command, outlet=1): |
33 tn = telnetlib.Telnet(self.host) | 33 tn = telnetlib.Telnet(self.host) |
34 tn.read_until('Username: ') | 34 tn.read_until('Username: ') |
35 tn.write(self.user + '\n') | 35 tn.write(self.user + '\n') |
36 tn.read_until('Password: ') | 36 tn.read_until('Password: ') |
37 tn.write(self.password + '\n') | 37 tn.write(self.password + '\n') |
38 tn.read_until('Switched CDU: ') | 38 tn.read_until('Switched CDU: ') |
39 tn.write('%s .a%d\n' % (command, outlet)) | 39 tn.write('%s .a%d\n' % (command, outlet)) |
40 tn.read_some() | 40 tn.read_some() |
41 tn.close() | 41 tn.close() |
OLD | NEW |