def export_machine_database(self, exportdir): element = MachineDatabaseElement(self.conn) exportdir = path(exportdir) makepaths(exportdir) filename = exportdir / 'machine_database.xml' xmlfile = file(filename, 'w') xmlfile.write(element.toprettyxml()) xmlfile.close() machine_dir = exportdir / 'machines' self.export_all_machines(machine_dir)
def export_machine_database(self, path): me = MachineDatabaseElement(self.conn) mdfile = file(join(path, 'machine_database.xml'), 'w') mtypepath = join(path, 'machine_types') mdfile.write(me.toprettyxml()) mdfile.close() for mtype in me.mtypes.machine_types: name = mtype.getAttribute('name') self.mtype.set_machine_type(name) self.mtype.export_machine_type(name, mtypepath)
if __name__ == '__main__': from os.path import join from paella.profile.base import PaellaConfig, PaellaConnection cfg = PaellaConfig() conn = PaellaConnection(cfg) from xmlgen import MachineDatabaseElement from paella.installer.base import CurrentEnvironment ev = CurrentEnvironment(conn, 'bard') xfile = file(join(cfg['import_path'], 'machine_database.xml')) mdata = xfile.read() xfile.close() element = parseString(mdata) me = MachineDatabaseElement(conn) md = MachineDatabaseParser(element.firstChild) mh = MachineHandler(conn) mods = ['via82cxxx', 'ide-generic', 'ide-disk'] def quick_wipe(conn): cursor = StatementCursor(conn) cursor.delete(table='machines') cursor.delete(table='partition_workspace') cursor.delete(table='partitions') cursor.delete(table='filesystem_mounts') cursor.delete(table='filesystem_disks') cursor.delete(table='partition_mounts') cursor.delete(table='machine_disks') cursor.delete(table='machine_types') cursor.delete(table='mounts')