mirror of
https://pagure.io/fedora-qa/createhdds.git
synced 2025-05-06 01:41:34 +00:00
all: allow filtering by release, turn --delete into --force
This enhances the `all` subcommand with some features inspired by what we need to do during Fedora branching (because I'm writing an SOP and realized what you have to do with createhdds at branch time is kinda dumb and hard to write down). This lets you pass a `--rel` arg to the `all` subcommand which limits its operation to a specific release (by number only), so we can say "rebuild all images for release XX", which is exactly what we need to do (for two releases) at branch time. Also, it turns `--delete` (which deleted all images *before* the creation step) into `--force` (which just forces the creation even if the image already exists). This is much more sensible; we avoid having a (potentially quite long) period where the image doesn't exist at all, and the image not existing at all if the build fails. I think `--delete` is from the time before I implemented the mechanism to allow rebuild of an existing image (by building it under a temporary rename and renaming on completion). Signed-off-by: Adam Williamson <awilliam@redhat.com>
This commit is contained in:
parent
545ef737da
commit
6caf3cf01d
@ -657,29 +657,35 @@ def check(hdds, nextrel=None):
|
||||
|
||||
def cli_all(args, hdds):
|
||||
"""Function for the CLI 'all' subcommand. Creates all images. If
|
||||
args.delete is set, blows all existing images away and recreates
|
||||
them; otherwise it will just fill in missing or outdated images.
|
||||
If args.clean is set, also wipes 'unknown' images.
|
||||
args.force is set, rebuild all images; otherwise it will just fill
|
||||
in missing or outdated images. If args.clean is set, also wipes
|
||||
'unknown' images. If args.rel is non-zero, operation is limited to
|
||||
the specified release number; implicitly, images without a release
|
||||
number (i.e. guestfs images) are skipped.
|
||||
"""
|
||||
if args.delete:
|
||||
logger.info("Removing all images...")
|
||||
delete_all()
|
||||
|
||||
# handle renamed images (see do_renames docstring)
|
||||
do_renames(hdds)
|
||||
|
||||
# call check() to find out what we need to do
|
||||
# call check() to find missing, outdated, unknown images
|
||||
(missing, outdated, unknown) = check(hdds, nextrel=args.nextrel)
|
||||
|
||||
if args.force or args.delete:
|
||||
# rebuild all images
|
||||
todo = get_all_images(hdds, nextrel=args.nextrel)
|
||||
else:
|
||||
# 'missing' plus 'outdated' is all the images we need to build
|
||||
todo = missing + outdated
|
||||
|
||||
# wipe 'unknown' images if requested
|
||||
if args.clean:
|
||||
clean(unknown)
|
||||
|
||||
# 'missing' plus 'outdated' is all the images we need to build; if
|
||||
# args.delete was set, all images will be in this list
|
||||
missing.extend(outdated)
|
||||
for (num, img) in enumerate(missing, 1):
|
||||
logger.info("Creating image %s...[%s/%s]", img.filename, str(num), str(len(missing)))
|
||||
# if args.rel was passed, limit to images for that release
|
||||
if args.rel:
|
||||
todo = [img for img in todo if (hasattr(img, "release") and img.release == args.rel)]
|
||||
|
||||
for (num, img) in enumerate(todo, 1):
|
||||
logger.info("Creating image %s...[%s/%s]", img.filename, str(num), str(len(todo)))
|
||||
img.create(args.textinst)
|
||||
|
||||
def cli_check(args, hdds):
|
||||
@ -692,7 +698,7 @@ def cli_check(args, hdds):
|
||||
if args.rename:
|
||||
do_renames(hdds)
|
||||
|
||||
(missing, outdated, unknown) = check(hdds, nextrel=args.nextrel)
|
||||
(missing, outdated, unknown) = check(hdds, nextrel=args.nextrel, rel=args.rel)
|
||||
if missing:
|
||||
print("Missing images: {0}".format(', '.join([img.filename for img in missing])))
|
||||
if outdated:
|
||||
@ -781,9 +787,6 @@ def parse_args(hdds):
|
||||
|
||||
parser_all = subparsers.add_parser(
|
||||
'all', description="Ensure all images are present and up-to-date.")
|
||||
parser_all.add_argument(
|
||||
'-d', '--delete', help="Delete and re-build all images",
|
||||
action='store_true')
|
||||
parser_all.add_argument(
|
||||
'-c', '--clean', help="Remove unknown (usually old) images",
|
||||
action='store_true')
|
||||
@ -792,6 +795,15 @@ def parse_args(hdds):
|
||||
"- this determines what releases some images will be built for. If "
|
||||
"not set or set to 0, createhdds will try to discover it when needed",
|
||||
type=int, default=0)
|
||||
parser_all.add_argument(
|
||||
'-r', '--rel', help="Limit operation to only the release specified (by number or 'eln')",
|
||||
type=str, default="")
|
||||
parser_all.add_argument(
|
||||
'-f', '--force', help="Rebuild images even if they exist and are up to date",
|
||||
action='store_true')
|
||||
parser_all.add_argument(
|
||||
'-d', '--delete', help="Deprecated, does the same as --force",
|
||||
action='store_true', deprecated=True)
|
||||
parser_all.set_defaults(func=cli_all)
|
||||
|
||||
parser_check = subparsers.add_parser(
|
||||
|
Loading…
Reference in New Issue
Block a user