Start lorax for each variant separately

The buildinstall phase now starts lorax for each variant separately.
Running with buildinstall should not be affected in any way.

Only variants of type=variant are considered. The side-effect of this is
that if an architecture is only used by variants of other types, lorax
will not be called at all.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2015-12-02 14:46:39 +01:00
parent 94f519d01c
commit cdec198b6d
2 changed files with 44 additions and 6 deletions

View File

@ -86,6 +86,8 @@ class BuildinstallPhase(PhaseBase):
noupgrade = not self.compose.conf.get("buildinstall_upgrade_image", False)
buildinstall_method = self.compose.conf["buildinstall_method"]
commands = []
for arch in self.compose.get_arches():
repo_baseurl = self.compose.paths.work.arch_repo(arch)
output_dir = self.compose.paths.work.buildinstall_dir(arch)
@ -93,11 +95,33 @@ class BuildinstallPhase(PhaseBase):
buildarch = get_valid_arches(arch)[0]
if buildinstall_method == "lorax":
cmd = lorax.get_lorax_cmd(product, version, release, repo_baseurl, output_dir, is_final=self.compose.supported, buildarch=buildarch, volid=volid, nomacboot=True, noupgrade=noupgrade)
for variant in self.compose.get_variants(arch=arch, types=['variant']):
commands.append(
lorax.get_lorax_cmd(product,
version,
release,
repo_baseurl,
output_dir,
variant=variant.uid,
buildinstallpackages=variant.buildinstallpackages,
is_final=self.compose.supported,
buildarch=buildarch,
volid=volid,
nomacboot=True,
noupgrade=noupgrade))
elif buildinstall_method == "buildinstall":
cmd = lorax.get_buildinstall_cmd(product, version, release, repo_baseurl, output_dir, is_final=self.compose.supported, buildarch=buildarch, volid=volid)
commands.append(lorax.get_buildinstall_cmd(product,
version,
release,
repo_baseurl,
output_dir,
is_final=self.compose.supported,
buildarch=buildarch,
volid=volid))
else:
raise ValueError("Unsupported buildinstall method: %s" % buildinstall_method)
for cmd in commands:
self.pool.add(BuildinstallThread(self.pool))
self.pool.queue_put((self.compose, arch, cmd))

View File

@ -32,6 +32,14 @@ class _DummyCompose(object):
def get_arches(self):
return ['x86_64', 'amd64']
def get_variants(self, arch, types):
variants = {
'x86_64': [mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'])],
'amd64': [mock.Mock(uid='Client', buildinstallpackages=[]),
mock.Mock(uid='Server', buildinstallpackages=['bash', 'vim'])],
}
return variants.get(arch, [])
class TestImageChecksumPhase(unittest.TestCase):
@ -72,17 +80,23 @@ class TestImageChecksumPhase(unittest.TestCase):
phase.run()
# Two items added for processing in total.
# Three items added for processing in total.
# Server.x86_64, Client.amd64, Server.x86_64
pool = poolCls.return_value
self.assertEqual(2, len(pool.queue_put.mock_calls))
self.assertEqual(3, len(pool.queue_put.mock_calls))
# Obtained correct lorax commands.
lorax = loraxCls.return_value
lorax.get_lorax_cmd.assert_has_calls(
[mock.call('Test', '1', '1', 'file:///a/b/', '/buildinstall_dir/x86_64',
buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id'),
buildarch='x86_64', is_final=True, nomacboot=True, noupgrade=True,
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim']),
mock.call('Test', '1', '1', 'file:///a/b/', '/buildinstall_dir/amd64',
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True, volid='vol_id')],
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True,
volid='vol_id', variant='Server', buildinstallpackages=['bash', 'vim']),
mock.call('Test', '1', '1', 'file:///a/b/', '/buildinstall_dir/amd64',
buildarch='amd64', is_final=True, nomacboot=True, noupgrade=True,
volid='vol_id', variant='Client', buildinstallpackages=[])],
any_order=True)
@mock.patch('pungi.phases.buildinstall.ThreadPool')