[ostree] Rename atomic to ostree

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
Lubomír Sedlář 2016-04-05 09:13:01 +02:00
parent ad87ea2d28
commit 96e7ddd3ea
11 changed files with 75 additions and 73 deletions

View File

@ -54,7 +54,7 @@ def run(config, topdir, has_old):
pungi.phases.GatherPhase(compose, pkgset_phase),
pungi.phases.ExtraFilesPhase(compose, pkgset_phase),
pungi.phases.CreaterepoPhase(compose),
pungi.phases.AtomicInstallerPhase(compose),
pungi.phases.OstreeInstallerPhase(compose),
pungi.phases.OSTreePhase(compose),
pungi.phases.ProductimgPhase(compose, pkgset_phase),
pungi.phases.CreateisoPhase(compose),

View File

@ -227,7 +227,7 @@ def run_compose(compose):
gather_phase = pungi.phases.GatherPhase(compose, pkgset_phase)
extrafiles_phase = pungi.phases.ExtraFilesPhase(compose, pkgset_phase)
createrepo_phase = pungi.phases.CreaterepoPhase(compose)
atomic_installer_phase = pungi.phases.AtomicInstallerPhase(compose)
ostree_installer_phase = pungi.phases.OstreeInstallerPhase(compose)
ostree_phase = pungi.phases.OSTreePhase(compose)
productimg_phase = pungi.phases.ProductimgPhase(compose, pkgset_phase)
createiso_phase = pungi.phases.CreateisoPhase(compose)
@ -242,7 +242,7 @@ def run_compose(compose):
buildinstall_phase, productimg_phase, gather_phase,
extrafiles_phase, createiso_phase, liveimages_phase,
livemedia_phase, image_build_phase, image_checksum_phase,
test_phase, ostree_phase, atomic_installer_phase):
test_phase, ostree_phase, ostree_installer_phase):
if phase.skip():
continue
try:
@ -348,13 +348,13 @@ def run_compose(compose):
liveimages_phase.start()
image_build_phase.start()
livemedia_phase.start()
atomic_installer_phase.start()
ostree_installer_phase.start()
createiso_phase.stop()
liveimages_phase.stop()
image_build_phase.stop()
livemedia_phase.stop()
atomic_installer_phase.stop()
ostree_installer_phase.stop()
image_checksum_phase.start()
image_checksum_phase.stop()

View File

@ -8,8 +8,8 @@ here = sys.path[0]
if here != '/usr/bin':
sys.path.insert(0, os.path.dirname(here))
from pungi import atomic
from pungi import ostree
if __name__ == '__main__':
atomic.main()
ostree.main()

View File

