예제 #1
0
 def set_machine(self, machine):
     self.check_target_set()
     self.machine.set_machine(machine)
     logdir = path(self.defenv.get('installer', 'base_log_directory'))
     if not logdir.isdir():
         logdir.mkdir()
     logfile = logdir / 'paella-install-%s.log' % machine
     os.environ['PAELLA_MACHINE'] = machine
     disklogpath = path(self.defenv.get('installer', 'disk_log_directory'))
     self.disklogpath = disklogpath / ('disklog-%s'  % machine)
     if not self.disklogpath.isdir():
         self.disklogpath.makedirs()
     self.set_logfile(logfile)
     self.log.info('machine set to %s' % machine)
     # we need to set machine_data before setting the profile
     # so that the machine_data is passed to the profile and trait installers
     self.machine_data = self.machine.get_machine_data()
     profile = self.machine.get_profile()
     self.set_profile(profile)
     self.curenv = CurrentEnvironment(self.conn, machine)
     self.helper = MachineInstallerHelper(self)
     self.helper.curenv = self.curenv
예제 #2
0
 def set_machine(self, machine):
     self.machine.set_machine(machine)
     # this needs to be a configuration option
     # in the default environment
     logdir = path('/paellalog')
     if not logdir.isdir():
         logdir.mkdir()
     logfile = logdir / 'paella-install-%s.log' % machine
     os.environ['PAELLA_MACHINE'] = machine
     self.disklogpath = logdir / ('disklog-%s'  % machine)
     if not self.disklogpath.isdir():
         self.disklogpath.mkdir()
     self.set_logfile(logfile)
     self.log.info('machine set to %s' % machine)
     # we need to set mtypedata before setting the profile
     # so that the mtypedata is passed to the profile and trait installers
     self.mtypedata = self.machine.mtype.get_machine_type_data()
     profile = self.machine.current.profile
     self.set_profile(profile)
     self.curenv = CurrentEnvironment(self.conn, machine)
     self.helper = MachineInstallerHelper(self)
     self.helper.curenv = self.curenv
예제 #3
0
 def set_machine(self, machine):
     self.check_target_set()
     self.machine.set_machine(machine)
     logdir = path(self.defenv.get('installer', 'base_log_directory'))
     if not logdir.isdir():
         logdir.mkdir()
     logfile = logdir / 'paella-install-%s.log' % machine
     os.environ['PAELLA_MACHINE'] = machine
     disklogpath = path(self.defenv.get('installer', 'disk_log_directory'))
     self.disklogpath = disklogpath / ('disklog-%s'  % machine)
     if not self.disklogpath.isdir():
         self.disklogpath.makedirs()
     self.set_logfile(logfile)
     self.log.info('machine set to %s' % machine)
     # we need to set machine_data before setting the profile
     # so that the machine_data is passed to the profile and trait installers
     self.machine_data = self.machine.get_machine_data()
     profile = self.machine.get_profile()
     self.set_profile(profile)
     self.curenv = CurrentEnvironment(self.conn, machine)
     self.helper = MachineInstallerHelper(self)
     self.helper.curenv = self.curenv
