Exemplo n.º 1
0
 def test_get_volumes(self):
     description = XMLDescription('../data/example_lvm_default_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     volume_type = namedtuple('volume_type', [
         'name', 'size', 'realpath', 'mountpoint', 'fullsize', 'label',
         'attributes'
     ])
     assert state.get_volumes() == [
         volume_type(name='usr_lib',
                     size='size:1024',
                     realpath='usr/lib',
                     mountpoint='usr/lib',
                     fullsize=False,
                     label='library',
                     attributes=[]),
         volume_type(name='LVRoot',
                     size='freespace:500',
                     realpath='/',
                     mountpoint=None,
                     fullsize=False,
                     label=None,
                     attributes=[]),
         volume_type(name='etc_volume',
                     size='freespace:30',
                     realpath='etc',
                     mountpoint='etc',
                     fullsize=False,
                     label=None,
                     attributes=['no-copy-on-write']),
         volume_type(name='bin_volume',
                     size=None,
                     realpath='/usr/bin',
                     mountpoint='/usr/bin',
                     fullsize=True,
                     label=None,
                     attributes=[]),
         volume_type(name='LVSwap',
                     size='size:128',
                     realpath='swap',
                     mountpoint=None,
                     fullsize=False,
                     label='SWAP',
                     attributes=[])
     ]
