Ejemplo n.º 1
0
 def test_init_for_ix86_platform(self, mock_machine):
     xml_state = mock.Mock()
     xml_state.xml_data.get_name = mock.Mock(return_value='some-image')
     xml_state.get_image_version = mock.Mock(return_value='1.2.3')
     mock_machine.return_value = 'i686'
     live_image = LiveImageBuilder(xml_state, 'target_dir', 'root_dir')
     assert live_image.arch == 'ix86'
Ejemplo n.º 2
0
 def __new__(self, xml_state, target_dir, root_dir, custom_args=None):
     requested_image_type = xml_state.get_build_type_name()
     if requested_image_type in Defaults.get_filesystem_image_types():
         return FileSystemBuilder(
             xml_state, target_dir, root_dir
         )
     elif requested_image_type in Defaults.get_disk_image_types():
         return DiskBuilder(
             xml_state, target_dir, root_dir, custom_args
         )
     elif requested_image_type in Defaults.get_live_image_types():
         return LiveImageBuilder(
             xml_state, target_dir, root_dir, custom_args
         )
     elif requested_image_type in Defaults.get_kis_image_types():
         return KisBuilder(
             xml_state, target_dir, root_dir, custom_args
         )
     elif requested_image_type in Defaults.get_archive_image_types():
         return ArchiveBuilder(
             xml_state, target_dir, root_dir, custom_args
         )
     elif requested_image_type in Defaults.get_container_image_types():
         return ContainerBuilder(
             xml_state, target_dir, root_dir, custom_args
         )
     else:
         raise KiwiRequestedTypeError(
             'requested image type %s not supported' % requested_image_type
         )
Ejemplo n.º 3
0
 def test_init_for_ix86_platform(self):
     Defaults.set_platform_name('i686')
     xml_state = Mock()
     xml_state.xml_data.get_name = Mock(return_value='some-image')
     xml_state.get_image_version = Mock(return_value='1.2.3')
     live_image = LiveImageBuilder(xml_state, 'target_dir', 'root_dir')
     assert live_image.arch == 'ix86'
Ejemplo n.º 4
0
 def setup(self, mock_machine):
     mock_machine.return_value = 'x86_64'
     self.firmware = mock.Mock()
     self.firmware.efi_mode = mock.Mock(return_value='uefi')
     kiwi.builder.live.FirmWare = mock.Mock(return_value=self.firmware)
     self.setup = mock.Mock()
     kiwi.builder.live.SystemSetup = mock.Mock(return_value=self.setup)
     self.boot_image_task = mock.Mock()
     self.boot_image_task.boot_root_directory = 'initrd_dir'
     self.boot_image_task.initrd_filename = 'initrd'
     kiwi.builder.live.BootImage = mock.Mock(
         return_value=self.boot_image_task)
     self.mbrid = mock.Mock()
     self.mbrid.get_id = mock.Mock(return_value='0xffffffff')
     kiwi.builder.live.SystemIdentifier = mock.Mock(return_value=self.mbrid)
     kiwi.builder.live.Path = mock.Mock()
     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.builder.live.Kernel = mock.Mock(return_value=self.kernel)
     self.xml_state = mock.Mock()
     self.xml_state.get_fs_mount_option_list = mock.Mock(
         return_value='async')
     self.xml_state.build_type.get_flags = mock.Mock(return_value=None)
     self.xml_state.get_image_version = mock.Mock(return_value='1.2.3')
     self.xml_state.xml_data.get_name = mock.Mock(
         return_value='result-image')
     self.xml_state.build_type.get_volid = mock.Mock(return_value='volid')
     self.xml_state.build_type.get_kernelcmdline = mock.Mock(
         return_value='custom_cmdline')
     self.live_image = LiveImageBuilder(
         self.xml_state,
         'target_dir',
         'root_dir',
         custom_args={'signing_keys': ['key_file_a', 'key_file_b']})
     self.live_image.machine = mock.Mock()
     self.live_image.machine.get_domain = mock.Mock(return_value='dom0')
     self.result = mock.Mock()
     self.live_image.result = self.result
     self.live_image.hybrid = True
