diff --git a/base/manifest-schema.json b/base/manifest-schema.json index 3a982c4..e66ef96 100644 --- a/base/manifest-schema.json +++ b/base/manifest-schema.json @@ -9,12 +9,12 @@ "bootstrapper": { "type": "object", "properties": { - "mount_dir": { "type": "string" }, + "workspace": { "type": "string" }, "mirror": { "type": "string" }, "tarball": { "type": "boolean" }, "tarball_dir": { "type": "string" } }, - "required": ["mount_dir"] + "required": ["workspace"] }, "system": { "type": "object", diff --git a/common/tasks/filesystem.py b/common/tasks/filesystem.py index f1d658e..82333b6 100644 --- a/common/tasks/filesystem.py +++ b/common/tasks/filesystem.py @@ -41,8 +41,8 @@ class CreateMountDir(Task): def run(self, info): import os - mount_dir = info.manifest.bootstrapper['mount_dir'] - info.root = '{mount_dir}/{id:x}'.format(mount_dir=mount_dir, id=info.run_id) + workspace = info.manifest.bootstrapper['workspace'] + info.root = '{workspace}/{id:x}'.format(workspace=workspace, id=info.run_id) # Works recursively, fails if last part exists, which is exactly what we want. os.makedirs(info.root) diff --git a/common/tasks/loopback.py b/common/tasks/loopback.py index 2db681c..81d6f10 100644 --- a/common/tasks/loopback.py +++ b/common/tasks/loopback.py @@ -13,3 +13,18 @@ class Create(Task): import os.path image_path = os.path.join(info.manifest.volume['loopback_dir'], loopback_filename) info.volume.create(image_path) + + +class MoveImage(Task): + description = 'Moving volume image' + phase = phases.image_registration + + def run(self, info): + import os.path + image_basename = os.path.basename(info.volume.image_path) + destination = os.path.join(info.manifest.bootstrapper['workspace'], image_basename) + import shutil + shutil.move(info.volume.image_path, destination) + import logging + log = logging.getLogger(__name__) + log.info('The volume image has been moved to {image_path}'.format(image_path=destination)) diff --git a/manifests/ec2-ebs-pvm.manifest.json b/manifests/ec2-ebs-pvm.manifest.json index fb0a704..d932077 100644 --- a/manifests/ec2-ebs-pvm.manifest.json +++ b/manifests/ec2-ebs-pvm.manifest.json @@ -7,7 +7,7 @@ }, "bootstrapper": { - "mount_dir": "/target", + "workspace": "/target", "mirror": "http://http.debian.net/debian" }, "image": { diff --git a/manifests/ec2-s3-pvm.manifest.json b/manifests/ec2-s3-pvm.manifest.json index 006de3b..9c8a5a5 100644 --- a/manifests/ec2-s3-pvm.manifest.json +++ b/manifests/ec2-s3-pvm.manifest.json @@ -10,7 +10,7 @@ }, "bootstrapper": { - "mount_dir": "/target", + "workspace": "/target", "mirror": "http://http.debian.net/debian" }, "image": { diff --git a/manifests/kvm-virtio.manifest.json b/manifests/kvm-virtio.manifest.json index c4b828a..d14a11d 100644 --- a/manifests/kvm-virtio.manifest.json +++ b/manifests/kvm-virtio.manifest.json @@ -3,7 +3,7 @@ "virtualization": "virtio", "bootstrapper": { - "mount_dir": "/mnt/target", + "workspace": "/mnt/target", "mirror" : "http://ftp.fr.debian.org/debian/" }, "image": { diff --git a/manifests/one-ide.manifest.json b/manifests/one-ide.manifest.json index 1593005..05264f4 100644 --- a/manifests/one-ide.manifest.json +++ b/manifests/one-ide.manifest.json @@ -3,7 +3,7 @@ "virtualization": "ide", "bootstrapper": { - "mount_dir": "/target" + "workspace": "/target" }, "image": { "name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}", diff --git a/manifests/one-virtio.manifest.json b/manifests/one-virtio.manifest.json index 62a81f8..930a16d 100644 --- a/manifests/one-virtio.manifest.json +++ b/manifests/one-virtio.manifest.json @@ -3,7 +3,7 @@ "virtualization": "virtio", "bootstrapper": { - "mount_dir": "/target" + "workspace": "/target" }, "image": { "name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}", diff --git a/manifests/virtualbox.manifest.json b/manifests/virtualbox.manifest.json index 1b0ab6a..b376127 100644 --- a/manifests/virtualbox.manifest.json +++ b/manifests/virtualbox.manifest.json @@ -3,7 +3,7 @@ "virtualization": "ide", "bootstrapper": { - "mount_dir": "/mnt/target", + "workspace": "/mnt/target", "mirror": "http://http.debian.net/debian/" }, "image": { diff --git a/plugins/convert_image/tasks.py b/plugins/convert_image/tasks.py index c547417..c573d08 100644 --- a/plugins/convert_image/tasks.py +++ b/plugins/convert_image/tasks.py @@ -1,10 +1,12 @@ from base import Task from common import phases +from common.tasks import loopback class ConvertImage(Task): description = 'Converting raw image' phase = phases.image_registration + before = [loopback.MoveImage] def run(self, info): from common.tools import log_check_call diff --git a/providers/virtualbox/__init__.py b/providers/virtualbox/__init__.py index c6382ae..b5a0fce 100644 --- a/providers/virtualbox/__init__.py +++ b/providers/virtualbox/__init__.py @@ -67,7 +67,7 @@ def tasks(tasklist, manifest): partitioning.UnmapPartitions(), volume_tasks.Detach(), filesystem.DeleteMountDir(), - volume_tasks.Delete()) + loopback.MoveImage()) if manifest.bootstrapper['tarball']: tasklist.add(bootstrap.MakeTarball())