Example #1
0
 def __init__(self,
              conn,
              table,
              section,
              mainfield=None,
              mainvalue=None,
              option='name',
              value='value'):
     self.conn = conn
     self.cursor = StatementCursor(self.conn)
     self.cursor.set_table(table)
     self._secfield = section
     bothnone = mainfield is None and mainvalue is None
     bothset = mainfield and mainvalue
     if not bothnone and not bothset:
         raise Error, 'both mainfield and mainvalue need to be set/unset'
     self._mainclause = None
     if bothset:
         self._mainclause = Eq(mainfield, mainvalue)
     self._fields = [self._secfield, option, value]
     Configuration.__init__(self)
     for row in self.cursor.select(fields=self._fields,
                                   clause=self._mainclause):
         if row[0] not in self.sections():
             self.add_section(row[0])
         self.set(*row)
Example #2
0
 def __init__(self, conn):
     self.conn = conn
     self.cfg = PaellaConfig()
     self.client_path = self.cfg.get('management_gui', 'client_path')
     self.client_cfg = Configuration(
         files=[os.path.join(self.client_path, 'config')])
     self.clients = self.client_cfg.sections()
Example #3
0
 def __init__(self, section=None, files=list_rcfiles('paellarc')):
     if section is None:
         section = 'database'
     Configuration.__init__(self, section=section, files=files)
     if 'PAELLARC' in os.environ:
         paellarc = os.environ['PAELLARC']
         print 'reading paellarc at', paellarc
         self.read([paellarc])
Example #4
0
 def edit(self):
     tmp, path = tempfile.mkstemp('variables', 'config')
     tmp = file(path, 'w')
     self.write(tmp)
     tmp.close()
     os.system('$EDITOR %s' % path)
     tmp = file(path, 'r')
     newconfig = Configuration()
     newconfig.readfp(tmp)
     tmp.close()
     os.remove(path)
     return newconfig
Example #5
0
 def __init__(self, conn, name='ClientManager'):
     CommandBoxWindow.__init__(self)
     self.set_title('Client Manager')
     self.conn = conn
     self.cfg = PaellaConfig()
     client_cmds = ['import', 'export', 'remove']
     self.add_menu(client_cmds, 'client', self.menu_command)
     self.client_view = ScrollCList()
     self.vbox.add(self.client_view)
     self.client_path = self.cfg.get('management_gui', 'client_path')
     self.client_cfg = Configuration(
         files=[os.path.join(self.client_path, 'config')])
     self.clients = self.client_cfg.sections()
     self.client_view.set_rows(self.clients, ['client'])
     self.dialogs = {}.fromkeys(client_cmds)
Example #6
0
 def edit(self):
     tmp, path = tempfile.mkstemp('variables', 'config')
     tmp = file(path, 'w')
     self.write(tmp)
     tmp.close()
     os.system('$EDITOR %s' % path)
     tmp = file(path, 'r')
     newconfig = Configuration()
     newconfig.readfp(tmp)
     tmp.close()
     os.remove(path)
     backupfile = '%s~' % path
     if os.path.exists(backupfile):
         os.remove(backupfile)
     return newconfig
Example #7
0
 def edit(self):
     tmp, path = tempfile.mkstemp('variables', 'config')
     tmp = file(path, 'w')
     self.write(tmp)
     tmp.close()
     os.system('$EDITOR %s' % path)
     tmp = file(path, 'r')
     newconfig = Configuration()
     newconfig.readfp(tmp)
     tmp.close()
     #os.remove(path)
     #backupfile = '%s~' % path
     #if os.path.exists(backupfile):
     #    os.remove(backupfile)
     remove_tmpfile(path)
     return newconfig
Example #8
0
 def __init__(self, conn, table, section,
              mainfield=None, mainvalue=None,
              option='name', value='value'):
     self.conn = conn
     self.cursor = StatementCursor(self.conn)
     self.cursor.set_table(table)
     self._secfield = section
     bothnone = mainfield is None and mainvalue is None
     bothset = mainfield and mainvalue
     if not bothnone and not bothset:
         raise Error, 'both mainfield and mainvalue need to be set/unset'
     self._mainclause = None
     if bothset:
         self._mainclause = Eq(mainfield, mainvalue)
     self._fields = [self._secfield, option, value]
     Configuration.__init__(self)
     for row in self.cursor.select(fields=self._fields, clause=self._mainclause):
         if row[0] not in self.sections():
             self.add_section(row[0])
         self.set(*row)
Example #9
0
 def __init__(self, conn, name='ClientManager'):
     CommandBoxWindow.__init__(self)
     self.set_title('Client Manager')
     self.conn = conn
     self.cfg = PaellaConfig()
     client_cmds = ['import', 'export', 'remove']
     self.add_menu(client_cmds, 'client', self.menu_command)
     self.client_view = ScrollCList()
     self.vbox.add(self.client_view)
     self.client_path = self.cfg.get('management_gui', 'client_path')
     self.client_cfg = Configuration(files=[os.path.join(self.client_path, 'config')])
     self.clients = self.client_cfg.sections()
     self.client_view.set_rows(self.clients, ['client'])
     self.dialogs = {}.fromkeys(client_cmds)
Example #10
0
 def __init__(self, conn, suite, trait, tmp_path, name='ConfigGen'):
     MenuWindow.__init__(self)
     self.__original_text__ = ''
     self.editor = TemplateEnvironment(conn)
     self.editor.set_suite(suite)
     self.editor.set_trait(trait)
     self.vbox.add(self.editor)
     self.conn = conn
     self.__add_menus__()
     self.filename = ''
     self.filesel = None
     self.set_size_request(600, 500)
     self.cfg = Configuration()
     self.cfg.section = 'paella-admin'
     self.conf_path = self.cfg['config_path']
     self.template_path = pjoin(self.cfg['template_path'], suite, trait)
     self.tmp_path = tmp_path
     makepaths(self.template_path)
     self.dialogs = {}.fromkeys(['template_record', 'environment'])
Example #11
0
class ClientManager(CommandBoxWindow):
    def __init__(self, conn, name='ClientManager'):
        CommandBoxWindow.__init__(self)
        self.set_title('Client Manager')
        self.conn = conn
        self.cfg = PaellaConfig()
        client_cmds = ['import', 'export', 'remove']
        self.add_menu(client_cmds, 'client', self.menu_command)
        self.client_view = ScrollCList()
        self.vbox.add(self.client_view)
        self.client_path = self.cfg.get('management_gui', 'client_path')
        self.client_cfg = Configuration(files=[os.path.join(self.client_path, 'config')])
        self.clients = self.client_cfg.sections()
        self.client_view.set_rows(self.clients, ['client'])
        self.dialogs = {}.fromkeys(client_cmds)
        
    def menu_command(self, menuitem, name):
        client = self.client_view.get_selected_data()[0][0]
        if name == 'export':
            self.export_client(client)
        elif name == 'import':
            self.import_client(client)
        elif name == 'remove':
            self.remove_client(client)
        else:
            dialogs.Message('%s %s' % (name, client))
            
    def _cpaths_(self, client):
        cpath = os.path.join(self.client_path, client)
        ppath = os.path.join(cpath, 'profiles')
        fpath = os.path.join(cpath, 'families')
        tpath = os.path.join(cpath, 'traits')
        return [cpath, ppath, fpath, tpath]

    def _client_schema(self, client):
        profiles = self.client_cfg.get_list('profiles', client)
        families = self.client_cfg.get_list('families', client)
        traits = self.client_cfg.get_list('traits', client)
        return [profiles, families, traits]
    
    def _client_mdata(self, client):
        disks = self.client_cfg.get_list('disks', client)
        mtypes = self.client_cfg.get_list('machine_types', client)
        machines = self.client_cfg.get_list('machines', client)
        return [disks, mtypes, machines]
    
    def export_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        makepaths(cpath)
        profiles, families, traits = self._client_schema(client) 
        disks, mtypes, machines = self._client_mdata(client)
        if not disks:
            disks = None
        if not mtypes:
            mtypes = None
        if not machines:
            machines = None
        element = ClientMachineDatabaseElement(self.conn, disks, mtypes, machines)
        mdbpath = join(cpath, 'machine_database.xml')
        mdfile = file(mdbpath, 'w')
        mdfile.write(element.toprettyxml())
        mdfile.close()
        if profiles:
            makepaths(ppath)
            pp = PaellaProfiles(self.conn)
            for profile in profiles:
                pp.write_profile(profile, ppath)
        if families:
            makepaths(fpath)
            f = Family(self.conn)
            for family in families:
                f.write_family(family, fpath)
        if traits:
            makepaths(tpath)

    def import_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        profiles, families, traits = self._client_schema(client)
        mdbpath = join(cpath, 'machine_database.xml')
        if families:
            f = Family(self.conn)
            f.import_families(fpath)
        if profiles:
            pp = PaellaProcessor(self.conn, self.cfg)
            pp.main_path = cpath
            pp.insert_profiles()
        mh = MachineHandler(self.conn)
        md = mh.parse_xmlfile(mdbpath)
        mh.insert_parsed_element(md)    
        
            
    def remove_client(self, client):
        profiles, families, traits = self._client_schema(client)
        disks, mtypes, machines = self._client_mdata(client)
        cursor = StatementCursor(self.conn)
        if machines:
            cursor.delete(table='machines', clause=In('machine', machines))
        for mtype in mtypes:
            cursor.execute("select * from delete_mtype('%s')" % mtype)
        for disk in disks:
            cursor.execute("select * from delete_disk('%s')" % disk)
        for profile in profiles:
            cursor.execute("select * from delete_profile('%s')" % profile)
        for family in families:
            cursor.execute("select * from delete_family('%s')" % family)
