Esempio n. 1
0
    def setup_live_image_config(self,
                                mbrid,
                                hypervisor='xen.gz',
                                kernel='linux',
                                initrd='initrd'):
        """
        Create grub2 config file to boot a live media ISO image

        :param string mbrid: mbrid file name on boot device
        :param string hypervisor: hypervisor name
        :param string kernel: kernel name
        :param string initrd: initrd name
        """
        log.info('Creating grub2 live ISO config file from template')
        self.iso_boot = True
        self.cmdline = self.get_boot_cmdline()
        self.cmdline_failsafe = ' '.join(
            [self.cmdline,
             Defaults.get_failsafe_kernel_options()])
        parameters = {
            'search_params':
            '--file --set=root /boot/' + mbrid.get_id(),
            'default_boot':
            '0',
            'kernel_file':
            kernel,
            'initrd_file':
            initrd,
            'boot_options':
            ' '.join([self.cmdline] + self.live_boot_options),
            'failsafe_boot_options':
            ' '.join([self.cmdline_failsafe] + self.live_boot_options),
            'gfxmode':
            self.gfxmode,
            'theme':
            self.theme,
            'boot_timeout':
            self.timeout,
            'title':
            self.get_menu_entry_title(plain=True),
            'bootpath':
            '/boot/' + self.arch + '/loader',
            'boot_directory_name':
            self.boot_directory_name
        }
        if self.multiboot:
            log.info('--> Using multiboot template')
            parameters['hypervisor'] = hypervisor
            template = self.grub2.get_multiboot_iso_template(
                self.failsafe_boot, self.terminal, self.mediacheck_boot)
        else:
            log.info('--> Using standard boot template')
            hybrid_boot = True
            template = self.grub2.get_iso_template(self.failsafe_boot,
                                                   hybrid_boot, self.terminal,
                                                   self.mediacheck_boot)
        try:
            self.config = template.substitute(parameters)
        except Exception as e:
            raise KiwiTemplateError('%s: %s' % (type(e).__name__, format(e)))
Esempio n. 2
0
    def setup_install_image_config(self,
                                   mbrid,
                                   hypervisor='xen.gz',
                                   kernel='linux',
                                   initrd='initrd'):
        """
        Create grub2 config file to boot from an ISO install image

        :param string mbrid: mbrid file name on boot device
        :param string hypervisor: hypervisor name
        :param string kernel: kernel name
        :param string initrd: initrd name
        """
        log.info('Creating grub2 install config file from template')
        self.iso_boot = True
        parameters = {
            'search_params':
            '--file --set=root /boot/' + mbrid.get_id(),
            'default_boot':
            self.get_install_image_boot_default(),
            'kernel_file':
            kernel,
            'initrd_file':
            initrd,
            'boot_options':
            ' '.join([self.cmdline] + self.install_boot_options),
            'failsafe_boot_options':
            ' '.join([self.cmdline_failsafe] + self.install_boot_options),
            'gfxmode':
            self.gfxmode,
            'theme':
            self.theme,
            'boot_timeout':
            self.timeout,
            'title':
            self.get_menu_entry_install_title(),
            'bootpath':
            self.get_boot_path('iso'),
            'boot_directory_name':
            self.boot_directory_name,
            'efi_image_name':
            Defaults.get_efi_image_name(self.arch),
            'terminal_setup':
            self.terminal
        }
        if self.multiboot:
            log.info('--> Using multiboot install template')
            parameters['hypervisor'] = hypervisor
            template = self.grub2.get_multiboot_install_template(
                self.failsafe_boot, self.terminal, self.continue_on_timeout)
        else:
            log.info('--> Using standard boot install template')
            hybrid_boot = True
            template = self.grub2.get_install_template(
                self.failsafe_boot, hybrid_boot, self.terminal,
                self.continue_on_timeout)
        try:
            self.config = template.substitute(parameters)
        except Exception as e:
            raise KiwiTemplateError('%s: %s' % (type(e).__name__, format(e)))