@ -142,7 +142,7 @@ Options
* live
* image-build
* live-media
* atomic_installer
* ostree-installer
.. note::
@ -950,7 +950,7 @@ runroot environment.
* ``treefile`` -- (*str*) Filename of configuration for ``rpm-ostree``.
* ``config_url`` -- (*str*) URL for Git repository with the ``treefile``.
* ``source_repo_from`` -- (*str*) Name of variant serving as source repository.
* ``atomic_repo`` -- (*str*) Where to put the atomic repository
* ``ostree_repo`` -- (*str*) Where to put the ostree repository
These keys are optional:
@ -968,19 +968,19 @@ Example config
"treefile": "fedora-atomic-docker-host.json",
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
"source_repo_from": "Everything",
"atomic_repo": "/mnt/koji/compose/atomic/Rawhide/"
"ostree_repo": "/mnt/koji/compose/atomic/Rawhide/"
}
})
]
Atomic Installer Settings
Ostree Installer Settings
=========================
The ``atomic_installer`` phase of *Pungi* can produce installer image bundling
The ``ostree_installer`` phase of *Pungi* can produce installer image bundling
an OSTree repository. This always runs in Koji as a ``runroot`` task.
**atomic**
**ostree_installer**
(*dict*) -- a variant/arch mapping of configuration. The format should be
``[(variant_uid_regex, {arch|*: config_dict})]``.
@ -1010,7 +1010,7 @@ Example config
--------------
::
atomic = [
ostree_installer = [
("^Atomic$", {
"x86_64": {
"source_repo_from": "Everything",

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
This module contains functions required by pungi-make-atomic.
This module contains functions required by pungi-make-ostree.
It is expected to be runnable in Koji runroot.
"""
@ -22,16 +22,16 @@ def make_log_file(log_dir, filename):
return os.path.join(log_dir, '{}.log'.format(filename))
def init_atomic_repo(repo, log_dir=None):
"""If the atomic repo does not exist, initialize it."""
log_file = make_log_file(log_dir, 'init-atomic-repo')
def init_ostree_repo(repo, log_dir=None):
"""If the ostree repo does not exist, initialize it."""
log_file = make_log_file(log_dir, 'init-ostree-repo')
if not os.path.isdir(repo):
shortcuts.run(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
logfile=log_file)
def make_ostree_repo(repo, config, log_dir=None):
log_file = make_log_file(log_dir, 'create-atomic-repo')
log_file = make_log_file(log_dir, 'create-ostree-repo')
shortcuts.run(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo), config],
logfile=log_file)
@ -68,9 +68,9 @@ def run(opts):
workdir = tempfile.mkdtemp()
repodir = prepare_config(workdir, opts.config_url, opts.config_branch,
opts.source_repo)
init_atomic_repo(opts.atomic_repo, log_dir=opts.log_dir)
init_ostree_repo(opts.ostree_repo, log_dir=opts.log_dir)
treefile = os.path.join(repodir, opts.treefile)
make_ostree_repo(opts.atomic_repo, treefile, log_dir=opts.log_dir)
make_ostree_repo(opts.ostree_repo, treefile, log_dir=opts.log_dir)
shutil.rmtree(workdir)
@ -79,8 +79,8 @@ def main(args=None):
parser.add_argument('--log-dir',
help='where to log output')
parser.add_argument('atomic_repo', metavar='ATOMIC_REPO',
help='where to put the atomic repo')
parser.add_argument('ostree_repo', metavar='OSTREE_REPO',
help='where to put the ostree repo')
parser.add_argument('--treefile', required=True,
help='treefile for rpm-ostree')
parser.add_argument('--config-url', required=True,

View File

@ -30,4 +30,4 @@ from test import TestPhase # noqa
from image_checksum import ImageChecksumPhase # noqa
from livemedia_phase import LiveMediaPhase # noqa
from ostree import OSTreePhase # noqa
from atomic_installer import AtomicInstallerPhase # noqa
from ostree_installer import OstreeInstallerPhase # noqa

View File

@ -41,16 +41,16 @@ class OSTreeThread(WorkerThread):
msg = 'OSTree phase for variant %s, arch %s' % (variant.uid, arch)
self.pool.log_info('[BEGIN] %s' % msg)
self.logdir = compose.paths.log.topdir('{}/atomic'.format(arch))
self.logdir = compose.paths.log.topdir('{}/ostree'.format(arch))
source_variant = compose.variants[config['source_repo_from']]
source_repo = translate_path(compose, compose.paths.compose.repository(arch, source_variant))
self._run_atomic_cmd(compose, variant, arch, config, source_repo)
self._run_ostree_cmd(compose, variant, arch, config, source_repo)
self.pool.log_info('[DONE ] %s' % msg)
def _run_atomic_cmd(self, compose, variant, arch, config, source_repo):
def _run_ostree_cmd(self, compose, variant, arch, config, source_repo):
cmd = [
'pungi-make-ostree',
'--log-dir={}'.format(self.logdir),
@ -58,7 +58,7 @@ class OSTreeThread(WorkerThread):
'--config-url={}'.format(config['config_url']),
'--config-branch={}'.format(config.get('config_branch', 'master')),
'--source-repo={}'.format(source_repo),
config['atomic_repo']
config['ostree_repo']
]
runroot_channel = compose.conf.get("runroot_channel", None)

View File

@ -11,48 +11,48 @@ from ..paths import translate_path
from ..wrappers import kojiwrapper, iso, lorax
class AtomicInstallerPhase(ConfigGuardedPhase):
name = 'atomic'
class OstreeInstallerPhase(ConfigGuardedPhase):
name = 'ostree_installer'
config_options = [
{
"name": "atomic",
"name": "ostree_installer",
"expected_types": [list],
"optional": True,
}
]
def __init__(self, compose):
super(AtomicInstallerPhase, self).__init__(compose)
super(OstreeInstallerPhase, self).__init__(compose)
self.pool = ThreadPool(logger=self.compose._logger)
def run(self):
for variant in self.compose.get_variants():
for arch in variant.arches:
for conf in util.get_arch_variant_data(self.compose.conf, self.name, arch, variant):
self.pool.add(AtomicInstallerThread(self.pool))
self.pool.add(OstreeInstallerThread(self.pool))
self.pool.queue_put((self.compose, variant, arch, conf))
self.pool.start()
class AtomicInstallerThread(WorkerThread):
class OstreeInstallerThread(WorkerThread):
def process(self, item, num):
compose, variant, arch, config = item
self.num = num
with util.failable(compose, variant, arch, 'atomic_installer', 'Atomic'):
with util.failable(compose, variant, arch, 'ostree-installer', 'Ostree installer'):
self.worker(compose, variant, arch, config)
def worker(self, compose, variant, arch, config):
msg = 'Atomic phase for variant %s, arch %s' % (variant.uid, arch)
msg = 'Ostree phase for variant %s, arch %s' % (variant.uid, arch)
self.pool.log_info('[BEGIN] %s' % msg)
self.logdir = compose.paths.log.topdir('{}/atomic'.format(arch))
self.logdir = compose.paths.log.topdir('{}/ostree'.format(arch))
source_variant = compose.variants[config['source_repo_from']]
source_repo = translate_path(
compose, compose.paths.compose.repository(arch, source_variant, create_dir=False))
self._run_atomic_cmd(compose, variant, arch, config, source_repo)
self._run_ostree_cmd(compose, variant, arch, config, source_repo)
disc_type = compose.conf.get('disc_types', {}).get('dvd', 'dvd')
filename = compose.get_image_name(arch, variant, disc_type=disc_type,
@ -100,7 +100,7 @@ class AtomicInstallerThread(WorkerThread):
pass
compose.im.add(variant.uid, arch, img)
def _run_atomic_cmd(self, compose, variant, arch, config, source_repo):
def _run_ostree_cmd(self, compose, variant, arch, config, source_repo):
image_dir = compose.paths.compose.os_tree(arch, variant, create_dir=False)
lorax_wrapper = lorax.LoraxWrapper()
cmd = lorax_wrapper.get_lorax_cmd(

View File

@ -11,14 +11,14 @@ import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
from tests import helpers
from pungi.phases import atomic_installer as atomic
from pungi.phases import ostree_installer as ostree
class AtomicInstallerPhaseTest(helpers.PungiTestCase):
class OstreeInstallerPhaseTest(helpers.PungiTestCase):
def test_validate(self):
compose = helpers.DummyCompose(self.topdir, {
'atomic': [
'ostree_installer': [
("^Atomic$", {
"x86_64": {
"source_repo_from": "Everything",
@ -41,7 +41,7 @@ class AtomicInstallerPhaseTest(helpers.PungiTestCase):
]
})
phase = atomic.AtomicInstallerPhase(compose)
phase = ostree.OstreeInstallerPhase(compose)
try:
phase.validate()
except:
@ -49,41 +49,41 @@ class AtomicInstallerPhaseTest(helpers.PungiTestCase):
def test_validate_bad_conf(self):
compose = helpers.DummyCompose(self.topdir, {
'atomic': 'yes please'
'ostree_installer': 'yes please'
})
phase = atomic.AtomicInstallerPhase(compose)
phase = ostree.OstreeInstallerPhase(compose)
with self.assertRaises(ValueError):
phase.validate()
@mock.patch('pungi.phases.atomic_installer.ThreadPool')
@mock.patch('pungi.phases.ostree_installer.ThreadPool')
def test_run(self, ThreadPool):
cfg = mock.Mock()
compose = helpers.DummyCompose(self.topdir, {
'atomic': [
'ostree_installer': [
('^Everything$', {'x86_64': cfg})
]
})
pool = ThreadPool.return_value
phase = atomic.AtomicInstallerPhase(compose)
phase = ostree.OstreeInstallerPhase(compose)
phase.run()
self.assertEqual(len(pool.add.call_args_list), 1)
self.assertEqual(pool.queue_put.call_args_list,
[mock.call((compose, compose.variants['Everything'], 'x86_64', cfg))])
@mock.patch('pungi.phases.atomic_installer.ThreadPool')
@mock.patch('pungi.phases.ostree_installer.ThreadPool')
def test_skip_without_config(self, ThreadPool):
compose = helpers.DummyCompose(self.topdir, {})
compose.just_phases = None
compose.skip_phases = []
phase = atomic.AtomicInstallerPhase(compose)
phase = ostree.OstreeInstallerPhase(compose)
self.assertTrue(phase.skip())
class AtomicThreadTest(helpers.PungiTestCase):
class OstreeThreadTest(helpers.PungiTestCase):
def assertImageAdded(self, compose, ImageCls, IsoWrapper):
image = ImageCls.return_value
@ -130,7 +130,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
get_mtime.return_value = 13579
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
t = atomic.AtomicInstallerThread(pool)
t = ostree.OstreeInstallerThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
@ -149,7 +149,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
task_id=True, use_shell=True)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/atomic/runroot.log')])
log_file=self.topdir + '/logs/x86_64/ostree/runroot.log')])
self.assertEqual(link.call_args_list,
[mock.call(self.topdir + '/compose/Everything/x86_64/os/images/boot.iso',
final_iso_path)])
@ -201,7 +201,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
get_mtime.return_value = 13579
final_iso_path = self.topdir + '/compose/Everything/x86_64/iso/image-name'
t = atomic.AtomicInstallerThread(pool)
t = ostree.OstreeInstallerThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
@ -228,7 +228,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
task_id=True, use_shell=True)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/atomic/runroot.log')])
log_file=self.topdir + '/logs/x86_64/ostree/runroot.log')])
self.assertEqual(link.call_args_list,
[mock.call(self.topdir + '/compose/Everything/x86_64/os/images/boot.iso',
final_iso_path)])
@ -253,7 +253,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
'koji_profile': 'koji',
'runroot_tag': 'rrt',
'failable_deliverables': [
('^.+$', {'*': ['atomic_installer']})
('^.+$', {'*': ['ostree-installer']})
],
})
pool = mock.Mock()
@ -265,11 +265,11 @@ class AtomicThreadTest(helpers.PungiTestCase):
koji = KojiWrapper.return_value
koji.run_runroot_cmd.side_effect = helpers.boom
t = atomic.AtomicInstallerThread(pool)
t = ostree.OstreeInstallerThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
compose.log_info.assert_has_calls([
mock.call('[FAIL] Atomic (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('[FAIL] Ostree installer (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('BOOM')
])
@ -287,7 +287,7 @@ class AtomicThreadTest(helpers.PungiTestCase):
'koji_profile': 'koji',
'runroot_tag': 'rrt',
'failable_deliverables': [
('^.+$', {'*': ['atomic_installer']})
('^.+$', {'*': ['ostree-installer']})
],
})
pool = mock.Mock()
@ -303,12 +303,12 @@ class AtomicThreadTest(helpers.PungiTestCase):
'retcode': 1,
}
t = atomic.AtomicInstallerThread(pool)
t = ostree.OstreeInstallerThread(pool)
t.process((compose, compose.variants['Everything'], 'x86_64', cfg), 1)
compose.log_info.assert_has_calls([
mock.call('[FAIL] Atomic (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('Runroot task failed: 1234. See %s/logs/x86_64/atomic/runroot.log for more details.'
mock.call('[FAIL] Ostree installer (variant Everything, arch x86_64) failed, but going on anyway.'),
mock.call('Runroot task failed: 1234. See %s/logs/x86_64/ostree/runroot.log for more details.'
% self.topdir)
])

View File

@ -24,7 +24,7 @@ class OSTreePhaseTest(helpers.PungiTestCase):
"treefile": "fedora-atomic-docker-host.json",
"config_url": "https://git.fedorahosted.org/git/fedora-atomic.git",
"source_repo_from": "Everything",
"atomic_repo": "/mnt/koji/compose/atomic/Rawhide/"
"ostree_repo": "/mnt/koji/compose/atomic/Rawhide/"
}
})
]
@ -86,7 +86,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
'config_url': 'https://git.fedorahosted.org/git/fedora-atomic.git',
'config_branch': 'f24',
'treefile': 'fedora-atomic-docker-host.json',
'atomic_repo': '/other/place/for/atomic'
'ostree_repo': '/other/place/for/atomic'
}
koji = KojiWrapper.return_value
koji.run_runroot_cmd.return_value = {
@ -102,7 +102,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
self.assertEqual(koji.get_runroot_cmd.call_args_list,
[mock.call('rrt', 'x86_64',
['pungi-make-ostree',
'--log-dir={}/logs/x86_64/atomic'.format(self.topdir),
'--log-dir={}/logs/x86_64/ostree'.format(self.topdir),
'--treefile=fedora-atomic-docker-host.json',
'--config-url=https://git.fedorahosted.org/git/fedora-atomic.git',
'--config-branch=f24',
@ -113,7 +113,7 @@ class OSTreeThreadTest(helpers.PungiTestCase):
task_id=True, use_shell=True)])
self.assertEqual(koji.run_runroot_cmd.call_args_list,
[mock.call(koji.get_runroot_cmd.return_value,
log_file=self.topdir + '/logs/x86_64/atomic/runroot.log')])
log_file=self.topdir + '/logs/x86_64/ostree/runroot.log')])
if __name__ == '__main__':

View File

@ -12,7 +12,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'bin'))
from tests import helpers
from pungi import atomic
from pungi import ostree
class OstreeScriptTest(helpers.PungiTestCase):
@ -28,13 +28,15 @@ class OstreeScriptTest(helpers.PungiTestCase):
tempfile.return_value = self.topdir
get_dir_from_scm.side_effect = self._dummy_config_repo
atomic.main([
repo = os.path.join(self.topdir, 'atomic')
ostree.main([
'--log-dir={}'.format(os.path.join(self.topdir, 'logs', 'Atomic')),
'--treefile={}'.format('fedora-atomic-docker-host.json'),
'--config-url=https://git.fedorahosted.org/git/fedora-atomic.git',
'--config-branch=f24',
'--source-repo=https://kojipkgs.fedoraproject.org/repo',
os.path.join(self.topdir, 'atomic'),
repo,
])
self.maxDiff = None
@ -44,11 +46,11 @@ class OstreeScriptTest(helpers.PungiTestCase):
self.topdir + '/config_repo')])
self.assertItemsEqual(
run.call_args_list,
[mock.call(['ostree', 'init', '--repo={}/atomic'.format(self.topdir), '--mode=archive-z2'],
logfile=self.topdir + '/logs/Atomic/init-atomic-repo.log'),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo={}/atomic'.format(self.topdir),
[mock.call(['ostree', 'init', '--repo={}'.format(repo), '--mode=archive-z2'],
logfile=self.topdir + '/logs/Atomic/init-ostree-repo.log'),
mock.call(['rpm-ostree', 'compose', 'tree', '--repo={}'.format(repo),
self.topdir + '/config_repo/fedora-atomic-docker-host.json'],
logfile=self.topdir + '/logs/Atomic/create-atomic-repo.log')])
logfile=self.topdir + '/logs/Atomic/create-ostree-repo.log')])
if __name__ == '__main__':