Example #12
0
 def __init__(self,
              section='umlmachines',
              files=list_rcfiles('umlmachines.conf')):
     if section is None:
         section = 'database'
     Configuration.__init__(self, section=section, files=files)
Example #13
0
        fltable = FilelistTable(self._table('files'))
        mk_filelist_table(self.cmd, fltable, config.get_files())
        print 'making conffiles'
        cftable = FilelistTable(self._table('conffiles'))
        mk_filelist_table(self.cmd, cftable, config.get_conffiles())
        print 'making md5sums'
        mdtable = Md5sumsTable(self._table('md5sums'))
        mk_md5sums_table(self.cmd, mdtable, config.get_md5sums())
        print 'making current'
        cutable = Md5sumsTable(self._table('current'))
        mk_current_table(self.cmd, cutable, config.get_files())


if __name__ == '__main__':
    from useless.base.config import Configuration
    cfg = Configuration()
    Host = cfg['dbhost']
    Dbname = 'sysconfig'
    User = cfg['dbusername']
    Password = cfg['dbpassword']
    dsn = dict(dbhost=cfg['dbhost'],
               dbname='sysconfig',
               dbusername=cfg['dbusername'],
               dbpassword=cfg['dbpassword'])
    c = QuickConn(dsn)
    cmd = CommandCursor(c, 'dsfsdf')
    #cmd.execute('create table %s' %t)
    co = ConfigObject()

    #co.set_every_config()
    #at = Table('atable', available_columns)
Example #14
0
class ClientManager(object):
    def __init__(self, conn):
        self.conn = conn
        self.cfg = PaellaConfig()
        self.client_path = self.cfg.get('management_gui', 'client_path')
        self.client_cfg = Configuration(files=[os.path.join(self.client_path, 'config')])
        self.clients = self.client_cfg.sections()

    def _cpaths_(self, client):
        cpath = os.path.join(self.client_path, client)
        ppath = os.path.join(cpath, 'profiles')
        fpath = os.path.join(cpath, 'families')
        tpath = os.path.join(cpath, 'traits')
        return [cpath, ppath, fpath, tpath]

    def _client_schema(self, client):
        profiles = self.client_cfg.get_list('profiles', client)
        families = self.client_cfg.get_list('families', client)
        traits = self.client_cfg.get_list('traits', client)
        return [profiles, families, traits]
    
    def _client_mdata(self, client):
        machines = self.client_cfg.get_list('machines', client)
        return machines
        
    def export_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        makepaths(cpath)
        profiles, families, traits = self._client_schema(client) 
        machines = self._client_mdata(client)
        if not machines:
            machines = None
        element = ClientMachineDatabaseElement(self.conn, machines)
        mdbpath = join(cpath, 'machine_database.xml')
        mdfile = file(mdbpath, 'w')
        mdfile.write(element.toprettyxml())
        mdfile.close()
        if profiles:
            makepaths(ppath)
            pp = PaellaProfiles(self.conn)
            for profile in profiles:
                pp.write_profile(profile, ppath)
        if families:
            makepaths(fpath)
            f = Family(self.conn)
            for family in families:
                f.write_family(family, fpath)
        if traits:
            makepaths(tpath)

    def import_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        profiles, families, traits = self._client_schema(client)
        mdbpath = join(cpath, 'machine_database.xml')
        if families:
            f = Family(self.conn)
            f.import_families(fpath)
        if profiles:
            importer = PaellaImporter(self.conn)
            importer.import_all_profiles(ppath)
        mh = MachineHandler(self.conn)
        md = mh.parse_xmlfile(mdbpath)
        mh.insert_parsed_element(md)    
        
            
    def remove_client(self, client):
        profiles, families, traits = self._client_schema(client)
        machines = self._client_mdata(client)
        cursor = StatementCursor(self.conn)
        for machine in machines:
            cursor.execute("select * from delete_machine('%s')" % machine)
        for profile in profiles:
            cursor.execute("select * from delete_profile('%s')" % profile)
        for family in families:
            cursor.execute("select * from delete_family('%s')" % family)
