Skip to content

Commit

Permalink
add vm img support
Browse files Browse the repository at this point in the history
  • Loading branch information
yanksyoon committed Apr 23, 2024
1 parent afb1b84 commit 9986a3f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions pylxd/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 9986a3f

Please sign in to comment.