diff --git a/manifests/one-raw-virtio.manifest.json b/manifests/raw-ide.manifest similarity index 100% rename from manifests/one-raw-virtio.manifest.json rename to manifests/raw-ide.manifest diff --git a/plugins/opennebula/__init__.py b/plugins/opennebula/__init__.py new file mode 100644 index 0000000..cf8567c --- /dev/null +++ b/plugins/opennebula/__init__.py @@ -0,0 +1,5 @@ + + +def tasks(tasklist, manifest): + from opennebula import OpenNebulaContext + tasklist.add(OpenNebulaContext()) diff --git a/providers/one/assets/one-context_3.8.1.deb b/plugins/opennebula/assets/one-context_3.8.1.deb similarity index 100% rename from providers/one/assets/one-context_3.8.1.deb rename to plugins/opennebula/assets/one-context_3.8.1.deb diff --git a/providers/one/assets/one-ec2.sh b/plugins/opennebula/assets/one-ec2.sh similarity index 100% rename from providers/one/assets/one-ec2.sh rename to plugins/opennebula/assets/one-ec2.sh diff --git a/providers/one/assets/one-pubkey.sh b/plugins/opennebula/assets/one-pubkey.sh similarity index 100% rename from providers/one/assets/one-pubkey.sh rename to plugins/opennebula/assets/one-pubkey.sh diff --git a/plugins/opennebula/opennebula.py b/plugins/opennebula/opennebula.py new file mode 100644 index 0000000..1899127 --- /dev/null +++ b/plugins/opennebula/opennebula.py @@ -0,0 +1,42 @@ +from base import Task +from common import phases +import os +from providers.one.tasks.locale import GenerateLocale + + +class OpenNebulaContext(Task): + description = 'Setup OpenNebula init context' + phase = phases.system_modification + after = [GenerateLocale] + + def run(self, info): + import stat + rwxr_xr_x = (stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR | + stat.S_IRGRP | stat.S_IXGRP | + stat.S_IROTH | stat.S_IXOTH) + + from shutil import copy + script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-context_3.8.1.deb')) + script_dst = os.path.join(info.root, 'tmp/one-context_3.8.1.deb') + copy(script_src, script_dst) + os.chmod(script_dst, rwxr_xr_x) + + from common.tools import log_check_call + log_check_call(['/usr/sbin/chroot', info.root, 'dpkg', '-i', '/tmp/one-context_3.8.1.deb']) + # Fix start + from common.tools import sed_i + vmcontext_def = os.path.join(info.root, 'etc/init.d/vmcontext') + sed_i(vmcontext_def, '# Default-Start:', '# Default-Start: 2 3 4 5') + os.chmod(vmcontext_def, rwxr_xr_x) + log_check_call(['/usr/sbin/chroot', info.root, 'update-rc.d', 'vmcontext', 'start', '90', '2', '3', '4', '5', 'stop', '90', '0', '6']) + + # Load all pubkeys in root authorized_keys + script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-pubkey.sh')) + script_dst = os.path.join(info.root, 'etc/one-context.d/one-pubkey.sh') + copy(script_src, script_dst) + + # If USER_EC2_DATA is a script, execute it + script_src = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets/one-ec2.sh')) + script_dst = os.path.join(info.root, 'etc/one-context.d/one-ec2.sh') + copy(script_src, script_dst) + diff --git a/providers/one/__init__.py b/providers/raw/__init__.py similarity index 100% rename from providers/one/__init__.py rename to providers/raw/__init__.py diff --git a/providers/one/assets/grub.d/40_custom b/providers/raw/assets/grub.d/40_custom similarity index 100% rename from providers/one/assets/grub.d/40_custom rename to providers/raw/assets/grub.d/40_custom diff --git a/providers/one/assets/grub.d/40_custom.orig b/providers/raw/assets/grub.d/40_custom.orig similarity index 100% rename from providers/one/assets/grub.d/40_custom.orig rename to providers/raw/assets/grub.d/40_custom.orig diff --git a/providers/one/assets/init.d/ec2-get-credentials b/providers/raw/assets/init.d/ec2-get-credentials similarity index 100% rename from providers/one/assets/init.d/ec2-get-credentials rename to providers/raw/assets/init.d/ec2-get-credentials diff --git a/providers/one/assets/init.d/ec2-run-user-data b/providers/raw/assets/init.d/ec2-run-user-data similarity index 100% rename from providers/one/assets/init.d/ec2-run-user-data rename to providers/raw/assets/init.d/ec2-run-user-data diff --git a/providers/one/assets/init.d/expand-volume b/providers/raw/assets/init.d/expand-volume similarity index 100% rename from providers/one/assets/init.d/expand-volume rename to providers/raw/assets/init.d/expand-volume diff --git a/providers/one/assets/init.d/generate-ssh-hostkeys b/providers/raw/assets/init.d/generate-ssh-hostkeys similarity index 100% rename from providers/one/assets/init.d/generate-ssh-hostkeys rename to providers/raw/assets/init.d/generate-ssh-hostkeys diff --git a/providers/one/assets/init.d/squeeze/generate-ssh-hostkeys b/providers/raw/assets/init.d/squeeze/generate-ssh-hostkeys similarity index 100% rename from providers/one/assets/init.d/squeeze/generate-ssh-hostkeys rename to providers/raw/assets/init.d/squeeze/generate-ssh-hostkeys diff --git a/providers/raw/assets/one-context_3.8.1.deb b/providers/raw/assets/one-context_3.8.1.deb new file mode 100644 index 0000000..2e81188 Binary files /dev/null and b/providers/raw/assets/one-context_3.8.1.deb differ diff --git a/providers/raw/assets/one-ec2.sh b/providers/raw/assets/one-ec2.sh new file mode 100755 index 0000000..e52c72d --- /dev/null +++ b/providers/raw/assets/one-ec2.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +if [ -n "$EC2_USER_DATA" ]; then + # Check if EC2 user data is a script, if yes, execute + if [[ $EC2_USER_DATA =~ ^#! ]]; then + echo "EC2 data is an executable script, so execute it now" + TMPFILE=$(mktemp /tmp/output.XXXXXXXXXX) + chmod 755 $TMPFILE + $TMPFILE + cat $TMPFILE + else + print "Not an executable" + fi +fi diff --git a/providers/raw/assets/one-pubkey.sh b/providers/raw/assets/one-pubkey.sh new file mode 100755 index 0000000..7d7a209 --- /dev/null +++ b/providers/raw/assets/one-pubkey.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +echo "Reconfigure host ssh keys" +dpkg-reconfigure openssh-server + +if [ ! -e /root/.ssh ]; then + mkdir /root/.ssh + touch /root/.ssh/authorized_keys + chmod 600 /root/.ssh/authorized_keys +fi + +echo "Copy public ssh keys to authorized_keys" +for f in /mnt/*.pub +do + cat $f >> /root/.ssh/authorized_keys + +done diff --git a/providers/one/manifest-schema.json b/providers/raw/manifest-schema.json similarity index 100% rename from providers/one/manifest-schema.json rename to providers/raw/manifest-schema.json diff --git a/providers/one/manifest.py b/providers/raw/manifest.py similarity index 100% rename from providers/one/manifest.py rename to providers/raw/manifest.py diff --git a/providers/one/tasks/__init__.py b/providers/raw/tasks/__init__.py similarity index 100% rename from providers/one/tasks/__init__.py rename to providers/raw/tasks/__init__.py diff --git a/providers/one/tasks/ami.py b/providers/raw/tasks/ami.py similarity index 100% rename from providers/one/tasks/ami.py rename to providers/raw/tasks/ami.py diff --git a/providers/one/tasks/apt.py b/providers/raw/tasks/apt.py similarity index 100% rename from providers/one/tasks/apt.py rename to providers/raw/tasks/apt.py diff --git a/providers/one/tasks/boot.py b/providers/raw/tasks/boot.py similarity index 100% rename from providers/one/tasks/boot.py rename to providers/raw/tasks/boot.py diff --git a/providers/one/tasks/bootstrap.py b/providers/raw/tasks/bootstrap.py similarity index 100% rename from providers/one/tasks/bootstrap.py rename to providers/raw/tasks/bootstrap.py diff --git a/providers/one/tasks/cleanup.py b/providers/raw/tasks/cleanup.py similarity index 100% rename from providers/one/tasks/cleanup.py rename to providers/raw/tasks/cleanup.py diff --git a/providers/one/tasks/connection.py b/providers/raw/tasks/connection.py similarity index 100% rename from providers/one/tasks/connection.py rename to providers/raw/tasks/connection.py diff --git a/providers/one/tasks/ebs.py b/providers/raw/tasks/ebs.py similarity index 100% rename from providers/one/tasks/ebs.py rename to providers/raw/tasks/ebs.py diff --git a/providers/one/tasks/fake.py b/providers/raw/tasks/fake.py similarity index 100% rename from providers/one/tasks/fake.py rename to providers/raw/tasks/fake.py diff --git a/providers/one/tasks/filesystem.py b/providers/raw/tasks/filesystem.py similarity index 100% rename from providers/one/tasks/filesystem.py rename to providers/raw/tasks/filesystem.py diff --git a/providers/one/tasks/host.py b/providers/raw/tasks/host.py similarity index 100% rename from providers/one/tasks/host.py rename to providers/raw/tasks/host.py diff --git a/providers/one/tasks/initd.py b/providers/raw/tasks/initd.py similarity index 100% rename from providers/one/tasks/initd.py rename to providers/raw/tasks/initd.py diff --git a/providers/one/tasks/locale.py b/providers/raw/tasks/locale.py similarity index 100% rename from providers/one/tasks/locale.py rename to providers/raw/tasks/locale.py diff --git a/providers/one/tasks/network.py b/providers/raw/tasks/network.py similarity index 100% rename from providers/one/tasks/network.py rename to providers/raw/tasks/network.py diff --git a/providers/one/tasks/one.py b/providers/raw/tasks/one.py similarity index 100% rename from providers/one/tasks/one.py rename to providers/raw/tasks/one.py diff --git a/providers/one/tasks/packages.py b/providers/raw/tasks/packages.py similarity index 100% rename from providers/one/tasks/packages.py rename to providers/raw/tasks/packages.py diff --git a/providers/one/tasks/security.py b/providers/raw/tasks/security.py similarity index 100% rename from providers/one/tasks/security.py rename to providers/raw/tasks/security.py