Exemplo n.º 1
0
 def get_all_defaults(self):
     suite_cursor = SuiteCursor(self.conn)
     suites = suite_cursor.get_suites()
     stmt = select_multisuite_union(suites, 'variables')
     print stmt
     self.cursor.execute(stmt)
     return self.cursor.fetchall()
Exemplo n.º 2
0
class SuiteManagerDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.cursor = SuiteCursor(self.conn)

    def set_suite(self, suite):
        self.suite = suite
        self.cursor.set_suite(suite)
        self.clear_body()
        attributes = dict(bgcolor='IndianRed', width='100%')
        title = SimpleTitleElement('Suite:  %s' % suite, **attributes)
        title.cell.attributes['align'] = 'center'
        self.body.append(title)
        apt_rows = self.cursor.get_apt_rows()
        if len(apt_rows):
            aptsrc_table = Table(bgcolor='khaki')
            self.body.append(aptsrc_table)
            fields = ['apt_id', 'uri', 'dist', 'sections', 'local_path']
            headrow = TableRow()
            for field in fields:
                headrow.append(TableCell(Bold(field)))
            for row in apt_rows:
                tblrow = TableRow()
                aptsrc_table.append(tblrow)
                for field in fields:
                    tblrow.append(TableCell(row[field]))
Exemplo n.º 3
0
 def get_all_defaults(self):
     suite_cursor = SuiteCursor(self.conn)
     suites = suite_cursor.get_suites()
     stmt = select_multisuite_union(suites, 'variables')
     print stmt
     self.cursor.execute(stmt)
     return self.cursor.fetchall()
Exemplo n.º 4
0
class SuiteManagerDoc(BaseDocument):
    def __init__(self, app, **atts):
        BaseDocument.__init__(self, app, **atts)
        self.cursor = SuiteCursor(self.conn)
        
        

    def set_suite(self, suite):
        self.suite = suite
        self.cursor.set_suite(suite)
        self.clear_body()
        attributes = dict(bgcolor='IndianRed', width='100%')
        title = SimpleTitleElement('Suite:  %s' % suite, **attributes)
        title.cell.attributes['align'] = 'center'
        self.body.append(title)
        apt_rows = self.cursor.get_apt_rows()
        if len(apt_rows):
            aptsrc_table = Table(bgcolor='khaki')
            self.body.append(aptsrc_table)
            fields = ['apt_id', 'uri', 'dist', 'sections', 'local_path']
            headrow = TableRow()
            for field in fields:
                headrow.append(TableCell(Bold(field)))
            for row in apt_rows:
                tblrow = TableRow()
                aptsrc_table.append(tblrow)
                for field in fields:
                    tblrow.append(TableCell(row[field]))
Exemplo n.º 5
0
 def __init__(self, parent, name='SuiteManagerWindow'):
     BaseSplitWindow.__init__(self, parent, SuiteManagerView, name=name)
     self.initPaellaCommon()
     self.suitecursor = SuiteCursor(self.conn)
     self.refreshListView()
     self.initActions()
     self.initMenus()
     self.initToolbar()
     self.resize(800, 300)
     self.splitter.setSizes([100, 700])
Exemplo n.º 6
0
 def __init__(self, parent, suite, name='SuiteAptAssigner'):
     self.suite = suite
     self.initPaellaCommon()
     self.suitecursor = SuiteCursor(self.conn)
     BaseAssigner.__init__(self, parent, name=name,
                           udbuttons=True)
     self.connect(self, SIGNAL('okClicked()'), self.slotAssignAptSrcs)
