/usr/share/perl5/Rex/Virtualization.pm is in rex 1.4.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 | #
# (c) Jan Gehring <jan.gehring@gmail.com>
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:
package Rex::Virtualization;
use strict;
use warnings;
our $VERSION = '1.4.1'; # VERSION
use Rex::Logger;
use Rex::Config;
my %VM_PROVIDER;
Rex::Config->register_config_handler(
virtualization => sub {
my ($param) = @_;
if ( ref($param) eq '' ) {
#support 'set virtualization => 'LibVirt', but leave the way open for using a hash in future
#other virtualisation drivers may need more settings...
$param = { type => $param };
}
if ( exists $param->{type} ) {
Rex::Config->set( virtualization => $param->{type} );
}
}
);
sub register_vm_provider {
my ( $class, $service_name, $service_class ) = @_;
$VM_PROVIDER{"\L$service_name"} = $service_class;
return 1;
}
sub create {
my ( $class, $wanted_provider ) = @_;
$wanted_provider ||= Rex::Config->get("virtualization");
if ( ref($wanted_provider) ) {
$wanted_provider = $wanted_provider->{type} || "LibVirt";
}
if ( !$wanted_provider ) {
die
"No virtualization provider set.\nPlease use `set virtualization => 'YourProvider';` to set one,\nor see `perldoc Rex::Commands::Virtualization` for more options";
}
my $klass = "Rex::Virtualization::$wanted_provider";
if ( exists $VM_PROVIDER{$wanted_provider} ) {
$klass = $VM_PROVIDER{$wanted_provider};
}
eval "use $klass";
if ($@) {
die
"Failed loading given virtualization module.\nTried to load <$klass>.\nError: $@\n";
}
Rex::Logger::debug("Using $klass for virtualization");
my $mod = $klass->new;
return $mod;
}
1;
|