def _PrepareFileUpload(getents_fn, node, filename): """Loads a file and prepares it for an upload to nodes. """ statcb = utils.FileStatHelper() data = _Compress(node, utils.ReadFile(filename, preread=statcb)) st = statcb.st if getents_fn is None: getents_fn = runtime.GetEnts getents = getents_fn() virt_filename = vcluster.MakeVirtualPath(filename) return [virt_filename, data, st.st_mode, getents.LookupUid(st.st_uid), getents.LookupGid(st.st_gid), st.st_atime, st.st_mtime]
def testNormal(self): self.assertEqual(vcluster.MakeVirtualPath("/tmp/file", _noderoot=None), "/tmp/file")
def testWithNodeRoot(self): path = vcluster.MakeVirtualPath("/tmp/node1.example.com/tmp/file", _noderoot="/tmp/node1.example.com") self.assertEqual(path, "%s/tmp/file" % vcluster._VIRT_PATH_PREFIX)