2013-07-13 15:10:04 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
2013-09-15 13:19:45 +02:00
|
|
|
import volume
|
2013-07-13 15:10:04 +02:00
|
|
|
|
|
|
|
|
|
|
|
class Create(Task):
|
|
|
|
description = 'Creating a loopback volume'
|
|
|
|
phase = phases.volume_creation
|
2013-11-21 15:54:42 +01:00
|
|
|
successors = [volume.Attach]
|
2013-07-13 15:10:04 +02:00
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-07-13 15:10:04 +02:00
|
|
|
import os.path
|
2013-09-15 16:59:56 +02:00
|
|
|
image_path = os.path.join(info.workspace, 'volume.{ext}'.format(ext=info.volume.extension))
|
2013-09-15 13:19:45 +02:00
|
|
|
info.volume.create(image_path)
|
2013-09-15 16:11:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class MoveImage(Task):
|
|
|
|
description = 'Moving volume image'
|
|
|
|
phase = phases.image_registration
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-12-29 16:48:55 +01:00
|
|
|
image_name = info.manifest.image['name'].format(**info.manifest_vars)
|
2013-12-28 13:52:48 +01:00
|
|
|
filename = '{image_name}.{ext}'.format(image_name=image_name, ext=info.volume.extension)
|
|
|
|
|
2013-09-15 16:11:45 +02:00
|
|
|
import os.path
|
2013-09-15 18:53:03 +02:00
|
|
|
destination = os.path.join(info.manifest.bootstrapper['workspace'], filename)
|
2013-09-15 16:11:45 +02:00
|
|
|
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))
|