From 501b336d0e342d6755838bc4d560cb6cbec78a59 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sun, 7 Jul 2013 13:02:04 +0200 Subject: [PATCH] Move ModifyFSTab task to filesystem --- providers/ec2/__init__.py | 2 +- providers/ec2/tasks/boot.py | 17 ----------------- providers/ec2/tasks/filesystem.py | 18 ++++++++++++++++++ 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/providers/ec2/__init__.py b/providers/ec2/__init__.py index d0c16ee..4caecde 100644 --- a/providers/ec2/__init__.py +++ b/providers/ec2/__init__.py @@ -43,7 +43,7 @@ def tasks(tasklist, manifest): apt.AptSources(), apt.AptUpgrade(), boot.ConfigureGrub(), - boot.ModifyFstab(), + filesystem.ModifyFstab(), boot.BlackListModules(), boot.DisableGetTTYs(), security.EnableShadowConfig(), diff --git a/providers/ec2/tasks/boot.py b/providers/ec2/tasks/boot.py index 0d221aa..a489268 100644 --- a/providers/ec2/tasks/boot.py +++ b/providers/ec2/tasks/boot.py @@ -35,23 +35,6 @@ class ConfigureGrub(Task): log_check_call(['chroot', info.root, 'ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst']) -class ModifyFstab(Task): - description = 'Adding root volume to the fstab' - phase = phases.system_modification - - def run(self, info): - mount_opts = ['defaults'] - if info.manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']: - mount_opts.append('barrier=0') - if info.manifest.volume['filesystem'].lower() == 'xfs': - mount_opts.append('nobarrier') - fstab_path = os.path.join(info.root, 'etc/fstab') - with open(fstab_path, 'a') as fstab: - fstab.write(('/dev/xvda1 / {filesystem} {mount_opts} 1 1' - .format(filesystem=info.manifest.volume['filesystem'].lower(), - mount_opts=','.join(mount_opts)))) - - class BlackListModules(Task): description = 'Blacklisting kernel modules' phase = phases.system_modification diff --git a/providers/ec2/tasks/filesystem.py b/providers/ec2/tasks/filesystem.py index 6697d52..c9f5284 100644 --- a/providers/ec2/tasks/filesystem.py +++ b/providers/ec2/tasks/filesystem.py @@ -105,3 +105,21 @@ class DeleteMountDir(Task): import os os.rmdir(info.root) del info.root + + +class ModifyFstab(Task): + description = 'Adding root volume to the fstab' + phase = phases.system_modification + + def run(self, info): + import os.path + mount_opts = ['defaults'] + if info.manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']: + mount_opts.append('barrier=0') + if info.manifest.volume['filesystem'].lower() == 'xfs': + mount_opts.append('nobarrier') + fstab_path = os.path.join(info.root, 'etc/fstab') + with open(fstab_path, 'a') as fstab: + fstab.write(('/dev/xvda1 / {filesystem} {mount_opts} 1 1' + .format(filesystem=info.manifest.volume['filesystem'].lower(), + mount_opts=','.join(mount_opts))))