Exemplo n.º 2
0
 def test_get_container_config_clear_commands(self):
     expected_config = {
         'maintainer': ['--author=tux'],
         'entry_subcommand': [
             '--clear=config.cmd'
         ],
         'container_name': 'container_name',
         'container_tag': 'container_tag',
         'workingdir': ['--config.workingdir=/root'],
         'user': ['--config.user=root'],
         'entry_command': [
             '--clear=config.entrypoint',
         ]
     }
     description = XMLDescription('../data/example_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data, ['derivedContainer'], 'docker')
     assert state.get_container_config() == expected_config
Exemplo n.º 3
0
    def setup(self, mock_machine, mock_exists):
        self.context_manager_mock = mock.Mock()
        self.file_mock = mock.Mock()
        self.enter_mock = mock.Mock()
        self.exit_mock = mock.Mock()
        self.enter_mock.return_value = self.file_mock
        setattr(self.context_manager_mock, '__enter__', self.enter_mock)
        setattr(self.context_manager_mock, '__exit__', self.exit_mock)

        mock_machine.return_value = 'x86_64'
        mock_exists.return_value = True
        description = XMLDescription('../data/example_config.xml')
        self.xml_state = XMLState(
            description.load()
        )
        self.boot_image = BootImageDracut(
            self.xml_state, 'some-target-dir', 'system-directory'
        )
Exemplo n.º 4
0
 def setup(self, mock_exists, mock_cmd):
     Defaults.set_platform_name('x86_64')
     mock_exists.return_value = True
     command_type = namedtuple('command', ['output'])
     mock_cmd.return_value = command_type(
         output='foo\nfoobar\nmodule'
     )
     description = XMLDescription('../data/example_config.xml')
     self.xml_state = XMLState(
         description.load()
     )
     self.boot_image = BootImageDracut(
         self.xml_state, 'some-target-dir', 'system-directory'
     )
     mock_cmd.assert_called_once_with([
         'chroot', 'system-directory', 'dracut',
         '--list-modules', '--no-kernel'
     ])
Exemplo n.º 5
0
 def setup(self, mock_machine):
     mock_machine.return_value = 'x86_64'
     self.xml_state = MagicMock()
     self.xml_state.get_package_manager = Mock(return_value='zypper')
     self.xml_state.build_type.get_filesystem = Mock(return_value='ext3')
     self.xml_state.xml_data.get_name = Mock(return_value='some-image')
     self.xml_state.get_image_version = Mock(return_value='1.2.3')
     self.xml_state.xml_data.description_dir = 'description_dir'
     self.setup = SystemSetup(self.xml_state, 'root_dir')
     description = XMLDescription(description='../data/example_config.xml',
                                  derived_from='derived/description')
     self.description_dir = os.path.dirname(description.description_origin)
     self.setup_with_real_xml = SystemSetup(XMLState(description.load()),
                                            'root_dir')
     command_run = namedtuple('command', ['output', 'error', 'returncode'])
     self.run_result = command_run(output='password-hash\n',
                                   error='stderr',
                                   returncode=0)
Exemplo n.º 6
0
    def test_init_with_derived_from_image(
        self, mock_get_logfile, mock_root_bind, mock_root_init, mock_root_import
    ):
        mock_get_logfile.return_value = 'logfile'
        description = XMLDescription(
            description='../data/example_config.xml',
            derived_from='derived/description'
        )
        xml = description.load()

        root_init = MagicMock()
        mock_root_init.return_value = root_init
        root_import = Mock()
        root_import.sync_data = Mock()
        mock_root_import.return_value = root_import
        root_bind = MagicMock()
        root_bind.root_dir = 'root_dir'
        mock_root_bind.return_value = root_bind
        state = XMLState(
            xml, profiles=['containerFlavour'], build_type='docker'
        )
        uri = Mock()
        get_derived_from_image_uri = Mock(
            return_value=uri
        )
        state.get_derived_from_image_uri = get_derived_from_image_uri
        system = SystemPrepare(
            xml_state=state, root_dir='root_dir',
        )
        mock_root_init.assert_called_once_with(
            'root_dir', False
        )
        root_init.create.assert_called_once_with()
        mock_root_import.assert_called_once_with(
            'root_dir', uri,
            state.build_type.get_image()
        )
        root_import.sync_data.assert_called_once_with()
        mock_root_bind.assert_called_once_with(
            root_init
        )
        root_bind.setup_intermediate_config.assert_called_once_with()
        root_bind.mount_kernel_file_systems.assert_called_once_with()
        assert system.issue_message == '{headline}: {reason}'
Exemplo n.º 7
0
    def load_boot_xml_description(self):
        """
        Load the boot image description referenced by the system image
        description boot attribute
        """
        log.info('Loading Boot XML description')
        boot_description_directory = self.get_boot_description_directory()
        if not boot_description_directory:
            raise KiwiConfigFileNotFound(
                'no boot reference specified in XML description'
            )
        boot_config_file = boot_description_directory + '/config.xml'
        if not os.path.exists(boot_config_file):
            raise KiwiConfigFileNotFound(
                'no Boot XML description found in %s' %
                boot_description_directory
            )
        boot_description = XMLDescription(
            description=boot_config_file,
            derived_from=self.xml_state.xml_data.description_dir
        )

        boot_image_profile = self.xml_state.build_type.get_bootprofile()
        if not boot_image_profile:
            boot_image_profile = 'default'
        boot_kernel_profile = self.xml_state.build_type.get_bootkernel()
        if not boot_kernel_profile:
            boot_kernel_profile = 'std'

        self.boot_xml_state = XMLState(
            boot_description.load(), [boot_image_profile, boot_kernel_profile]
        )
        log.info('--> loaded %s', boot_config_file)
        if self.boot_xml_state.build_type:
            log.info(
                '--> Selected build type: %s',
                self.boot_xml_state.get_build_type_name()
            )
        if self.boot_xml_state.profiles:
            log.info(
                '--> Selected boot profiles: image: %s, kernel: %s',
                boot_image_profile, boot_kernel_profile
            )
Exemplo n.º 8
0
 def test_get_volumes_custom_root_volume_name(self):
     description = XMLDescription(
         '../data/example_lvm_custom_rootvol_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     volume_type = namedtuple('volume_type', [
         'name', 'size', 'realpath', 'mountpoint', 'fullsize', 'label',
         'attributes', 'is_root_volume'
     ])
     assert state.get_volumes() == [
         volume_type(name='myroot',
                     size='freespace:500',
                     realpath='/',
                     mountpoint=None,
                     fullsize=False,
                     label=None,
                     attributes=[],
                     is_root_volume=True)
     ]
Exemplo n.º 9
0
 def test_get_volumes_no_explicit_root_setup(self):
     description = XMLDescription('../data/example_lvm_no_root_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     volume_type = namedtuple(
         'volume_type', [
             'name',
             'size',
             'realpath',
             'mountpoint',
             'fullsize'
         ]
     )
     assert state.get_volumes() == [
         volume_type(
             name='LVRoot', size=None, realpath='/',
             mountpoint=None, fullsize=True
         )
     ]
