Changes 'MoveImage' from loopback to image

This commit is contained in:
Tiago Ilieve 2015-10-16 00:41:53 -03:00 committed by Tiago Ilieve
parent 10742f8ca3
commit 3d3c303ee1
8 changed files with 39 additions and 33 deletions

View file

@ -0,0 +1,21 @@
from bootstrapvz.base import Task
from bootstrapvz.common import phases
class MoveImage(Task):
description = 'Moving volume image'
phase = phases.image_registration
@classmethod
def run(cls, info):
image_name = info.manifest.image['name'].format(**info.manifest_vars)
filename = image_name + '.' + info.volume.extension
import os.path
destination = os.path.join(info.manifest.bootstrapper['workspace'], filename)
import shutil
shutil.move(info.volume.image_path, destination)
info.volume.image_path = destination
import logging
log = logging.getLogger(__name__)
log.info('The volume image has been moved to ' + destination)

View file

@ -1,5 +1,5 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from .. import phases from bootstrapvz.common import phases
import host import host
import volume import volume
@ -30,22 +30,3 @@ class Create(Task):
import os.path import os.path
image_path = os.path.join(info.workspace, 'volume.' + info.volume.extension) image_path = os.path.join(info.workspace, 'volume.' + info.volume.extension)
info.volume.create(image_path) info.volume.create(image_path)
class MoveImage(Task):
description = 'Moving volume image'
phase = phases.image_registration
@classmethod
def run(cls, info):
image_name = info.manifest.image['name'].format(**info.manifest_vars)
filename = image_name + '.' + info.volume.extension
import os.path
destination = os.path.join(info.manifest.bootstrapper['workspace'], filename)
import shutil
shutil.move(info.volume.image_path, destination)
info.volume.image_path = destination
import logging
log = logging.getLogger(__name__)
log.info('The volume image has been moved to ' + destination)

View file

@ -1,22 +1,22 @@
import tasks import tasks
from bootstrapvz.common import task_groups
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import ssh
from bootstrapvz.common.tasks import volume
import os
def validate_manifest(data, validator, error): def validate_manifest(data, validator, error):
import os.path
schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml')) schema_path = os.path.normpath(os.path.join(os.path.dirname(__file__), 'manifest-schema.yml'))
validator(data, schema_path) validator(data, schema_path)
def resolve_tasks(taskset, manifest): def resolve_tasks(taskset, manifest):
from bootstrapvz.common import task_groups
from bootstrapvz.common.tasks import ssh
taskset.update(task_groups.ssh_group) taskset.update(task_groups.ssh_group)
taskset.discard(image.MoveImage)
taskset.discard(ssh.DisableSSHPasswordAuthentication) taskset.discard(ssh.DisableSSHPasswordAuthentication)
from bootstrapvz.common.tasks import loopback
taskset.discard(loopback.MoveImage)
from bootstrapvz.common.tasks import volume
taskset.update([tasks.CheckBoxPath, taskset.update([tasks.CheckBoxPath,
tasks.CreateVagrantBoxDir, tasks.CreateVagrantBoxDir,
tasks.AddPackages, tasks.AddPackages,

View file

@ -1,6 +1,7 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages import tasks.packages
import tasks.boot import tasks.boot
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import initd
from bootstrapvz.common.tasks import ssh from bootstrapvz.common.tasks import ssh
@ -19,7 +20,7 @@ def resolve_tasks(taskset, manifest):
tasks.packages.DefaultPackages, tasks.packages.DefaultPackages,
loopback.AddRequiredCommands, loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
loopback.MoveImage, image.MoveImage,
initd.InstallInitScripts, initd.InstallInitScripts,
ssh.AddOpenSSHPackage, ssh.AddOpenSSHPackage,
ssh.ShredHostkeys, ssh.ShredHostkeys,

View file

@ -8,6 +8,7 @@ import tasks.host
import tasks.packages import tasks.packages
from bootstrapvz.common.tasks import apt from bootstrapvz.common.tasks import apt
from bootstrapvz.common.tasks import boot from bootstrapvz.common.tasks import boot
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import initd
from bootstrapvz.common.tasks import kernel from bootstrapvz.common.tasks import kernel
@ -47,7 +48,7 @@ def resolve_tasks(taskset, manifest):
ssh.DisableSSHPasswordAuthentication, ssh.DisableSSHPasswordAuthentication,
tasks.apt.CleanGoogleRepositoriesAndKeys, tasks.apt.CleanGoogleRepositoriesAndKeys,
loopback.MoveImage, image.MoveImage,
tasks.image.CreateTarball, tasks.image.CreateTarball,
volume.Delete, volume.Delete,
]) ])

View file

@ -1,6 +1,6 @@
from bootstrapvz.base import Task from bootstrapvz.base import Task
from bootstrapvz.common import phases from bootstrapvz.common import phases
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import image
from bootstrapvz.common.tools import log_check_call from bootstrapvz.common.tools import log_check_call
import os.path import os.path
@ -8,7 +8,7 @@ import os.path
class CreateTarball(Task): class CreateTarball(Task):
description = 'Creating tarball with image' description = 'Creating tarball with image'
phase = phases.image_registration phase = phases.image_registration
predecessors = [loopback.MoveImage] predecessors = [image.MoveImage]
@classmethod @classmethod
def run(cls, info): def run(cls, info):

View file

@ -1,5 +1,6 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages import tasks.packages
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
from bootstrapvz.common.tasks import initd from bootstrapvz.common.tasks import initd
from bootstrapvz.common.tasks import ssh from bootstrapvz.common.tasks import ssh
@ -21,7 +22,7 @@ def resolve_tasks(taskset, manifest):
ssh.AddOpenSSHPackage, ssh.AddOpenSSHPackage,
ssh.ShredHostkeys, ssh.ShredHostkeys,
ssh.AddSSHKeyGeneration, ssh.AddSSHKeyGeneration,
loopback.MoveImage, image.MoveImage,
]) ])
if manifest.provider.get('virtio', []): if manifest.provider.get('virtio', []):

View file

@ -1,5 +1,6 @@
from bootstrapvz.common import task_groups from bootstrapvz.common import task_groups
import tasks.packages import tasks.packages
from bootstrapvz.common.tasks import image
from bootstrapvz.common.tasks import loopback from bootstrapvz.common.tasks import loopback
@ -15,7 +16,7 @@ def resolve_tasks(taskset, manifest):
taskset.update([tasks.packages.DefaultPackages, taskset.update([tasks.packages.DefaultPackages,
loopback.AddRequiredCommands, loopback.AddRequiredCommands,
loopback.Create, loopback.Create,
loopback.MoveImage, image.MoveImage,
]) ])
if manifest.provider.get('guest_additions', False): if manifest.provider.get('guest_additions', False):