# Copyright (c) 2010 - RZ Uni Freiburg
# Copyright (c) 2010 - 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/
# -----------------------------------------------------------------------------
# xen.pm
# - implementation of the 'xen' plugin
# -----------------------------------------------------------------------------
package OpenSLX::OSPlugin::xen;
use strict;
use warnings;
use base qw(OpenSLX::OSPlugin::Base);
use File::Path;
use OpenSLX::Basics;
use OpenSLX::Utils;
sub new
{
my $class = shift;
my $self = {
name => 'xen',
};
return bless $self, $class;
}
sub getInfo
{
my $self = shift;
return {
description => unshiftHereDoc(<<' End-of-Here'),
Configures Xen diskless boot, no installation yet.
End-of-Here
precedence => 10,
};
}
sub getAttrInfo
{
my $self = shift;
return {
'xen::active' => {
applies_to_systems => 1,
applies_to_clients => 1,
description => unshiftHereDoc(<<' End-of-Here'),
should the 'xen'-plugin be executed during boot?
End-of-Here
content_regex => qr{^(0|1)$},
content_descr => '1 means active - 0 means inactive',
# set active to 0, later set specially created Xen system to 1
default => '0',
},
# attribute 'imagesrc' defines where we can find xen images
'xen::imagesrc' => {
applies_to_systems => 1,
applies_to_clients => 1,
description => unshiftHereDoc(<<' End-of-Here'),
Where do we store our xen images? NFS? Filesystem?
End-of-Here
content_regex => qr{^(/|nfs://)},
content_descr => 'local path or URI or "-" (unset)',
default => undef,
},
# attribute 'tftpdir' defines TFTP dir for network boots /w NAT
'xen::tftpdir' => {
applies_to_systems => 1,
applies_to_clients => 1,
description => unshiftHereDoc(<<' End-of-Here'),
Do you want to define a stage 4 TFTP dir for netwoork boots?
Needed to boot Xen via NFS, we only need the initramfs
Hint: Mount your TFTP ro via NFS to a local dir
End-of-Here
content_regex => qr{^(/)},
content_descr => 'local path or "-" (unset)',
default => undef,
},
};
}
sub installationPhase
{
my $self = shift;
my $info = shift;
$self->{pluginRepositoryPath} = $info->{'plugin-repo-path'};
$self->{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 =
"$self->{openslxBasePath}/lib/plugins/$pluginName/files";
foreach my $file ( qw( run-virt.include machine.include hvm.include ) ) {
copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/");
chmod 0644, "$self->{pluginRepositoryPath}/$file";
}
return;
}
sub removalPhase
{
my $self = shift;
my $info = shift;
return;
}
sub suggestAdditionalKernelModules
{
my $self = shift;
my $makeInitRamFSEngine = shift;
my @suggestedModules;
# Xen needs bridge module, for guests xennet and maybe xenblk
# earlier versions needed netloop
push @suggestedModules, qw( bridge xennet xenblk );
return @suggestedModules;
}
#sub _xenLabel
#{
# # set label for each Xen system
# foreach my $info (@$systemInfos) {
# if ($info->{xen::active} eq 1) {
# my $label = $info->{label} || '';
# if (!length($label) || $label eq $info->{name}) {
# if ($info->{name} =~ m{^(.+)::(.+)$}) {
# my $system = $1;
# my $exportType = $2;
# $label = $system . "-xen" . ' ' x (36-length($system))
# . $exportType;
# } else {
# $label = $info->{name};
# }
# }
# }
# $info->{pxeLabel} = $label;
# }
# return $info; #???
#}
#sub _xenBootEntry
#{
# # Xen entries look different
# # Example:
# # KERNEL mboot.c32 vendor-os/xen.gz dom0_mem=128000 ---
# # vendor-os/vmlinuz-xen debug=3 --- vendor-os/initramfs-1
# # TODO: versionsort oder per attr?
# if ($info->{xen::active} eq 1) {
# my $xenKernel = slxsystem(ls /boot/xen* | sort | tail -n 1);
# $append .= " file=$bootURI" if length($bootURI);
# $append .= " file=$tftpPrefix" if length($tftpPrefix);
# $append .= " $clientAppend";
# $append .= " --- $pxePrefix$vendorOSName/$info->{'initramfs-name'}";
# $slxLabels .= "LABEL openslx-$info->{'external-id'}-xen\n";
# # $slxLabels .= $pxeDefault;
# $slxLabels .= "\tMENU LABEL ^$info->{pxeLabel}\n";
# $slxLabels .= "\tKERNEL mboot.c32\n";
# $slxLabels .= "\tAPPEND $pxePrefix$vendorOSName/$xenKernel";
# # $slxLabels .= " dom0_mem=128000";
# $slxLabels .= " --- $pxePrefix$vendorOSName/$kernelName";
# $slxLabels .= " --- $append\n";
# $slxLabels .= "\tIPAPPEND 3\n";
# }
# return $slxLabels;
#}
1;