diff --git a/plugins/opennebula/README.md b/plugins/opennebula/README.md index 1d96eaa..49ab0c9 100644 --- a/plugins/opennebula/README.md +++ b/plugins/opennebula/README.md @@ -11,6 +11,3 @@ It set ups the network and ssh keys. TO do so you should configure your virtual ETH0_NETWORK $NETWORK[NETWORK, NETWORK_ID=2] FILES path_to_my_ssh_public_key.pub -Provider will install all *.pub* files in the root authorized_keys file. - -In case of an EC2 start, if the USER_EC2_DATA element is a script it will be executed. diff --git a/plugins/opennebula/__init__.py b/plugins/opennebula/__init__.py index 3bb0a7f..4164c31 100644 --- a/plugins/opennebula/__init__.py +++ b/plugins/opennebula/__init__.py @@ -2,5 +2,7 @@ import tasks def resolve_tasks(taskset, manifest): - taskset.add(tasks.AddONEContextPackage) - taskset.add(tasks.OpenNebulaContext) + if manifest.system['release'] in ['wheezy', 'stable']: + taskset.add(tasks.AddBackports) + taskset.update([tasks.AddONEContextPackage]) + diff --git a/plugins/opennebula/assets/one-context_3.8.1.deb b/plugins/opennebula/assets/one-context_3.8.1.deb deleted file mode 100644 index 2e81188..0000000 Binary files a/plugins/opennebula/assets/one-context_3.8.1.deb and /dev/null differ diff --git a/plugins/opennebula/assets/one-ec2.sh b/plugins/opennebula/assets/one-ec2.sh deleted file mode 100755 index e52c72d..0000000 --- a/plugins/opennebula/assets/one-ec2.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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/plugins/opennebula/assets/one-pubkey.sh b/plugins/opennebula/assets/one-pubkey.sh deleted file mode 100755 index 7d7a209..0000000 --- a/plugins/opennebula/assets/one-pubkey.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/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/plugins/opennebula/tasks.py b/plugins/opennebula/tasks.py index ecb5bb3..eb2ee60 100644 --- a/plugins/opennebula/tasks.py +++ b/plugins/opennebula/tasks.py @@ -1,42 +1,31 @@ from base import Task +from common.tasks import apt from common import phases import os -assets = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets')) - -class AddONEContextPackage(Task): - description = 'Adding the OpenNebula context package' +class AddBackports(Task): + description = 'Adding backports to the apt sources' phase = phases.preparation @classmethod def run(cls, info): - package = os.path.join(assets, 'one-context_3.8.1.deb') - info.packages.add_local(package) + if info.source_lists.target_exists('{system.release}-backports'): + import logging + msg = ('{system.release}-backports target already exists').format(**info.manifest_vars) + logging.getLogger(__name__).info(msg) + else: + info.source_lists.add('backports', 'deb {apt_mirror} {system.release}-backports main') + info.source_lists.add('backports', 'deb-src {apt_mirror} {system.release}-backports main') - -class OpenNebulaContext(Task): - description = 'Setup OpenNebula init context' - phase = phases.system_modification +class AddONEContextPackage(Task): + description = 'Adding the OpenNebula context package' + phase = phases.preparation + predecessors = [apt.AddDefaultSources, AddBackports] @classmethod def run(cls, info): - # 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') - - from common.tools import log_check_call - log_check_call(['/usr/sbin/chroot', info.root, 'update-rc.d', 'vmcontext', 'start', - '90', '2', '3', '4', '5', 'stop', '90', '0', '6']) - - from shutil import copy - # Load all pubkeys in root authorized_keys - script_src = os.path.join(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.join(assets, 'one-ec2.sh') - script_dst = os.path.join(info.root, 'etc/one-context.d/one-ec2.sh') - copy(script_src, script_dst) + target = None + if info.manifest.system['release'] in ['wheezy', 'stable']: + target = '{system.release}-backports' + info.packages.add('opennebula-context', target)