This hook in the source allows additional cleanup to take place once
the run command is terminated. This is not used by the docker source,
but will be used by the virt-builder one
---
libvirt-sandbox/image/cli.py | 1 +
libvirt-sandbox/image/sources/Source.py | 12 ++++++++++++
2 files changed, 13 insertions(+)
diff --git a/libvirt-sandbox/image/cli.py b/libvirt-sandbox/image/cli.py
index 75daf72..e991e2d 100755
--- a/libvirt-sandbox/image/cli.py
+++ b/libvirt-sandbox/image/cli.py
@@ -142,6 +142,7 @@ def run(args):
cmd = cmd + params + ['--'] + commandToRun
subprocess.call(cmd)
os.unlink(diskfile)
+ source.post_run(tmpl, args.template_dir, name)
except Exception,e:
print "Run Error %s" % str(e)
diff --git a/libvirt-sandbox/image/sources/Source.py
b/libvirt-sandbox/image/sources/Source.py
index 33feb7c..20f4af0 100644
--- a/libvirt-sandbox/image/sources/Source.py
+++ b/libvirt-sandbox/image/sources/Source.py
@@ -102,3 +102,15 @@ class Source():
Get the dict of environment variables to set
"""
pass
+
+ def post_run(self, template, templatedir, imagename):
+ """
+ :param template: libvirt_sandbox.template.Template object
+ :param templatedir: local directory path in which to find template
+ :param imagename: name of the image that just stopped running
+
+ Hook called after the image has been stopped. By default is doesn't
+ do anything, subclasses can override this to do some additional
+ cleanup.
+ """
+ pass
--
2.1.4