[createiso] Enable customizing media reserve
Add a documented and tested config options for setting ISO parameters instead of hardcoding magic values. Fixes: #256 Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
This commit is contained in:
parent
a8d7f8a63e
commit
b62b468ccf
@ -765,6 +765,15 @@ Options
|
|||||||
``optional`` variants. By default only variants with type ``variant`` or
|
``optional`` variants. By default only variants with type ``variant`` or
|
||||||
``layered-product`` will get ISOs.
|
``layered-product`` will get ISOs.
|
||||||
|
|
||||||
|
**iso_size** = 4700000000
|
||||||
|
(*int|str*) -- size of ISO image. The value should either be an integer
|
||||||
|
meaning size in bytes, or it can be a string with ``k``, ``M``, ``G``
|
||||||
|
suffix (using multiples of 1024).
|
||||||
|
|
||||||
|
**split_iso_reserve** = 10MiB
|
||||||
|
(*int|str*) -- how much free space should be left on each disk. The format
|
||||||
|
is the same as for ``iso_size`` option.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
Source architecture needs to be listed explicitly.
|
Source architecture needs to be listed explicitly.
|
||||||
|
@ -32,7 +32,7 @@ from pungi.wrappers.kojiwrapper import KojiWrapper
|
|||||||
from pungi.phases.base import PhaseBase
|
from pungi.phases.base import PhaseBase
|
||||||
from pungi.util import (makedirs, get_volid, get_arch_variant_data, failable,
|
from pungi.util import (makedirs, get_volid, get_arch_variant_data, failable,
|
||||||
get_file_size, get_mtime)
|
get_file_size, get_mtime)
|
||||||
from pungi.media_split import MediaSplitter
|
from pungi.media_split import MediaSplitter, convert_media_size
|
||||||
from pungi.compose_metadata.discinfo import read_discinfo, write_discinfo
|
from pungi.compose_metadata.discinfo import read_discinfo, write_discinfo
|
||||||
|
|
||||||
|
|
||||||
@ -284,19 +284,20 @@ class CreateIsoThread(WorkerThread):
|
|||||||
|
|
||||||
|
|
||||||
def split_iso(compose, arch, variant):
|
def split_iso(compose, arch, variant):
|
||||||
# XXX: hardcoded
|
"""
|
||||||
media_size = 4700000000
|
Split contents of the os/ directory for given tree into chunks fitting on ISO.
|
||||||
media_reserve = 10 * 1024 * 1024
|
|
||||||
|
|
||||||
ms = MediaSplitter(str(media_size - media_reserve), compose)
|
All files from the directory are taken except for possible boot.iso image.
|
||||||
|
Files added in extra_files phase are put on all disks.
|
||||||
|
"""
|
||||||
|
media_size = compose.conf.get('iso_size', 4700000000)
|
||||||
|
media_reserve = compose.conf.get('split_iso_reserve', 10 * 1024 * 1024)
|
||||||
|
|
||||||
|
ms = MediaSplitter(convert_media_size(media_size) - convert_media_size(media_reserve), compose)
|
||||||
|
|
||||||
os_tree = compose.paths.compose.os_tree(arch, variant)
|
os_tree = compose.paths.compose.os_tree(arch, variant)
|
||||||
extra_files_dir = compose.paths.work.extra_files_dir(arch, variant)
|
extra_files_dir = compose.paths.work.extra_files_dir(arch, variant)
|
||||||
|
|
||||||
# ti_path = os.path.join(os_tree, ".treeinfo")
|
|
||||||
# ti = productmd.treeinfo.TreeInfo()
|
|
||||||
# ti.load(ti_path)
|
|
||||||
|
|
||||||
# scan extra files to mark them "sticky" -> they'll be on all media after split
|
# scan extra files to mark them "sticky" -> they'll be on all media after split
|
||||||
extra_files = set()
|
extra_files = set()
|
||||||
for root, dirs, files in os.walk(extra_files_dir):
|
for root, dirs, files in os.walk(extra_files_dir):
|
||||||
|
@ -603,6 +603,34 @@ class SplitIsoTest(helpers.PungiTestCase):
|
|||||||
os.path.join(base_path, 'Packages/spacer.rpm')])
|
os.path.join(base_path, 'Packages/spacer.rpm')])
|
||||||
self.assertEqual(data[1]['files'], [os.path.join(base_path, 'Packages/x/pad.rpm')])
|
self.assertEqual(data[1]['files'], [os.path.join(base_path, 'Packages/x/pad.rpm')])
|
||||||
|
|
||||||
|
def test_can_customize_reserve(self):
|
||||||
|
compose = helpers.DummyCompose(self.topdir, {'split_iso_reserve': 1024 ** 2})
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/.treeinfo'),
|
||||||
|
TREEINFO)
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/Packages/spacer.rpm'))
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/Packages/x/pad.rpm'))
|
||||||
|
|
||||||
|
M = 1024 ** 2
|
||||||
|
|
||||||
|
with mock.patch('os.path.getsize', DummySize({'spacer': 4688465664, 'pad': 5 * M})):
|
||||||
|
data = createiso.split_iso(compose, 'x86_64', compose.variants['Server'])
|
||||||
|
|
||||||
|
self.assertEqual(len(data), 1)
|
||||||
|
|
||||||
|
def test_can_change_iso_size(self):
|
||||||
|
compose = helpers.DummyCompose(self.topdir, {'iso_size': '8G'})
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/.treeinfo'),
|
||||||
|
TREEINFO)
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/Packages/spacer.rpm'))
|
||||||
|
helpers.touch(os.path.join(self.topdir, 'compose/Server/x86_64/os/Packages/x/pad.rpm'))
|
||||||
|
|
||||||
|
M = 1024 ** 2
|
||||||
|
|
||||||
|
with mock.patch('os.path.getsize', DummySize({'spacer': 4688465664, 'pad': 5 * M})):
|
||||||
|
data = createiso.split_iso(compose, 'x86_64', compose.variants['Server'])
|
||||||
|
|
||||||
|
self.assertEqual(len(data), 1)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Loading…
Reference in New Issue
Block a user