From 1fe0d56bc3369cc2041f449bdee21f20add76708 Mon Sep 17 00:00:00 2001 From: Olivier Sallou Date: Fri, 26 Jul 2013 08:50:53 +0200 Subject: [PATCH] updates --- manifests/one-raw-virtio.manifest.json | 2 +- providers/one/__init__.py | 2 ++ providers/one/tasks/boot.py | 6 ++++-- providers/one/tasks/fake.py | 13 +++++++++++++ providers/one/tasks/filesystem.py | 14 +++++++++++--- providers/one/tasks/packages.py | 1 + 6 files changed, 32 insertions(+), 6 deletions(-) create mode 100644 providers/one/tasks/fake.py diff --git a/manifests/one-raw-virtio.manifest.json b/manifests/one-raw-virtio.manifest.json index 6bf2579..33cff2a 100644 --- a/manifests/one-raw-virtio.manifest.json +++ b/manifests/one-raw-virtio.manifest.json @@ -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", diff --git a/providers/one/__init__.py b/providers/one/__init__.py index 067a964..2e64e1c 100644 --- a/providers/one/__init__.py +++ b/providers/one/__init__.py @@ -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(), diff --git a/providers/one/tasks/boot.py b/providers/one/tasks/boot.py index 4265b9d..58c0918 100644 --- a/providers/one/tasks/boot.py +++ b/providers/one/tasks/boot.py @@ -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']) diff --git a/providers/one/tasks/fake.py b/providers/one/tasks/fake.py new file mode 100644 index 0000000..33648ac --- /dev/null +++ b/providers/one/tasks/fake.py @@ -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") + diff --git a/providers/one/tasks/filesystem.py b/providers/one/tasks/filesystem.py index d3d9a4f..070d3cb 100644 --- a/providers/one/tasks/filesystem.py +++ b/providers/one/tasks/filesystem.py @@ -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']) diff --git a/providers/one/tasks/packages.py b/providers/one/tasks/packages.py index 45359a1..3f8ff36 100644 --- a/providers/one/tasks/packages.py +++ b/providers/one/tasks/packages.py @@ -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',