MoveImage task now uses image.name from manifest

This commit is contained in:
Anders Ingemann 2013-12-28 13:52:48 +01:00
parent 1e0aa634d2
commit 91cff897c8

View file

@ -19,8 +19,20 @@ class MoveImage(Task):
phase = phases.image_registration phase = phases.image_registration
def run(self, info): def run(self, info):
manifest_vars = {'release': info.manifest.system['release'],
'architecture': info.manifest.system['architecture']}
from datetime import datetime
now = datetime.now()
time_vars = ['%a', '%A', '%b', '%B', '%c', '%d', '%f', '%H',
'%I', '%j', '%m', '%M', '%p', '%S', '%U', '%w',
'%W', '%x', '%X', '%y', '%Y', '%z', '%Z']
for var in time_vars:
manifest_vars[var] = now.strftime(var)
image_name = info.manifest.image['name'].format(**manifest_vars)
filename = '{image_name}.{ext}'.format(image_name=image_name, ext=info.volume.extension)
import os.path import os.path
filename = 'volume-{id:x}.{ext}'.format(id=info.run_id, ext=info.volume.extension)
destination = os.path.join(info.manifest.bootstrapper['workspace'], filename) destination = os.path.join(info.manifest.bootstrapper['workspace'], filename)
import shutil import shutil
shutil.move(info.volume.image_path, destination) shutil.move(info.volume.image_path, destination)