Ejemplo n.º 5
0
    def setup(self, mock_machine):
        mock_machine.return_value = 'x86_64'

        self.firmware = mock.Mock()
        self.firmware.efi_mode = mock.Mock(return_value='uefi')
        kiwi.builder.live.FirmWare = mock.Mock(return_value=self.firmware)

        self.setup = mock.Mock()
        kiwi.builder.live.SystemSetup = mock.Mock(return_value=self.setup)

        self.filesystem = mock.Mock()
        kiwi.builder.live.FileSystem = mock.Mock(return_value=self.filesystem)

        self.filesystem_setup = mock.Mock()
        kiwi.builder.live.FileSystemSetup = mock.Mock(
            return_value=self.filesystem_setup)

        self.loop = mock.Mock()
        kiwi.builder.live.LoopDevice = mock.Mock(return_value=self.loop)

        self.bootloader = mock.Mock()
        kiwi.builder.live.BootLoaderConfig = mock.Mock(
            return_value=self.bootloader)

        self.boot_image_task = mock.Mock()
        self.boot_image_task.boot_root_directory = 'initrd_dir'
        self.boot_image_task.initrd_filename = 'initrd'
        kiwi.builder.live.BootImageDracut = mock.Mock(
            return_value=self.boot_image_task)

        self.mbrid = mock.Mock()
        self.mbrid.get_id = mock.Mock(return_value='0xffffffff')
        kiwi.builder.live.SystemIdentifier = mock.Mock(return_value=self.mbrid)

        kiwi.builder.live.Path = mock.Mock()

        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.builder.live.Kernel = mock.Mock(return_value=self.kernel)

        self.xml_state = mock.Mock()
        self.xml_state.get_fs_mount_option_list = mock.Mock(
            return_value='async')
        self.xml_state.build_type.get_flags = mock.Mock(return_value=None)
        self.xml_state.get_image_version = mock.Mock(return_value='1.2.3')
        self.xml_state.xml_data.get_name = mock.Mock(
            return_value='result-image')
        self.xml_state.build_type.get_volid = mock.Mock(return_value='volid')
        self.xml_state.build_type.get_kernelcmdline = mock.Mock(
            return_value='custom_cmdline')
        self.xml_state.build_type.get_mediacheck = mock.Mock(return_value=True)
        self.xml_state.build_type.get_publisher = mock.Mock(
            return_value='Custom publisher')

        self.live_image = LiveImageBuilder(
            self.xml_state,
            'target_dir',
            'root_dir',
            custom_args={'signing_keys': ['key_file_a', 'key_file_b']})

        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.result = mock.Mock()
        self.live_image.result = self.result
Ejemplo n.º 6
0
    def setup(self):
        Defaults.set_platform_name('x86_64')

        self.firmware = Mock()
        self.firmware.efi_mode = Mock(return_value='uefi')
        kiwi.builder.live.FirmWare = Mock(return_value=self.firmware)

        self.setup = Mock()
        kiwi.builder.live.SystemSetup = Mock(return_value=self.setup)

        self.filesystem_setup = Mock()
        kiwi.builder.live.FileSystemSetup = Mock(
            return_value=self.filesystem_setup)

        self.loop = Mock()
        kiwi.builder.live.LoopDevice = Mock(return_value=self.loop)

        self.bootloader = Mock()
        kiwi.builder.live.BootLoaderConfig.new = Mock(
            return_value=self.bootloader)

        self.boot_image_task = Mock()
        self.boot_image_task.boot_root_directory = 'initrd_dir'
        self.boot_image_task.initrd_filename = 'initrd'
        kiwi.builder.live.BootImageDracut = Mock(
            return_value=self.boot_image_task)

        self.mbrid = Mock()
        self.mbrid.get_id = Mock(return_value='0xffffffff')
        kiwi.builder.live.SystemIdentifier = Mock(return_value=self.mbrid)

        kiwi.builder.live.Path = Mock()

        self.kernel = Mock()
        self.kernel.get_kernel = Mock()
        self.kernel.get_xen_hypervisor = Mock()
        self.kernel.copy_kernel = Mock()
        self.kernel.copy_xen_hypervisor = Mock()
        kiwi.builder.live.Kernel = Mock(return_value=self.kernel)

        self.xml_state = Mock()
        self.xml_state.get_fs_mount_option_list = Mock(return_value=['async'])
        self.xml_state.get_fs_create_option_list = Mock(
            return_value=['-O', 'option'])
        self.xml_state.build_type.get_flags = Mock(return_value=None)
        self.xml_state.build_type.get_squashfscompression = Mock(
            return_value='lzo')
        self.xml_state.get_image_version = Mock(return_value='1.2.3')
        self.xml_state.xml_data.get_name = Mock(return_value='result-image')
        self.xml_state.build_type.get_volid = Mock(return_value='volid')
        self.xml_state.build_type.get_kernelcmdline = Mock(
            return_value='custom_cmdline')
        self.xml_state.build_type.get_mediacheck = Mock(return_value=True)
        self.xml_state.build_type.get_publisher = Mock(
            return_value='Custom publisher')

        self.live_image = LiveImageBuilder(
            self.xml_state,
            'target_dir',
            'root_dir',
            custom_args={'signing_keys': ['key_file_a', 'key_file_b']})

        self.result = Mock()
        self.live_image.result = self.result