diff --git a/pylxd/models/image.py b/pylxd/models/image.py index 2fc486ee..6673b5eb 100644 --- a/pylxd/models/image.py +++ b/pylxd/models/image.py @@ -98,7 +98,7 @@ def all(cls, client): return images @classmethod - def create(cls, client, image_data, metadata=None, public=False, wait=True): + def create(cls, client, image_data, metadata=None, public=False, wait=True, vm=False): """Create an image. If metadata is provided, a multipart form data request is formed to @@ -123,10 +123,17 @@ def create(cls, client, image_data, metadata=None, public=False, wait=True): # Image uploaded as chunked/stream (metadata, rootfs) # multipart message. # Order of parts is important metadata should be passed first - files = collections.OrderedDict( - metadata=("metadata", metadata, "application/octet-stream"), - rootfs=("rootfs", image_data, "application/octet-stream"), - ) + files: collections.OrderedDict + if not vm: + files = collections.OrderedDict( + metadata=("metadata", metadata, "application/octet-stream"), + rootfs=("rootfs", image_data, "application/octet-stream"), + ) + else: + files = collections.OrderedDict({ + "metadata":("metadata", metadata, "application/octet-stream"), + "rootfs.img":("rootfs.img", image_data, "application/octet-stream"), + }) data = MultipartEncoder(files) headers.update({"Content-Type": data.content_type}) else: