diff --git a/ClusterController/ClusterNode.py b/ClusterController/ClusterNode.py index c51d9e2..70b2cf5 100644 --- a/ClusterController/ClusterNode.py +++ b/ClusterController/ClusterNode.py @@ -57,17 +57,17 @@ class ClusterNode: bUpdateRequiredChecks = True if bUpdateRequiredChecks: if self.m_powerState == PowerState.ON: - self.m_machineStatusUpdater.m_bCheckPowerState = True - self.m_machineStatusUpdater.m_bCheckSensors = True + self.m_machineStatusUpdater.m_bCheckPowerState = True + self.m_machineStatusUpdater.m_bCheckSensors = True elif self.m_powerState == PowerState.OFF: - self.m_machineStatusUpdater.m_bCheckPowerState = True - self.m_machineStatusUpdater.m_bCheckSensors = False + self.m_machineStatusUpdater.m_bCheckPowerState = True + self.m_machineStatusUpdater.m_bCheckSensors = False elif self.m_powerState == PowerState.SLEEP: - self.m_machineStatusUpdater.m_bCheckPowerState = True - self.m_machineStatusUpdater.m_bCheckSensors = False + self.m_machineStatusUpdater.m_bCheckPowerState = True + self.m_machineStatusUpdater.m_bCheckSensors = False elif self.m_powerState == PowerState.UNPLUGGED: - self.m_machineStatusUpdater.m_bCheckPowerState = True - self.m_machineStatusUpdater.m_bCheckSensors = False + self.m_machineStatusUpdater.m_bCheckPowerState = True + self.m_machineStatusUpdater.m_bCheckSensors = False else: assert( False ) diff --git a/ClusterController/WebServer.py b/ClusterController/WebServer.py index ea84c30..f17fd38 100644 --- a/ClusterController/WebServer.py +++ b/ClusterController/WebServer.py @@ -7,6 +7,7 @@ import threading import Util #import pri from urlparse import urlparse, parse_qs +import xml.dom.minidom #>>> url = 'http://example.com/?foo=bar&one=1' #>>> parse_qs(urlparse(url).query) #{'foo': ['bar'], 'one': ['1']} @@ -36,12 +37,23 @@ class MyHandler(BaseHTTPRequestHandler): return if self.path.endswith("ShowControlledMachines"): #http://simpatix10.univ-rennes1.fr:8080/ShowControlledMachines self.send_response(200) - self.send_header('Content-type', 'text/html') + self.send_header('Content-type', 'text/xml') self.end_headers() - self.wfile.write("hey, today is the" + str(time.localtime()[7])) - self.wfile.write(" day in the year " + str(time.localtime()[0])) + + # Create the minidom document + doc = xml.dom.minidom.Document() + + # Create the root element + controlledMachinesElement = doc.createElement("ControlledMachines") + doc.appendChild(controlledMachinesElement) + for machine in self.server.m_clusterController.m_clusterStatus.m_clusterNodes.itervalues(): - self.wfile.write("%s is controlled by ClusterController" % machine.getName()) + # Create the main element + controlledMachineElement = doc.createElement("Machine") + controlledMachineElement.setAttribute("name", machine.getName()) + controlledMachinesElement.appendChild(controlledMachineElement) + # Print our newly created XML + self.wfile.write(doc.toprettyxml(indent=" ")) return if urlparse(self.path).path == '/SetControlOnMachine': #http://simpatix10.univ-rennes1.fr:8080/SetControlOnMachine?machineName=simpatix30&control=1 machineName = paramsDict['machineName'][0]