2013-08-10 17:43:15 +02:00
|
|
|
from base import Task
|
|
|
|
from common import phases
|
|
|
|
import os
|
|
|
|
|
2013-12-29 23:21:50 +01:00
|
|
|
assets = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets'))
|
|
|
|
|
2013-08-10 17:43:15 +02:00
|
|
|
|
2014-01-09 22:00:09 +01:00
|
|
|
class AddONEContextPackage(Task):
|
|
|
|
description = 'Adding the OpenNebula context package'
|
|
|
|
phase = phases.preparation
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
|
|
|
package = os.path.join(assets, 'one-context_3.8.1.deb')
|
|
|
|
info.packages.add_local(package)
|
|
|
|
|
|
|
|
|
2013-08-10 17:43:15 +02:00
|
|
|
class OpenNebulaContext(Task):
|
|
|
|
description = 'Setup OpenNebula init context'
|
|
|
|
phase = phases.system_modification
|
|
|
|
|
2014-01-05 15:57:11 +01:00
|
|
|
@classmethod
|
|
|
|
def run(cls, info):
|
2013-08-10 17:43:15 +02:00
|
|
|
# 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')
|
2014-01-09 22:00:09 +01:00
|
|
|
|
|
|
|
from common.tools import log_check_call
|
2013-08-10 17:43:15 +02:00
|
|
|
log_check_call(['/usr/sbin/chroot', info.root, 'update-rc.d', 'vmcontext', 'start',
|
|
|
|
'90', '2', '3', '4', '5', 'stop', '90', '0', '6'])
|
|
|
|
|
2014-01-09 22:00:09 +01:00
|
|
|
from shutil import copy
|
2013-08-10 17:43:15 +02:00
|
|
|
# Load all pubkeys in root authorized_keys
|
2013-12-29 23:21:50 +01:00
|
|
|
script_src = os.path.join(assets, 'one-pubkey.sh')
|
2013-08-10 17:43:15 +02:00
|
|
|
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
|
2013-12-29 23:21:50 +01:00
|
|
|
script_src = os.path.join(assets, 'one-ec2.sh')
|
2013-08-10 17:43:15 +02:00
|
|
|
script_dst = os.path.join(info.root, 'etc/one-context.d/one-ec2.sh')
|
|
|
|
copy(script_src, script_dst)
|