add ModifyFstab

This commit is contained in:
Anders Ingemann 2013-07-01 23:25:11 +02:00
parent c187cf6c13
commit 8fb605e8f2
3 changed files with 26 additions and 9 deletions

View file

@ -29,8 +29,7 @@ def tasks(tasklist, manifest):
tasklist.add(filesystem.FormatVolume())
if manifest.volume['filesystem'].lower() == 'xfs':
tasklist.add(filesystem.AddXFSProgs())
import re
if re.search('ext.', manifest.volume['filesystem'].lower()):
if manifest.volume['filesystem'].lower() in ['ext2', 'ext3', 'ext4']:
tasklist.add(filesystem.TuneVolumeFS())
tasklist.add(filesystem.CreateMountDir(), filesystem.MountVolume())
if manifest.bootstrapper['tarball']:
@ -41,7 +40,8 @@ def tasks(tasklist, manifest):
locale.SetTimezone(),
apt.AptSources(),
apt.AptUpgrade(),
boot.ConfigureGrub())
boot.ConfigureGrub(),
boot.ModifyFstab())
from common.tasks import TriggerRollback
tasklist.add(TriggerRollback())

View file

@ -13,13 +13,13 @@ class AptSources(Task):
sources_path = os.path.join(info.root, 'etc/apt/sources.list')
with open(sources_path, 'w') as apt_sources:
apt_sources.write(('deb {apt_mirror} {release} main\n'
'deb-src {apt_mirror} {release} main\n'.
format(apt_mirror='http://http.debian.net/debian',
release=info.manifest.system['release'])))
'deb-src {apt_mirror} {release} main\n'
.format(apt_mirror='http://http.debian.net/debian',
release=info.manifest.system['release'])))
apt_sources.write(('deb {apt_mirror} {release}/updates main\n'
'deb-src {apt_mirror} {release}/updates main\n'.
format(apt_mirror='http://security.debian.org/',
release=info.manifest.system['release'])))
'deb-src {apt_mirror} {release}/updates main\n'
.format(apt_mirror='http://security.debian.org/',
release=info.manifest.system['release'])))
class AptUpgrade(Task):

View file

@ -33,3 +33,20 @@ class ConfigureGrub(Task):
from common.tools import log_check_call
log_check_call(['chroot', info.root, 'update-grub'])
log_check_call(['chroot', info.root, 'ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])
class ModifyFstab(Task):
description = 'Add root volume to the fstab'
phase = phases.system_modification
def run(self, info):
fstab_path = os.path.join(info.root, 'etc/fstab')
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')
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))))