class ProfileInstaller(Installer):
    def __init__(self, conn, cfg):
        os.environ["DEBIAN_FRONTEND"] = "noninteractive"
        Installer.__init__(self, conn, cfg)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self.cfg = cfg
        self._profile = Profile(self.conn)
        self.log.info("profile installer initialized")

    def set_profile(self, profile):
        self.profile = profile
        self._profile.set_profile(profile)
        os.environ["PAELLA_PROFILE"] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.familydata = self._profile.get_family_data()
        self.profiledata = self._profile.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        self.installer.log = self.log
        self.installer.familydata = self.familydata
        self.installer.profiledata = self.profiledata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info("profile set to %s" % profile)

    def get_profile_data(self):
        return self.env.ProfileData()

    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, "installer"):
            self.installer.set_logpath(logpath)

    def make_traitlist_orig(self):
        traitparent = TraitParent(self.conn, self.suite)
        profile_traits = [x.trait for x in self.profiletrait.trait_rows()]
        all_traits = list(self.traitparent.get_traitset(profile_traits))
        traitlist = []
        while len(profile_traits):
            profile_traits_prepended = False
            trait = profile_traits[0]
            traitparent.set_trait(trait)
            parents = [r.parent for r in traitparent.parents()]
            for p in parents:
                if not profile_traits_prepended and p not in traitlist:
                    profile_traits = [p] + profile_traits
                    profile_traits_prepended = True
                    self.log.info("profile_traits prepended with %s" % p)
            if not profile_traits_prepended:
                traitlist.append(trait)
                del profile_traits[0]
            self.log.info("%s %s" % (str(traitlist), profile_traits))
        return traitlist

    def make_traitlist(self):
        tp = TraitParent(self.conn, self.suite)
        listed = [x.trait for x in self.profiletrait.trait_rows()]
        all = list(self.traitparent.get_traitset(listed))
        setfun = tp.set_trait
        parfun = tp.parents
        log = self.log
        return make_deplist(listed, all, setfun, parfun, log)

    def process(self):
        traits = self.make_traitlist()
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info("currently processed %s" % ",".join(self.processed))
        self.log.info("all traits processed for profile %s" % self.profile)
        self.log.info("------------------------------------")

    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info("processing trait %s" % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info("processed:  %s" % ", ".join(self.processed))

    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command("apt-get update"))

    def install_kernel(self, package):
        os.system(self.command("touch /boot/vmlinuz-fake"))
        os.system(self.command("ln -s boot/vmlinuz-fake vmlinuz"))
        os.system(self.command("apt-get -y install %s" % package))
        print "kernel %s installed" % package
Exemple #2
0
class ProfileInstaller(Installer):
    def __init__(self, conn, cfg):
        os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
        Installer.__init__(self, conn, cfg)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self.cfg = cfg
        self._profile = Profile(self.conn)
        self.log.info('profile installer initialized')

    def set_profile(self, profile):
        self.profile = profile
        self._profile.set_profile(profile)
        os.environ['PAELLA_PROFILE'] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.familydata = self._profile.get_family_data()
        self.profiledata = self._profile.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        self.installer.log = self.log
        self.installer.familydata = self.familydata
        self.installer.profiledata = self.profiledata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info('profile set to %s' % profile)

    def get_profile_data(self):
        return self.env.ProfileData()

    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, 'installer'):
            self.installer.set_logpath(logpath)

    def make_traitlist_orig(self):
        traitparent = TraitParent(self.conn, self.suite)
        profile_traits = [x.trait for x in self.profiletrait.trait_rows()]
        all_traits = list(self.traitparent.get_traitset(profile_traits))
        traitlist = []
        while len(profile_traits):
            profile_traits_prepended = False
            trait = profile_traits[0]
            traitparent.set_trait(trait)
            parents = [r.parent for r in traitparent.parents()]
            for p in parents:
                if not profile_traits_prepended and p not in traitlist:
                    profile_traits = [p] + profile_traits
                    profile_traits_prepended = True
                    self.log.info('profile_traits prepended with %s' % p)
            if not profile_traits_prepended:
                traitlist.append(trait)
                del profile_traits[0]
            self.log.info('%s %s' % (str(traitlist), profile_traits))
        return traitlist

    def make_traitlist(self):
        tp = TraitParent(self.conn, self.suite)
        listed = [x.trait for x in self.profiletrait.trait_rows()]
        all = list(self.traitparent.get_traitset(listed))
        setfun = tp.set_trait
        parfun = tp.parents
        log = self.log
        return make_deplist(listed, all, setfun, parfun, log)

    def process(self):
        traits = self.make_traitlist()
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info('currently processed %s' % ','.join(self.processed))
        self.log.info('all traits processed for profile %s' % self.profile)
        self.log.info('------------------------------------')

    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info('processing trait %s' % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info('processed:  %s' % ', '.join(self.processed))

    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command('apt-get update'))

    def install_kernel(self, package):
        os.system(self.command('touch /boot/vmlinuz-fake'))
        os.system(self.command('ln -s boot/vmlinuz-fake vmlinuz'))
        os.system(self.command('apt-get -y install %s' % package))
        print 'kernel %s installed' % package
Exemple #3
0
class ProfileInstaller(Installer):
    def __init__(self, conn):
        os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
        Installer.__init__(self, conn)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self._profile = Profile(self.conn)
        if hasattr(self, 'log'):
            self.log.info('profile installer initialized')
        self.mtypedata = {}

    def set_profile(self, profile):
        self.profile = profile
        self._profile.set_profile(profile)
        os.environ['PAELLA_PROFILE'] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.familydata = self._profile.get_family_data()
        self.profiledata = self._profile.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite)
        self.installer.log = self.log
        self.installer.familydata = self.familydata
        self.installer.profiledata = self.profiledata
        self.installer.mtypedata = self.mtypedata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info('profile set to %s' % profile)

    def get_profile_data(self):
        return self.env.ProfileData()

    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, 'installer'):
            self.installer.set_logpath(logpath)

    def make_traitlist(self):
        tp = TraitParent(self.conn, self.suite)
        listed = [x.trait for x in self.profiletrait.trait_rows()]
        all = list(self.traitparent.get_traitset(listed))
        setfun = tp.set_trait
        parfun = tp.parents
        log = self.log
        return make_deplist(listed, all, setfun, parfun, log)

    def setup_initial_paellainfo_files(self, traits):
        makepaths(self.paelladir)
        traitlist = file(join(self.paelladir, 'traitlist'), 'w')
        for trait in traits:
            traitlist.write('%s\n' % trait)
        traitlist.close()
        itraits = file(join(self.paelladir, 'installed_traits'), 'w')
        itraits.write('Installed Traits:\n')
        itraits.close()

    def setup_initial_paellainfo_env(self, traits):
        if os.environ.has_key('PAELLA_MACHINE'):
            machine = os.environ['PAELLA_MACHINE']
            curenv = CurrentEnvironment(self.conn, machine)
            curenv['current_profile'] = self.profile
            curenv['traitlist'] = ', '.join(traits)
            curenv['installed_traits'] = ''

    def process(self):
        traits = self.make_traitlist()
        self.setup_initial_paellainfo_files(traits)
        self.setup_initial_paellainfo_env(traits)
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info('currently processed %s' % ','.join(self.processed))
        self.log.info('all traits processed for profile %s' % self.profile)
        self.log.info('------------------------------------')

    def _append_installed_traits_file(self, trait):
        itraits = file(join(self.paelladir, 'installed_traits'), 'a')
        itraits.write(trait + '\n')
        itraits.close()

    def _append_installed_traits_db(self, trait):
        if os.environ.has_key('PAELLA_MACHINE'):
            machine = os.environ['PAELLA_MACHINE']
            curenv = CurrentEnvironment(self.conn, machine)
            line = curenv['installed_traits']
            traits = [t.strip() for t in line.split(',')]
            traits.append(trait)
            curenv['installed_traits'] = ', '.join(traits)

    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info('processing trait %s' % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info('processed:  %s' % ', '.join(self.processed))
        self.append_installed_traits(trait)

    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command('apt-get update'))

    def install_kernel(self, package):
        os.system(self.command('touch /boot/vmlinuz-fake'))
        os.system(self.command('ln -s boot/vmlinuz-fake vmlinuz'))
        os.system(self.command('apt-get -y install %s' % package))
        print 'kernel %s installed' % package

    def append_installed_traits(self, trait):
        self._append_installed_traits_file(trait)
        self._append_installed_traits_db(trait)