Esempio n. 3
0
    def setup_live_image_config(self,
                                mbrid,
                                hypervisor='xen.gz',
                                kernel='linux',
                                initrd='initrd'):
        """
        Create isolinux.cfg in memory from a template suitable to boot
        a live system from an ISO image in BIOS boot mode

        :param string mbrid: mbrid file name on boot device
        :param string hypervisor: hypervisor name
        :param string kernel: kernel name
        :param string initrd: initrd name
        """
        # mbrid parameter is not used, the information is placed as the
        # application id when creating the iso filesystem. Thus not part
        # of the configuration file
        log.info('Creating isolinux live ISO config file from template')
        parameters = {
            'default_boot':
            self.get_menu_entry_title(plain=True),
            'kernel_file':
            kernel,
            'initrd_file':
            initrd,
            'boot_options':
            ' '.join([self.cmdline] + self.live_boot_options),
            'failsafe_boot_options':
            ' '.join([self.cmdline_failsafe] + self.live_boot_options),
            'gfxmode':
            self.gfxmode,
            'boot_timeout':
            self.timeout,
            'title':
            self.get_menu_entry_title(plain=True)
        }
        if self.multiboot:
            log.info('--> Using multiboot standard ISO template')
            parameters['hypervisor'] = hypervisor
            template = self.isolinux.get_multiboot_template(
                self.failsafe_boot, self._have_theme(), self.terminal,
                self.mediacheck_boot)
        else:
            log.info('--> Using standard ISO template')
            template = self.isolinux.get_template(self.failsafe_boot,
                                                  self._have_theme(),
                                                  self.terminal,
                                                  self.mediacheck_boot)
        try:
            self.config = template.substitute(parameters)
            template = self.isolinux.get_message_template()
            self.config_message = template.substitute(parameters)
        except Exception as e:
            raise KiwiTemplateError('%s: %s' % (type(e).__name__, format(e)))
Esempio n. 4
0
    def setup_disk_image_config(
        self, boot_uuid, root_uuid, hypervisor='xen.gz',
        kernel=None, initrd=None, boot_options=''
    ):
        """
        Create the grub.cfg in memory from a template suitable to boot
        from a disk image

        :param string boot_uuid: boot device UUID
        :param string root_uuid: root device UUID
        :param string hypervisor: hypervisor name
        :param string kernel: kernel name
        :param string initrd: initrd name
        :param string boot_options: kernel options as string
        """
        log.info('Creating grub2 config file from template')
        self.cmdline = ' '.join(
            [self.get_boot_cmdline(root_uuid), boot_options]
        )
        self.cmdline_failsafe = ' '.join(
            [self.cmdline, Defaults.get_failsafe_kernel_options(), boot_options]
        )
        parameters = {
            'search_params': ' '.join(['--fs-uuid', '--set=root', boot_uuid]),
            'default_boot': '0',
            'kernel_file': kernel,
            'initrd_file': initrd,
            'boot_options': self.cmdline,
            'failsafe_boot_options': self.cmdline_failsafe,
            'gfxmode': self.gfxmode,
            'theme': self.theme,
            'boot_timeout': self.timeout,
            'title': self.get_menu_entry_title(),
            'bootpath': self.get_boot_path('disk'),
            'boot_directory_name': self.boot_directory_name,
            'terminal_setup': self.terminal
        }
        if self.multiboot:
            log.info('--> Using multiboot disk template')
            parameters['hypervisor'] = hypervisor
            template = self.grub2.get_multiboot_disk_template(
                self.failsafe_boot, self.terminal
            )
        else:
            log.info('--> Using hybrid boot disk template')
            template = self.grub2.get_disk_template(
                self.failsafe_boot, self.hybrid_boot, self.terminal
            )
        try:
            self.config = template.substitute(parameters)
        except Exception as e:
            raise KiwiTemplateError(
                '%s: %s' % (type(e).__name__, format(e))
            )
