summaryrefslogtreecommitdiffstats
path: root/src/virtBootstrap/sources.py
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov1@gmail.com>2017-07-03 08:27:25 +0100
committerCédric Bosdonnat <cbosdonnat@suse.com>2017-07-04 09:06:23 +0200
commit970b4247bd9a39d36ade980967371e4d1bc3f893 (patch)
treed29a27d21fd1a4312557cc125a164db52f4c8dfb /src/virtBootstrap/sources.py
parent65ef323df230b770c56217367e9c019cffcb0a7d (diff)
downloadvirt-bootstrap.git-970b4247bd9a39d36ade980967371e4d1bc3f893.tar.gz
virt-bootstrap.git-970b4247bd9a39d36ade980967371e4d1bc3f893.tar.xz
virt-bootstrap.git-970b4247bd9a39d36ade980967371e4d1bc3f893.zip
bootstrap: Use explicit arguments
Specify explicitly the arguments of bootstrap method. This change allows to easily bootstrap a container from another python application when the module virtBootstrap is imported. Example: import virtBootstrap virtBootstrap.bootstrap(uri="docker://fedora", dest="/tmp/foo")
Diffstat (limited to 'src/virtBootstrap/sources.py')
-rw-r--r--src/virtBootstrap/sources.py23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/virtBootstrap/sources.py b/src/virtBootstrap/sources.py
index 617adc6..ab1091a 100644
--- a/src/virtBootstrap/sources.py
+++ b/src/virtBootstrap/sources.py
@@ -211,9 +211,9 @@ class FileSource(object):
"""
Extract root filesystem from file.
"""
- def __init__(self, url, args):
- self.path = url.path
- self.output_format = args.format
+ def __init__(self, **kwargs):
+ self.path = kwargs['uri'].path
+ self.output_format = kwargs['fmt']
def unpack(self, dest):
"""
@@ -249,7 +249,7 @@ class DockerSource(object):
Extract files from Docker image
"""
- def __init__(self, url, args):
+ def __init__(self, **kwargs):
"""
Bootstrap root filesystem from Docker registry
@@ -261,13 +261,14 @@ class DockerSource(object):
@param no_cache: Whether to store downloaded images or not
"""
- self.registry = url.netloc
- self.image = url.path
- self.username = args.username
- self.password = args.password
- self.output_format = args.format
- self.insecure = args.not_secure
- self.no_cache = args.no_cache
+ self.registry = kwargs['uri'].netloc
+ self.image = kwargs['uri'].path
+ self.username = kwargs['username']
+ self.password = kwargs['password']
+ self.output_format = kwargs['fmt']
+ self.insecure = kwargs['not_secure']
+ self.no_cache = kwargs['no_cache']
+
if not self.registry and self.image.startswith('/'):
self.image = self.image[1:]
elif self.image and not self.image.startswith('/'):