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": { "image": {
"name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}", "name" : "debian-{release}-{architecture}-{virtualization}-{%y}{%m}{%d}",
"description": "Debian {release} {architecture} AMI ({virtualization})" "description": "Debian {release} {architecture} Open Nebula ({virtualization})"
}, },
"system": { "system": {
"release" : "wheezy", "release" : "wheezy",

View file

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

View file

@ -26,11 +26,13 @@ class ConfigureGrub(Task):
from common.tools import sed_i from common.tools import sed_i
grub_def = os.path.join(info.root, 'etc/default/grub') grub_def = os.path.join(info.root, 'etc/default/grub')
sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n' #sed_i(grub_def, '^GRUB_TIMEOUT=[0-9]+', 'GRUB_TIMEOUT=0\n'
'GRUB_HIDDEN_TIMEOUT=true') # 'GRUB_HIDDEN_TIMEOUT=true')
from common.tools import log_check_call 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, '/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']) 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): def run(self, info):
mkmount = ['/usr/bin/qemu-img', 'create', '-f', 'raw', info.manifest.bootstrapper['image_file'], str(info.manifest.volume['size'])+'M'] mkmount = ['/usr/bin/qemu-img', 'create', '-f', 'raw', info.manifest.bootstrapper['image_file'], str(info.manifest.volume['size'])+'M']
log_check_call(mkmount) 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']] #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) #log_check_call(ddcmd)
loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']] loopcmd = ['/sbin/losetup', '/dev/loop0', info.manifest.bootstrapper['image_file']]
log_check_call(loopcmd) log_check_call(loopcmd)
mkfs = [ '/sbin/mkfs.{fs}'.format(fs=info.manifest.volume['filesystem']), '-m', '1', '-v', '/dev/loop0'] 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') mount_opts.append('nobarrier')
fstab_path = os.path.join(info.root, 'etc/fstab') fstab_path = os.path.join(info.root, 'etc/fstab')
with open(fstab_path, 'a') as 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(), .format(filesystem=info.manifest.volume['filesystem'].lower(),
mount_opts=','.join(mount_opts)))) 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 manifest = info.manifest
# Add some basic packages we are going to need # Add some basic packages we are going to need
include = set(['udev', include = set(['udev',
'mbr',
'openssh-server', 'openssh-server',
# We could bootstrap without locales, but things just suck without them, error messages etc. # We could bootstrap without locales, but things just suck without them, error messages etc.
'locales', 'locales',