Example #1
0
 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.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'])
Example #2
0
 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.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"])
Example #3
0
 def set_suite(self, suite):
     self.installer = ProfileInstaller(self.conn)
     self._suite = suite
     self.suitecursor = SuiteCursor(self.conn)
Example #4
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()
Example #5
0
class InstallerTools(object):
    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.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"])

    # this needs updating for machine type data
    def env(self):
        env = TemplatedEnvironment(self.tp.Environment())
        env.update(self.pr.get_family_data())
        env.update(self.pr.get_profile_data())
        return env

    def set_trait(self, trait):
        self.trait = trait
        self.tp.set_trait(trait)
        self.tr.set_trait(trait)
        self.parents = self.tr.parents()
        self._envv = self.env()
        tinstaller = self.installer.installer
        tinstaller.set_trait(trait)
        self.packages = tinstaller.traitpackage.packages()
        self.templates = tinstaller.traittemplate.templates()

    def get(self, key):
        if self._envv is None:
            raise Error, "need to set trait first"
        return self._envv.dereference(key)

    def lget(self, key):
        key = "_".join([self.trait, key])
        return self.get(key)

    def install_modules(self, name):
        modules = str2list(self.get(name))
        print "installing modules", modules, "to %s/etc/modules" % self.target
        setup_modules(self.target, modules)

    def remove_packages(self, packages=None):
        if packages is None:
            packages = self.packages
        if len(packages):
            if hasattr(packages[0], "package"):
                packages = [p.package for p in packages]
        package_list = " ".join(packages)
        command = "apt-get -y remove %s" % package_list
        self.installer.run("remove", command, proc=True)

    def chroot_command(self, cmd):
        return "chroot %s %s" % (self.target, cmd)
Example #6
0
 def set_suite(self, suite):
     self.installer = ProfileInstaller(self.conn)
     self._suite = suite
     self.suitecursor = SuiteCursor(self.conn)
Example #7
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()
Example #8
0
class InstallerTools(object):
    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.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'])

    # this needs updating for machine type data
    def env(self):
        env = TemplatedEnvironment(self.tp.Environment())
        env.update(self.pr.get_family_data())
        env.update(self.pr.get_profile_data())
        return env

    def set_trait(self, trait):
        self.trait = trait
        self.tp.set_trait(trait)
        self.tr.set_trait(trait)
        self.parents = self.tr.parents()
        self._envv = self.env()
        tinstaller = self.installer.installer
        tinstaller.set_trait(trait)
        self.packages = tinstaller.traitpackage.packages()
        self.templates = tinstaller.traittemplate.templates()

    def get(self, key):
        if self._envv is None:
            raise Error, 'need to set trait first'
        return self._envv.dereference(key)

    def lget(self, key):
        key = '_'.join([self.trait, key])
        return self.get(key)

    def install_modules(self, name):
        modules = str2list(self.get(name))
        print 'installing modules', modules, 'to %s/etc/modules' % self.target
        setup_modules(self.target, modules)

    def remove_packages(self, packages=None):
        if packages is None:
            packages = self.packages
        if len(packages):
            if hasattr(packages[0], 'package'):
                packages = [p.package for p in packages]
        package_list = ' '.join(packages)
        command = 'apt-get -y remove %s' % package_list
        self.installer.run('remove', command, proc=True)

    def chroot_command(self, cmd):
        return 'chroot %s %s' % (self.target, cmd)