Revision 601dfcbb lib/rpc.py
b/lib/rpc.py | ||
---|---|---|
516 | 516 |
for name, disks in value.items()) |
517 | 517 |
|
518 | 518 |
|
519 |
def _PrepareFileUpload(filename): |
|
519 |
def _PrepareFileUpload(getents_fn, filename):
|
|
520 | 520 |
"""Loads a file and prepares it for an upload to nodes. |
521 | 521 |
|
522 | 522 |
""" |
523 |
# TODO: Use ReadFile(preread=...) and os.fstat |
|
523 | 524 |
data = _Compress(utils.ReadFile(filename)) |
524 | 525 |
st = os.stat(filename) |
525 |
getents = runtime.GetEnts() |
|
526 |
|
|
527 |
if getents_fn is None: |
|
528 |
getents_fn = runtime.GetEnts |
|
529 |
|
|
530 |
getents = getents_fn() |
|
531 |
|
|
526 | 532 |
return [filename, data, st.st_mode, getents.LookupUid(st.st_uid), |
527 | 533 |
getents.LookupGid(st.st_gid), st.st_atime, st.st_mtime] |
528 | 534 |
|
... | ... | |
569 | 575 |
rpc_defs.ED_OBJECT_DICT: _ObjectToDict, |
570 | 576 |
rpc_defs.ED_OBJECT_DICT_LIST: _ObjectListToDict, |
571 | 577 |
rpc_defs.ED_NODE_TO_DISK_DICT: _EncodeNodeToDiskDict, |
572 |
rpc_defs.ED_FILE_DETAILS: _PrepareFileUpload, |
|
573 | 578 |
rpc_defs.ED_COMPRESS: _Compress, |
574 | 579 |
rpc_defs.ED_FINALIZE_EXPORT_DISKS: _PrepareFinalizeExportDisks, |
575 | 580 |
rpc_defs.ED_IMPEXP_IO: _EncodeImportExportIO, |
... | ... | |
597 | 602 |
|
598 | 603 |
encoders = _ENCODERS.copy() |
599 | 604 |
|
600 |
# Add encoders requiring configuration object |
|
601 | 605 |
encoders.update({ |
606 |
# Encoders requiring configuration object |
|
602 | 607 |
rpc_defs.ED_INST_DICT: self._InstDict, |
603 | 608 |
rpc_defs.ED_INST_DICT_HVP_BEP: self._InstDictHvpBep, |
604 | 609 |
rpc_defs.ED_INST_DICT_OSP: self._InstDictOsp, |
610 |
|
|
611 |
# Encoders with special requirements |
|
612 |
rpc_defs.ED_FILE_DETAILS: compat.partial(_PrepareFileUpload, _getents), |
|
605 | 613 |
}) |
606 | 614 |
|
607 | 615 |
# Resolver using configuration |
Also available in: Unified diff