From b89601fb0784af527337d175340e8efc322e8807 Mon Sep 17 00:00:00 2001 From: Anders Ingemann Date: Sat, 10 Aug 2013 17:43:15 +0200 Subject: [PATCH] Rename raw provider to one, move ONE task to provider --- plugins/opennebula/__init__.py | 5 -- plugins/opennebula/opennebula.py | 42 ----------------- .../opennebula => providers/one}/README.md | 9 ++-- providers/{raw => one}/REAME.md | 0 providers/{raw => one}/__init__.py | 2 + .../{raw => one}/assets/grub.d/40_custom | 0 .../one}/assets/one-context_3.8.1.deb | Bin .../one}/assets/one-ec2.sh | 0 .../one}/assets/one-pubkey.sh | 0 providers/{raw => one}/manifest-schema.json | 0 providers/{raw => one}/manifest.py | 0 providers/{raw => one}/tasks/__init__.py | 0 providers/{raw => one}/tasks/boot.py | 0 providers/one/tasks/context.py | 43 ++++++++++++++++++ providers/{raw => one}/tasks/filesystem.py | 0 providers/{raw => one}/tasks/packages.py | 0 16 files changed, 49 insertions(+), 52 deletions(-) delete mode 100644 plugins/opennebula/__init__.py delete mode 100644 plugins/opennebula/opennebula.py rename {plugins/opennebula => providers/one}/README.md (66%) rename providers/{raw => one}/REAME.md (100%) rename providers/{raw => one}/__init__.py (97%) rename providers/{raw => one}/assets/grub.d/40_custom (100%) rename {plugins/opennebula => providers/one}/assets/one-context_3.8.1.deb (100%) rename {plugins/opennebula => providers/one}/assets/one-ec2.sh (100%) rename {plugins/opennebula => providers/one}/assets/one-pubkey.sh (100%) rename providers/{raw => one}/manifest-schema.json (100%) rename providers/{raw => one}/manifest.py (100%) rename providers/{raw => one}/tasks/__init__.py (100%) rename providers/{raw => one}/tasks/boot.py (100%) create mode 100644 providers/one/tasks/context.py rename providers/{raw => one}/tasks/filesystem.py (100%) rename providers/{raw => one}/tasks/packages.py (100%) diff --git a/plugins/opennebula/__init__.py b/plugins/opennebula/__init__.py deleted file mode 100644 index cf8567c..0000000 --- a/plugins/opennebula/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ - - -def tasks(tasklist, manifest): - from opennebula import OpenNebulaContext - tasklist.add(OpenNebulaContext()) diff --git a/plugins/opennebula/opennebula.py b/plugins/opennebula/opennebula.py deleted file mode 100644 index df50a4b..0000000 --- a/plugins/opennebula/opennebula.py +++ /dev/null @@ -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) - diff --git a/plugins/opennebula/README.md b/providers/one/README.md similarity index 66% rename from plugins/opennebula/README.md rename to providers/one/README.md index c36f2b3..1d96eaa 100644 --- a/plugins/opennebula/README.md +++ b/providers/one/README.md @@ -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. diff --git a/providers/raw/REAME.md b/providers/one/REAME.md similarity index 100% rename from providers/raw/REAME.md rename to providers/one/REAME.md diff --git a/providers/raw/__init__.py b/providers/one/__init__.py similarity index 97% rename from providers/raw/__init__.py rename to providers/one/__init__.py index 4e1602f..03a7b5c 100644 --- a/providers/raw/__init__.py +++ b/providers/one/__init__.py @@ -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): diff --git a/providers/raw/assets/grub.d/40_custom b/providers/one/assets/grub.d/40_custom similarity index 100% rename from providers/raw/assets/grub.d/40_custom rename to providers/one/assets/grub.d/40_custom diff --git a/plugins/opennebula/assets/one-context_3.8.1.deb b/providers/one/assets/one-context_3.8.1.deb similarity index 100% rename from plugins/opennebula/assets/one-context_3.8.1.deb rename to providers/one/assets/one-context_3.8.1.deb diff --git a/plugins/opennebula/assets/one-ec2.sh b/providers/one/assets/one-ec2.sh similarity index 100% rename from plugins/opennebula/assets/one-ec2.sh rename to providers/one/assets/one-ec2.sh diff --git a/plugins/opennebula/assets/one-pubkey.sh b/providers/one/assets/one-pubkey.sh similarity index 100% rename from plugins/opennebula/assets/one-pubkey.sh rename to providers/one/assets/one-pubkey.sh diff --git a/providers/raw/manifest-schema.json b/providers/one/manifest-schema.json similarity index 100% rename from providers/raw/manifest-schema.json rename to providers/one/manifest-schema.json diff --git a/providers/raw/manifest.py b/providers/one/manifest.py similarity index 100% rename from providers/raw/manifest.py rename to providers/one/manifest.py diff --git a/providers/raw/tasks/__init__.py b/providers/one/tasks/__init__.py similarity index 100% rename from providers/raw/tasks/__init__.py rename to providers/one/tasks/__init__.py diff --git a/providers/raw/tasks/boot.py b/providers/one/tasks/boot.py similarity index 100% rename from providers/raw/tasks/boot.py rename to providers/one/tasks/boot.py diff --git a/providers/one/tasks/context.py b/providers/one/tasks/context.py new file mode 100644 index 0000000..d45cbd6 --- /dev/null +++ b/providers/one/tasks/context.py @@ -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) diff --git a/providers/raw/tasks/filesystem.py b/providers/one/tasks/filesystem.py similarity index 100% rename from providers/raw/tasks/filesystem.py rename to providers/one/tasks/filesystem.py diff --git a/providers/raw/tasks/packages.py b/providers/one/tasks/packages.py similarity index 100% rename from providers/raw/tasks/packages.py rename to providers/one/tasks/packages.py