diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2016-12-13 20:07:07 +1300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-12-14 12:25:07 +0000 |
commit | 8c33063a1de7234e681675ee45ec7a376c84cefe (patch) | |
tree | 31d578a9d693996f9a07faa2c59c8c90bed8e612 /bitbake/lib | |
parent | 7d5c9860de05efc4272256ccefc530113f01d24e (diff) | |
download | poky-8c33063a1de7234e681675ee45ec7a376c84cefe.tar.gz |
bitbake: remotedata: enable transporting datastore from the client to the server
For the purposes of server-side parsing and expansion allowing for
client-side use of the datastore, we need a means of sending a datastore
from the client back to the server, where the datastore probably
consists of a remote (server-side) original plus some client-side
modifications. To do this we need to take care of a couple of things:
1) xmlrpc can't handle nested dicts, so if you enable memres and simply
try passing a serialised datastore then things break. Instead of
serialising the entire datastore, just take the naive option of
transferring the internal dict alone (as a list of tuples) for now.
2) Change the TinfoilDataStoreConnector object into simply the handle
(number) when transmitting; it gets substituted with the real
datastore when the server receives it.
(Bitbake rev: 784d2f1a024efe632fc9049ce5b78692d419d938)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/remotedata.py | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/bitbake/lib/bb/remotedata.py b/bitbake/lib/bb/remotedata.py index 932ee430ea..68ecffc198 100644 --- a/bitbake/lib/bb/remotedata.py +++ b/bitbake/lib/bb/remotedata.py | |||
@@ -72,3 +72,45 @@ class RemoteDatastores: | |||
72 | if idx in self.locked: | 72 | if idx in self.locked: |
73 | raise Exception('Tried to release locked datastore %d' % idx) | 73 | raise Exception('Tried to release locked datastore %d' % idx) |
74 | del self.datastores[idx] | 74 | del self.datastores[idx] |
75 | |||
76 | def receive_datastore(self, remote_data): | ||
77 | """Receive a datastore object sent from the client (as prepared by transmit_datastore())""" | ||
78 | dct = dict(remote_data) | ||
79 | d = bb.data_smart.DataSmart() | ||
80 | d.dict = dct | ||
81 | while True: | ||
82 | if '_remote_data' in dct: | ||
83 | dsindex = dct['_remote_data']['_content'] | ||
84 | del dct['_remote_data'] | ||
85 | if dsindex is None: | ||
86 | dct['_data'] = self.cooker.data.dict | ||
87 | else: | ||
88 | dct['_data'] = self.datastores[dsindex].dict | ||
89 | break | ||
90 | elif '_data' in dct: | ||
91 | idct = dict(dct['_data']) | ||
92 | dct['_data'] = idct | ||
93 | dct = idct | ||
94 | else: | ||
95 | break | ||
96 | return d | ||
97 | |||
98 | @staticmethod | ||
99 | def transmit_datastore(d): | ||
100 | """Prepare a datastore object for sending over IPC from the client end""" | ||
101 | # FIXME content might be a dict, need to turn that into a list as well | ||
102 | def copy_dicts(dct): | ||
103 | if '_remote_data' in dct: | ||
104 | dsindex = dct['_remote_data']['_content'].dsindex | ||
105 | newdct = dct.copy() | ||
106 | newdct['_remote_data'] = {'_content': dsindex} | ||
107 | return list(newdct.items()) | ||
108 | elif '_data' in dct: | ||
109 | newdct = dct.copy() | ||
110 | newdata = copy_dicts(dct['_data']) | ||
111 | if newdata: | ||
112 | newdct['_data'] = newdata | ||
113 | return list(newdct.items()) | ||
114 | return None | ||
115 | main_dict = copy_dicts(d.dict) | ||
116 | return main_dict | ||