Rename raw provider to one, move ONE task to provider

This commit is contained in:
Anders Ingemann 2013-08-10 17:43:15 +02:00
parent 355f29c23c
commit b89601fb07
16 changed files with 49 additions and 52 deletions

View file

@ -1,5 +0,0 @@
def tasks(tasklist, manifest):
from opennebula import OpenNebulaContext
tasklist.add(OpenNebulaContext())

View file

@ -1,42 +0,0 @@
from base import Task
from common import phases
import os
from providers.raw.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)

View file

@ -1,6 +1,6 @@
# Open Nebula context plugin
# Open Nebula provider
This plugin adds OpenNebula contextualization to the virtual image (see http://opennebula.org/documentation:rel4.2:cong).
This provider adds OpenNebula contextualization to the virtual image (see http://opennebula.org/documentation:rel4.2:cong).
It set ups the network and ssh keys. TO do so you should configure your virtual machine context with something like:
@ -11,7 +11,6 @@ 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
Plugin 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, the plugin will execute it.
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

@ -8,6 +8,7 @@ from common.tasks import locale
from common.tasks import apt
from tasks import boot
from common.tasks import boot as common_boot
from tasks import context
from common.tasks import security
from common.tasks import network
from common.tasks import initd
@ -61,6 +62,7 @@ def tasks(tasklist, manifest):
common_filesystem.UnmountSpecials(),
filesystem.UnmountVolume(),
common_filesystem.DeleteMountDir())
tasklist.add(context.OpenNebulaContext())
def rollback_tasks(tasklist, tasks_completed, manifest):

View file

@ -0,0 +1,43 @@
from base import Task
from common import phases
from common.tasks.locale import GenerateLocale
import os
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
assets_dir = os.path.normpath(os.path.join(os.path.dirname(__file__), 'assets'))
script_src = os.path.join(assets_dir, '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.join(assets_dir, '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_dir, 'one-ec2.sh')
script_dst = os.path.join(info.root, 'etc/one-context.d/one-ec2.sh')
copy(script_src, script_dst)