import click
+import subprocess
+import re
from lftools.openstack import image as os_image
from lftools.openstack import object as os_object
def upload(ctx, image, name, disk_format):
"""Upload image to OpenStack cloud."""
name = " ".join(name)
+
+ disktype = subprocess.check_output(["qemu-img", "info", image]).decode("utf-8")
+ pattern = disk_format
+ result = re.search(pattern, disktype)
+ if result:
+ print("PASS Image format matches {}".format(disk_format))
+ else:
+ print("ERROR Image is not in {} format".format(disk_format))
+ exit(1)
+
os_image.upload(ctx.obj["os_cloud"], image, name, disk_format)
--- /dev/null
+---
+upgrade:
+ - |
+ lftools image upload command:
+ NOTE: `qemu-img` is now required to be installed and on the path for image
+ uploading to work
+
+fixes:
+ - |
+ lftools image upload command:
+ Previously image was not verified to match the type of image specified
+ prior to upload. Image is now checked with `qemu-img` before upload to
+ ensure it is of the correct type.