[lxc-devel] [pylxd/master] Allow wait argument to be True/False in create_from_simplestreams and create_from_url
e1ee1e11 on Github
lxc-bot at linuxcontainers.org
Wed Jul 25 03:23:26 UTC 2018
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 922 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20180725/4b73b334/attachment.bin>
-------------- next part --------------
From 410bbef2c72f1b2a4600c4519ed766fc2684a412 Mon Sep 17 00:00:00 2001
From: e1ee1e11 <e1ee1e11e1ee at gmail.com>
Date: Tue, 24 Jul 2018 18:23:13 +0800
Subject: [PATCH] Allow wait argument to be True/False in
create_from_simplestreams and create_from_url
Signed-off-by: e1ee1e11 <e1ee1e11e1ee at gmail.com>
---
doc/source/images.rst | 4 ++--
pylxd/models/image.py | 14 ++++++++------
2 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/doc/source/images.rst b/doc/source/images.rst
index 0011d65..09781a2 100644
--- a/doc/source/images.rst
+++ b/doc/source/images.rst
@@ -22,9 +22,9 @@ image:
- `create(data, public=False, wait=True)` - Create a new image. The first
argument is the binary data of the image itself. If the image is public,
set `public` to `True`.
- - `create_from_simplestreams(server, alias, public=False, auto_update=False, wait=False)` -
+ - `create_from_simplestreams(server, alias, public=False, auto_update=False, wait=True)` -
Create an image from simplestreams.
- - `create_from_url(url, public=False, auto_update=False, wait=False)` -
+ - `create_from_url(url, public=False, auto_update=False, wait=True)` -
Create an image from a url.
Image attributes
diff --git a/pylxd/models/image.py b/pylxd/models/image.py
index c335d34..fa775cc 100644
--- a/pylxd/models/image.py
+++ b/pylxd/models/image.py
@@ -137,7 +137,7 @@ def create(
@classmethod
def create_from_simplestreams(cls, client, server, alias,
- public=False, auto_update=False):
+ public=False, auto_update=False, wait=True):
"""Copy an image from simplestreams."""
config = {
'public': public,
@@ -152,13 +152,14 @@ def create_from_simplestreams(cls, client, server, alias,
}
}
- op = _image_create_from_config(client, config, wait=True)
+ op = _image_create_from_config(client, config, wait)
- return client.images.get(op.metadata['fingerprint'])
+ if wait:
+ return client.images.get(op.metadata['fingerprint'])
@classmethod
def create_from_url(cls, client, url,
- public=False, auto_update=False):
+ public=False, auto_update=False, wait=True):
"""Copy an image from an url."""
config = {
'public': public,
@@ -171,9 +172,10 @@ def create_from_url(cls, client, url,
}
}
- op = _image_create_from_config(client, config, wait=True)
+ op = _image_create_from_config(client, config, wait)
- return client.images.get(op.metadata['fingerprint'])
+ if wait:
+ return client.images.get(op.metadata['fingerprint'])
def export(self):
"""Export the image.
More information about the lxc-devel
mailing list