Filesystem tasks

This commit is contained in:
Anders Ingemann 2013-06-27 00:11:09 +02:00
parent ba461a815c
commit 1214210738
3 changed files with 58 additions and 1 deletions

View file

@ -3,6 +3,7 @@ from tasks import packages
from tasks import connection
from tasks import host
from tasks import ebs
from tasks import filesystem
def tasks(tasklist, manifest):
@ -10,6 +11,12 @@ def tasks(tasklist, manifest):
connection.GetCredentials(), host.GetInfo(), connection.Connect())
if manifest.volume['backing'].lower() == 'ebs':
tasklist.add(ebs.CreateVolume(), ebs.AttachVolume())
tasklist.add(filesystem.FormatVolume())
if manifest.volume['filesystem'].lower() == 'xfs':
tasklist.add(filesystem.AddXFSProgs())
import re
if re.search('ext.', manifest.volume['filesystem'].lower()):
tasklist.add(filesystem.TuneVolumeFS())
from common.tasks import TriggerRollback
tasklist.add(TriggerRollback())

View file

@ -12,9 +12,13 @@
"backing": {
"type": "string",
"enum": ["ebs", "s3"]
},
"filesystem": {
"type": "string",
"enum": ["ext2", "ext3", "ext4", "xfs"]
}
},
"required": ["backing"]
"required": ["backing", "filesystem"]
}
},
"required": ["bootstrapdir", "volume"]

View file

@ -0,0 +1,46 @@
from base import Task
from common import phases
from common.exceptions import TaskError
class FormatVolume(Task):
description = 'Formatting the volume'
phase = phases.volume_preparation
after = []
def run(self, info):
import subprocess
from os import devnull
dev_path = info.bootstrap_device['path']
mkfs = '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem'])
try:
with open(devnull, 'w') as dev_null:
subprocess.check_call([mkfs, dev_path], stdout=dev_null, stderr=dev_null)
except subprocess.CalledProcessError:
raise TaskError('Unable to format the bootstrap device')
class TuneVolumeFS(Task):
description = 'Tuning the bootstrap volume filesystem'
phase = phases.volume_preparation
after = [FormatVolume]
def run(self, info):
import subprocess
from os import devnull
dev_path = info.bootstrap_device['path']
try:
with open(devnull, 'w') as dev_null:
subprocess.check_call(['/sbin/tune2fs', '-i', '0', dev_path], stdout=dev_null, stderr=dev_null)
except subprocess.CalledProcessError:
raise TaskError('Unable to disable the time based check interval for the bootstrap volume')
class AddXFSProgs(Task):
description = 'Adding `xfsprogs\' to the image packages'
phase = phases.preparation
after = []
def run(self, info):
include, exclude = info.img_packages
include.add('xfsprogs')