Re: [sandbox PATCH v2 19/19] Image: Add custom environment support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 04, 2015 at 08:11:25PM +0000, Eren Yagdiran wrote:
> Any custom key=value pair can be used as a custom environment variable
> in virt-sandbox-image.
> e.g virt-sandbox-image run ubuntu /var/lib/libvirt/templates -c lxc:/// -i /bin/bash -e key1=val1
> ---
>  virt-sandbox-image/sources/DockerSource.py | 10 ++++++++++
>  virt-sandbox-image/sources/Source.py       |  4 ++++
>  virt-sandbox-image/virt-sandbox-image.py   | 19 +++++++++++++++++++
>  3 files changed, 33 insertions(+)
> 
> diff --git a/virt-sandbox-image/sources/DockerSource.py b/virt-sandbox-image/sources/DockerSource.py
> index 44bc238..54b68b9 100644
> --- a/virt-sandbox-image/sources/DockerSource.py
> +++ b/virt-sandbox-image/sources/DockerSource.py
> @@ -48,6 +48,12 @@ class DockerConfParser():
>            for key,value in volumes.iteritems():
>              volumelist.append(key)
>          return volumelist
> +    def getEnvs(self):
> +        lst = self.json_data['container_config']['Env']
> +        if lst is not None and isinstance(lst,list):
> +          return lst
> +        else:
> +          return []
>  
>  class DockerSource(Source):
>      default_index_server = "index.docker.io"
> @@ -411,5 +417,9 @@ class DockerSource(Source):
>          configParser = DockerConfParser(configfile)
>          return configParser.getVolumes()
>  
> +    def get_environment(self,configfile):
> +        configParser = DockerConfParser(configfile)
> +        return configParser.getEnvs()
> +
>  def debug(msg):
>      sys.stderr.write(msg)
> diff --git a/virt-sandbox-image/sources/Source.py b/virt-sandbox-image/sources/Source.py
> index 6898c15..ad82986 100644
> --- a/virt-sandbox-image/sources/Source.py
> +++ b/virt-sandbox-image/sources/Source.py
> @@ -53,3 +53,7 @@ class Source():
>      @abstractmethod
>      def get_volume(self,**args):
>        pass
> +
> +    @abstractmethod
> +    def get_env(self,**args):

Here you call it 'get_env' but in the DockerSource you call
it 'get_environment'. This causes python to immediately exit
saying that DockerSource doens't implement the API defined
by Source.


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 :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]