Exemplo n.º 10
0
 def test_get_system_packages_some_arch(self, mock_machine):
     mock_machine.return_value = 's390'
     description = XMLDescription(
         '../data/example_config.xml'
     )
     state = XMLState(
         description.load()
     )
     assert state.get_system_packages() == [
         'foo',
         'gfxboot-branding-openSUSE',
         'grub2-branding-openSUSE',
         'ifplugd',
         'iputils',
         'kernel-default',
         'openssh',
         'plymouth-branding-openSUSE',
         'vim'
     ]
Exemplo n.º 11
0
    def setup(self, mock_machine, mock_exists, mock_mkdtemp):
        mock_machine.return_value = 'x86_64'
        mock_exists.return_value = True
        description = XMLDescription('../data/example_config.xml')
        self.xml_state = XMLState(description.load())

        self.manager = mock.Mock()
        self.system_prepare = mock.Mock()
        self.setup = mock.Mock()
        self.profile = mock.Mock()
        self.system_prepare.setup_repositories = mock.Mock(
            return_value=self.manager)
        kiwi.boot.image.builtin_kiwi.SystemPrepare = mock.Mock(
            return_value=self.system_prepare)
        kiwi.boot.image.builtin_kiwi.SystemSetup = mock.Mock(
            return_value=self.setup)
        kiwi.boot.image.builtin_kiwi.Profile = mock.Mock(
            return_value=self.profile)
        mock_mkdtemp.return_value = 'boot-root-directory'
        self.boot_image = BootImageKiwi(self.xml_state, 'some-target-dir')
Exemplo n.º 12
0
    def setup(self, mock_boot_path, mock_exists, mock_Temporary):
        mock_Temporary.return_value.new_dir.return_value.name = \
            'boot-root-directory'
        mock_boot_path.return_value = '../data'
        Defaults.set_platform_name('x86_64')
        mock_exists.return_value = True
        description = XMLDescription('../data/example_config.xml')
        self.xml_state = XMLState(description.load())

        self.manager = Mock()
        self.system_prepare = Mock()
        self.setup = Mock()
        self.profile = Mock()
        self.profile.dot_profile = dict()
        self.system_prepare.setup_repositories = Mock(
            return_value=self.manager)
        kiwi.boot.image.builtin_kiwi.SystemPrepare = Mock(
            return_value=self.system_prepare)
        kiwi.boot.image.builtin_kiwi.SystemSetup = Mock(
            return_value=self.setup)
        kiwi.boot.image.builtin_kiwi.Profile = Mock(return_value=self.profile)
        self.boot_image = BootImageKiwi(self.xml_state, 'some-target-dir')
Exemplo n.º 13
0
 def test_get_volumes_no_explicit_root_setup_other_fullsize_volume(self):
     description = XMLDescription(
         '../data/example_lvm_no_root_full_usr_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     volume_type = namedtuple('volume_type', [
         'name', 'size', 'realpath', 'mountpoint', 'fullsize', 'attributes'
     ])
     assert state.get_volumes() == [
         volume_type(name='usr',
                     size=None,
                     realpath='usr',
                     mountpoint='usr',
                     fullsize=True,
                     attributes=[]),
         volume_type(name='LVRoot',
                     size='freespace:30',
                     realpath='/',
                     mountpoint=None,
                     fullsize=False,
                     attributes=[])
     ]
Exemplo n.º 14
0
    def setup(self, mock_get_logfile, mock_root_bind, mock_root_init):
        Defaults.set_platform_name('x86_64')
        mock_get_logfile.return_value = None
        description = XMLDescription(
            description='../data/example_config.xml',
            derived_from='derived/description'
        )
        self.description_dir = os.path.dirname(description.description_origin)
        self.xml = description.load()

        self.manager = MagicMock(
            return_value=MagicMock()
        )
        self.manager.package_requests = ['foo']
        self.manager.collection_requests = ['foo']
        self.manager.product_requests = ['foo']

        root_init = MagicMock()
        mock_root_init.return_value = root_init
        root_bind = MagicMock()
        root_bind.root_dir = 'root_dir'
        mock_root_bind.return_value = root_bind
        self.state = XMLState(
            self.xml
        )
        self.system = SystemPrepare(
            xml_state=self.state, root_dir='root_dir',
            allow_existing=True
        )
        mock_root_init.assert_called_once_with(
            'root_dir', True
        )
        root_init.create.assert_called_once_with()
        mock_root_bind.assert_called_once_with(
            root_init
        )
        root_bind.setup_intermediate_config.assert_called_once_with()
        root_bind.mount_kernel_file_systems.assert_called_once_with()