class ProfileInstaller(Installer):
    def __init__(self, conn):
        os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
        Installer.__init__(self, conn)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self._profile = Profile(self.conn)
        if hasattr(self, 'log'):
            self.log.info('profile installer initialized')
        else:
            self.set_logfile()
            self.log.info('profile installer initialized')
        self.mtypedata = {}
        
        
    def set_profile(self, profile):
        self.profile = profile
        self._profile.set_profile(profile)
        os.environ['PAELLA_PROFILE'] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.familydata = self._profile.get_family_data()
        self.profiledata = self._profile.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite)
        self.installer.log = self.log
        self.installer.familydata = self.familydata
        self.installer.profiledata = self.profiledata
        self.installer.mtypedata = self.mtypedata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info('profile set to %s' % profile)
        traitlist = self.make_traitlist()
        self.setup_initial_paellainfo_env(traitlist)
        
    def get_profile_data(self):
        return self.env.ProfileData()
    
    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, 'installer'):
            self.installer.set_logpath(logpath)
        
    def make_traitlist(self):
        listed = [x.trait for x in self.profiletrait.trait_rows()]
        #log = self.log
        log = None
        return self._profile.make_traitlist_with_traits(listed, log=log)

    def setup_initial_paellainfo_files(self, traits):
        makepaths(self.paelladir)
        traitlist = file(join(self.paelladir, 'traitlist'), 'w')
        for trait in traits:
            traitlist.write('%s\n' % trait)
        traitlist.close()
        itraits = file(join(self.paelladir, 'installed_traits'), 'w')
        itraits.write('Installed Traits:\n')
        itraits.close()

    def setup_initial_paellainfo_env(self, traits):
        if os.environ.has_key('PAELLA_MACHINE'):
            machine = os.environ['PAELLA_MACHINE']
            curenv = CurrentEnvironment(self.conn, machine)
            curenv['current_profile'] = self.profile
            curenv['traitlist'] = ', '.join(traits)
            curenv['installed_traits'] = ''
            
    def process(self):
        traits = self.make_traitlist()
        self.setup_initial_paellainfo_files(traits)
        self.setup_initial_paellainfo_env(traits)
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info('currently processed %s' % ','.join(self.processed))
        self.log.info('all traits processed for profile %s' % self.profile)
        self.log.info('------------------------------------')
        
    def _append_installed_traits_file(self, trait):
        itraits = file(join(self.paelladir, 'installed_traits'), 'a')
        itraits.write(trait + '\n')
        itraits.close()

    def _append_installed_traits_db(self, trait):
        if os.environ.has_key('PAELLA_MACHINE'):
            machine = os.environ['PAELLA_MACHINE']
            curenv = CurrentEnvironment(self.conn, machine)
            line = curenv['installed_traits']
            traits = [t.strip() for t in line.split(',')]
            traits.append(trait)
            curenv['installed_traits'] = ', '.join(traits)
            
            
        
    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info('processing trait %s' % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info('processed:  %s' % ', '.join(self.processed))
        self.append_installed_traits(trait)

    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command('apt-get update'))

    def install_kernel(self, package):
        os.system(self.command('touch /boot/vmlinuz-fake'))
        os.system(self.command('ln -s boot/vmlinuz-fake vmlinuz'))
        os.system(self.command('apt-get -y install %s' % package))
        print 'kernel %s installed' % package

    def append_installed_traits(self, trait):
        self._append_installed_traits_file(trait)
        self._append_installed_traits_db(trait)
class ProfileInstaller(Installer):
    def __init__(self, conn, cfg):
        Installer.__init__(self, conn, cfg)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self.cfg = cfg
        self.log.info('profile installer initialized')
        
    def set_profile(self, profile):
        self.profile = profile
        os.environ['PAELLA_PROFILE'] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.profiledata = self.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        self.installer.log = self.log
        self.installer.profiledata = self.profiledata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info('profile set to %s' % profile)
                
    def get_profile_data(self):
        return self.env.ProfileData()
    
    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, 'installer'):
            self.installer.set_logpath(logpath)
        
    def make_traitlist(self):
        traitparent = TraitParent(self.conn, self.suite)
        profile_traits = [x.trait for x in self.profiletrait.trait_rows()]
        all_traits = list(self.traitparent.get_traitset(profile_traits))
        traitlist = []
        while len(profile_traits):
            profile_traits_prepended = False
            trait = profile_traits[0]
            traitparent.set_trait(trait)
            parents = [r.parent for r in traitparent.parents()]
            for p in parents:
                if not profile_traits_prepended and p not in traitlist:
                    profile_traits = [p] + profile_traits
                    profile_traits_prepended = True
                    self.log.info('profile_traits prepended with %s' % p)
            if not profile_traits_prepended:
                traitlist.append(trait)
                del profile_traits[0]
            self.log.info('%s %s' % (str(traitlist), profile_traits))
        return traitlist
    
    def process(self):
        traits = self.make_traitlist()
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info('currently processed %s' % ','.join(self.processed))
        self.log.info('all traits processed for profile %s' % self.profile)
        self.log.info('------------------------------------')
        
    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info('processing trait %s' % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info('processed:  %s' % ', '.join(self.processed))
        
    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command('apt-get update'))

    def install_kernel(self, package):
        os.system(self.command('touch /boot/vmlinuz-fake'))
        os.system(self.command('ln -s boot/vmlinuz-fake vmlinuz'))
        os.system(self.command('apt-get -y install %s' % package))
        print 'kernel %s installed' % package
