def cmd_add(self, args): chunkfile = os.path.abspath(args.chunkfile) if not os.path.exists(chunkfile): raise Exception("Chunkfile %s does not exist" % chunkfile) r = Repo(filename=chunkfile, root=args.directory, name=args.name, key=args.key, config=self.config) r.save_state() self.repos[r.uuid] = r r.start() return {"status": "ok"}
def cmd_create(self, args): r = Repo(type=args.type, root=args.directory, name=args.name, key=args.key, config=self.config) if args.chunkfile: r.save(args.chunkfile, state=False) if args.add: r.save_state() self.repos[r.uuid] = r r.start() return {"status": "ok"}
def testSaveState(self): r = Repo("/tmp/test-repo.chunker", "/tmp/test-repo") r.save_state()
def testSelfHeal(self): r = Repo("/tmp/test-repo.chunker", "/tmp/test-repo") print r.get_known_chunks() print r.get_missing_chunks() self.assertEqual(1, len(r.get_known_chunks())) self.assertEqual(1, len(r.get_missing_chunks())) r.self_heal() self.assertEqual(2, len(r.get_known_chunks())) self.assertEqual(0, len(r.get_missing_chunks()))