From 8f47c4882b657de73801dab06b173ef6d9865e4f Mon Sep 17 00:00:00 2001 From: Dirk Date: Wed, 6 Jul 2011 16:12:38 +0200 Subject: Adding dummy frontend for several emulators to be called via vmchooser. --- .../plugins/emufe/OpenSLX/Distro/Base.pm | 60 +++++++++ .../plugins/emufe/OpenSLX/OSPlugin/emufe.pm | 139 +++++++++++++++++++++ src/os-plugins/plugins/emufe/XX_emufe.sh | 36 ++++++ .../plugins/emufe/files/run-virt.include | 85 +++++++++++++ src/os-plugins/plugins/vmchooser/files/run-virt.sh | 8 +- 5 files changed, 324 insertions(+), 4 deletions(-) create mode 100644 src/os-plugins/plugins/emufe/OpenSLX/Distro/Base.pm create mode 100644 src/os-plugins/plugins/emufe/OpenSLX/OSPlugin/emufe.pm create mode 100644 src/os-plugins/plugins/emufe/XX_emufe.sh create mode 100644 src/os-plugins/plugins/emufe/files/run-virt.include (limited to 'src') diff --git a/src/os-plugins/plugins/emufe/OpenSLX/Distro/Base.pm b/src/os-plugins/plugins/emufe/OpenSLX/Distro/Base.pm new file mode 100644 index 00000000..b330681f --- /dev/null +++ b/src/os-plugins/plugins/emufe/OpenSLX/Distro/Base.pm @@ -0,0 +1,60 @@ +# Copyright (c) 2011 - 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/ +# ----------------------------------------------------------------------------- +# emufe/OpenSLX/Distro/Base.pm +# - provides base implementation of the Distro API for the emufe plugin. +# ----------------------------------------------------------------------------- +package emufe::OpenSLX::Distro::Base; + +use strict; +use warnings; + +our $VERSION = 1.01; # API-version . implementation-version + +use Scalar::Util qw( weaken ); + +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; + weaken($self->{engine}); + # avoid circular reference between plugin and its engine + + 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/src/os-plugins/plugins/emufe/OpenSLX/OSPlugin/emufe.pm b/src/os-plugins/plugins/emufe/OpenSLX/OSPlugin/emufe.pm new file mode 100644 index 00000000..4ef09e5e --- /dev/null +++ b/src/os-plugins/plugins/emufe/OpenSLX/OSPlugin/emufe.pm @@ -0,0 +1,139 @@ +# Copyright (c) 2011 - RZ Uni Freiburg +# Copyright (c) 2011 - 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/ +# ----------------------------------------------------------------------------- +# emufe.pm +# - Declares necessary information for the emufe plugin +# ----------------------------------------------------------------------------- +package OpenSLX::OSPlugin::emufe; + +use strict; +use warnings; + +use base qw(OpenSLX::OSPlugin::Base); + +use File::Basename; +use File::Path; + +use OpenSLX::Basics; +use OpenSLX::Utils; +use OpenSLX::DistroUtils; + +sub new +{ + my $class = shift; + my $self = { + name => 'emufe', + }; + + return bless $self, $class; +} + +sub getInfo +{ + my $self = shift; + + return { + description => unshiftHereDoc(<<' End-of-Here'), + Module for enabling selection of emulators via the vmchooser plugin + and mount a content directory if required. Mostly dummy functionality. + End-of-Here + precedence => 70, + required => [ qw( vmchooser ) ], + }; +} + +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 + 'emufe::active' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + should the 'emufe'-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 the different emulator + # images + 'emufe::imagesrc' => { + applies_to_systems => 1, + applies_to_clients => 1, + description => unshiftHereDoc(<<' End-of-Here'), + Where should the vm images be stored? 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 => '', + }, + + }; +} + +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'}; + my $pluginRepoPath = $info->{'plugin-repo-path'}; + my $openslxBasePath = $info->{'openslx-base-path'}; + + # Copy run-virt.include and template files to the appropriate place for + # inclusion in stage4 + my $pluginName = $self->{'name'}; + my $pluginBasePath = "$openslxBasePath/lib/plugins/$pluginName/files"; + foreach my $file ( qw( run-virt.include ) ) { + copyFile("$pluginBasePath/$file", "$pluginRepoPath/"); + } + + # not needed yet (all emulators run in userspace) + #my $initFile = newInitFile(); + #$initFile->setName("emufe"); + #$initFile->setDesc("Setup environment for different emulators"); + + return; +} + +sub removalPhase +{ + my $self = shift; + my $info = shift; + + return; +} + +sub checkStage3AttrValues +{ + my $self = shift; + my $stage3Attrs = shift; + my $vendorOSAttrs = shift; + + return; +} + +1; diff --git a/src/os-plugins/plugins/emufe/XX_emufe.sh b/src/os-plugins/plugins/emufe/XX_emufe.sh new file mode 100644 index 00000000..7977e246 --- /dev/null +++ b/src/os-plugins/plugins/emufe/XX_emufe.sh @@ -0,0 +1,36 @@ +# Copyright (c) 2011 - RZ Uni Freiburg +# Copyright (c) 2011 - 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 + +# include default directories +. /etc/openslx.conf + +# check if the configuration file is available +if [ -e ${CONFFILE} ]; then + + # load needed variables + . ${CONFFILE} + + # Test if this plugin is activated... more or less useless with the + # new plugin system + if [ ${emufe_active} -ne 0 2>/dev/null ]; then + [ $DEBUGLEVEL -gt 0 ] && echo "executing the 'emufe' os-plugin ..."; + + # copy virtualization include files and emufe.conf to config dir + testmkd ${PLUGINCONFDIR} + cp /mnt/${PLUGINDIR}/run-virt.include ${PLUGINCONFDIR} + cp ${CONFFILE} ${PLUGINCONFDIR} + +else + [ $DEBUGLEVEL -gt 0 ] && echo " * Configuration of 'emufe' plugin failed" +fi diff --git a/src/os-plugins/plugins/emufe/files/run-virt.include b/src/os-plugins/plugins/emufe/files/run-virt.include new file mode 100644 index 00000000..913b0380 --- /dev/null +++ b/src/os-plugins/plugins/emufe/files/run-virt.include @@ -0,0 +1,85 @@ +# run-virt.include +# ----------------------------------------------------------------------------- +# Copyright (c) 2011 - RZ Uni Freiburg +# Copyright (c) 2011 - 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 +# ----------------------------------------------------------------------------- +# run-virt.include +# - Include script for running the various emulators via a common frontend +# script via the common run-virt.sh of the vmchooser +################################################################################ + +################################################################################ +### Include general configuration +################################################################################ +if [ -f ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf ]; then + . ${OPENSLX_DEFAULT_CONFDIR}/plugins/${self}/${self}.conf +else + writelog "Problems reading config file of ${self} plugin" + # TODO: exit wenn conf wichtig + #exit 1 +fi + +################################################################################ +### Declaration of default variables +################################################################################ + +PLUGINCONFQK="${PLUGINCONFROOT}/${self}" +PLUGINDIRQK=${OPENSLX_DEFAULT_DIR}/plugin-repo/${self} +# create TMPDIR for all users +mkdir -m 1777 /tmp/${self} 2>/dev/null +# TMPDIR +QKTMPDIR="/tmp/${self}/${USER}/${VM_ID}" +# define dirs and files which can be removed after exit, be carefull! +RMDIRS="${QKTMPDIR}" +rm -rf ${RMDIRS} 2>/dev/null +mkdir -m 1777 -p ${QKTMPDIR} 2>/dev/null +# vmpath is the path to the emulator/original system image +diskfile=${vmpath} + + +# display name, remove blanks because of cmdline problems +displayname=$(echo ${displayname} | sed -e "s, ,-,g") +VIRTCMDOPTS="${VIRTCMDOPTS} -name ${displayname}" + +writelog "Directories:" +writelog "\tTMPDIR:\t\t\t$QKTMPDIR" +writelog "Diskimage:" +writelog "\tDisk type:\t\t$imgtype" +writelog "\tDisk file:\t\t$diskfile" + +################################################################################ +### Emulator definitions +################################################################################ + + +writelog "Virtual Hardware:" +writelog "\tGuest RAM:\t\t${mem} MB" +# echo nur wenn memhost gesetzt +[ -n "${memhost}" ] && writelog "\tHost RAM:\t\t${memhost} MB" +writelog "\tMAC address:\t\t$macaddr" +writelog "\tNetwork card:\t\t${network_card}" +writelog "\tNetwork kind:\t\t${network_kind}" +#writelog "\tCD-ROM1:\t${cdrom0}" +#writelog "\tCD-ROM2:\t${cdrom1}" +#writelog "\tFloppy_A:\t${floppy0}" +#writelog "\tFloppy_B:\t${floppy1}" +#writelog "\tShared Folders 'home':\t/home/${USER}" + +################################################################################ +### finally set env for run-virt.sh +################################################################################ + + +# define first, you do not want VIRTCMDOPTS from graphical start +VIRTCMDHL=${VIRTCMD} +VIRTCMDOPTSHL="${VIRTCMDOPTS} -nographic ${diskfile}" + + diff --git a/src/os-plugins/plugins/vmchooser/files/run-virt.sh b/src/os-plugins/plugins/vmchooser/files/run-virt.sh index 37db0c23..c4866212 100644 --- a/src/os-plugins/plugins/vmchooser/files/run-virt.sh +++ b/src/os-plugins/plugins/vmchooser/files/run-virt.sh @@ -133,14 +133,14 @@ if ! [ -r "${xmlfile}" ]; then exit 1 fi -# Test if XML file +# test if XML file if ! grep '/dev/null 2>&1; then writelog \ "Submitted configuration file ${xmlfile} seems to have wrong XML format" exit 1 fi -# Theck for running in graphical environment otherwise no much use here +# check for running in graphical environment otherwise no much use here [ -z "$DISPLAY" ] && echo -e "\n\tStart only within a graphical desktop!\n" \ && exit 1 @@ -207,11 +207,11 @@ vm_shortname=$(basename ${xmlfile%.xml} | sed -e "s, ,-,g") # vm_name = displayname, define for old scripts displayname=${vm_name} -# Image is for the following virtual machine +# image is for the following virtual machine xmlvirt=$(grep -o 'virtualmachine param=.*"' ${xmlfile} \ | sed -e "s/&.*;/; /g" | awk -F '"' '{print $2}') -# Make a guess from the filename extension if ${xmlvirt} is empty +# make a guess from the filename extension if ${xmlvirt} is empty # (not set within the XML file) # TODO: implement possibility to submit own configuration files if [ -z "${xmlvirt}" ] && [ -n "${additional_config}" ]; then -- cgit v1.2.3-55-g7522