[libvirt] [sandbox PATCH 10/11] Image: Add get_disk function to Source

Eren Yagdiran erenyagdiran at gmail.com
Thu Jul 23 15:57:36 UTC 2015


Provide a way to know which disk image to use for the sandbox depending on the used source
DockerSource will need to locate the topmost disk image among all the layers images
---
 virt-sandbox-image/sources/DockerSource.py | 9 +++++++++
 virt-sandbox-image/sources/Source.py       | 2 ++
 2 files changed, 11 insertions(+)

diff --git a/virt-sandbox-image/sources/DockerSource.py b/virt-sandbox-image/sources/DockerSource.py
index 4326624..01ef901 100644
--- a/virt-sandbox-image/sources/DockerSource.py
+++ b/virt-sandbox-image/sources/DockerSource.py
@@ -342,6 +342,15 @@ class DockerSource(Source):
                     parent = None
             imagetagid = parent
 
+    def get_disk(self,**args):
+        name = args['name']
+        destdir = args['path']
+        imageList = self.__get_image_list(name,destdir)
+        toplayer = imageList[0]
+        diskfile = destdir + "/" + toplayer + "/template.qcow2"
+        configfile = destdir + "/" + toplayer + "/template.json"
+        return (diskfile,configfile)
+
     def get_command(self,configfile):
         configParser = DockerConfParser(configfile)
         commandToRun = configParser.getRunCommand()
diff --git a/virt-sandbox-image/sources/Source.py b/virt-sandbox-image/sources/Source.py
index c4087ca..739de78 100644
--- a/virt-sandbox-image/sources/Source.py
+++ b/virt-sandbox-image/sources/Source.py
@@ -23,3 +23,5 @@ class Source():
     def get_command(self,**args):
       pass
 
+    def get_disk(self,**args):
+      pass
-- 
2.1.0




More information about the libvir-list mailing list