Example #1
0
    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"}
Example #2
0
 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"}
Example #3
0
 def testSaveState(self):
     r = Repo("/tmp/test-repo.chunker", "/tmp/test-repo")
     r.save_state()
Example #4
0
 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()))