Exemplo n.º 7
0
class SuiteManagerWindow(BaseSplitWindow, BasePaellaWindow):
    def __init__(self, parent, name='SuiteManagerWindow'):
        BaseSplitWindow.__init__(self, parent, SuiteManagerView, name=name)
        self.initPaellaCommon()
        self.suitecursor = SuiteCursor(self.conn)
        self.refreshListView()
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.resize(800, 300)
        self.splitter.setSizes([100, 700])

    def initActions(self):
        collection = self.actionCollection()
        self.newAction = KStdAction.openNew(self.slotNew, collection)
        self.quitAction = KStdAction.quit(self.close, collection)

    def initMenus(self):
        pass

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newAction.plug(toolbar)
        self.quitAction.plug(toolbar)
        

    def initlistView(self):
        self.listView.addColumn('suite')

    def refreshListView(self):
        self.listView.clear()
        for suite in self.suitecursor.get_suites():
            item = KListViewItem(self.listView, suite)
            item.suite = suite
            
        
    def selectionChanged(self):
        item = self.listView.currentItem()
        self.mainView.set_suite(item.suite)

    def slotNew(self):
        win = BaseRecordDialog(self, ['name'])
        win.connect(win, SIGNAL('okClicked()'), self.slotNewSuiteNamed)
        self._dialog = win
        win.show()
        
    def slotNewSuiteNamed(self):
        win = self._dialog
        suite = win.getRecordData()['name']
        suite = suite.strip()
        if not suite:
            raise RuntimeError, 'no suite in slotNewSuiteNamed'
        win = SuiteAptAssigner(self, suite)
        win.show()
    
    def _destroy_dialog(self):
        self._dialog = None

    def _connect_dialog_destroy(self, dialog):
        pass
Exemplo n.º 8
0
class SuiteManagerWindow(BaseSplitWindow, BasePaellaWindow):
    def __init__(self, parent, name='SuiteManagerWindow'):
        BaseSplitWindow.__init__(self, parent, SuiteManagerView, name=name)
        self.initPaellaCommon()
        self.suitecursor = SuiteCursor(self.conn)
        self.refreshListView()
        self.initActions()
        self.initMenus()
        self.initToolbar()
        self.resize(800, 300)
        self.splitter.setSizes([100, 700])

    def initActions(self):
        collection = self.actionCollection()
        self.newAction = KStdAction.openNew(self.slotNew, collection)
        self.quitAction = KStdAction.quit(self.close, collection)

    def initMenus(self):
        pass

    def initToolbar(self):
        toolbar = self.toolBar()
        self.newAction.plug(toolbar)
        self.quitAction.plug(toolbar)

    def initlistView(self):
        self.listView.addColumn('suite')

    def refreshListView(self):
        self.listView.clear()
        for suite in self.suitecursor.get_suites():
            item = KListViewItem(self.listView, suite)
            item.suite = suite

    def selectionChanged(self):
        item = self.listView.currentItem()
        self.mainView.set_suite(item.suite)

    def slotNew(self):
        win = BaseRecordDialog(self, ['name'])
        win.connect(win, SIGNAL('okClicked()'), self.slotNewSuiteNamed)
        self._dialog = win
        win.show()

    def slotNewSuiteNamed(self):
        win = self._dialog
        suite = win.getRecordData()['name']
        suite = suite.strip()
        if not suite:
            raise RuntimeError, 'no suite in slotNewSuiteNamed'
        win = SuiteAptAssigner(self, suite)
        win.show()

    def _destroy_dialog(self):
        self._dialog = None

    def _connect_dialog_destroy(self, dialog):
        pass
Exemplo n.º 9
0
def make_sources_list_common(conn, target, suite, installer=False):
    defenv = DefaultEnvironment(conn)
    suitecursor = SuiteCursor(conn)
    apt_rows = suitecursor.get_apt_rows(suite)
    if installer:
        # while installing use sources from local mirror
        uri = defenv.get('installer', 'http_mirror')
    else:
        # otherwise use official sources list
        uri = None
    apt_lines = make_sources_list_lines(apt_rows, uri=uri, installer=installer)
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    for line in apt_lines:
        sources_list.write('%s\n' % line)
    sources_list.write('\n')
    sources_list.close()