Example #15
0
 def __init__(self, section=None, files=list_rcfiles('paellarc')):
     if section is None:
         section = 'database'
     Configuration.__init__(self, section=section, files=files)
Example #16
0
 def __init__(self, section='umlmachines',
              files=list_rcfiles('umlmachines.conf')):
     if section is None:
         section = 'database'
     Configuration.__init__(self, section=section, files=files)
Example #17
0
 def __init__(self, conn):
     self.conn = conn
     self.cfg = PaellaConfig()
     self.client_path = self.cfg.get('management_gui', 'client_path')
     self.client_cfg = Configuration(files=[os.path.join(self.client_path, 'config')])
     self.clients = self.client_cfg.sections()
Example #18
0
 def get_dsn(self):
     return Configuration.get_dsn(self, fields=['dbname', 'dbhost', 'dbusername', 'dbpassword'])
Example #19
0
 def __init__(self, section=None, files=list_rcfiles("paellarc")):
     if section is None:
         section = "database"
     Configuration.__init__(self, section=section, files=files)
Example #20
0
class ClientManager(CommandBoxWindow):
    def __init__(self, conn, name='ClientManager'):
        CommandBoxWindow.__init__(self)
        self.set_title('Client Manager')
        self.conn = conn
        self.cfg = PaellaConfig()
        client_cmds = ['import', 'export', 'remove']
        self.add_menu(client_cmds, 'client', self.menu_command)
        self.client_view = ScrollCList()
        self.vbox.add(self.client_view)
        self.client_path = self.cfg.get('management_gui', 'client_path')
        self.client_cfg = Configuration(
            files=[os.path.join(self.client_path, 'config')])
        self.clients = self.client_cfg.sections()
        self.client_view.set_rows(self.clients, ['client'])
        self.dialogs = {}.fromkeys(client_cmds)

    def menu_command(self, menuitem, name):
        client = self.client_view.get_selected_data()[0][0]
        if name == 'export':
            self.export_client(client)
        elif name == 'import':
            self.import_client(client)
        elif name == 'remove':
            self.remove_client(client)
        else:
            dialogs.Message('%s %s' % (name, client))

    def _cpaths_(self, client):
        cpath = os.path.join(self.client_path, client)
        ppath = os.path.join(cpath, 'profiles')
        fpath = os.path.join(cpath, 'families')
        tpath = os.path.join(cpath, 'traits')
        return [cpath, ppath, fpath, tpath]

    def _client_schema(self, client):
        profiles = self.client_cfg.get_list('profiles', client)
        families = self.client_cfg.get_list('families', client)
        traits = self.client_cfg.get_list('traits', client)
        return [profiles, families, traits]

    def _client_mdata(self, client):
        disks = self.client_cfg.get_list('disks', client)
        mtypes = self.client_cfg.get_list('machine_types', client)
        machines = self.client_cfg.get_list('machines', client)
        return [disks, mtypes, machines]

    def export_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        makepaths(cpath)
        profiles, families, traits = self._client_schema(client)
        disks, mtypes, machines = self._client_mdata(client)
        if not disks:
            disks = None
        if not mtypes:
            mtypes = None
        if not machines:
            machines = None
        element = ClientMachineDatabaseElement(self.conn, disks, mtypes,
                                               machines)
        mdbpath = join(cpath, 'machine_database.xml')
        mdfile = file(mdbpath, 'w')
        mdfile.write(element.toprettyxml())
        mdfile.close()
        if profiles:
            makepaths(ppath)
            pp = PaellaProfiles(self.conn)
            for profile in profiles:
                pp.write_profile(profile, ppath)
        if families:
            makepaths(fpath)
            f = Family(self.conn)
            for family in families:
                f.write_family(family, fpath)
        if traits:
            makepaths(tpath)

    def import_client(self, client):
        cpath, ppath, fpath, tpath = self._cpaths_(client)
        profiles, families, traits = self._client_schema(client)
        mdbpath = join(cpath, 'machine_database.xml')
        if families:
            f = Family(self.conn)
            f.import_families(fpath)
        if profiles:
            pp = PaellaProcessor(self.conn, self.cfg)
            pp.main_path = cpath
            pp.insert_profiles()
        mh = MachineHandler(self.conn)
        md = mh.parse_xmlfile(mdbpath)
        mh.insert_parsed_element(md)

    def remove_client(self, client):
        profiles, families, traits = self._client_schema(client)
        disks, mtypes, machines = self._client_mdata(client)
        cursor = StatementCursor(self.conn)
        if machines:
            cursor.delete(table='machines', clause=In('machine', machines))
        for mtype in mtypes:
            cursor.execute("select * from delete_mtype('%s')" % mtype)
        for disk in disks:
            cursor.execute("select * from delete_disk('%s')" % disk)
        for profile in profiles:
            cursor.execute("select * from delete_profile('%s')" % profile)
        for family in families:
            cursor.execute("select * from delete_family('%s')" % family)