Exemplo n.º 15
0
 def import_system_description_elements(self) -> None:
     """
     Copy information from the system image relevant to create the
     boot image to the boot image state XML description
     """
     self.xml_state.copy_displayname(self.boot_xml_state)
     self.xml_state.copy_name(self.boot_xml_state)
     self.xml_state.copy_repository_sections(
         target_state=self.boot_xml_state, wipe=True)
     self.xml_state.copy_drivers_sections(self.boot_xml_state)
     strip_description = XMLDescription(
         Defaults.get_boot_image_strip_file())
     strip_xml_state = XMLState(strip_description.load())
     strip_xml_state.copy_strip_sections(self.boot_xml_state)
     self.xml_state.copy_strip_sections(self.boot_xml_state)
     preferences_subsection_names = [
         'bootloader_theme', 'bootsplash_theme', 'locale', 'packagemanager',
         'rpm_check_signatures', 'rpm_excludedocs', 'showlicense'
     ]
     self.xml_state.copy_preferences_subsections(
         preferences_subsection_names, self.boot_xml_state)
     self.xml_state.copy_bootincluded_packages(self.boot_xml_state)
     self.xml_state.copy_bootincluded_archives(self.boot_xml_state)
     self.xml_state.copy_bootdelete_packages(self.boot_xml_state)
     type_attributes = [
         'bootkernel', 'bootprofile', 'btrfs_root_is_snapshot',
         'gpt_hybrid_mbr', 'devicepersistency', 'filesystem', 'firmware',
         'fsmountoptions', 'hybridpersistent',
         'hybridpersistent_filesystem', 'initrd_system', 'installboot',
         'installprovidefailsafe', 'kernelcmdline', 'ramonly',
         'target_removable', 'vga', 'wwid_wait_timeout'
     ]
     self.xml_state.copy_build_type_attributes(type_attributes,
                                               self.boot_xml_state)
     self.xml_state.copy_bootloader_section(self.boot_xml_state)
     self.xml_state.copy_systemdisk_section(self.boot_xml_state)
     self.xml_state.copy_machine_section(self.boot_xml_state)
     self.xml_state.copy_oemconfig_section(self.boot_xml_state)
Exemplo n.º 16
0
 def setup(self, mock_machine):
     mock_machine.return_value = 'x86_64'
     self.context_manager_mock = mock.Mock()
     self.file_mock = mock.Mock()
     self.enter_mock = mock.Mock()
     self.exit_mock = mock.Mock()
     self.enter_mock.return_value = self.file_mock
     setattr(self.context_manager_mock, '__enter__', self.enter_mock)
     setattr(self.context_manager_mock, '__exit__', self.exit_mock)
     self.xml_state = mock.MagicMock()
     self.xml_state.build_type.get_filesystem = mock.Mock(
         return_value='ext3'
     )
     self.xml_state.xml_data.get_name = mock.Mock(
         return_value='some-image'
     )
     self.xml_state.get_image_version = mock.Mock(
         return_value='1.2.3'
     )
     self.xml_state.xml_data.description_dir = 'description_dir'
     self.setup = SystemSetup(
         self.xml_state, 'root_dir'
     )
     description = XMLDescription(
         description='../data/example_config.xml',
         derived_from='derived/description'
     )
     self.setup_with_real_xml = SystemSetup(
         XMLState(description.load()), 'root_dir'
     )
     command_run = namedtuple(
         'command', ['output', 'error', 'returncode']
     )
     self.run_result = command_run(
         output='password-hash\n',
         error='stderr',
         returncode=0
     )
Exemplo n.º 17
0
    def setup(self, mock_root_bind, mock_root_init):
        description = XMLDescription('../data/example_config.xml')
        self.xml = description.load()

        self.manager = mock.MagicMock(return_value=mock.MagicMock())
        self.manager.package_requests = ['foo']
        self.manager.collection_requests = ['foo']
        self.manager.product_requests = ['foo']

        root_init = mock.MagicMock()
        mock_root_init.return_value = root_init
        root_bind = mock.MagicMock()
        root_bind.root_dir = 'root_dir'
        mock_root_bind.return_value = root_bind
        self.state = XMLState(self.xml)
        self.system = System(xml_state=self.state,
                             root_dir='root_dir',
                             allow_existing=True)
        mock_root_init.assert_called_once_with('root_dir', True)
        root_init.create.assert_called_once_with()
        mock_root_bind.assert_called_once_with(root_init)
        root_bind.setup_intermediate_config.assert_called_once_with()
        root_bind.mount_kernel_file_systems.assert_called_once_with()
