summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2014-06-11 10:19:03 +0100
committerAlexandru DAMIAN <alexandru.damian@intel.com>2014-06-12 14:38:28 +0100
commitdb5390940c0afbcdc9fbcf1225761968ae51d4a7 (patch)
tree42813af2f140c44d91777c04cef5c7fc1c4a2fa6 /lib
parent272a4bba0804bb6b5e0d498d3453321b5ed1dc76 (diff)
downloadbitbake-contrib-db5390940c0afbcdc9fbcf1225761968ae51d4a7.tar.gz
xmlrpc: add support for token reusing
We add support to specify a connection token in the command line and in the environment variable BBTOKEN. When a client registers to a bitbake server, that client will have exclusive access to the server. The client is identified by a server-supplied token. If a client terminates, we cannot reconnect to the server as the token is lost. This patch adds the capability to specify the connection token in the command line for xmlrpc clients. This allows us to have bitbake work as an already-authenticated client with the server and resume sending commands to a server. Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/server/xmlrpc.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/bb/server/xmlrpc.py b/lib/bb/server/xmlrpc.py
index d6f4338ae..4205a4c35 100644
--- a/lib/bb/server/xmlrpc.py
+++ b/lib/bb/server/xmlrpc.py
@@ -281,13 +281,16 @@ class BitBakeXMLRPCServerConnection(BitBakeBaseServerConnection):
self.observer_only = observer_only
self.featureset = featureset
- def connect(self):
- if not self.observer_only:
- token = self.connection.addClient()
- else:
- token = "observer"
+ def connect(self, token = None):
+ if token is None:
+ if self.observer_only:
+ token = "observer"
+ else:
+ token = self.connection.addClient()
+
if token is None:
return None
+
self.transport.set_connection_token(token)
self.events = uievent.BBUIEventQueue(self.connection, self.clientinfo)
@@ -336,7 +339,9 @@ class BitBakeServer(BitBakeBaseServer):
class BitBakeXMLRPCClient(BitBakeBaseServer):
- def __init__(self, observer_only = False):
+ def __init__(self, observer_only = False, token = None):
+ self.token = token
+
self.observer_only = observer_only
# if we need extra caches, just tell the server to load them all
pass
@@ -366,7 +371,7 @@ class BitBakeXMLRPCClient(BitBakeBaseServer):
try:
self.serverImpl = XMLRPCProxyServer(host, port)
self.connection = BitBakeXMLRPCServerConnection(self.serverImpl, (ip, 0), self.observer_only, featureset)
- return self.connection.connect()
+ return self.connection.connect(self.token)
except Exception as e:
bb.warn("Could not connect to server at %s:%s (%s)" % (host, port, str(e)))
raise e