diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2013-06-17 12:11:51 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-06-17 16:09:10 +0100 |
commit | 3ea9d647ec35c4d30dcaa5b58e9471b775a4716c (patch) | |
tree | e3e5022ce0e34320bd555942c418a3cb02282651 /bitbake/lib/bb/server/xmlrpc.py | |
parent | 194b395f85dbed216b7dd51e66f8b567955307f2 (diff) | |
download | poky-3ea9d647ec35c4d30dcaa5b58e9471b775a4716c.tar.gz |
bitbake: knotty, xmlrpc: add observer-only mode
I add an observer only mode for the knotty UI and
the XMLRPC server that will allow the UI to register
a callback with a server in order to receive events.
The observer-UI is able to send read-only commands to the
server, and also is able to register as an event handler.
Read-only commands are the commands that do not change
the state of the server and have been marked as such in
the command module.
The observer can switch to a full client if it calls addClient
at any time, and the server has no other client running.
(Bitbake rev: 4de9ee21f1fa4d04937cc7430fb1fc8b7a8f61e2)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/server/xmlrpc.py')
-rw-r--r-- | bitbake/lib/bb/server/xmlrpc.py | 26 |
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. |
125 | class BitBakeXMLRPCRequestHandler(SimpleXMLRPCRequestHandler): | 125 | class 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 | ||
285 | class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection): | 289 | class 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 | ||
332 | class BitBakeXMLRPCClient(BitBakeBaseServer): | 341 | class 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): |