summaryrefslogtreecommitdiffstats
path: root/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
diff options
context:
space:
mode:
Diffstat (limited to 'os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm')
-rw-r--r--os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm123
1 files changed, 86 insertions, 37 deletions
diff --git a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
index fd1424f1..f8fad1ba 100644
--- a/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
+++ b/os-plugins/plugins/virtualbox/OpenSLX/OSPlugin/virtualbox.pm
@@ -45,7 +45,8 @@ sub getInfo
stateless client.
End-of-Here
precedence => 70,
- required => [ qw( desktop ) ],
+ # headless mode does not require a desktop!
+ #required => [ qw( desktop ) ],
};
}
@@ -67,7 +68,7 @@ sub getAttrInfo
should the 'virtualbox'-plugin be executed during boot?
End-of-Here
content_regex => qr{^(0|1)$},
- content_descr => '1 means active - 0 means inactive',
+ content_descr => '1 for active, 0 for inactive',
default => '1',
},
# attribute 'imagesrc' defines where we can find virtualbox images
@@ -77,13 +78,14 @@ sub getAttrInfo
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 => '',
+ content_regex => qr{^(/|nfs://)},
+ content_descr => 'local path or URI or "-" (unset)',
+ default => undef,
},
# attribute 'bridge' defines if bridged network mode should be
# switched on
+ # TODO: change to net -> nat, bridge, hostonly?
+ # TODO: since we use def in XML maybe use to override
'virtualbox::bridge' => {
applies_to_systems => 1,
applies_to_clients => 1,
@@ -92,10 +94,46 @@ sub getAttrInfo
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',
+ content_descr => '0 or 1',
default => '1',
},
-
+ # attribute 'mem' defines if memory should be forced
+ 'virtualbox::mem' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Do you want to force a ralative amount of RAM?
+ (Not implemented right now!)
+ End-of-Here
+ content_regex => qr{^(\d\d??)$},
+ content_descr => 'Between 0 - 99',
+ default => undef,
+ },
+ # attribute 'kvm' defines if KVM modules should be forced
+ 'virtualbox::kvm' => {
+ applies_to_systems => 1,
+ applies_to_clients => 1,
+ description => unshiftHereDoc(<<' End-of-Here'),
+ Do you want to force the usage of KVM modules where applicable?
+ (Not implemented right now!)
+ End-of-Here
+ content_regex => qr{^(0|1)$},
+ content_descr => '0 or 1',
+ default => undef,
+ },
+ # attribute 'tftpdir' defines TFTP dir for network boots /w NAT
+ 'virtualbox::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 when
+ using NAT?
+ 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,
+ },
};
}
@@ -103,7 +141,7 @@ 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'};
@@ -111,22 +149,31 @@ sub installationPhase
$self->{attrs} = $info->{'plugin-attrs'};
my $engine = $self->{'os-plugin-engine'};
-
+
# Different names of the tool (should be unified somehow!?)
if (!isInPath('VirtualBox')) {
# todo: fix this
- $self->{distro}->installVbox();
+ $self->{distro}->installVbox();
}
if (!isInPath('VirtualBox')) {
- print "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n";
-# exit
- }
+ print
+ "VirtualBox is not installed. VirtualBox Plugin won't be installed!\n"
+ ;
+ #exit
+ }
$self->_writeRunlevelScript();
- # Copy run-virt.include to the appropriate place for inclusion in stage4
- copyFile("$self->{openslxBasePath}/lib/plugins/virtualbox/files/run-virt.include",
- "$self->{pluginRepositoryPath}/");
+ # 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 virtualbox.include machine.include
+ empty-diff.vdi.gz rwimg.vdi.gz ) ) {
+ copyFile("$pluginBasePath/$file", "$self->{pluginRepositoryPath}/");
+ chmod 0644, "$self->{pluginRepositoryPath}/$file";
+ }
return;
}
@@ -155,8 +202,8 @@ sub checkStage3AttrValues
sub _writeRunlevelScript
{
my $self = shift;
-
my $initfile = newInitFile();
+ my $script = "";
$initfile->setName("vbox-slx");
$initfile->setDesc("Setup environment for virtualbox. Part of OpenSLX virtualbox plugin.");
@@ -166,30 +213,34 @@ sub _writeRunlevelScript
'running',
'lsmod | grep -q "$1[^_-]"'
);
+ #
+ $script = unshiftHereDoc(<<' End-of-Here');
+ if running vboxdrv; then
+ if running vboxnetflt; then
+ echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded."
+ else
+ echo "VirtualBox kernel module is loaded."
+ fi
+ #TODO: check it: ignore user check. handling our own way:
+ for i in /tmp/.vbox-*-ipc; do
+ echo "Running: "
+ $(VBoxManage -q list runningvms | sed -e 's/^".*"//' 2>/dev/null)
+ done
+ else
+ echo "VirtualBox kernel module(s) are not loaded."
+ fi
+ End-of-Here
$initfile->addFunction(
- 'vmstatus',
- 'if running vboxdrv; then
- if running vboxnetflt; then
- echo "VirtualBox kernel modules (vboxdrv and vboxnetflt) are loaded."
- else
- echo "VirtualBox kernel module is loaded."
- fi
- #TODO: check it: ignore user check. handling our own way:
- for i in /tmp/.vbox-*-ipc; do
- echo "Running: "
- $(VBoxManage --nologo list runningvms | sed -e \'s/^".*"//\' 2>/dev/null)
- done
- else
- echo "VirtualBox kernel module is not loaded."
- fi'
+ "vmstatus",
+ "$script"
);
$initfile->addFunction(
'start',
- ' modprobe vboxdrv && modprobe vboxnetflt',
+ ' modprobe -qa vboxdrv vboxnetflt vboxnetadp',
);
$initfile->addFunction(
'stop',
- ' rmmod vboxnetflt && rmmod vboxdrv',
+ ' rmmod vboxnetadp vboxnetflt vboxdrv',
);
$initfile->addToCase(
'start',
@@ -212,8 +263,6 @@ sub _writeRunlevelScript
my $distro = (split('-',$self->{'os-plugin-engine'}->distroName()))[0];
my $runlevelscript = getInitFileForDistro($initfile, $distro);
- # todo: because we dont have distribution or version dependend
- # init scripts we could put it directly into /etc/init.d...
spitFile("$self->{'pluginRepositoryPath'}/vbox-slx", $runlevelscript);
}