Exemplo n.º 18
0
    def setup(self, mock_machine, mock_domain, mock_theme, mock_firmware):
        self.os_exists = {
            'root_dir/boot/unicode.pf2': True,
            'root_dir/usr/share/grub2': True,
            'root_dir/usr/share/grub': False,
            'root_dir/boot/grub2/themes': False,
            'root_dir/usr/share/grub2/themes/some-theme': True,
            'root_dir/usr/lib/grub2': True,
            'root_dir/usr/lib/grub': False,
            'root_dir/boot/grub2/x86_64-efi': False,
            'root_dir/boot/grub2/i386-pc': False,
            'root_dir/boot/grub2/x86_64-xen': False,
            'root_dir/usr/lib64/efi/shim.efi': True,
            'root_dir/usr/lib64/efi/grub.efi': True
        }
        mock_machine.return_value = 'x86_64'
        mock_theme.return_value = None
        mock_domain.return_value = None
        kiwi.bootloader_config_grub2.Path = mock.Mock()
        kiwi.bootloader_config_base.Path = mock.Mock()
        kiwi.bootloader_config_grub2.Command = mock.Mock()

        self.firmware = mock.Mock()
        self.firmware.ec2_mode = mock.Mock(return_value=None)
        self.firmware.efi_mode = mock.Mock(return_value=None)
        mock_firmware.return_value = self.firmware

        self.mbrid = mock.Mock()
        self.mbrid.get_id = mock.Mock(return_value='0xffffffff')

        self.grub2 = mock.Mock()
        kiwi.bootloader_config_grub2.BootLoaderTemplateGrub2 = mock.Mock(
            return_value=self.grub2)

        self.state = XMLState(
            XMLDescription('../data/example_config.xml').load())
        self.bootloader = BootLoaderConfigGrub2(self.state, 'root_dir')
Exemplo n.º 19
0
    def setup(self, mock_machine):
        mock_machine.return_value = 'x86_64'
        self.size = mock.Mock()
        self.size.customize = mock.Mock(return_value=42)
        self.size.accumulate_mbyte_file_sizes = mock.Mock(return_value=42)
        kiwi.storage.setup.SystemSize = mock.Mock(return_value=self.size)

        description = XMLDescription('../data/example_disk_size_config.xml')
        self.setup = DiskSetup(XMLState(description.load()), 'root_dir')

        description = XMLDescription(
            '../data/example_disk_size_volume_config.xml')
        self.setup_volumes = DiskSetup(XMLState(description.load()),
                                       'root_dir')

        description = XMLDescription(
            '../data/example_disk_size_oem_volume_config.xml')
        self.setup_oem_volumes = DiskSetup(XMLState(description.load()),
                                           'root_dir')

        description = XMLDescription(
            '../data/example_disk_size_empty_vol_config.xml')
        self.setup_empty_volumes = DiskSetup(XMLState(description.load()),
                                             'root_dir')

        description = XMLDescription(
            '../data/example_disk_size_vol_root_config.xml')
        self.setup_root_volume = DiskSetup(XMLState(description.load()),
                                           'root_dir')

        mock_machine.return_value = 'ppc64'
        description = XMLDescription(
            '../data/example_ppc_disk_size_config.xml')
        self.setup_ppc = DiskSetup(XMLState(description.load()), 'root_dir')

        mock_machine.return_value = 'arm64'
        description = XMLDescription(
            '../data/example_arm_disk_size_config.xml')
        self.setup_arm = DiskSetup(XMLState(description.load()), 'root_dir')
Exemplo n.º 20
0
    def test_install_bootstrap_archive_target_dir(
        self, mock_tar, mock_poll, mock_root_bind, mock_root_init
    ):
        Defaults.set_platform_name('x86_64')
        description = XMLDescription(
            description='../data/example_config_target_dir.xml'
        )
        self.xml = description.load()
        root_bind = MagicMock()
        root_bind.root_dir = 'root_dir'
        mock_root_bind.return_value = root_bind
        self.state = XMLState(
            self.xml
        )
        self.system = SystemPrepare(
            xml_state=self.state, root_dir='root_dir',
            allow_existing=True
        )
        tar = Mock()
        mock_tar.return_value = tar

        self.system.install_bootstrap(self.manager)

        tar.extract.assert_called_once_with('root_dir/foo')
