return 0
class ePowerSwitchOld(PCUControl):
- def run_http(self, node_port, dryrun):
- self.url = "http://%s:%d/" % (self.host,80)
- uri = "%s:%d" % (self.host,80)
-
- # create authinfo
- authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm()
- authinfo.add_password (None, uri, self.username, self.password)
- authhandler = urllib2.HTTPBasicAuthHandler( authinfo )
-
- # NOTE: it doesn't seem to matter whether this authinfo is here or not.
- transport = urllib2.build_opener(authinfo)
- f = transport.open(self.url)
- if self.transport.verbose: print f.read()
+ supported_ports = [80]
+ def run_http(self, node_port, dryrun):
+ self.url = "http://%s" % (self.host)
+
+ authinfo = { "pwd" : self.password }
+ data = urllib.urlencode(authinfo)
+ req = urllib2.Request(self.url + "/elogin.html", data)
+ print self.url
+ print data
+ response = urllib2.urlopen(req)
+ reply = response.read()
if not dryrun:
- transport = urllib2.build_opener(authhandler)
- f = transport.open(self.url + "cmd.html", "P%d=r" % node_port)
- if self.transport.verbose: print f.read()
-
- self.transport.close()
- return 0
-
-class ePowerSwitchOld(PCUControl):
- supported_ports = [80]
- def run_http(self, node_port, dryrun):
- self.url = "http://%s:%d/" % (self.host,80)
- uri = "%s:%d" % (self.host,80)
-
- # TODO: I'm still not sure what the deal is here.
- # two independent calls appear to need to be made before the
- # reboot will succeed. It doesn't seem to be possible to do
- # this with a single call. I have no idea why.
-
- # create authinfo
- authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm()
- authinfo.add_password (None, uri, self.username, self.password)
- authhandler = urllib2.HTTPBasicAuthHandler( authinfo )
-
- # NOTE: it doesn't seem to matter whether this authinfo is here or not.
- transport = urllib2.build_opener()
- f = transport.open(self.url + "elogin.html", "pwd=%s" % self.password)
- if self.transport.verbose: print f.read()
-
- if not dryrun:
- transport = urllib2.build_opener(authhandler)
- f = transport.open(self.url + "econtrol.html", "P%d=r" % node_port)
- if self.transport.verbose: print f.read()
-
- # data= "P%d=r" % node_port
- #self.open(self.host, self.username, self.password)
- #self.sendHTTP("elogin.html", "pwd=%s" % self.password)
- #self.sendHTTP("econtrol.html", data)
- #self.sendHTTP("cmd.html", data)
+ try:
+ data = urllib.urlencode({'P%d' % node_port : "r"})
+ req = urllib2.Request(self.url + "econtrol.html")
+ f = urllib2.urlopen(req, data)
+ except:
+ import traceback; traceback.print_exc()
- #self.close()
- return 0
+ return 0