Exemplo n.º 10
0
def make_sources_list_common(conn, target, suite, installer=False):
    defenv = DefaultEnvironment(conn)
    suitecursor = SuiteCursor(conn)
    apt_rows = suitecursor.get_apt_rows(suite)
    if installer:
        # while installing use sources from local mirror
        uri = defenv.get('installer', 'http_mirror')
    else:
        # otherwise use official sources list
        uri = None
    apt_lines = make_sources_list_lines(apt_rows, uri=uri, installer=installer)
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    for line in apt_lines:
        sources_list.write('%s\n' % line)
    sources_list.write('\n')
    sources_list.close()
Exemplo n.º 11
0
 def __init__(self, parent, name='SuiteManagerWindow'):
     BaseSplitWindow.__init__(self, parent, SuiteManagerView, name=name)
     self.initPaellaCommon()
     self.suitecursor = SuiteCursor(self.conn)
     self.refreshListView()
     self.initActions()
     self.initMenus()
     self.initToolbar()
     self.resize(800, 300)
     self.splitter.setSizes([100, 700])
Exemplo n.º 12
0
class SuiteAptAssigner(BaseAssigner, BasePaellaWidget):
    def __init__(self, parent, suite, name='SuiteAptAssigner'):
        self.suite = suite
        self.initPaellaCommon()
        self.suitecursor = SuiteCursor(self.conn)
        BaseAssigner.__init__(self, parent, name=name, udbuttons=True)
        self.connect(self, SIGNAL('okClicked()'), self.slotAssignAptSrcs)

    def initView(self):
        abox = self.listBox.availableListBox()
        apt_ids = [r.apt_id for r in self.suitecursor.get_apt_sources()]
        for apt_id in apt_ids:
            QListBoxText(abox, apt_id)

    def slotAssignAptSrcs(self):
        sbox = self.listBox.selectedListBox()
        apt_ids = [str(sbox.item(n).text()) for n in range(sbox.numRows())]

        suite = self.suite
        self.suitecursor.make_suite(suite, apt_ids)
Exemplo n.º 13
0
class SuiteAptAssigner(BaseAssigner, BasePaellaWidget):
    def __init__(self, parent, suite, name='SuiteAptAssigner'):
        self.suite = suite
        self.initPaellaCommon()
        self.suitecursor = SuiteCursor(self.conn)
        BaseAssigner.__init__(self, parent, name=name,
                              udbuttons=True)
        self.connect(self, SIGNAL('okClicked()'), self.slotAssignAptSrcs)
        

    def initView(self):
        abox = self.listBox.availableListBox()
        apt_ids = [r.apt_id for r in self.suitecursor.get_apt_sources()]
        for apt_id in apt_ids:
            QListBoxText(abox, apt_id)
            
        
        
    def slotAssignAptSrcs(self):
        sbox = self.listBox.selectedListBox()
        apt_ids = [str(sbox.item(n).text()) for n in range(sbox.numRows())]
        
        suite = self.suite
        self.suitecursor.make_suite(suite, apt_ids)
Exemplo n.º 14
0
 def set_suite(self, suite):
     self.installer = ProfileInstaller(self.conn)
     self._suite = suite
     self.suitecursor = SuiteCursor(self.conn)
