summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/server/xmlrpc.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/server/xmlrpc.py')
-rw-r--r--bitbake/lib/bb/server/xmlrpc.py26
1 files changed, 18 insertions, 8 deletions
diff --git a/bitbake/lib/bb/server/xmlrpc.py b/bitbake/lib/bb/server/xmlrpc.py
index 5045e55ae2..026415efd5 100644
--- a/bitbake/lib/bb/server/xmlrpc.py
+++ b/bitbake/lib/bb/server/xmlrpc.py
@@ -93,7 +93,7 @@ class BitBakeServerCommands():
93 """ 93 """
94 Run a cooker command on the server 94 Run a cooker command on the server
95 """ 95 """
96 return self.cooker.command.runCommand(command) 96 return self.cooker.command.runCommand(command, self.server.readonly)
97 97
98 def terminateServer(self): 98 def terminateServer(self):
99 """ 99 """
@@ -124,7 +124,7 @@ class BitBakeServerCommands():
124# ("service unavailable") is returned to the client. 124# ("service unavailable") is returned to the client.
125class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): 125class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
126 def __init__(self, request, client_address, server): 126 def __init__(self, request, client_address, server):
127 self.connection_token = server.connection_token 127 self.server = server
128 SimpleXMLRPCRequestHandler.__init__(self, request, client_address, server) 128 SimpleXMLRPCRequestHandler.__init__(self, request, client_address, server)
129 129
130 def do_POST(self): 130 def do_POST(self):
@@ -132,9 +132,13 @@ class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
132 remote_token = self.headers["Bitbake-token"] 132 remote_token = self.headers["Bitbake-token"]
133 except: 133 except:
134 remote_token = None 134 remote_token = None
135 if remote_token != self.connection_token: 135 if remote_token != self.server.connection_token and remote_token != "observer":
136 self.report_503() 136 self.report_503()
137 else: 137 else:
138 if remote_token == "observer":
139 self.server.readonly = True
140 else:
141 self.server.readonly = False
138 SimpleXMLRPCRequestHandler.do_POST(self) 142 SimpleXMLRPCRequestHandler.do_POST(self)
139 143
140 def report_503(self): 144 def report_503(self):
@@ -283,13 +287,17 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
283 self.connection_token = token 287 self.connection_token = token
284 288
285class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection): 289class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
286 def __init__(self, serverImpl, clientinfo=("localhost", 0)): 290 def __init__(self, serverImpl, clientinfo=("localhost", 0), observer_only = False):
287 self.connection, self.transport = _create_server(serverImpl.host, serverImpl.port) 291 self.connection, self.transport = _create_server(serverImpl.host, serverImpl.port)
288 self.clientinfo = clientinfo 292 self.clientinfo = clientinfo
289 self.serverImpl = serverImpl 293 self.serverImpl = serverImpl
294 self.observer_only = observer_only
290 295
291 def connect(self): 296 def connect(self):
292 token = self.connection.addClient() 297 if not self.observer_only:
298 token = self.connection.addClient()
299 else:
300 token = "observer"
293 if token is None: 301 if token is None:
294 return None 302 return None
295 self.transport.set_connection_token(token) 303 self.transport.set_connection_token(token)
@@ -299,7 +307,8 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
299 return self 307 return self
300 308
301 def removeClient(self): 309 def removeClient(self):
302 self.connection.removeClient() 310 if not self.observer_only:
311 self.connection.removeClient()
303 312
304 def terminate(self): 313 def terminate(self):
305 # Don't wait for server indefinitely 314 # Don't wait for server indefinitely
@@ -331,7 +340,8 @@ class BitBakeServer(BitBakeBaseServer):
331 340
332class BitBakeXMLRPCClient(BitBakeBaseServer): 341class BitBakeXMLRPCClient(BitBakeBaseServer):
333 342
334 def __init__(self): 343 def __init__(self, observer_only = False):
344 self.observer_only = observer_only
335 pass 345 pass
336 346
337 def saveConnectionDetails(self, remote): 347 def saveConnectionDetails(self, remote):
@@ -354,7 +364,7 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
354 except: 364 except:
355 return None 365 return None
356 self.serverImpl = XMLRPCProxyServer(host, port) 366 self.serverImpl = XMLRPCProxyServer(host, port)
357 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0)) 367 self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only)
358 return self.connection.connect() 368 return self.connection.connect()
359 369
360 def endSession(self): 370 def endSession(self):