This commit is contained in:
Olivier Sallou 2013-07-26 08:50:53 +02:00
parent a2e8d0838e
commit 1fe0d56bc3
6 changed files with 32 additions and 6 deletions

View file

@ -15,7 +15,7 @@
},
"image": {
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",
"description": "Debian {release} {architecture} AMI ({virtualization})"
"description": "Debian {release} {architecture} Open Nebula ({virtualization})"
},
"system": {
"release" : "wheezy",

View file

@ -14,6 +14,7 @@ from tasks import security
from tasks import network
from tasks import initd
from tasks import cleanup
from tasks import fake
def initialize():
@ -55,6 +56,7 @@ def tasks(tasklist, manifest):
network.RemoveDNSInfo(),
network.ConfigureNetworkIF(),
network.ConfigureDHCP(),
fake.Fake(),
initd.ResolveInitScripts(),
initd.InstallInitScripts(),
cleanup.ClearMOTD(),

View file

@ -26,11 +26,13 @@ class ConfigureGrub(Task):
from common.tools import sed_i
grub_def = os.path.join(info.root, 'etc/default/grub')
sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n'
'GRUB_HIDDEN_TIMEOUT=true')
#sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n'
# 'GRUB_HIDDEN_TIMEOUT=true')
from common.tools import log_check_call
log_check_call(['/usr/sbin/chroot', info.root, '/usr/sbin/update-grub'])
log_check_call(['/usr/sbin/chroot', info.root, 'cat', '/boot/grub/grub.cfg'])
log_check_call(['/usr/sbin/chroot', info.root, 'cat', '/boot/grub/device.map'])
log_check_call(['/usr/sbin/chroot', info.root, 'ln', '-s', '/boot/grub/grub.cfg', '/boot/grub/menu.lst'])

View file

@ -0,0 +1,13 @@
from base import Task
from common import phases
import os.path
class Fake(Task):
description = 'create fake file'
phase = phases.system_modification
def run(self, info):
fake_path = os.path.join(info.root, 'fake.txt')
with open(fake_path, 'a') as fakefile:
fakefile.write("fake file")

View file

@ -12,8 +12,8 @@ class FormatVolume(Task):
def run(self, info):
mkmount = ['/usr/bin/qemu-img', 'create', '-f', 'raw', info.manifest.bootstrapper['image_file'], str(info.manifest.volume['size'])+'M']
log_check_call(mkmount)
ddcmd = ['/bin/dd', 'if=/dev/zero', 'bs=1024', 'conv=notrunc', 'count='+str(info.manifest.volume['size']), 'of='+info.manifest.bootstrapper['image_file']]
log_check_call(ddcmd)
#ddcmd = ['/bin/dd', 'if=/dev/zero', 'bs=1024', 'conv=notrunc', 'count='+str(info.manifest.volume['size']), 'of='+info.manifest.bootstrapper['image_file']]
#log_check_call(ddcmd)
loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']]
log_check_call(loopcmd)
mkfs = [ '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']), '-m', '1', '-v', '/dev/loop0']
@ -127,6 +127,14 @@ class ModifyFstab(Task):
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\n'
fstab.write(('/dev/sda1 / {filesystem} {mount_opts} 1 1\n'
.format(filesystem=info.manifest.volume['filesystem'].lower(),
mount_opts=','.join(mount_opts))))
log_check_call(['/usr/sbin/chroot', info.root, 'cat', '/etc/fstab'])
class InstallMbr(Task):
description = 'Install MBR'
phase = phases.system_modification
def run(self, info):
log_check_call(['/usr/sbin/chroot', info.root, 'install-mbr', '/dev/sda'])

View file

@ -22,6 +22,7 @@ class ImagePackages(Task):
manifest = info.manifest
# Add some basic packages we are going to need
include = set(['udev',
'mbr',
'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc.
'locales',