class ProfileInstaller(Installer):
    def __init__(self, conn, cfg):
        os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
        Installer.__init__(self, conn, cfg)
        self.profiletrait = ProfileTrait(self.conn)
        self.profile = None
        self.installer = None
        self.cfg = cfg
        self._profile = Profile(self.conn)
        self.log.info('profile installer initialized')
        
    def set_profile(self, profile):
        self.profile = profile
        self._profile.set_profile(profile)
        os.environ['PAELLA_PROFILE'] = profile
        self.profiletrait.set_profile(profile)
        self.traits = self.profiletrait.trait_rows()
        self.env = ProfileEnvironment(self.conn, self.profile)
        self.familydata = self._profile.get_family_data()
        self.profiledata = self._profile.get_profile_data()
        self.suite = get_suite(self.conn, profile)
        self.installer = TraitInstaller(self.conn, self.suite, self.cfg)
        self.installer.log = self.log
        self.installer.familydata = self.familydata
        self.installer.profiledata = self.profiledata
        self.traitparent = TraitParent(self.conn, self.suite)
        self.log.info('profile set to %s' % profile)
                
    def get_profile_data(self):
        return self.env.ProfileData()
    
    def set_logpath(self, logpath):
        Installer.set_logpath(self, logpath)
        if hasattr(self, 'installer'):
            self.installer.set_logpath(logpath)
        
    def make_traitlist(self):
        tp = TraitParent(self.conn, self.suite)
        listed = [x.trait for x in self.profiletrait.trait_rows()]
        all = list(self.traitparent.get_traitset(listed))
        setfun = tp.set_trait
        parfun = tp.parents
        log = self.log
        return make_deplist(listed, all, setfun, parfun, log)

    def setup_initial_paellainfo_files(self, traits):
        makepaths(self.paelladir)
        traitlist = file(join(self.paelladir, 'traitlist'), 'w')
        for trait in traits:
            traitlist.write('%s\n' % trait)
        traitlist.close()
        itraits = file(join(self.paelladir, 'installed_traits'), 'w')
        itraits.write('Installed Traits:\n')
        itraits.close()
        
    def process(self):
        traits = self.make_traitlist()
        self.setup_initial_paellainfo_files(traits)
        self.processed = []
        for trait in traits:
            self.process_trait(trait)
            self.log.info('currently processed %s' % ','.join(self.processed))
        self.log.info('all traits processed for profile %s' % self.profile)
        self.log.info('------------------------------------')
        
    def _append_installed_traits_file(self, trait):
        itraits = file(join(self.paelladir, 'installed_traits'), 'a')
        itraits.write(trait + '\n')
        itraits.close()
        
    def process_trait(self, trait):
        self.traitparent.set_trait(trait)
        self.installer.set_trait(trait)
        parents = [r.parent for r in self.traitparent.parents()]
        for p in parents:
            if p not in self.processed:
                raise UnbornError
        self.log.info('processing trait %s' % trait)
        self.installer.process()
        self.processed.append(trait)
        self.log.info('processed:  %s' % ', '.join(self.processed))
        self._append_installed_traits_file(trait)
        
    def set_template_path(self, path):
        self.installer.set_template_path(path)

    def set_target(self, target, update=False):
        Installer.set_target(self, target)
        self.installer.set_target(target)
        if update:
            os.system(self.command('apt-get update'))

    def install_kernel(self, package):
        os.system(self.command('touch /boot/vmlinuz-fake'))
        os.system(self.command('ln -s boot/vmlinuz-fake vmlinuz'))
        os.system(self.command('apt-get -y install %s' % package))
        print 'kernel %s installed' % package