dans l'optique de remettre ClusterController en production, les administateurs peuvent désormais ajouter ou supprimer une machine du contrôle du cluster controller

This commit is contained in:
Guillaume Raffy 2012-06-28 12:22:07 +00:00
parent 2c807fefe2
commit d67c4d6a21
2 changed files with 24 additions and 12 deletions

View File

@ -7,6 +7,7 @@ import threading
import Util import Util
#import pri #import pri
from urlparse import urlparse, parse_qs from urlparse import urlparse, parse_qs
import xml.dom.minidom
#>>> url = 'http://example.com/?foo=bar&one=1' #>>> url = 'http://example.com/?foo=bar&one=1'
#>>> parse_qs(urlparse(url).query) #>>> parse_qs(urlparse(url).query)
#{'foo': ['bar'], 'one': ['1']} #{'foo': ['bar'], 'one': ['1']}
@ -36,12 +37,23 @@ class MyHandler(BaseHTTPRequestHandler):
return return
if self.path.endswith("ShowControlledMachines"): #http://simpatix10.univ-rennes1.fr:8080/ShowControlledMachines if self.path.endswith("ShowControlledMachines"): #http://simpatix10.univ-rennes1.fr:8080/ShowControlledMachines
self.send_response(200) self.send_response(200)
self.send_header('Content-type', 'text/html') self.send_header('Content-type', 'text/xml')
self.end_headers() 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 <ControlledMachines> root element
controlledMachinesElement = doc.createElement("ControlledMachines")
doc.appendChild(controlledMachinesElement)
for machine in self.server.m_clusterController.m_clusterStatus.m_clusterNodes.itervalues(): 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 <card> 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 return
if urlparse(self.path).path == '/SetControlOnMachine': #http://simpatix10.univ-rennes1.fr:8080/SetControlOnMachine?machineName=simpatix30&control=1 if urlparse(self.path).path == '/SetControlOnMachine': #http://simpatix10.univ-rennes1.fr:8080/SetControlOnMachine?machineName=simpatix30&control=1
machineName = paramsDict['machineName'][0] machineName = paramsDict['machineName'][0]