# Dummy.pm
#
# This file is a sample for VNUML extension plugins. It can be used
# as a template to implement custom user plugins. Note that, in order
# to conform the VNUML plugins API, the modules has to implement all
# the methods.
package dummy;
@ISA = qw(Exporter);
@EXPORT = qw(createPlugin
bootingCreateFiles
bootingCommands
execCreateFiles
execCommands
shutdownCommand
finalizePlugin);
use strict;
# createPlugin
#
# To be called always, just before starting procesing the scenario specification
#
# Arguments:
# - the operation mode ("t","x","d" or "P")
# - the plugin configuration file
#
# Returns:
# - an error message or 0 if all is ok
#
sub createPlugin {
my $self = shift;
my $mode = shift;
my $conf = shift;
# Sample code
print "dummy plugin: creating in mode $mode with file $conf\n";
# Example of error message returning:
#
# return "an error has occur in dummy plugin"
#
return 0;
}
# bootingCreateFiles
#
# To be called during "t" mode, for each vm in the scenario
#
# Arguments:
# - vm name
#
# Returns:
# - a hashname which kyes are absolute pathnames of files in vm filesystem and
# values the the pathname of the file in the host filesystem. The file in the
# host filesytesm is removed after VNUML processed it, so temporal files in
# /tmp are preferable)
#
sub bootingCreateFiles {
my $self = shift;
my $vm = shift;
my %files;
# Sample code
print "dummy plugin: booting create files for vm $vm\n";
system("touch /tmp/boot1.$vm");
system("touch /tmp/boot2.$vm");
$files{"/etc/init.d/boot1"} = "/tmp/boot1.$vm";
$files{"/etc/init.d/boot2"} = "/tmp/boot2.$vm";
return %files;
}
# bootingCommands
#
# To be called during "t" mode, for each vm in the scenario
#
# Arguments:
# - vm name
#
# Returns:
# - list of commands to execute in the virtual machine at booting time
#
sub bootingCommands {
my $self = shift;
my $vm = shift;
my @commands;
# Sample code
print "dummy plugin: booting commands for vm $vm\n";
push (@commands,"sh /etc/init.d/boot1");
push (@commands,"sh /etc/init.d/boot2");
return @commands;
}
# execCreateFiles
#
# To be called during "x" mode, for each vm in the scenario
#
# Arguments:
# - vm name
# - seq command sequence
#
# Returns:
# - a hashname which keys are absolute pathnames of files in vm filesystem and
# values the the pathname of the file in the host filesystem. The file in the
# host filesytesm is removed after VNUML processed it, so temporal files in
# /tmp are preferable)
#
sub execCreateFiles {
my $self = shift;
my $vm = shift;
my $seq = shift;
my %files;
# Sample code
print "dummy plugin: exec create files for vm $vm and seq $seq\n";
system("touch /tmp/exec1.$vm.$seq");
system("touch /tmp/exec2.$vm.$seq");
$files{"/etc/init.d/exec1.$seq"} = "/tmp/exec1.$vm.$seq";
$files{"/etc/init.d/exec2.$seq"} = "/tmp/exec2.$vm.$seq";
return %files;
}
# execCommands
#
# To be called during "x" mode, for each vm in the scenario
#
# Arguments:
# - vm name
# - seq command sequence
#
# Returns:
# - list of commands to execute in the virtual machine after <exec> processing
#
sub execCommands {
my $self = shift;
my $vm = shift;
my $seq = shift;
my @commands;
# Sample code
print "dummy plugin: exec commands for vm $vm and seq $seq\n";
push (@commands,"sh /etc/init.d/exec1.$seq");
push (@commands,"sh /etc/init.d/exec2.$seq");
return @commands;
}
# shutdownCommand
#
# To be called during "d" mode, for each vm in the scenario
#
# Arguments:
# - vm name
#
# Returns:
# - list of commands to execute in the virtual machine at shutdown time
#
sub shutdownCommands {
my $self = shift;
my $vm = shift;
my @commands;
# Sample code
print "dummy plugin: shutdown commands for vm $vm\n";
push (@commands,"sh /etc/init.d/shutdown1");
push (@commands,"sh /etc/init.d/shutdown2");
return @commands;
}
# finalizePlugin
#
# To be called always, just before ending the procesing the scenario specification
#
# Arguments:
# - none
#
# Returns:
# - none
#
sub finalizePlugin {
my $self = shift;
# Sample code
print "dummy plugin: finishing\n"
}
1;