Revision 30474135
b/lib/rpc.py | ||
---|---|---|
180 | 180 |
return wrapper |
181 | 181 |
|
182 | 182 |
|
183 |
def _Compress(data): |
|
184 |
"""Compresses a string for transport over RPC. |
|
185 |
|
|
186 |
Small amounts of data are not compressed. |
|
187 |
|
|
188 |
@type data: str |
|
189 |
@param data: Data |
|
190 |
@rtype: tuple |
|
191 |
@return: Encoded data to send |
|
192 |
|
|
193 |
""" |
|
194 |
# Small amounts of data are not compressed |
|
195 |
if len(data) < 512: |
|
196 |
return (constants.RPC_ENCODING_NONE, data) |
|
197 |
|
|
198 |
# Compress with zlib and encode in base64 |
|
199 |
return (constants.RPC_ENCODING_ZLIB_BASE64, |
|
200 |
base64.b64encode(zlib.compress(data, 3))) |
|
201 |
|
|
202 |
|
|
183 | 203 |
class RpcResult(object): |
184 | 204 |
"""RPC Result class. |
185 | 205 |
|
... | ... | |
566 | 586 |
c.ConnectNode(node, read_timeout=read_timeout) |
567 | 587 |
return c.GetResults()[node] |
568 | 588 |
|
569 |
@staticmethod |
|
570 |
def _Compress(data): |
|
571 |
"""Compresses a string for transport over RPC. |
|
572 |
|
|
573 |
Small amounts of data are not compressed. |
|
574 |
|
|
575 |
@type data: str |
|
576 |
@param data: Data |
|
577 |
@rtype: tuple |
|
578 |
@return: Encoded data to send |
|
579 |
|
|
580 |
""" |
|
581 |
# Small amounts of data are not compressed |
|
582 |
if len(data) < 512: |
|
583 |
return (constants.RPC_ENCODING_NONE, data) |
|
584 |
|
|
585 |
# Compress with zlib and encode in base64 |
|
586 |
return (constants.RPC_ENCODING_ZLIB_BASE64, |
|
587 |
base64.b64encode(zlib.compress(data, 3))) |
|
588 |
|
|
589 | 589 |
# |
590 | 590 |
# Begin RPC calls |
591 | 591 |
# |
... | ... | |
1176 | 1176 |
|
1177 | 1177 |
""" |
1178 | 1178 |
file_contents = utils.ReadFile(file_name) |
1179 |
data = cls._Compress(file_contents)
|
|
1179 |
data = _Compress(file_contents) |
|
1180 | 1180 |
st = os.stat(file_name) |
1181 | 1181 |
getents = runtime.GetEnts() |
1182 | 1182 |
params = [file_name, data, st.st_mode, getents.LookupUid(st.st_uid), |
... | ... | |
1430 | 1430 |
|
1431 | 1431 |
""" |
1432 | 1432 |
return cls._StaticMultiNodeCall(node_list, "jobqueue_update", |
1433 |
[file_name, cls._Compress(content)],
|
|
1433 |
[file_name, _Compress(content)], |
|
1434 | 1434 |
address_list=address_list) |
1435 | 1435 |
|
1436 | 1436 |
@classmethod |
Also available in: Unified diff