blob: c3d2009522faeacdfeae806ba71dc088a7ddadbf [file] [log] [blame]
# 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 logging, os, urllib
remote_switch1 = ''
remote_power_switch_machines = {
'hostfoo' : {'power_ip': 'switchbar_ip', 'power_port': 'switchbar_port'},
'' : {'power_ip': remote_switch1, 'power_port': 61},
# factory function for choosing which remote power class to
# return
def RemotePower(host):
if host in remote_power_switch_machines:
return RemotePowerSwitch(remote_power_switch_machines[host])
return None
class RemotePowerSwitch(object):
This class implements power control for the remotepowerswitch box.
def __init__(self, dict):
self.dict = dict
self.cmd_url = 'http://admin:12345678@%s/Set.cmd?CMD=' % (
def _set_power(self, state):
set_power_url = '%sSetPower&P%s=%s' % (self.cmd_url,
self.dict['power_port'], state)
f = urllib.urlopen(set_power_url)
def set_power_on(self):
def set_power_off(self):