Esempio n. 5
0
    def setup_disk_image_config(self,
                                boot_uuid=None,
                                root_uuid=None,
                                hypervisor=None,
                                kernel=None,
                                initrd=None,
                                boot_options=''):
        """
        Create the zipl config in memory from a template suitable to
        boot from a disk image.

        :param string boot_uuid: unused
        :param string root_uuid: unused
        :param string hypervisor: unused
        :param string kernel: kernel name
        :param string initrd: initrd name
        :param string boot_options: kernel options as string
        """
        log.info('Creating zipl config file from template')
        parameters = {
            'device':
            self.target_device,
            'target_type':
            self.target_type,
            'blocksize':
            self.target_blocksize,
            'offset':
            self._get_target_offset(),
            'geometry':
            self._get_target_geometry(),
            'default_boot':
            '1',
            'bootpath':
            self.bootpath,
            'boot_timeout':
            self.timeout,
            'title':
            self.quote_title(self.get_menu_entry_title()),
            'kernel_file':
            kernel,
            'initrd_file':
            initrd,
            'boot_options':
            ' '.join([self.cmdline, boot_options]),
            'failsafe_boot_options':
            ' '.join([self.cmdline_failsafe, boot_options])
        }
        log.info('--> Using standard disk boot template')
        template = self.zipl.get_template(self.failsafe_boot)
        try:
            self.config = template.substitute(parameters)
        except Exception as e:
            raise KiwiTemplateError('%s: %s' % (type(e).__name__, format(e)))
Esempio n. 6
0
File: vmdk.py Progetto: jfkw/kiwi
    def _create_vmware_settings_file(self):
        """
        In order to run a vmdk image in VMware products a settings file is
        needed or the possibility to convert machine settings into an ovf
        via VMware's proprietary ovftool
        """
        displayname = self.xml_state.xml_data.get_displayname()
        template_record = {
            'display_name':
            displayname or self.xml_state.xml_data.get_name(),
            'vmdk_file':
            os.path.basename(self.get_target_file_path_for_format('vmdk')),
            'virtual_hardware_version':
            '9',
            'guest_os':
            'suse-64',
            'disk_id':
            '0'
        }

        # Basic setup
        machine_setup = self.xml_state.get_build_type_machine_section()
        memory_setup = None
        cpu_setup = None
        if machine_setup:
            memory_setup = machine_setup.get_memory()
            hardware_version = machine_setup.get_HWversion()
            guest_os = machine_setup.get_guestOS()
            cpu_setup = machine_setup.get_ncpus()
            if hardware_version:
                template_record['virtual_hardware_version'] = hardware_version
            if guest_os:
                template_record['guest_os'] = guest_os
            if memory_setup:
                template_record['memory_size'] = memory_setup
            if cpu_setup:
                template_record['number_of_cpus'] = cpu_setup

        # CD/DVD setup
        iso_setup = self.xml_state.get_build_type_vmdvd_section()
        iso_controller = 'ide'
        if iso_setup:
            iso_controller = iso_setup.get_controller() or iso_controller
            template_record['iso_id'] = iso_setup.get_id()

        # Network setup
        network_entries = self.xml_state.get_build_type_vmnic_entries()
        network_setup = {}
        for network_entry in network_entries:
            network_setup[network_entry.get_interface() or '0'] = {
                'driver': network_entry.get_driver(),
                'connection_type': network_entry.get_mode(),
                'mac': network_entry.get_mac() or 'generated',
            }

        # Disk setup
        disk_setup = self.xml_state.get_build_type_vmdisk_section()
        disk_controller = 'ide'
        if disk_setup:
            disk_controller = disk_setup.get_controller() or disk_controller
            disk_id = disk_setup.get_id()
            if not disk_controller == 'ide':
                template_record['scsi_controller_name'] = disk_controller
            if disk_id:
                template_record['disk_id'] = disk_id

        # Addition custom entries
        custom_entries = self.xml_state.get_build_type_vmconfig_entries()

        # Build settings template and write settings file
        settings_template = VmwareSettingsTemplate().get_template(
            memory_setup, cpu_setup, network_setup, iso_setup, disk_controller,
            iso_controller)
        try:
            settings_file = self.get_target_file_path_for_format('vmx')
            with open(settings_file, 'w') as config:
                config.write(settings_template.substitute(template_record))
                for custom_entry in custom_entries:
                    config.write(custom_entry + os.linesep)
        except Exception as e:
            raise KiwiTemplateError('%s: %s' % (type(e).__name__, format(e)))