[live-images] Add customizing disc type

Relates: #105
Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-03-08 12:59:40 +01:00
parent 0c9ad96a31
commit 44d7b31a80
3 changed files with 60 additions and 2 deletions

View File

@ -244,6 +244,9 @@ There a couple common format specifiers available for both the options:
Available keys are:
* ``boot`` -- for ``boot.iso`` images created in *buildinstall* phase
* ``live`` -- for images created by *live_images* phase
Default values are the same as the keys.
Example
-------
@ -267,6 +270,7 @@ Example
disc_types = {
'boot': 'netinst',
'live': 'Live',
}

View File

@ -178,6 +178,8 @@ class LiveImagesPhase(PhaseBase):
if self.compose.conf.get('live_images_no_rename', False):
return None
disc_type = self.compose.conf.get('disc_types', {}).get('live', 'live')
format = "%(compose_id)s-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s"
# Custom name (prefix)
if name:
@ -186,8 +188,8 @@ class LiveImagesPhase(PhaseBase):
custom_iso_name += "-%s" % version
format = custom_iso_name + "-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s"
# XXX: hardcoded disc_type and disc_num
return self.compose.get_image_name(arch, variant, disc_type="live",
# XXX: hardcoded disc_num
return self.compose.get_image_name(arch, variant, disc_type=disc_type,
disc_num=None, format=format)
def stop(self, *args, **kwargs):

View File

@ -58,6 +58,10 @@ class TestLiveImagesPhase(PungiTestCase):
'ksurl': None},
compose.variants['Client'],
'amd64'))])
self.assertItemsEqual(
compose.get_image_name.mock_calls,
[mock.call('amd64', compose.variants['Client'], disc_num=None, disc_type='live',
format='%(compose_id)s-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s')])
@mock.patch('pungi.phases.live_images.ThreadPool')
def test_live_image_build_single_repo_from(self, ThreadPool):
@ -260,6 +264,54 @@ class TestLiveImagesPhase(PungiTestCase):
self.assertEqual(resolve_git_url.mock_calls,
[mock.call('https://git.example.com/kickstarts.git?#HEAD')])
@mock.patch('pungi.phases.live_images.ThreadPool')
def test_live_image_build_custom_type(self, ThreadPool):
compose = DummyCompose(self.topdir, {
'disc_types': {'live': 'Live'},
'live_images': [
('^Client$', {
'amd64': {
'kickstart': 'test.ks',
'additional_repos': ['http://example.com/repo/'],
'repo_from': ['Everything'],
'release': None,
}
})
],
})
phase = LiveImagesPhase(compose)
phase.run()
# assert at least one thread was started
self.assertTrue(phase.pool.add.called)
self.maxDiff = None
self.assertItemsEqual(phase.pool.queue_put.mock_calls,
[mock.call((compose,
{'ks_file': 'test.ks',
'build_arch': 'amd64',
'dest_dir': self.topdir + '/compose/Client/amd64/iso',
'scratch': False,
'repos': [self.topdir + '/compose/Client/amd64/os',
'http://example.com/repo/',
self.topdir + '/compose/Everything/amd64/os'],
'label': '',
'name': None,
'filename': 'image-name',
'version': None,
'specfile': None,
'sign': False,
'type': 'live',
'release': '20151203.0',
'ksurl': None},
compose.variants['Client'],
'amd64'))])
self.assertItemsEqual(
compose.get_image_name.mock_calls,
[mock.call('amd64', compose.variants['Client'], disc_num=None, disc_type='Live',
format='%(compose_id)s-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s')])
class TestCreateLiveImageThread(PungiTestCase):