Rename mount_dir to workspace

We'll be using it for a bucnh of different things in the future
This commit is contained in:
Anders Ingemann 2013-09-15 16:11:45 +02:00
parent ff7c04c120
commit 9cb4b3e375
11 changed files with 28 additions and 11 deletions

View file

@ -9,12 +9,12 @@
"bootstrapper": { "bootstrapper": {
"type": "object", "type": "object",
"properties": { "properties": {
"mount_dir": { "type": "string" }, "workspace": { "type": "string" },
"mirror": { "type": "string" }, "mirror": { "type": "string" },
"tarball": { "type": "boolean" }, "tarball": { "type": "boolean" },
"tarball_dir": { "type": "string" } "tarball_dir": { "type": "string" }
}, },
"required": ["mount_dir"] "required": ["workspace"]
}, },
"system": { "system": {
"type": "object", "type": "object",

View file

@ -41,8 +41,8 @@ class CreateMountDir(Task):
def run(self, info): def run(self, info):
import os import os
mount_dir = info.manifest.bootstrapper['mount_dir'] workspace = info.manifest.bootstrapper['workspace']
info.root = '{mount_dir}/{id:x}'.format(mount_dir=mount_dir, id=info.run_id) 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. # Works recursively, fails if last part exists, which is exactly what we want.
os.makedirs(info.root) os.makedirs(info.root)

View file

@ -13,3 +13,18 @@ class Create(Task):
import os.path import os.path
image_path = os.path.join(info.manifest.volume['loopback_dir'], loopback_filename) image_path = os.path.join(info.manifest.volume['loopback_dir'], loopback_filename)
info.volume.create(image_path) 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))

View file

@ -7,7 +7,7 @@
}, },
"bootstrapper": { "bootstrapper": {
"mount_dir": "/target", "workspace": "/target",
"mirror": "http://http.debian.net/debian" "mirror": "http://http.debian.net/debian"
}, },
"image": { "image": {

View file

@ -10,7 +10,7 @@
}, },
"bootstrapper": { "bootstrapper": {
"mount_dir": "/target", "workspace": "/target",
"mirror": "http://http.debian.net/debian" "mirror": "http://http.debian.net/debian"
}, },
"image": { "image": {

View file

@ -3,7 +3,7 @@
"virtualization": "virtio", "virtualization": "virtio",
"bootstrapper": { "bootstrapper": {
"mount_dir": "/mnt/target", "workspace": "/mnt/target",
"mirror" : "http://ftp.fr.debian.org/debian/" "mirror" : "http://ftp.fr.debian.org/debian/"
}, },
"image": { "image": {

View file

@ -3,7 +3,7 @@
"virtualization": "ide", "virtualization": "ide",
"bootstrapper": { "bootstrapper": {
"mount_dir": "/target" "workspace": "/target"
}, },
"image": { "image": {
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}", "name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",

View file

@ -3,7 +3,7 @@
"virtualization": "virtio", "virtualization": "virtio",
"bootstrapper": { "bootstrapper": {
"mount_dir": "/target" "workspace": "/target"
}, },
"image": { "image": {
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}", "name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",

View file

@ -3,7 +3,7 @@
"virtualization": "ide", "virtualization": "ide",
"bootstrapper": { "bootstrapper": {
"mount_dir": "/mnt/target", "workspace": "/mnt/target",
"mirror": "http://http.debian.net/debian/" "mirror": "http://http.debian.net/debian/"
}, },
"image": { "image": {

View file

@ -1,10 +1,12 @@
from base import Task from base import Task
from common import phases from common import phases
from common.tasks import loopback
class ConvertImage(Task): class ConvertImage(Task):
description = 'Converting raw image' description = 'Converting raw image'
phase = phases.image_registration phase = phases.image_registration
before = [loopback.MoveImage]
def run(self, info): def run(self, info):
from common.tools import log_check_call from common.tools import log_check_call

View file

@ -67,7 +67,7 @@ def tasks(tasklist, manifest):
partitioning.UnmapPartitions(), partitioning.UnmapPartitions(),
volume_tasks.Detach(), volume_tasks.Detach(),
filesystem.DeleteMountDir(), filesystem.DeleteMountDir(),
volume_tasks.Delete()) loopback.MoveImage())
if manifest.bootstrapper['tarball']: if manifest.bootstrapper['tarball']:
tasklist.add(bootstrap.MakeTarball()) tasklist.add(bootstrap.MakeTarball())