[live-images] Add customizing disc type
Relates: #105 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
0c9ad96a31
commit
44d7b31a80
@ -244,6 +244,9 @@ There a couple common format specifiers available for both the options:
|
|||||||
|
|
||||||
Available keys are:
|
Available keys are:
|
||||||
* ``boot`` -- for ``boot.iso`` images created in *buildinstall* phase
|
* ``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
|
Example
|
||||||
-------
|
-------
|
||||||
@ -267,6 +270,7 @@ Example
|
|||||||
|
|
||||||
disc_types = {
|
disc_types = {
|
||||||
'boot': 'netinst',
|
'boot': 'netinst',
|
||||||
|
'live': 'Live',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -178,6 +178,8 @@ class LiveImagesPhase(PhaseBase):
|
|||||||
if self.compose.conf.get('live_images_no_rename', False):
|
if self.compose.conf.get('live_images_no_rename', False):
|
||||||
return None
|
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"
|
format = "%(compose_id)s-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s"
|
||||||
# Custom name (prefix)
|
# Custom name (prefix)
|
||||||
if name:
|
if name:
|
||||||
@ -186,8 +188,8 @@ class LiveImagesPhase(PhaseBase):
|
|||||||
custom_iso_name += "-%s" % version
|
custom_iso_name += "-%s" % version
|
||||||
format = custom_iso_name + "-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s"
|
format = custom_iso_name + "-%(variant)s-%(arch)s-%(disc_type)s%(disc_num)s%(suffix)s"
|
||||||
|
|
||||||
# XXX: hardcoded disc_type and disc_num
|
# XXX: hardcoded disc_num
|
||||||
return self.compose.get_image_name(arch, variant, disc_type="live",
|
return self.compose.get_image_name(arch, variant, disc_type=disc_type,
|
||||||
disc_num=None, format=format)
|
disc_num=None, format=format)
|
||||||
|
|
||||||
def stop(self, *args, **kwargs):
|
def stop(self, *args, **kwargs):
|
||||||
|
@ -58,6 +58,10 @@ class TestLiveImagesPhase(PungiTestCase):
|
|||||||
'ksurl': None},
|
'ksurl': None},
|
||||||
compose.variants['Client'],
|
compose.variants['Client'],
|
||||||
'amd64'))])
|
'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')
|
@mock.patch('pungi.phases.live_images.ThreadPool')
|
||||||
def test_live_image_build_single_repo_from(self, 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,
|
self.assertEqual(resolve_git_url.mock_calls,
|
||||||
[mock.call('https://git.example.com/kickstarts.git?#HEAD')])
|
[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):
|
class TestCreateLiveImageThread(PungiTestCase):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user