예제 #4
0
class MachineInstaller(BaseMachineInstaller):
    def __init__(self, conn):
        BaseMachineInstaller.__init__(self, conn)
        # the processes are mostly the same as in the
        # ChrootInstaller
        self._processes = list(DEFAULT_PROCESSES)
        pmap = dict(setup_disks=self.setup_disks,
                    mount_target=self.mount_target,
                    install_fstab=self.install_fstab,
                    install_modules=self.install_modules,
                    install_kernel=self.install_kernel,
                    prepare_bootloader=self.prepare_bootloader
                    )
        self._process_map.update(pmap)
        self.machine = MachineHandler(self.conn)
        self.helper = None
        self._target_mounted = False
        self._disks_setup = False
        
    def set_machine(self, machine):
        self.check_target_set()
        self.machine.set_machine(machine)
        logdir = path(self.defenv.get('installer', 'base_log_directory'))
        if not logdir.isdir():
            logdir.mkdir()
        logfile = logdir / 'paella-install-%s.log' % machine
        os.environ['PAELLA_MACHINE'] = machine
        disklogpath = path(self.defenv.get('installer', 'disk_log_directory'))
        self.disklogpath = disklogpath / ('disklog-%s'  % machine)
        if not self.disklogpath.isdir():
            self.disklogpath.makedirs()
        self.set_logfile(logfile)
        self.log.info('machine set to %s' % machine)
        # we need to set machine_data before setting the profile
        # so that the machine_data is passed to the profile and trait installers
        self.machine_data = self.machine.get_machine_data()
        profile = self.machine.get_profile()
        self.set_profile(profile)
        self.curenv = CurrentEnvironment(self.conn, machine)
        self.helper = MachineInstallerHelper(self)
        self.helper.curenv = self.curenv

    def make_script(self, procname):
        self.check_machine_set()
        script = self.machine.relation.get_script(procname, inherited=True)
        if script is not None:
            return make_script(procname, script, '/')
        else:
            return None
        
    def ready_base_for_install(self):
        self.check_target_mounted()
        # run ready_base_for_install from chroot installer first
        ChrootInstaller.ready_base_for_install(self)
        
    def install_modules(self):
        self.check_install_complete()
        self.log.info("install_modules isn't being used anymore.")
        msg = "This step is still here, in case you need to use a script"
        msg += " to add modules to /etc/modules ."
        self.log.info(msg)
        if False:
            self.helper.install_modules()

    def install_kernel(self):
        self.check_install_complete()
        self.helper.install_kernel()

    def prepare_bootloader(self):
        self.helper.prepare_bootloader()
        
    def install_fstab(self):
        self.check_install_complete()
        self.helper.install_fstab()

    def setup_disks(self):
        self.helper.setup_disks()
        self._disks_setup = True
        
    def mount_target(self):
        self.check_target_exists()
        self.check_disks_setup()
        self.helper.mount_target()
        self._target_mounted = True
예제 #5
0
class MachineInstaller(BaseMachineInstaller):
    def __init__(self, conn):
        BaseMachineInstaller.__init__(self, conn)
        # the processes are mostly the same as in the
        # ChrootInstaller
        self._processes = list(DEFAULT_PROCESSES)
        pmap = dict(setup_disks=self.setup_disks,
                    mount_target=self.mount_target,
                    install_fstab=self.install_fstab,
                    install_modules=self.install_modules,
                    install_kernel=self.install_kernel,
                    prepare_bootloader=self.prepare_bootloader
                    )
        self._process_map.update(pmap)
        self.machine = MachineHandler(self.conn)
        self.helper = None
        self._target_mounted = False
        self._disks_setup = False
        
    def set_machine(self, machine):
        self.check_target_set()
        self.machine.set_machine(machine)
        logdir = path(self.defenv.get('installer', 'base_log_directory'))
        if not logdir.isdir():
            logdir.mkdir()
        logfile = logdir / 'paella-install-%s.log' % machine
        os.environ['PAELLA_MACHINE'] = machine
        disklogpath = path(self.defenv.get('installer', 'disk_log_directory'))
        self.disklogpath = disklogpath / ('disklog-%s'  % machine)
        if not self.disklogpath.isdir():
            self.disklogpath.makedirs()
        self.set_logfile(logfile)
        self.log.info('machine set to %s' % machine)
        # we need to set machine_data before setting the profile
        # so that the machine_data is passed to the profile and trait installers
        self.machine_data = self.machine.get_machine_data()
        profile = self.machine.get_profile()
        self.set_profile(profile)
        self.curenv = CurrentEnvironment(self.conn, machine)
        self.helper = MachineInstallerHelper(self)
        self.helper.curenv = self.curenv

    def make_script(self, procname):
        self.check_machine_set()
        script = self.machine.relation.get_script(procname, inherited=True)
        if script is not None:
            return make_script(procname, script, '/')
        else:
            return None
        
    def ready_base_for_install(self):
        self.check_target_mounted()
        # run ready_base_for_install from chroot installer first
        ChrootInstaller.ready_base_for_install(self)
        
    def install_modules(self):
        self.check_install_complete()
        self.log.info("install_modules isn't being used anymore.")
        msg = "This step is still here, in case you need to use a script"
        msg += " to add modules to /etc/modules ."
        self.log.info(msg)
        if False:
            self.helper.install_modules()

    def install_kernel(self):
        self.check_install_complete()
        self.helper.install_kernel()

    def prepare_bootloader(self):
        self.helper.prepare_bootloader()
        
    def install_fstab(self):
        self.check_install_complete()
        self.helper.install_fstab()

    def setup_disks(self):
        self.helper.setup_disks()
        self._disks_setup = True
        
    def mount_target(self):
        self.check_target_exists()
        self.check_disks_setup()
        self.helper.mount_target()
        # this is now done in post_process
        #self._target_mounted = True
        
    def log_all_processes_started(self):
        machine = self.machine.current_machine
        installer = self.__class__.__name__
        self.log.info('Starting all processes for %s(%s)' % (installer, machine))
        
    def log_all_processes_finished(self):
        machine = self.machine.current_machine
        installer = self.__class__.__name__
        self.log.info('Finished all processes for %s(%s)' % (installer, machine))

    def post_process(self, procname):
        # be sure to run parent's post_process first
        BaseMachineInstaller.post_process(self, procname)
        name = self.__class__.__name__
        # now check for processes specific to the machine installer
        if procname == 'mount_target':
            self.log.info('%s marking %s finished' % (name, procname))
            self._target_mounted = True
        elif procname == 'setup_disks':
            self.log.info('%s marking %s finished' % (name, procname))
            self._disks_setup = True