Exemplo n.º 15
0
class BaseChrootInstaller(Installer):
    def __init__(self, conn, installer=None):
        Installer.__init__(self, conn)
        self._bootstrapped = False
        self.installer = installer
        self.debmirror = self.defenv.get('installer', 'http_mirror')
        self.suitecursor = SuiteCursor(self.conn)
        
        
    def _make_target_dir(self, target):
        makepaths(target)
        
    def _check_target(self):
        if self.target is None:
            raise InstallError, 'no target specified'

    def _check_target_exists(self):
        self._check_target()
        if not isdir(self.target):
            self._make_target_dir(self.target)
        if not isdir(self.target):
            raise InstallError, 'unable to create target directory %s' % self.target
        
    def _check_installer(self):
        if self.installer is None:
            raise InstallError, 'no installer available'

    def _check_bootstrap(self):
        self._check_target_exists()
        if not self._bootstrapped:
            raise InstallError, 'target not bootstrapped'

    def _check_target_proc(self):
        if not self._proc_mounted:
            raise InstallError, 'target /proc not mounted'
        
    def _extract_base_tarball(self, suite):
        self._check_target_exists()
        runlog('echo extracting premade base tarball')
        suite_path = self.defenv.get('installer', 'suite_storage')
        filename = '%s.tar.gz' % suite
        basefile = join(suite_path, filename)
        taropts = '-xzf'
        if not os.path.exists(basefile):
            filename = '%s.tar' % suite
            basefile = join(suite_path, filename)
            taropts = '-xf'
        runvalue = runlog('tar -C %s %s %s' % (self.target, taropts, basefile))
        if runvalue:
            raise InstallError, 'problems extracting %s' % basefile
        else:
            self._bootstrapped = True

    def _bootstrap_target(self):
        self._check_installer()
        suite = self.suitecursor.get_base_suite(self.suite)
        if self.defenv.is_it_true('installer', 'bootstrap_target'):
            mirror = self.debmirror
            self._run_bootstrap(mirror, suite)
        else:
            self._extract_base_tarball(suite)

    def _mount_target_proc(self):
        self._check_bootstrap()
        tproc = join(self.target, 'proc')
        cmd = 'mount --bind /proc %s' % tproc
        runvalue = runlog(cmd)
        if runvalue:
            raise InstallError, 'problem mounting target /proc at %s' % tproc
        else:
            self._proc_mounted = True

    def _umount_target_proc(self):
        self._check_target_proc()
        tproc = join(self.target, 'proc')
        cmd = 'umount %s' % tproc
        runvalue = runlog(cmd)
        if runvalue:
            raise InstallError, 'problem unmounting target /proc at %s' % tproc
        else:
            self._proc_mounted = False
            
    def _run_bootstrap(self, mirror, suite):
        self._check_target_exists()
        runvalue = runlog(debootstrap(suite, self.target, mirror))
        if runvalue:
            print "runvalue returned from bootstrap", runvalue
            raise InstallError, 'bootstrapping %s on %s failed.' % (suite, self.target)
        else:
            self._bootstrapped = True
Exemplo n.º 16
0
 def __init__(self, conn, installer=None):
     Installer.__init__(self, conn)
     self._bootstrapped = False
     self.installer = installer
     self.debmirror = self.defenv.get('installer', 'http_mirror')
     self.suitecursor = SuiteCursor(self.conn)
Exemplo n.º 17
0
 def __init__(self, app, **atts):
     BaseDocument.__init__(self, app, **atts)
     self.cursor = SuiteCursor(self.conn)
Exemplo n.º 18
0
 def __init__(self, parent, name='SuiteComboBox'):
     KComboBox.__init__(self, parent, name)
     self.initPaellaCommon()
     self.suites = SuiteCursor(self.conn)
     self.insertStrList(self.suites.get_suites())
Exemplo n.º 19
0
    if installer:
        # while installing use sources from local mirror
        uri = defenv.get('installer', 'http_mirror')
    else:
        # otherwise use official sources list
        uri = None
    apt_lines = make_sources_list_lines(apt_rows, uri=uri, installer=installer)
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    for line in apt_lines:
        sources_list.write('%s\n' % line)
    sources_list.write('\n')
    sources_list.close()


def make_sources_list(conn, target, suite):
    make_sources_list_common(conn, target, suite, installer=True)


def make_official_sources_list(conn, target, suite):
    make_sources_list_common(conn, target, suite)


if __name__ == '__main__':
    from paella.db import PaellaConnection
    conn = PaellaConnection()
    cursor = SuiteCursor(conn)
    rows = cursor.get_apt_rows('desksarge')
    msll = make_sources_list_lines
