Skip to content

Commit

Permalink
Merge pull request #577 from yanksyoon/main
Browse files Browse the repository at this point in the history
feat: add vm img support
  • Loading branch information
simondeziel authored Apr 23, 2024
2 parents afb1b84 + 3847fcc commit a83c322
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions pylxd/models/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ 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 +125,23 @@ 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 a83c322

Please sign in to comment.