예제 #6
0
class MachineInstaller(ChrootInstaller):
    def __init__(self, conn):
        ChrootInstaller.__init__(self, conn)
        # the processes are mostly the same as in the
        # ChrootInstaller
        self._processes = list(DEFAULT_PROCESSES)
        pmap = dict(setup_disks=self.setup_disks,
                    mount_target=self.mount_target,
                    install_fstab=self.install_fstab,
                    install_modules=self.install_modules,
                    install_kernel=self.install_kernel
                    )
        self._process_map.update(pmap)
        self.machine = MachineHandler(self.conn)
        self.helper = None
        self._target_mounted = False
        self._disks_setup = False
        
    @requires_target_set
    def set_machine(self, machine):
        self.machine.set_machine(machine)
        # this needs to be a configuration option
        # in the default environment
        logdir = path('/paellalog')
        if not logdir.isdir():
            logdir.mkdir()
        logfile = logdir / 'paella-install-%s.log' % machine
        os.environ['PAELLA_MACHINE'] = machine
        self.disklogpath = logdir / ('disklog-%s'  % machine)
        if not self.disklogpath.isdir():
            self.disklogpath.mkdir()
        self.set_logfile(logfile)
        self.log.info('machine set to %s' % machine)
        # we need to set mtypedata before setting the profile
        # so that the mtypedata is passed to the profile and trait installers
        self.mtypedata = self.machine.mtype.get_machine_type_data()
        profile = self.machine.current.profile
        self.set_profile(profile)
        self.curenv = CurrentEnvironment(self.conn, machine)
        self.helper = MachineInstallerHelper(self)
        self.helper.curenv = self.curenv

    @requires_machine_set
    def make_script(self, procname):
        script = self.machine.get_script(procname)
        if script is not None:
            return make_script(procname, script, '/')
        else:
            return None
        
    @requires_target_mounted
    def ready_base_for_install(self):
        # run ready_base_for_install from chroot installer first
        ChrootInstaller.ready_base_for_install(self)
        self.log.info('checking for raid devices')
        raid_devices = self.helper.get_raid_devices()
        if raid_devices:
            self.log.info('raid devices found')
            create_mdadm_conf(self.target, raid_devices)
        else:
            self.log.info('no raid devices found')
        
    @requires_install_complete
    def install_modules(self):
        self.helper.install_modules()

    @requires_install_complete
    def install_kernel(self):
        self.helper.install_kernel()

    @requires_install_complete
    def install_fstab(self):
        self.helper.install_fstab()

    def setup_disks(self):
        self.helper.setup_disks()
        self._disks_setup = True
        
    @requires_target_exists
    @requires_disks_setup
    def mount_target(self):
        device = self.machine.array_hack()
        mounts = self.machine.get_installable_fsmounts()
        mount_target(self.target, mounts, device)
        self._target_mounted = True