Exemplo n.º 20
0
class UmlProfileInstaller(BaseUmlInstaller):
    @guest_mode
    def set_suite(self, suite):
        self.installer = ProfileInstaller(self.conn)
        self._suite = suite
        self.suitecursor = SuiteCursor(self.conn)

    @guest_mode
    def _set_profile_in_guest(self, profile):
        self.set_suite(get_suite(self.conn, profile))
        self.installer.set_profile(profile)
        if hasattr(self, 'target'):
            self.installer.set_target(self.target)

    def set_profile(self, profile):
        if self.mode == 'host':
            self.options['paellaprofile'] = profile
        elif self.mode == 'guest':
            self._set_profile_in_guest(profile)
        else:
            raise ValueError, 'bad mode %s' % self.mode

    @guest_mode
    def set_template_path(self, path=None):
        self.installer.set_template_path(path)

    @host_mode
    def install_profile(self, profile, path):
        self.set_profile(profile)
        self.make_root_device(path)
        self.run_uml(popen=True)

    @host_mode
    def restore_profile(self, name, path):
        self.options['paella_action'] = 'restore'
        self.options['paellaprofile'] = name
        self.options['paellasuite'] = 'none'
        self.make_root_device(path)
        self.run_uml(popen=False)

    @guest_mode
    def extract_base_tarball(self):
        suite = self.suitecursor.get_base_suite(self._suite)
        fstype = self.cfg.get('umlmachines', 'backup_filesystem')
        if fstype == 'hostfs':
            #backup_path = path(self.cfg.get('umlmachines', 'hostfs_backup_path')).expand()
            backup_path = path(self.options['hostfs_backup_path'].value)
        else:
            backup_path = path('/mnt')
        basetarball = backup_path / path('%s.base.tar.gz' % suite)
        if not basetarball.isfile():
            basetarball = backup_path / path('%s.base.tar' % suite)
        if basetarball.isfile():
            extract_tarball(self.target, basetarball)
        else:
            raise RuntimeError, 'No base tarball found for suite %s' % suite

    @guest_mode
    def ready_base_for_install(self):
        cfg = self.installer.defenv
        ready_base_for_install(self.target, self.conn, self._suite)

    @guest_mode
    def perform_install(self, profile=None, backup_filesystem=None):
        machine = os.environ['PAELLA_MACHINE']
        curenv = CurrentEnvironment(self.conn, machine)
        curenv['current_trait'] = 'None'
        curenv['current_trait_process'] = 'None'
        curenv['traitlist'] = ''
        mpkey = 'current_machine_process'
        if backup_filesystem is not None:
            curenv[mpkey] = 'mount_backup'
            self.mount_backup('/mnt', backup_filesystem)
        curenv[mpkey] = 'setup_target'
        self.setup_target()
        curenv[mpkey] = 'set_profile'
        self.set_profile(profile)
        curenv[mpkey] = 'extract_base_tarball'
        self.extract_base_tarball()
        curenv[mpkey] = 'ready_base_for_install'
        self.ready_base_for_install()
        curenv[mpkey] = 'set_template_path'
        self.set_template_path()
        curenv[mpkey] = 'process'
        self.process()
Exemplo n.º 21
0
 def set_suite(self, suite):
     self.installer = ProfileInstaller(self.conn)
     self._suite = suite
     self.suitecursor = SuiteCursor(self.conn)
Exemplo n.º 22
0
 def __init__(self, parent, suite, name='SuiteAptAssigner'):
     self.suite = suite
     self.initPaellaCommon()
     self.suitecursor = SuiteCursor(self.conn)
     BaseAssigner.__init__(self, parent, name=name, udbuttons=True)
     self.connect(self, SIGNAL('okClicked()'), self.slotAssignAptSrcs)
Exemplo n.º 23
0
    suitecursor = SuiteCursor(conn)
    apt_rows = suitecursor.get_apt_rows(suite)
    if installer:
        # while installing use sources from local mirror
        uri = defenv.get('installer', 'http_mirror')
    else:
        # otherwise use official sources list
        uri = None
    apt_lines = make_sources_list_lines(apt_rows, uri=uri, installer=installer)
    aptdir = os.path.join(target, 'etc', 'apt')
    makepaths(aptdir)
    sources_list = file(os.path.join(aptdir, 'sources.list'), 'w')
    for line in apt_lines:
        sources_list.write('%s\n' % line)
    sources_list.write('\n')
    sources_list.close()

def make_sources_list(conn, target, suite):
    make_sources_list_common(conn, target, suite, installer=True)

def make_official_sources_list(conn, target, suite):
    make_sources_list_common(conn, target, suite)

if __name__ == '__main__':
    from paella.db import PaellaConnection
    conn = PaellaConnection()
    cursor = SuiteCursor(conn)
    rows = cursor.get_apt_rows('desksarge')
    msll = make_sources_list_lines
    
Exemplo n.º 24
0
 def __init__(self, app, **atts):
     BaseDocument.__init__(self, app, **atts)
     self.cursor = SuiteCursor(self.conn)
Exemplo n.º 25
0
class UmlProfileInstaller(BaseUmlInstaller):
    @guest_mode
    def set_suite(self, suite):
        self.installer = ProfileInstaller(self.conn)
        self._suite = suite
        self.suitecursor = SuiteCursor(self.conn)

    @guest_mode
    def _set_profile_in_guest(self, profile):
        self.set_suite(get_suite(self.conn, profile))
        self.installer.set_profile(profile)
        if hasattr(self, 'target'):
            self.installer.set_target(self.target)
            
    def set_profile(self, profile):
        if self.mode == 'host':
            self.options['paellaprofile'] = profile
        elif self.mode == 'guest':
            self._set_profile_in_guest(profile)
        else:
            raise ValueError, 'bad mode %s' % self.mode
        
    @guest_mode
    def set_template_path(self, path=None): 
        self.installer.set_template_path(path)

    @host_mode
    def install_profile(self, profile, path):
        self.set_profile(profile)
        self.make_root_device(path)
        self.run_uml(popen=True)

    @host_mode
    def restore_profile(self, name, path):
        self.options['paella_action'] = 'restore'
        self.options['paellaprofile'] = name
        self.options['paellasuite'] = 'none'
        self.make_root_device(path)
        self.run_uml(popen=False)
        
    @guest_mode
    def extract_base_tarball(self):
        suite = self.suitecursor.get_base_suite(self._suite)
        fstype = self.cfg.get('umlmachines', 'backup_filesystem')
        if fstype == 'hostfs':
            #backup_path = path(self.cfg.get('umlmachines', 'hostfs_backup_path')).expand()
            backup_path = path(self.options['hostfs_backup_path'].value)
        else:
            backup_path = path('/mnt')
        basetarball = backup_path / path('%s.base.tar.gz' % suite)
        if not basetarball.isfile():
            basetarball = backup_path / path('%s.base.tar' % suite)
        if basetarball.isfile():
            extract_tarball(self.target, basetarball)
        else:
            raise RuntimeError, 'No base tarball found for suite %s' % suite
        
    @guest_mode
    def ready_base_for_install(self):
        cfg = self.installer.defenv
        ready_base_for_install(self.target, self.conn, self._suite)

    @guest_mode
    def perform_install(self, profile=None, backup_filesystem=None):
        machine = os.environ['PAELLA_MACHINE']
        curenv = CurrentEnvironment(self.conn, machine)
        curenv['current_trait'] = 'None'
        curenv['current_trait_process'] = 'None'
        curenv['traitlist'] = ''
        mpkey = 'current_machine_process'
        if backup_filesystem is not None:
            curenv[mpkey] = 'mount_backup'
            self.mount_backup('/mnt', backup_filesystem)
        curenv[mpkey] = 'setup_target'
        self.setup_target()
        curenv[mpkey] = 'set_profile'
        self.set_profile(profile)
        curenv[mpkey] = 'extract_base_tarball'
        self.extract_base_tarball()
        curenv[mpkey] = 'ready_base_for_install'
        self.ready_base_for_install()
        curenv[mpkey] = 'set_template_path'
        self.set_template_path()
        curenv[mpkey] = 'process'
        self.process()
Exemplo n.º 26
0
 def __init__(self, parent, name='SuiteComboBox'):
     KComboBox.__init__(self, parent, name)
     self.initPaellaCommon()
     self.suites = SuiteCursor(self.conn)
     self.insertStrList(self.suites.get_suites())