Exemplo n.º 21
0
 def test_get_volumes_no_explicit_root_setup(self):
     description = XMLDescription('../data/example_lvm_no_root_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     volume_type = namedtuple('volume_type', [
         'name', 'size', 'realpath', 'mountpoint', 'fullsize', 'label',
         'attributes'
     ])
     assert state.get_volumes() == [
         volume_type(name='LVRoot',
                     size=None,
                     realpath='/',
                     mountpoint=None,
                     fullsize=True,
                     label=None,
                     attributes=[]),
         volume_type(name='LVSwap',
                     size='size:128',
                     realpath='swap',
                     mountpoint=None,
                     fullsize=False,
                     label='SWAP',
                     attributes=[])
     ]
Exemplo n.º 22
0
 def test_get_container_config(self):
     expected_config = {
         'labels': [
             '--config.label=somelabel=labelvalue',
             '--config.label=someotherlabel=anotherlabelvalue'
         ],
         'maintainer': ['--author=tux'],
         'entry_subcommand': [
             '--config.cmd=ls',
             '--config.cmd=-l'
         ],
         'container_name': 'container_name',
         'container_tag': 'container_tag',
         'workingdir': ['--config.workingdir=/root'],
         'environment': [
             '--config.env=PATH=/bin:/usr/bin:/home/user/bin',
             '--config.env=SOMEVAR=somevalue'
         ],
         'user': ['--config.user=root'],
         'volumes': [
             '--config.volume=/tmp',
             '--config.volume=/var/log'
         ],
         'entry_command': [
             '--config.entrypoint=/bin/bash',
             '--config.entrypoint=-x'
         ],
         'expose_ports': [
             '--config.exposedports=80',
             '--config.exposedports=8080'
         ]
     }
     description = XMLDescription('../data/example_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data, ['vmxFlavour'], 'docker')
     assert state.get_container_config() == expected_config
Exemplo n.º 23
0
 def setup(self, mock_machine):
     mock_machine.return_value = 'x86_64'
     description = XMLDescription('../data/example_config.xml')
     self.state = XMLState(description.load())
     self.bootloader = BootLoaderConfigBase(self.state, 'root_dir')
Exemplo n.º 24
0
 def setup(self):
     self.tmpfile = mock.Mock()
     self.tmpfile.name = 'tmpfile'
     description = XMLDescription('../data/example_dot_profile_config.xml')
     self.profile = Profile(XMLState(description.load()))
Exemplo n.º 25
0
 def setup(self):
     description = XMLDescription(
         '../data/example_runtime_checker_config.xml')
     self.xml_state = XMLState(description.load())
     self.runtime_checker = RuntimeChecker(self.xml_state)
Exemplo n.º 26
0
 def setup(self, mock_machine, mock_exists):
     mock_machine.return_value = 'x86_64'
     mock_exists.return_value = True
     description = XMLDescription(
         '../data/example_disk_config.xml'
     )
     self.device_map = {
         'root': MappedDevice('/dev/root-device', mock.Mock()),
         'boot': MappedDevice('/dev/boot-device', mock.Mock()),
         'efi': MappedDevice('/dev/efi-device', mock.Mock())
     }
     self.id_map = {
         'kiwi_RootPart': 1,
         'kiwi_BootPart': 1
     }
     self.id_map_sorted = OrderedDict(
         sorted(self.id_map.items())
     )
     self.loop_provider = mock.Mock()
     kiwi.disk_builder.LoopDevice = mock.Mock(
         return_value=self.loop_provider
     )
     self.disk = mock.Mock()
     provider = mock.Mock()
     provider.get_device = mock.Mock(
         return_value='/dev/some-loop'
     )
     self.disk.storage_provider = provider
     self.partitioner = mock.Mock()
     self.partitioner.get_id = mock.Mock(
         return_value=1
     )
     self.disk.partitioner = self.partitioner
     self.disk.get_uuid = mock.Mock(
         return_value='0815'
     )
     self.disk.get_partition_id_map = mock.Mock(
         return_value=self.id_map_sorted
     )
     self.disk.get_device = mock.Mock(
         return_value=self.device_map
     )
     self.kernel = mock.Mock()
     self.kernel.get_kernel = mock.Mock()
     self.kernel.get_xen_hypervisor = mock.Mock()
     self.kernel.copy_kernel = mock.Mock()
     self.kernel.copy_xen_hypervisor = mock.Mock()
     kiwi.disk_builder.Kernel = mock.Mock(
         return_value=self.kernel
     )
     self.disk_format = mock.Mock()
     self.disk_format.get_target_name_for_format = mock.Mock(
         return_value='some-target-format-name'
     )
     kiwi.disk_builder.DiskFormat = mock.Mock(
         return_value=self.disk_format
     )
     kiwi.disk_builder.Disk = mock.Mock(
         return_value=self.disk
     )
     self.disk_setup = mock.Mock()
     self.disk_setup.get_efi_label = mock.Mock(
         return_value='EFI'
     )
     self.disk_setup.get_root_label = mock.Mock(
         return_value='ROOT'
     )
     self.disk_setup.get_boot_label = mock.Mock(
         return_value='BOOT'
     )
     self.disk_setup.need_boot_partition = mock.Mock(
         return_value=True
     )
     self.bootloader_install = mock.Mock()
     kiwi.disk_builder.BootLoaderInstall = mock.MagicMock(
         return_value=self.bootloader_install
     )
     self.bootloader_config = mock.Mock()
     kiwi.disk_builder.BootLoaderConfig = mock.MagicMock(
         return_value=self.bootloader_config
     )
     kiwi.disk_builder.DiskSetup = mock.MagicMock(
         return_value=self.disk_setup
     )
     self.boot_image_task = mock.Mock()
     self.boot_image_task.boot_root_directory = 'boot_dir'
     self.boot_image_task.kernel_filename = 'kernel'
     self.boot_image_task.initrd_filename = 'initrd'
     self.boot_image_task.xen_hypervisor_filename = 'xen_hypervisor'
     kiwi.disk_builder.BootImageTask = mock.Mock(
         return_value=self.boot_image_task
     )
     self.firmware = mock.Mock()
     self.firmware.efi_mode = mock.Mock(
         return_value='efi'
     )
     kiwi.disk_builder.FirmWare = mock.Mock(
         return_value=self.firmware
     )
     self.system_setup = mock.Mock()
     kiwi.disk_builder.SystemSetup = mock.Mock(
         return_value=self.system_setup
     )
     self.install_image = mock.Mock()
     kiwi.disk_builder.InstallImageBuilder = mock.Mock(
         return_value=self.install_image
     )
     self.raid_root = mock.Mock()
     kiwi.disk_builder.RaidDevice = mock.Mock(
         return_value=self.raid_root
     )
     self.luks_root = mock.Mock()
     kiwi.disk_builder.LuksDevice = mock.Mock(
         return_value=self.luks_root
     )
     self.disk_builder = DiskBuilder(
         XMLState(description.load()), 'target_dir', 'root_dir'
     )
     self.disk_builder.build_type_name = 'oem'
     self.machine = mock.Mock()
     self.machine.get_domain = mock.Mock(
         return_value='dom0'
     )
     self.disk_builder.machine = self.machine
     self.disk_builder.image_format = None
Exemplo n.º 27
0
 def test_get_build_type_vmconfig_entries_no_machine_section(self):
     description = XMLDescription('../data/example_disk_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     assert state.get_build_type_vmconfig_entries() == []
Exemplo n.º 28
0
 def test_get_oemconfig_swap_mbytes_default(self):
     description = XMLDescription('../data/example_btrfs_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     assert state.get_oemconfig_swap_mbytes() == 128
Exemplo n.º 29
0
 def test_build_type_not_found_no_default_type(self):
     description = XMLDescription('../data/example_no_default_type.xml')
     xml_data = description.load()
     with raises(KiwiTypeNotFound):
         XMLState(xml_data, ['minimal'])
Exemplo n.º 30
0
 def test_get_volume_management_lvm_default(self):
     description = XMLDescription('../data/example_lvm_default_config.xml')
     xml_data = description.load()
     state = XMLState(xml_data)
     assert state.get_volume_management() == 'lvm'