blob: 8d3a7a103729a190cf9375b285ce010dc5f7019d [file] [log] [blame]
Matt Hart76fb2542014-06-01 14:24:56 +01001#! /usr/bin/python
2
3# Copyright 2013 Linaro Limited
4# Author Matt Hart <matthew.hart@linaro.org>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19# MA 02110-1301, USA.
20
21import logging
Matt Hart132d43c2015-02-25 18:19:53 +000022from lavapdu.drivers.apc7952 import APC7952
23
Matt Hart76fb2542014-06-01 14:24:56 +010024
Matt Hart2af71142014-07-22 10:40:41 +010025class APC9218(APC7952):
Matt Hart76fb2542014-06-01 14:24:56 +010026
Matt Hart132d43c2015-02-25 18:19:53 +000027 @classmethod
28 def accepts(cls, drivername):
Matt Harte7bddc02015-07-08 18:05:08 +010029 models = ["ap9606","apc9606","ap9218","apc9218"]
30 if drivername.lower() in models:
Matt Hart132d43c2015-02-25 18:19:53 +000031 return True
32 return False
33
Matt Hart76fb2542014-06-01 14:24:56 +010034 def _port_interaction(self, command, port_number):
Matt Hart76fb2542014-06-01 14:24:56 +010035 ### make sure in main menu here
36 self._back_to_main()
37 self.connection.send("\r")
38 self.connection.expect("1- Device Manager")
39 self.connection.expect("> ")
40 logging.debug("Entering Device Manager")
41 self.connection.send("1\r")
42 self.connection.expect("------- Device Manager")
43 logging.debug("Got to Device Manager")
44 self._enter_outlet(port_number, False)
45 res = self.connection.expect(["1- Control Outlet", "1- Outlet Control/Configuration"])
46 self.connection.expect("> ")
47 self.connection.send("1\r")
48 res = self.connection.expect(["> ", "Press <ENTER> to continue..."])
49 if res == 1:
50 logging.debug("Stupid paging thingmy detected, pressing enter")
51 self.connection.send("\r")
52 self.connection.send("\r")
53 res = self.connection.expect(["Control Outlet %s" % port_number, "Control Outlet"])
54 self.connection.expect("3- Immediate Reboot")
55 self.connection.expect("> ")
56 if command == "on":
57 self.connection.send("1\r")
58 self.connection.expect("Immediate On")
59 self._do_it()
60 elif command == "off":
61 self.connection.send("2\r")
62 self.connection.expect("Immediate Off")
63 self._do_it()
64 else:
Matt Hart2af71142014-07-22 10:40:41 +010065 logging.debug("Unknown command!")