Added custom argument handling for disk formats
This commit is contained in:
parent
7ddb0ae86b
commit
87d7273c86
@ -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
|
||||
)
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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'}
|
||||
)
|
||||
|
||||
@ -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'
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user