def test_archive(self): self.assertEqual([], self.luct_glo.listing()) inst = LucteriosInstance("inst_e", self.path_dir) inst.add() path_usr = join(self.path_dir, 'inst_e', 'usr', 'foo') makedirs(path_usr) with open(join(path_usr, 'myfile'), mode='w+') as myfile: myfile.write('boooo!!') inst.filename = join(self.path_dir, "inst_e.arc") self.assertEqual(True, inst.archive()) import tarfile list_file = [] with tarfile.open(inst.filename, "r:gz") as tar: for tarinfo in tar: list_file.append(tarinfo.name) list_file.sort() self.assertEqual( ['dump.json', 'target', 'usr', 'usr/foo', 'usr/foo/myfile'], list_file) inst = LucteriosInstance("inst_f", self.path_dir) inst.add() inst.filename = join(self.path_dir, "inst_e.arc") self.assertEqual(True, inst.restore()) self.assertEqual(True, isdir(join(self.path_dir, 'inst_f', 'usr'))) self.assertEqual( True, isdir(join(self.path_dir, 'inst_f', 'usr', 'foo'))) self.assertEqual( True, isfile(join(self.path_dir, 'inst_f', 'usr', 'foo', 'myfile')))
def restore_instance(self, instance_name, file_name): self.stop_current_instance(instance_name) rest_inst = LucteriosInstance(instance_name) rest_inst.filename = file_name if rest_inst.restore(): showinfo(ugettext_lazy("Lucterios launcher"), ugettext_lazy("Instance restore from %s") % file_name) else: showerror(ugettext_lazy("Lucterios launcher"), ugettext_lazy("Instance not restored!")) self.refresh(instance_name)
def restore_instance(self, instance_name, file_name): if file_name[-4:] == '.bkf': rest_inst = MigrateFromV1(instance_name, withlog=True) else: rest_inst = LucteriosInstance(instance_name) rest_inst.filename = file_name if rest_inst.restore(): showinfo(ugettext("Lucterios installer"), ugettext( "Instance restore from %s") % file_name) else: showerror( ugettext("Lucterios installer"), ugettext("Instance not restored!")) self.refresh(instance_name)
def test_archive(self): self.assertEqual([], self.luct_glo.listing()) inst = LucteriosInstance("inst_h", self.path_dir) inst.add() inst.filename = join(self.path_dir, "inst_h.arc") self.assertEqual(True, inst.archive()) inst = LucteriosInstance("inst_psql", self.path_dir) inst.set_database( "postgresql:name=" + self.data['dbname'] + ",user=puser,password=123456,host=localhost") inst.add() inst.filename = join(self.path_dir, "inst_h.arc") self.assertEqual(True, inst.restore())
def test_archive(self): self.assertEqual([], self.luct_glo.listing()) inst = LucteriosInstance("inst_g", self.path_dir) inst.add() inst.filename = join(self.path_dir, "inst_g.arc") self.assertEqual(True, inst.archive()) inst = LucteriosInstance("inst_mysql", self.path_dir) inst.set_database( "mysql:name=testv2,user=myuser,password=123456,host=localhost") inst.add() inst.filename = join(self.path_dir, "inst_g.arc") self.assertEqual(True, inst.restore())