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 )
def test_setup_warn_no_initrd_support(self, mock_boot, mock_filesystem): boot_image_task = MagicMock() boot_image_task.has_initrd_support = Mock( return_value=False ) mock_boot.new.return_value = boot_image_task with self._caplog.at_level(logging.WARNING): KisBuilder(self.xml_state, 'target_dir', 'root_dir')
def setup(self, mock_boot, mock_filesystem): self.setup = Mock() self.runtime_config = Mock() self.runtime_config.get_max_size_constraint = Mock( return_value=None ) kiwi.builder.kis.RuntimeConfig = Mock( return_value=self.runtime_config ) kiwi.builder.kis.SystemSetup = Mock( return_value=self.setup ) self.boot_image_task = MagicMock() self.boot_image_task.boot_root_directory = 'initrd_dir' self.boot_image_task.initrd_filename = 'initrd_file_name' mock_boot.new.return_value = self.boot_image_task self.filesystem = MagicMock() self.filesystem.filename = 'myimage.fs' self.filesystem.root_uuid = 'some_uuid' mock_filesystem.return_value = self.filesystem self.xml_state = Mock() self.xml_state.profiles = None self.xml_state.get_image_version = Mock( return_value='1.2.3' ) self.xml_state.get_initrd_system = Mock( return_value='dracut' ) self.xml_state.xml_data.get_name = Mock( return_value='some-image' ) self.xml_state.build_type = Mock() self.xml_state.build_type.get_kernelcmdline = Mock( return_value='console=hvc0' ) kernel_type = namedtuple( 'kernel', ['filename', 'version'] ) xen_type = namedtuple( 'xen', ['filename', 'name'] ) self.kernel = Mock() self.kernel.get_kernel = Mock( return_value=kernel_type(filename='some-kernel', version='42') ) self.kernel.get_xen_hypervisor = Mock( return_value=xen_type(filename='hypervisor', name='xen.gz') ) kiwi.builder.kis.Kernel = Mock( return_value=self.kernel ) self.kis = KisBuilder( self.xml_state, 'target_dir', 'root_dir', custom_args={'signing_keys': ['key_file_a', 'key_file_b']} ) self.kis.image_name = 'myimage' self.kis.compressed = True