diff --git a/kiwi/disk_format.py b/kiwi/disk_format.py index ff1da863..429b4755 100644 --- a/kiwi/disk_format.py +++ b/kiwi/disk_format.py @@ -42,10 +42,21 @@ class DiskFormat(object): xml_state, source_dir, target_dir, custom_args ) elif name == 'vhdfixed': + disk_tag = xml_state.build_type.get_vhdfixedtag() + if disk_tag: + custom_args = { + '--tag': disk_tag + } return DiskFormatVhdFixed( xml_state, source_dir, target_dir, custom_args ) elif name == 'vmdk': + vmdisk_section = xml_state.get_build_type_vmdisk_section() + if vmdisk_section: + custom_args = { + 'subformat=': vmdisk_section.get_diskmode(), + 'adapter_type=': vmdisk_section.get_controller() + } return DiskFormatVmdk( xml_state, source_dir, target_dir, custom_args ) diff --git a/kiwi/xml_state.py b/kiwi/xml_state.py index b88c1ba5..acda2027 100644 --- a/kiwi/xml_state.py +++ b/kiwi/xml_state.py @@ -274,6 +274,16 @@ class XMLState(object): if machine_sections: return machine_sections[0] + def get_build_type_vmdisk_section(self): + """ + get vmdisk section from build type + """ + machine_section = self.get_build_type_machine_section() + if machine_section: + vmdisk_sections = machine_section.get_vmdisk() + if vmdisk_sections: + return vmdisk_sections[0] + def get_build_type_oemconfig_section(self): """ get oemconfig section from build type diff --git a/test/unit/disk_format_test.py b/test/unit/disk_format_test.py index 2e0a4085..d23cdfeb 100644 --- a/test/unit/disk_format_test.py +++ b/test/unit/disk_format_test.py @@ -33,15 +33,29 @@ class TestDiskFormat(object): @patch('kiwi.disk_format.DiskFormatVhdFixed') def test_disk_format_vhdfixed(self, mock_vhdfixed): xml_state = mock.Mock() + xml_state.build_type.get_vhdfixedtag = mock.Mock( + return_value='disk-tag' + ) DiskFormat('vhdfixed', xml_state, 'source_dir', 'target_dir') mock_vhdfixed.assert_called_once_with( - xml_state, 'source_dir', 'target_dir', None + xml_state, 'source_dir', 'target_dir', {'--tag': 'disk-tag'} ) @patch('kiwi.disk_format.DiskFormatVmdk') def test_disk_format_vmdk(self, mock_vmdk): xml_state = mock.Mock() + vmdisk = mock.Mock() + vmdisk.get_controller = mock.Mock( + return_value='controller' + ) + vmdisk.get_diskmode = mock.Mock( + return_value='disk-mode' + ) + xml_state.get_build_type_vmdisk_section = mock.Mock( + return_value=vmdisk + ) DiskFormat('vmdk', xml_state, 'source_dir', 'target_dir') mock_vmdk.assert_called_once_with( - xml_state, 'source_dir', 'target_dir', None + xml_state, 'source_dir', 'target_dir', + {'adapter_type=': 'controller', 'subformat=': 'disk-mode'} ) diff --git a/test/unit/xml_state_test.py b/test/unit/xml_state_test.py index 2db2486c..31b8f18d 100644 --- a/test/unit/xml_state_test.py +++ b/test/unit/xml_state_test.py @@ -112,6 +112,9 @@ class TestXMLState(object): assert self.state.get_build_type_system_disk_section().get_name() == \ 'mydisk' + def test_get_build_type_vmdisk_section(self): + assert self.state.get_build_type_vmdisk_section().get_id() == 0 + def test_get_volume_management(self): assert self.state.get_volume_management() == 'lvm'