composer-cli: Add new start-ostree command
This is used to start an ostree build, it is only supported on ostree-composer, and requires the ostree ref and parent. It may also include --size and optionally be uploaded. Resolves: rhbz#1844649
This commit is contained in:
parent
7c705c17d1
commit
7da012a92b
@ -75,6 +75,7 @@ def compose_cmd_v1(opts):
|
|||||||
"results": compose_results,
|
"results": compose_results,
|
||||||
"logs": compose_logs,
|
"logs": compose_logs,
|
||||||
"image": compose_image,
|
"image": compose_image,
|
||||||
|
"start-ostree": compose_ostree,
|
||||||
}
|
}
|
||||||
return run_command(opts, cmd_map)
|
return run_command(opts, cmd_map)
|
||||||
|
|
||||||
@ -375,6 +376,88 @@ def compose_start_v1(socket_path, api_version, args, show_json=False, testmode=0
|
|||||||
|
|
||||||
return rc
|
return rc
|
||||||
|
|
||||||
|
def compose_ostree(socket_path, api_version, args, show_json=False, testmode=0):
|
||||||
|
"""Start a new compose using the selected blueprint and type
|
||||||
|
|
||||||
|
:param socket_path: Path to the Unix socket to use for API communication
|
||||||
|
:type socket_path: str
|
||||||
|
:param api_version: Version of the API to talk to. eg. "0"
|
||||||
|
:type api_version: str
|
||||||
|
:param args: List of remaining arguments from the cmdline
|
||||||
|
:type args: list of str
|
||||||
|
:param show_json: Set to True to show the JSON output instead of the human readable output
|
||||||
|
:type show_json: bool
|
||||||
|
:param testmode: Set to 1 to simulate a failed compose, set to 2 to simulate a finished one.
|
||||||
|
:type testmode: int
|
||||||
|
:param api: Details about the API server, "version" and "backend"
|
||||||
|
:type api: dict
|
||||||
|
|
||||||
|
compose start [--size XXX] <blueprint-name> <compose-type> <ostree-ref> <ostree-parent> [<image-name> <provider> <profile> | <image-name> <profile.toml>]
|
||||||
|
"""
|
||||||
|
# Get the optional size before checking other parameters
|
||||||
|
try:
|
||||||
|
args, size = get_size(args)
|
||||||
|
except (RuntimeError, ValueError) as e:
|
||||||
|
log.error(str(e))
|
||||||
|
return 1
|
||||||
|
|
||||||
|
if len(args) == 0:
|
||||||
|
log.error("start-ostree is missing the blueprint name, output type, and ostree details")
|
||||||
|
return 1
|
||||||
|
if len(args) == 1:
|
||||||
|
log.error("start-ostree is missing the output type")
|
||||||
|
return 1
|
||||||
|
if len(args) == 2:
|
||||||
|
log.error("start-ostree is missing the ostree reference")
|
||||||
|
return 1
|
||||||
|
if len(args) == 3:
|
||||||
|
log.error("start-ostree is missing the ostree parent")
|
||||||
|
return 1
|
||||||
|
if len(args) == 5:
|
||||||
|
log.error("start-ostree is missing the provider and profile details")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
config = {
|
||||||
|
"blueprint_name": args[0],
|
||||||
|
"compose_type": args[1],
|
||||||
|
"branch": "master",
|
||||||
|
"ostree": {"ref": args[2], "parent": args[3]},
|
||||||
|
}
|
||||||
|
if size > 0:
|
||||||
|
config["size"] = size
|
||||||
|
|
||||||
|
if len(args) == 6:
|
||||||
|
config["upload"] = {"image_name": args[4]}
|
||||||
|
# profile TOML file (maybe)
|
||||||
|
try:
|
||||||
|
config["upload"].update(toml.load(open(args[5])))
|
||||||
|
except toml.TomlError as e:
|
||||||
|
log.error(str(e))
|
||||||
|
return 1
|
||||||
|
elif len(args) == 7:
|
||||||
|
config["upload"] = {
|
||||||
|
"image_name": args[4],
|
||||||
|
"provider": args[5],
|
||||||
|
"profile": args[6]
|
||||||
|
}
|
||||||
|
|
||||||
|
if testmode:
|
||||||
|
test_url = "?test=%d" % testmode
|
||||||
|
else:
|
||||||
|
test_url = ""
|
||||||
|
api_route = client.api_url(api_version, "/compose" + test_url)
|
||||||
|
result = client.post_url_json(socket_path, api_route, json.dumps(config))
|
||||||
|
(rc, exit_now) = handle_api_result(result, show_json)
|
||||||
|
if exit_now:
|
||||||
|
return rc
|
||||||
|
|
||||||
|
print("Compose %s added to the queue" % result["build_id"])
|
||||||
|
|
||||||
|
if "upload_id" in result and result["upload_id"]:
|
||||||
|
print ("Upload %s added to the upload queue" % result["upload_id"])
|
||||||
|
|
||||||
|
return rc
|
||||||
|
|
||||||
def compose_log(socket_path, api_version, args, show_json=False, testmode=0):
|
def compose_log(socket_path, api_version, args, show_json=False, testmode=0):
|
||||||
"""Show the last part of the compose log
|
"""Show the last part of the compose log
|
||||||
|
|
||||||
|
@ -20,6 +20,10 @@ compose start [--size XXXX] <BLUEPRINT> <TYPE> [<IMAGE-NAME> <PROVIDER> <PROFILE
|
|||||||
Start a compose using the selected blueprint and output type. --size is in MiB.
|
Start a compose using the selected blueprint and output type. --size is in MiB.
|
||||||
NOTE: uploading and --size are only supported by osbuild-composer.
|
NOTE: uploading and --size are only supported by osbuild-composer.
|
||||||
|
|
||||||
|
compose start-ostree [--size XXXX] <BLUEPRINT> <TYPE> <REF> <PARENT> [<IMAGE-NAME> <PROVIDER> <PROFILE> | <IMAGE-NAME> <PROFILE.TOML>]
|
||||||
|
Start an ostree compose using the selected blueprint and output type. Optionally start an upload. This command
|
||||||
|
is only supported by osbuild-composer, and requires the ostree REF and PARENT. --size is in MiB.
|
||||||
|
|
||||||
compose types
|
compose types
|
||||||
List the supported output types.
|
List the supported output types.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user