Example #21
0
import os, sys
from os.path import join, isfile, isdir
from time import sleep
import commands

from useless.base import Error
from useless.base.config import Configuration

config = Configuration(files=['./kernels.conf'])
here = os.getcwd()


def get_all_kernels():
    return config.get_list('allkernels', 'DEFAULT')


def get_version(dir=here):
    changelog = join(dir, 'debian/changelog')
    pipeline = "head -n1 %s | gawk '{print $2}' " % changelog
    pipeline += " | cut -f2 -d\( | cut -f1 -d\)"
    command = 'bash -c "%s"' % pipeline
    return commands.getoutput(command)


def commalist(a_list):
    return ','.join(a_list)


def kernel_name(flavor):
    config.change(flavor)
    kver = config['kver']
Example #22
0
 def __init__(self, section=None, files=list_rcfiles('paellarc')):
     if section is None:
         section = 'database'
     Configuration.__init__(self, section=section, files=files)
Example #23
0
    umcfg = get_machines_config(machine)
    u = UmlRunner(umcfg)
    u.set(machine)
    u.run(oldway=False)
    u.command('apt-get -y update')
    u.command('apt-get build-depends %s' % package)
    u.command('apt-get source %s' % package)
    u.uml.shutdown()


def extract(tarball, basefile=None, size=None):
    cfg = UmlConfig()
    u = UmlChroot(cfg)
    u.options['paella_system_tarball'] = tarball
    u.options['paella_action'] = 'extract'
    u.options['devfs'] = 'mount'
    u.set_targetimage(basefile)
    if size is None:
        size = cfg['basefile_size']
    create_sparse_file(basefile, size=size)
    u.run_uml()


if __name__ == '__main__':
    umcfg = Configuration(
        files=Configuration('umlmachines')['uml_machines_conf'])
    u = UmlRunner(umcfg)
    import sys
    if len(sys.argv) > 1:
        run(sys.argv[1])
Example #24
0
        dict(
            zip(cols, [
                'base', 'light sea green', 'lavender', 'azure3', 'yellow',
                'aquamarine'
            ])))
    q4 = insert(
        'themebase',
        dict(
            zip(cols,
                ['text', 'wheat', 'black', 'black', 'black', 'dark violet'])))
    map(cmd.execute, [q1, q2, q3, q4])


if __name__ == '__main__':
    from useless.base.config import Configuration
    dsn = Configuration().get_dsn()
    dsn['dbname'] = 'themes'
    c = QuickConn(dsn)
    win = ColorThingyWindow(cd, c)
    t = NameTable('themes', ['theme'])

    cmd = CommandCursor(c, 'dsfsdf')

    def dtable():
        cmd.execute('drop table themebase')

    def dtables():
        for t in cmd.tables():
            if t not in ['footable']:
                cmd.execute('drop table %s' % t)