[libvirt] [sandbox PATCH v2 04/19] Image: Add download function
Daniel P. Berrange
berrange at redhat.com
Mon Aug 10 16:25:57 UTC 2015
On Tue, Aug 04, 2015 at 08:11:10PM +0000, Eren Yagdiran wrote:
> Refactor download function from virt-sandbox-image to use
> the newly introduced Source abstract class. The docker-specific
> download code is moved to a new DockerSource class.
> ---
> virt-sandbox-image/Makefile.am | 1 +
> virt-sandbox-image/sources/DockerSource.py | 227 +++++++++++++++++++++++++++++
> virt-sandbox-image/sources/Source.py | 4 +
> virt-sandbox-image/virt-sandbox-image.py | 199 ++++---------------------
> 4 files changed, 259 insertions(+), 172 deletions(-)
> create mode 100644 virt-sandbox-image/sources/DockerSource.py
>
> diff --git a/virt-sandbox-image/sources/DockerSource.py b/virt-sandbox-image/sources/DockerSource.py
> new file mode 100644
> index 0000000..cf81ffe
> --- /dev/null
> +++ b/virt-sandbox-image/sources/DockerSource.py
> @@ -0,0 +1,227 @@
> +'''
> +*
> +* libvirt-sandbox-config-diskaccess.h: libvirt sandbox configuration
> +*
> +* Copyright (C) 2015 Universitat Politècnica de Catalunya.
> +*
> +* This library is free software; you can redistribute it and/or
> +* modify it under the terms of the GNU Lesser General Public
> +* License as published by the Free Software Foundation; either
> +* version 2.1 of the License, or (at your option) any later version.
> +*
> +* This library is distributed in the hope that it will be useful,
> +* but WITHOUT ANY WARRANTY; without even the implied warranty of
> +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +* Lesser General Public License for more details.
> +*
> +* You should have received a copy of the GNU Lesser General Public
> +* License along with this library; if not, write to the Free Software
> +* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> +*
> +* Author: Eren Yagdiran <erenyagdiran at gmail.com>
> +*
> +'''
> +#!/usr/bin/python
Same points here about comment syntax, etc
> +
> +from Source import Source
> +import urllib2
> +import sys
> +import json
> +import traceback
> +import os
> +import subprocess
> +import shutil
> +
> +class DockerSource(Source):
> + default_index_server = "index.docker.io"
> + default_template_dir = "/var/lib/libvirt/templates"
> + default_image_path = "/var/lib/libvirt/templates"
> + default_disk_format = "qcow2"
> +
> + www_auth_username = None
> + www_auth_password = None
> +
> + def __init__(self,server="index.docker.io",destdir="/var/lib/libvirt/templates"):
> + self.default_index_server = server
> + self.default_template_dir = destdir
> +
> + def _check_cert_validate(self):
> + major = sys.version_info.major
> + SSL_WARNING = "SSL certificates couldn't be validated by default. You need to have 2.7.9/3.4.3 or higher"
> + SSL_WARNING +="\nSee https://bugs.python.org/issue22417"
> + py2_7_9_hexversion = 34015728
> + py3_4_3_hexversion = 50594800
> + if (major == 2 and sys.hexversion < py2_7_9_hexversion) or (major == 3 and sys.hexversion < py3_4_3_hexversion):
> + print SSL_WARNING
Should print this to stderr, rather than stdout.
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list