use opennebula package in Jessie or backports instead of local assets

This commit is contained in:
Olivier Sallou 2014-03-25 14:32:49 +01:00
parent 5693d3e877
commit 167418991a
6 changed files with 22 additions and 65 deletions

View file

@ -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.

View file

@ -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])

View file

@ -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

View file

@ -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

View file

@ -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)