Provide a way to know how a template can be started depending on the used source
DockerSource will need to parse the topmost config file in order to find the igniter
command
---
virt-sandbox-image/sources/DockerSource.py | 14 ++++++++++++++
virt-sandbox-image/sources/Source.py | 4 ++++
2 files changed, 18 insertions(+)
diff --git a/virt-sandbox-image/sources/DockerSource.py
b/virt-sandbox-image/sources/DockerSource.py
index 760ba6c..3e0362b 100644
--- a/virt-sandbox-image/sources/DockerSource.py
+++ b/virt-sandbox-image/sources/DockerSource.py
@@ -29,6 +29,15 @@ import os
import subprocess
import shutil
+class DockerConfParser():
+
+ def __init__(self,jsonfile):
+ with open(jsonfile) as json_file:
+ self.json_data = json.load(json_file)
+ def getRunCommand(self):
+ cmd = self.json_data['container_config']['Cmd'][2]
+ return cmd[cmd.index('"') + 1:cmd.rindex('"')]
+
class DockerSource(Source):
www_auth_username = None
@@ -363,5 +372,10 @@ class DockerSource(Source):
parent = None
imagetagid = parent
+ def get_command(self,configfile):
+ configParser = DockerConfParser(configfile)
+ commandToRun = configParser.getRunCommand()
+ return commandToRun
+
def debug(msg):
sys.stderr.write(msg)
diff --git a/virt-sandbox-image/sources/Source.py b/virt-sandbox-image/sources/Source.py
index d66e61e..9daf62d 100644
--- a/virt-sandbox-image/sources/Source.py
+++ b/virt-sandbox-image/sources/Source.py
@@ -37,3 +37,7 @@ class Source():
@abstractmethod
def delete_template(self,**args):
pass
+
+ @abstractmethod
+ def get_command(self,**args):
+ pass
--
2.1.0