summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins
diff options
context:
space:
mode:
authorDirk von Suchodoletz2009-02-17 21:15:21 +0100
committerDirk von Suchodoletz2009-02-17 21:15:21 +0100
commitf4438b73ff48269de1e6049257042a092b24ae8f (patch)
tree938ad04fa92af264a39bf7d3969a0b55883c7f04 /os-plugins/plugins
parentvmchooser binary: (diff)
downloadcore-f4438b73ff48269de1e6049257042a092b24ae8f.tar.gz
core-f4438b73ff48269de1e6049257042a092b24ae8f.tar.xz
core-f4438b73ff48269de1e6049257042a092b24ae8f.zip
Framework stuff (not working) for the VirtualBox virtual machine ...
git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@2589 95ad53e4-c205-0410-b2fa-d234c58c8868
Diffstat (limited to 'os-plugins/plugins')
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm56
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm41
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm40
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm23
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm156
-rw-r--r--os-plugins/plugins/virtualbox/XX_virtualbox.sh71
-rw-r--r--os-plugins/plugins/virtualbox/files/run-virt.include43
7 files changed, 430 insertions, 0 deletions
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm
new file mode 100644
index 00000000..1d1aacb7
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Base.pm
@@ -0,0 +1,56 @@
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# virtualbox/OpenSLX/Distro/Base.pm
+# - provides base implementation of the Distro API for the VirtualBox plugin.
+# -----------------------------------------------------------------------------
+package virtualbox::OpenSLX::Distro::Base;
+
+use strict;
+use warnings;
+
+our $VERSION = 1.01; # API-version . implementation-version
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+sub new
+{
+ my $class = shift;
+ my $self = {};
+ return bless $self, $class;
+
+}
+
+sub initialize
+{
+ my $self = shift;
+ my $engine = shift;
+
+ return 1;
+}
+
+sub fillRunlevelScript
+{
+ my $self = shift;
+ my $location = shift;
+ my $kind = shift;
+
+ my $script = unshiftHereDoc(<<' End-of-Here');
+
+ End-of-Here
+
+ return $script;
+}
+
+1;
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm
new file mode 100644
index 00000000..dbc75665
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Debian.pm
@@ -0,0 +1,41 @@
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# virtualbox/OpenSLX/Distro/debian.pm
+# - provides Debian-specific overrides of the Distro API for the VirtualBox
+# plugin.
+# -----------------------------------------------------------------------------
+package virtualbox::OpenSLX::Distro::Debian;
+
+use strict;
+use warnings;
+
+use base qw(virtualbox::OpenSLX::Distro::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+
+sub fillRunlevelScript
+{
+ my $self = shift;
+ my $location = shift;
+ my $kind = shift;
+
+ my $script = unshiftHereDoc(<<' End-of-Here');
+
+ End-of-Here
+ return $script;
+}
+
+1;
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm
new file mode 100644
index 00000000..77473533
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Suse.pm
@@ -0,0 +1,40 @@
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# virtualbox/OpenSLX/Distro/Suse.pm
+# - provides SUSE specific overrides of the distro API for the VirtualBox
+# plugin.
+# -----------------------------------------------------------------------------
+package virtualbox::OpenSLX::Distro::Suse;
+
+use strict;
+use warnings;
+
+use base qw(virtualbox::OpenSLX::Distro::Base);
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+################################################################################
+### interface methods
+################################################################################
+
+sub fillRunlevelScript
+{
+ my $self = shift;
+ my $location = shift;
+ my $kind = shift;
+
+ my $script = bla;
+
+ return $script;
+}
+
+1;
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm
new file mode 100644
index 00000000..067f53c2
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/OpenSLX/Distro/Ubuntu.pm
@@ -0,0 +1,23 @@
+# Copyright (c) 2008 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# virtualbox/OpenSLX/Distro/Ubuntu.pm
+# - provides Ubuntu-specific overrides of the Distro API for the virtualbox
+# plugin.
+# -----------------------------------------------------------------------------
+package virtualbox::OpenSLX::Distro::Ubuntu;
+
+use strict;
+use warnings;
+
+# inherit everything from Debian (as Ubuntu is based on it anyway)
+use base qw(virtualbox::OpenSLX::Distro::Debian);
+
+1;
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
new file mode 100644
index 00000000..fa676e4a
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
@@ -0,0 +1,156 @@
+# Copyright (c) 2008 - OpenSLX GmbH
+#
+# This program is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your suggestions, praise, or complaints to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org/
+# -----------------------------------------------------------------------------
+# virtualbox.pm
+# - declares necessary information for the virtualbox plugin
+# -----------------------------------------------------------------------------
+package OpenSLX::OSPlugin::virtualbox;
+
+use strict;
+use warnings;
+
+use base qw(OpenSLX::OSPlugin::Base);
+
+use File::Basename;
+use File::Path;
+
+use OpenSLX::Basics;
+use OpenSLX::Utils;
+
+sub new
+{
+ my $class = shift;
+ my $self = {
+ name => 'virtualbox',
+ };
+
+ return bless $self, $class;
+}
+
+sub getInfo
+{
+ my $self = shift;
+
+ return {
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Module for enabling services for the VirtualBox on an OpenSLX
+ stateless client.
+ End-of-Here
+ precedence => 70,
+ required => [ qw( desktop ) ],
+ };
+}
+
+sub getAttrInfo
+{
+ # returns a hash-ref with information about all attributes supported
+ # by this specific plugin
+ my $self = shift;
+
+ # This default configuration will be added as attributes to the default
+ # system, such that it can be overruled for any specific system by means
+ # of slxconfig.
+ return {
+ # attribute 'active' is mandatory for all plugins
+ 'virtualbox::active' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ should the 'virtualbox'-plugin be executed during boot?
+ End-of-Here
+ content_regex => qr{^(0|1)$},
+ content_descr => '1 means active - 0 means inactive',
+ default => '1',
+ },
+ # attribute 'imagesrc' defines where we can find virtualbox images
+ 'virtualbox::imagesrc' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Where do we store our virtualbox images? NFS? Filesystem?
+ End-of-Here
+ #TODO: check if the input is valid
+ #content_regex => qr{^(0|1)$},
+ content_descr => 'Allowed values: local path or URI',
+ default => '',
+ },
+ # attribute 'bridge' defines if bridged network mode should be
+ # switched on
+ 'virtualbox::bridge' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Should the bridging (direct access of the virtualbox clients
+ to the ethernet the host is connected to) be enabled
+ End-of-Here
+ content_regex => qr{^(0|1)$},
+ content_descr => 'Allowed values: 0 or 1',
+ default => '1',
+ },
+
+ };
+}
+
+sub installationPhase
+{
+ my $self = shift;
+ my $info = shift;
+
+ $self->{pluginRepositoryPath} = $info->{'plugin-repo-path'};
+ $self->{pluginTempPath} = $info->{'plugin-temp-path'};
+ $self->{openslxBasePath} = $info->{'openslx-base-path'};
+ $self->{openslxConfigPath} = $info->{'openslx-config-path'};
+ $self->{attrs} = $info->{'plugin-attrs'};
+
+ my $engine = $self->{'os-plugin-engine'};
+
+ # different names of the tool (should be unified somehow!?)
+ if (!isInPath('???')) {
+ $engine->installPackages(
+ $engine->getInstallablePackagesForSelection('???')
+ );
+ }
+ return;
+}
+
+sub removalPhase
+{
+ my $self = shift;
+ my $info = shift;
+
+ return;
+}
+
+sub checkStage3AttrValues
+{
+ my $self = shift;
+ my $stage3Attrs = shift;
+ my $vendorOSAttrs = shift;
+ #my @problems;
+
+ #my $vmimg = $stage3Attrs->{'virtualbox::imagesrc'} || '';
+
+ return;
+}
+
+# write the runlevelscript
+sub _writeRunlevelScript
+{
+ my $self = shift;
+ my $location = shift;
+ my $file = shift;
+ my $kind = shift;
+
+ my $runlevelScript = $self->{distro}->fillRunlevelScript($location, $kind);
+
+ spitFile($file, $runlevelScript);
+}
+
+1;
diff --git a/os-plugins/plugins/virtualbox/XX_virtualbox.sh b/os-plugins/plugins/virtualbox/XX_virtualbox.sh
new file mode 100644
index 00000000..5fdf9f49
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/XX_virtualbox.sh
@@ -0,0 +1,71 @@
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# script is included from init via the "." load function - thus it has all
+# variables and functions available
+
+
+# check if the configuration file is available
+if [ -e /initramfs/plugin-conf/virtualbox.conf ]; then
+
+ # load needed variables
+ . /initramfs/plugin-conf/virtualbox.conf
+
+ # Test if this plugin is activated... more or less useless with the
+ # new plugin system
+ if [ $virtualbox_active -ne 0 ]; then
+
+ [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'virtualbox' os-plugin ...";
+ # load general configuration
+ . /initramfs/machine-setup
+
+ # get source of virtualbox image server (get type, server and path)
+ if strinstr "/" "${virtualbox_imagesrc}" ; then
+ vbimgprot=$(uri_token ${virtualbox_imagesrc} prot)
+ vbimgserv=$(uri_token ${virtualbox_imagesrc} server)
+ vbimgpath="$(uri_token ${virtualbox_imagesrc} path)"
+ fi
+ if [ -n "${vbimgserv}" ] ; then
+ # directory where qemu images are expected in
+ testmkd /mnt/var/lib/virt/virtualbox
+ case "${vbimgprot}" in
+ *nbd)
+ # TODO: to be filled in ...
+ ;;
+ lbdev)
+ # we expect the stuff on toplevel directory, filesystem type should be
+ # autodetected here ... (vmimgserv is blockdev here)
+ vbbdev=/dev/${vbimgserv}
+ waitfor ${vbbdev} 20000
+ echo -e "ext2\nreiserfs\nvfat\nxfs" >/etc/filesystems
+ mount -o ro ${vbbdev} /mnt/var/lib/virt/virtualbox || \
+ error "$scfg_evmlm" nonfatal
+ ;;
+ *)
+ # we expect nfs mounts here ...
+ for proto in tcp udp fail; do
+ [ $proto = "fail" ] && { error "$scfg_nfs" nonfatal;
+ noimg=yes; break;}
+ mount -n -t nfs -o ro,nolock,$proto ${vbimgserv}:${vbimgpath} \
+ /mnt/var/lib/virt/virtualbox && break
+ done
+ ;;
+ esac
+ fi
+ # copy version depending files - the vmchooser expects for every virtua-
+ # lization plugin a file named after it (here run-virtualbox.include)
+ testmkd /mnt/etc/opt/openslx
+ cp /mnt/opt/openslx/plugin-repo/run-virtualbox/files/run-virt.include \
+ /mnt/etc/opt/openslx/run-virtualbox.include
+
+ fi
+else
+ [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of virtualbox plugin failed"
+fi
diff --git a/os-plugins/plugins/virtualbox/files/run-virt.include b/os-plugins/plugins/virtualbox/files/run-virt.include
new file mode 100644
index 00000000..541acd61
--- /dev/null
+++ b/os-plugins/plugins/virtualbox/files/run-virt.include
@@ -0,0 +1,43 @@
+# run-virtualbox.include
+#
+# Copyright (c) 2009 - OpenSLX GmbH
+#
+# This program/file is free software distributed under the GPL version 2.
+# See http://openslx.org/COPYING
+#
+# If you have any feedback please consult http://openslx.org/feedback and
+# send your feedback to feedback@openslx.org
+#
+# General information about OpenSLX can be found at http://openslx.org
+#
+# Include script for running the Virtual Box on an OpenSLX client via the
+# run-virt.sh. The stuff is copied to /etc/opt/openslx/run-virtualbox.include
+# during stage3.
+
+
+permem=66
+mem=expr(${totalmem} * ${permem})
+
+# virtual fd/cd/dvd and drive devices, floppy b: for configuration
+#floppya is always false, if we have a floppy device or not isn't
+#important.
+floppya="FALSE"
+floppyb="TRUE"
+floppybname="/etc/vmware/loopimg/fd.img"
+cdr_1="FALSE"
+cdr_2="FALSE"
+# ide is expected default, test for the virtual disk image type should
+# be done while creating the runscripts ...
+ide="TRUE"
+hddrv="ide"
+
+
+# folder of virtual machine images
+vmdir="/var/lib/virt/virtualbox"
+
+# image file
+diskfile="${vmdir}/${imagename}"
+
+# set the variables appropriately
+VIRTCMD=$(which vbox???)
+