def __init__(self, cfg=None): if cfg is None: cfg = PaellaConfig('database') if type(cfg) is not dict: dsn = cfg.get_dsn() else: dsn = cfg if os.environ.has_key('PAELLA_DBHOST'): dsn['dbhost'] = os.environ['PAELLA_DBHOST'] if os.environ.has_key('PAELLA_DBNAME'): dsn['dbname'] = os.environ['PAELLA_DBNAME'] if os.environ.has_key('PAELLA_DBPORT'): dsn['dbport'] = int(os.environ['PAELLA_DBPORT']) if dsn['dbport'] not in range(1, 65536): raise ValueError, 'bad database port %s' % dsn['dbport'] user = dsn['dbusername'] host = dsn['dbhost'] dbname = dsn['dbname'] passwd = dsn['dbpassword'] autocommit = 0 if dsn['autocommit'] == 'true': autocommit = 1 if 'dbport' in dsn: port = dsn['dbport'] else: port = 5432 BasicConnection.__init__(self, user=user, host=host, dbname=dbname, passwd=passwd, port=port) self.autocommit = autocommit
def __init__(self, cfg=None): if cfg is None: cfg = PaellaConfig() dsn = cfg.get_dsn() dsn['dbusername'] = '******' PaellaConnection.__init__(self, dsn) print 'installer connection made'
def __init__(self, name='Manager'): CommandBoxWindow.__init__(self) self.cfg = PaellaConfig('database') self.dialogs = {}.fromkeys(['dbname', 'suitemanager']) apps = ['profiles', 'families', 'suitemanager', 'traitmanager', 'machines', 'traits', 'tdiff', 'sdiff', 'fdiff', 'default_environment', 'clients', 'browser'] self.workspace = {}.fromkeys(apps) self.add_menu(dbcommands, 'database', self.database_command) self.add_menu(self.workspace.keys(), 'edit', self.edit_command) self.set_size_request(150,200) self.conn = None self.dbname = None self.dblist = ScrollCList() self.vbox.add(self.dblist) conn = PaellaConnection(self.cfg) cursor = StatementCursor(conn, 'quicky') self.dblist.set_rows(cursor.select(table='pg_database')) cursor.close() conn.close() self.tbar.add_button('profiles', 'profile manager', self.run_tbar) self.tbar.add_button('families', 'family manager', self.run_tbar) self.tbar.add_button('machines', 'machine manager', self.run_tbar) self.tbar.add_button('traits', 'trait manager', self.run_tbar) self.tbar.add_button('tdiff', 'template differ', self.run_tbar) self.tbar.add_button('sdiff', 'script differ', self.run_tbar) self.tbar.add_button('fdiff', 'family differ', self.run_tbar)
def __init__(self, cfg=None): if cfg is None: cfg = PaellaConfig() dsn = cfg.get_dsn() dsn["dbusername"] = "******" PaellaConnection.__init__(self, dsn) print "installer connection made"
def __init__(self, conn): self.cfg = PaellaConfig() self.conn = conn default_path = path(self.cfg.get('database', 'default_path')).expand() self.import_dir = default_path self.export_dir = default_path self.exporter = PaellaExporter(self.conn) self.importer = PaellaImporter(self.conn)
def __init__(self, cfg=None): if cfg is None: cfg = PaellaConfig() dsn = cfg.get_dsn() # enforce user to be paella dsn['dbusername'] = '******' PaellaConnection.__init__(self, dsn) print 'installer connection made'
def __init__(self, cfg=None): if cfg is None: cfg = PaellaConfig('database') if type(cfg) is not dict: dsn = cfg.get_dsn() else: dsn = cfg if os.environ.has_key('PAELLA_DBHOST'): dsn['dbhost'] = os.environ['PAELLA_DBHOST'] if os.environ.has_key('PAELLA_DBNAME'): dsn['dbname'] = os.environ['PAELLA_DBNAME'] QuickConn.__init__(self, dsn)
def __init__(self, dsn=None, cfg=None): if dsn is None: dsn = PaellaConfig('database').get_dsn() if cfg is not None: deprecated('cfg parameter to PaellaConnection is deprecated') dsn = None if type(cfg) is PaellaConfig: dsn = cfg.get_dsn() if dsn is None: raise RuntimeError, 'Problem with the arguements to PaellaConnection' if os.environ.has_key('PAELLA_DBHOST'): dsn['dbhost'] = os.environ['PAELLA_DBHOST'] if os.environ.has_key('PAELLA_DBNAME'): dsn['dbname'] = os.environ['PAELLA_DBNAME'] if os.environ.has_key('PAELLA_DBPORT'): dsn['dbport'] = int(os.environ['PAELLA_DBPORT']) if dsn['dbport'] not in range(1, 65536): raise ValueError, 'bad database port %s' % dsn['dbport'] user = dsn['dbusername'] host = dsn['dbhost'] dbname = dsn['dbname'] passwd = dsn['dbpassword'] if 'dbport' in dsn: port = dsn['dbport'] else: port = 5432 BasicConnection.__init__(self, user=user, host=host, dbname=dbname, passwd=passwd, port=port) self.autocommit = 1 self.__dict__['suitecursor'] = SuiteCursor(self)
def __init__(self, conn=None, cfg=None): self.conn = conn UmlChroot.__init__(self, cfg=cfg) self.options['paella_action'] = 'install' paellarc = path(self.cfg['paellarc']).expand() self.paellarc = PaellaConfig(files=[paellarc]) self.options['paellarc'] = paellarc
class DatabaseManager(object): """This class is used to import/export the paella database """ def __init__(self, conn): self.cfg = PaellaConfig() self.conn = conn default_path = path(self.cfg.get("database", "default_path")).expand() self.import_dir = default_path self.export_dir = default_path # self.importer = PaellaProcessor(self.conn, self.cfg) # self.exporter = PaellaDatabase(self.conn, '/') self.exporter = PaellaExporter(self.conn) self.importer = PaellaImporter(self.conn) def export_all(self, path): self.exporter.perform_full_export(path) def import_all(self, dirname): self.importer.perform_full_import(dirname) def restore(self, path): if not os.path.isdir(path): raise Error, "argument needs to be a directory" dbpath = os.path.join(path, "database.xml") mdbpath = os.path.join(path, "machine_database.xml") pp = PaellaProcessor(self.conn, self.cfg) pp.create(dbpath)
def __init__(self): object.__init__(self) self.cfg = PaellaConfig() self.conn = InstallerConnection() self.profile = os.environ['PAELLA_PROFILE'] self.target = os.environ['PAELLA_TARGET'] self.machine = None self.trait = None self.suite = get_suite(self.conn, self.profile) self.pr = Profile(self.conn) self.pr.set_profile(self.profile) self.traitlist = self.pr.make_traitlist() self.pe = ProfileEnvironment(self.conn, self.profile) self.tp = TraitParent(self.conn, self.suite) self.fm = Family(self.conn) self.tr = Trait(self.conn, self.suite) self.families = list( self.fm.get_related_families(self.pr.get_families())) self._envv = None self.default = DefaultEnvironment(self.conn) #self.installer = TraitInstaller(self.conn, self.suite) self.installer = ProfileInstaller(self.conn) self.installer.set_logfile() self.installer.set_profile(self.profile) self.installer.set_target(self.target) if os.environ.has_key('PAELLA_MACHINE'): self.machine = os.environ['PAELLA_MACHINE'] if os.environ.has_key('PAELLA_TRAIT'): self.set_trait(os.environ['PAELLA_TRAIT'])
class DatabaseManager(object): """This class is used to import/export the paella database """ def __init__(self, conn): self.cfg = PaellaConfig() self.conn = conn default_path = path(self.cfg.get('database', 'default_path')).expand() self.import_dir = default_path self.export_dir = default_path #self.importer = PaellaProcessor(self.conn, self.cfg) #self.exporter = PaellaDatabase(self.conn, '/') self.exporter = PaellaExporter(self.conn) self.importer = PaellaImporter(self.conn) def export_all(self, path): self.exporter.perform_full_export(path) def import_all(self, dirname): self.importer.perform_full_import(dirname) def restore(self, path): if not os.path.isdir(path): raise Error, 'argument needs to be a directory' dbpath = os.path.join(path, 'database.xml') mdbpath = os.path.join(path, 'machine_database.xml') pp = PaellaProcessor(self.conn, self.cfg) pp.create(dbpath)
def __init__(self): object.__init__(self) self.cfg = PaellaConfig() self.conn = InstallerConnection() self.profile = os.environ['PAELLA_PROFILE'] self.target = path(os.environ['PAELLA_TARGET']) self.machine = None self.trait = None self.suite = get_suite(self.conn, self.profile) self.db = ToolkitDatabase(self.conn) self.db.set_profile(self.profile) self.traits = self.db.profile.make_traitlist() profile_families = self.db.profile.get_families() self.families = list( self.db.family.get_related_families(profile_families)) self.default = DefaultEnvironment(self.conn) if os.environ.has_key('PAELLA_MACHINE'): self.machine = os.environ['PAELLA_MACHINE'] self.db.set_machine(self.machine) # we need to make an installer to do # some of the installer functions. self.installer = None if os.environ.has_key('PAELLA_TRAIT'): self.set_trait(os.environ['PAELLA_TRAIT'])
def restore(machine, basefile=None): raise Error, 'need to fix me' cfg = PaellaConfig() umcfg = get_machines_config(machine) conn = InstallerConnection(cfg) ui = UmlInstaller(conn, umcfg) if basefile is None: basefile = join(umcfg['base_path'], umcfg['basefile']) ui.restore_profile(machine, basefile)
def __init__(self, *args): KApplication.__init__(self) self.cfg = PaellaConfig() self.conn = PaellaConnection(self.cfg) self.db = BaseDatabase(self.conn, 'paelladb', None) dirs = KStandardDirs() self.tmpdir = str(dirs.findResourceDir('tmp', '/')) self.datadir = str(dirs.findResourceDir('data', '/')) self.socketdir = str(dirs.findResourceDir('socket', '/')) dsn = {}
def __init__(self, conn): self.cfg = PaellaConfig() self.conn = conn default_path = path(self.cfg.get("database", "default_path")).expand() self.import_dir = default_path self.export_dir = default_path # self.importer = PaellaProcessor(self.conn, self.cfg) # self.exporter = PaellaDatabase(self.conn, '/') self.exporter = PaellaExporter(self.conn) self.importer = PaellaImporter(self.conn)
def make_image(target='/tmp/isotarget', kernel='kernel-image-2.6.2installer'): cfg = PaellaConfig() kpath = '/mirrors/debian/local/questron' setup_directory(target) isolinuxcfg(target) unpack_kernel(kernel, target) os.system( 'mkisofs -V "paella-nfsboot" -r -pad -b isolinux/isolinux.bin -no-emul-boot -boot-load-size 4 -boot-info-table -o nfsboot.iso %s' % target) os.system('rm %s -fr' % target)
def __init__(self, conn, suite, cfg=None, name='SuiteManager'): if cfg is None: cfg = PaellaConfig() CommandBoxWindow.__init__(self, name=name) self.set_title('%s toolbar' % suite) self.cfg = cfg self.conn = conn self.suite = suite self.tbar.add_button('traits', 'trait manager', self.traitgen) self.tbar.add_button('templates', 'template manager', self.templates) self.tbar.add_button('environ', 'environment manager', self.environ) #self.tbar.add_button('debconf', 'debconf manager', self.debconf) self.tbar.add_button('scripts', 'script manager', self.scripts)
def __init__(self): object.__init__(self) self.cfg = PaellaConfig() self.conn = InstallerConnection() self.profile = os.environ['PAELLA_PROFILE'] self.target = path(os.environ['PAELLA_TARGET']) self.machine = None self.trait = None self.suite = get_suite(self.conn, self.profile) # we add this here as a convenience # we need to think about using check_call # instead of call for subprocess (just found # out about it) self.CmdLineError = CmdLineError # another convenience for using # pipes in subprocess calls self.PIPE = subprocess.PIPE self.db = ToolkitDatabase(self.conn) self.db.set_profile(self.profile) self.traits = self.db.profile.make_traitlist() # we need better family attributes # for both profile families and machine families profile_families = self.db.profile.get_families() self.profile_families = list( self.db.family.get_related_families(profile_families)) self.default = DefaultEnvironment(self.conn) # we should really use __getattr__ to raise a # warning when the families attribute is being # accessed so that we can be notified when there # are scripts that use it. self.families = self.profile_families if os.environ.has_key('PAELLA_MACHINE'): self.machine = os.environ['PAELLA_MACHINE'] self.db.set_machine(self.machine) # we need to make an installer to do # some of the installer functions. self.installer = None if os.environ.has_key('PAELLA_TRAIT'): self.set_trait(os.environ['PAELLA_TRAIT'])
class DatabaseManager(object): """This class is used to import/export the paella database """ def __init__(self, conn): self.cfg = PaellaConfig() self.conn = conn default_path = path(self.cfg.get('database', 'default_path')).expand() self.import_dir = default_path self.export_dir = default_path self.exporter = PaellaExporter(self.conn) self.importer = PaellaImporter(self.conn) def export_all(self, dirname): self.exporter.perform_full_export(dirname) def import_all(self, dirname): self.importer.perform_full_import(dirname)
class DatabaseManager(object): def __init__(self, conn): object.__init__(self) self.cfg = PaellaConfig() self.conn = conn self.import_dir = self.cfg.get('database', 'import_path') self.export_dir = self.cfg.get('database', 'export_path') def backup(self, path): if not os.path.isdir(path): raise Error, 'arguement needs to be a directory' pdb = PaellaDatabase(self.conn, path) pdb.backup(path) mh = MachineHandler(self.conn) mh.export_machine_database(path) def restore(self, path): if not os.path.isdir(path): raise Error, 'arguement needs to be a directory' dbpath = join(path, 'database.xml') mdbpath = join(path, 'machine_database.xml') pp = PaellaProcessor(self.conn, self.cfg) pp.create(dbpath)
def parse_package_rows(packages): grouped = {} package_count = 0 for action in actions: grouped[action] = [p.package for p in packages if p.action == action] package_count += len(grouped[action]) if package_count != len(packages): raise Error, 'SOMETHING WENT WRONG in parse_package_rows' return grouped def install_packages_uml(conn, suite, profile, target): traits = get_traits(conn, profile) tp = TraitParent(conn, suite) pp = TraitPackage(conn, suite) packages = ' '.join([p.package for p in pp.all_packages(traits, tp)]) os.system('chroot %s apt-get update' % target) os.system('chroot %s apt-get -y install %s' % (target, packages)) if __name__ == '__main__': from useless.db.midlevel import StatementCursor from useless.db.midlevel import Environment from base import PaellaConnection c = PaellaConnection() cfg = PaellaConfig() p = ProfileInstaller(c, cfg) p.set_profile('bard') pl = p.make_traitlist()
class Manager(CommandBoxWindow): def __init__(self, name='Manager'): CommandBoxWindow.__init__(self) self.cfg = PaellaConfig('database') self.dialogs = {}.fromkeys(['dbname', 'suitemanager']) apps = ['profiles', 'families', 'suitemanager', 'traitmanager', 'machines', 'traits', 'tdiff', 'sdiff', 'fdiff', 'default_environment', 'clients', 'browser'] self.workspace = {}.fromkeys(apps) self.add_menu(dbcommands, 'database', self.database_command) self.add_menu(self.workspace.keys(), 'edit', self.edit_command) self.set_size_request(150,200) self.conn = None self.dbname = None self.dblist = ScrollCList() self.vbox.add(self.dblist) conn = PaellaConnection(self.cfg) cursor = StatementCursor(conn, 'quicky') self.dblist.set_rows(cursor.select(table='pg_database')) cursor.close() conn.close() self.tbar.add_button('profiles', 'profile manager', self.run_tbar) self.tbar.add_button('families', 'family manager', self.run_tbar) self.tbar.add_button('machines', 'machine manager', self.run_tbar) self.tbar.add_button('traits', 'trait manager', self.run_tbar) self.tbar.add_button('tdiff', 'template differ', self.run_tbar) self.tbar.add_button('sdiff', 'script differ', self.run_tbar) self.tbar.add_button('fdiff', 'family differ', self.run_tbar) def edit_command(self, menuitem, name): if self.conn is None: dialogs.Message('Not Connected') else: if name == 'profiles': self.workspace['profiles'] = ProfileGenWin(self.conn, self.dbname) elif name in ['suitemanager']: if not self.dialogs[name]: msg = 'select a suite' self.dialogs[name] = dialogs.CList(msg, name=name) lbox = self.dialogs[name] lbox.set_rows(self.main.select(table='suites')) lbox.set_ok(self.suite_selected) lbox.set_cancel(self.destroy_dialog) else: self.run_tbar(None, name) def run_tbar(self, button=None, data=None): if data == 'profiles': self.workspace[data] = ProfileGenWin(self.conn, self.dbname) elif data == 'machines': self.workspace[data] = MainMachineWin(self.conn) elif data == 'traits': self.workspace[data] = TraitManagerWin(self.conn) elif data == 'families': self.workspace[data] = FamilyWin(self.conn) elif data == 'tdiff': self.workspace[data] = DifferWin(self.conn, 'template') elif data == 'sdiff': self.workspace[data] = DifferWin(self.conn, 'script') elif data == 'fdiff': self.workspace[data] = DifferWin(self.conn, 'family') elif data == 'default_environment': self.workspace[data] = DefEnvEditor(self.conn) elif data == 'clients': self.workspace[data] = ClientManager(self.conn) elif data == 'browser': self.workspace[data] = 'working' print data os.spawnlpe(os.P_NOWAIT, 'paella-kde-management', '--display :0', os.environ) print data, 'running' else: dialogs.Message('bad command %s' % data) def database_command(self, menuitem, name): if name == 'connect': if self.conn is None and not self.dialogs['dbname']: msg = 'connect to which database?' dbname = self.dblist.get_selected_data()[0].datname self.dialogs['dbname'] = dialogs.Entry(msg, name='dbname') entry = self.dialogs['dbname'] entry.set_ok(self.ok_dialog) entry.set_cancel(self.destroy_dialog) entry.set(dbname) else: dialogs.Message('no multiple connections yet') elif name == 'disconnect': if self.conn is not None: self.main.close() self.conn.close() self.conn = None self.dbname = None else: dialogs.Message('no connection to leave') elif name in ['backup', 'restore']: filesel = FileSelection(title='%s database' %name) filesel.cancel_button.connect('clicked', lambda x: filesel.destroy()) filesel.show() bkup_path = self.cfg['import_path'] filesel.set_filename(self._filepath_(bkup_path)) filesel.ok_button.connect('clicked', self.ok_file, filesel) filesel.set_data('action', name) else: dialogs.Message('%s unimplemented'%name) def ok_file(self, button, filesel): path = filesel.get_filename() mdpath = join(dirname(path), 'machine_database.xml') action = filesel.get_data('action') filesel.destroy() dir = dirname(path) dbm = DatabaseManager(self.conn) if action == 'backup': dbm.backup(dir) elif action == 'restore': dbm.restore(dir) def suite_selected(self, button): name = button.get_name() row = self.dialogs[name].get_selected_data()[0] debug(row.suite) self.destroy_dialog(self.dialogs[name]) SuiteManager(self.conn, row.suite) def _filepath_(self, path): return join(path, self.dbname + '.xml') def ok_dialog(self, button): name = button.get_name() if name == 'dbname': dbname = self.dialogs[name].get() self.dbconnect(dbname) self.destroy_dialog(self.dialogs[name]) def dbconnect(self, dbname): self.cfg.change('database') dsn = self.cfg.get_dsn() dsn['dbname'] = dbname self.conn = PaellaConnection(dsn) self.main = StatementCursor(self.conn, 'mainManager') self.dbname = dbname dialogs.Message('connected to database %s' %dbname) def destroy_dialog(self, dying): name = dying.get_name() self.dialogs[name] = None dying.destroy()
def __init__(self, conn): object.__init__(self) self.cfg = PaellaConfig() self.conn = conn self.import_dir = self.cfg.get('database', 'import_path') self.export_dir = self.cfg.get('database', 'export_path')
def __init__(self, conn=None, cfg=None): self.conn = conn UmlChroot.__init__(self, cfg=cfg) self.options['paella_action'] = 'install' paellarc_files = [self.cfg['paellarc']] self.paellarc = PaellaConfig(files=paellarc_files)