image-info: show format version for qcow2

Change the "image-format" from a string to a dict, with a "type":
$value entry, where $value contains the previous plain string
data.
Additionally, include the qcow2 format version, if the given
image is indeed a qcow2.
Adapt all manifest test accordingly (partly done by Ondřej)

Python 3 script used for conversion of manifest tests:
import os
import json

for name in os.listdir(os.getcwd()):
    if not name.endswith(".json"):
        continue
    print(name)
    with open(name, "r") as old:
        data = json.load(old)
        info = data.get("image-info", {})
        format = info.get("image-format")
        if not format:
            continue
        info["image-format"] = {
            "type": format
        }
        if format != "qcow2":
            continue
        info["image-format"]["compat"] = "1.1"
        with open(name + ".new", "w") as new:
            json.dump(data, new, indent=2)
            new.write("\n")
            new.flush()
    os.rename(name+".new", name)

test: use the new image-info format in all test manifests

The previous commit converted only qcow2 and openstack manifests but this change
is actually needed for all manifests produced by the qemu assembler.

Co-Developed-by: Ondřej Budai <ondrej@budai.cz>
This commit is contained in:
Christian Kellner 2021-04-07 17:35:25 +00:00 committed by Ondřej Budai
parent 41fdfbd168
commit 5937b9adca
49 changed files with 179 additions and 50 deletions

View file

@ -10329,7 +10329,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -11038,7 +11038,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -11030,7 +11030,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -11124,7 +11124,10 @@
"wheel:x:10:"
],
"hostname": "my-host",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",
@ -11770,4 +11773,4 @@
},
"timezone": "London"
}
}
}

View file

@ -10952,7 +10952,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10540,7 +10540,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "vmdk",
"image-format": {
"type": "vmdk"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8957,7 +8957,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9311,7 +9311,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8811,7 +8811,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9207,7 +9207,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9561,7 +9561,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9197,7 +9197,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9312,7 +9312,10 @@
"wheel:x:10:"
],
"hostname": "my-host",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8809,7 +8809,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8915,7 +8915,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "vmdk",
"image-format": {
"type": "vmdk"
},
"os-release": {
"ANSI_COLOR": "0;34",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9878,7 +9878,9 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9449,7 +9449,9 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9768,7 +9768,10 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9389,7 +9389,10 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9492,7 +9492,10 @@
"wheel:x:10:"
],
"hostname": "my-host",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9051,7 +9051,9 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9389,7 +9389,9 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "vmdk",
"image-format": {
"type": "vmdk"
},
"os-release": {
"ANSI_COLOR": "0;38;2;60;110;180",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8569,7 +8569,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9138,7 +9138,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9594,7 +9594,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10324,7 +10324,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10204,7 +10204,10 @@
"wheel:x:10:",
"zkeyadm:x:996:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8557,7 +8557,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9141,7 +9141,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9567,7 +9567,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9696,7 +9696,10 @@
"wheel:x:10:"
],
"hostname": "my-host",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9050,7 +9050,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8693,7 +8693,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "vmdk",
"image-format": {
"type": "vmdk"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -8981,7 +8981,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9550,7 +9550,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9472,7 +9472,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10199,7 +10199,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10131,7 +10131,10 @@
"wheel:x:10:",
"zkeyadm:x:996:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9149,7 +9149,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9733,7 +9733,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9610,7 +9610,10 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9706,7 +9706,10 @@
"wheel:x:10:"
],
"hostname": "my-host",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9657,7 +9657,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "raw",
"image-format": {
"type": "raw"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9308,7 +9308,9 @@
"video:x:39:",
"wheel:x:10:"
],
"image-format": "vmdk",
"image-format": {
"type": "vmdk"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9569,7 +9569,10 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -10320,7 +10320,10 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9775,7 +9775,10 @@
"zkeyadm:x:987:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -9706,7 +9706,10 @@
"wheel:x:10:"
],
"hostname": "localhost.localdomain",
"image-format": "qcow2",
"image-format": {
"type": "qcow2",
"compat": "1.1"
},
"os-release": {
"ANSI_COLOR": "0;31",
"BUG_REPORT_URL": "https://bugzilla.redhat.com/",

View file

@ -152,7 +152,11 @@ def subprocess_check_output(argv, parse_fn=None):
def read_image_format(device):
qemu = subprocess_check_output(["qemu-img", "info", "--output=json", device], json.loads)
return qemu["format"]
format = qemu["format"]
result = {"type": format}
if format == "qcow2":
result["compat"] = qemu["format-specific"]["data"]["compat"]
return result
def read_partition(device, partition):