line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::vm_os_types; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
67525
|
use strict; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
49
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
458
|
use Rex::Logger; |
|
1
|
|
|
|
|
11138
|
|
|
1
|
|
|
|
|
37
|
|
13
|
1
|
|
|
1
|
|
409
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
76205
|
|
|
1
|
|
|
|
|
73
|
|
14
|
1
|
|
|
1
|
|
8
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1757
|
|
15
|
1
|
|
|
1
|
|
13
|
use Rex::Commands::User; |
|
1
|
|
|
|
|
104072
|
|
|
1
|
|
|
|
|
8
|
|
16
|
1
|
|
|
1
|
|
620
|
use Rex::Commands::Fs; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub execute { |
19
|
0
|
|
|
0
|
0
|
|
my ($class) = @_; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
Rex::Logger::debug("Getting a list of VM OS types for CBSD "); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# get where CBSD is installed to |
24
|
0
|
|
|
|
|
|
my %cbsd; |
25
|
0
|
0
|
|
|
|
|
eval { %cbsd = get_user('cbsd'); } or do { |
|
0
|
|
|
|
|
|
|
26
|
0
|
|
0
|
|
|
|
my $error = $@ || 'Unknown failure'; |
27
|
0
|
|
|
|
|
|
die( "get_user('cbsd') died with... " . $error ); |
28
|
|
|
|
|
|
|
}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $cbsd_etc_defaults_dir = $cbsd{home} . '/etc/defaults/'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# get a list of the VM/OS configs |
33
|
0
|
|
|
|
|
|
my @vm_configs = grep { /^vm\-/ } list_files($cbsd_etc_defaults_dir); |
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# find what OS we have profiles for |
36
|
0
|
|
|
|
|
|
my %os_types; |
37
|
0
|
|
|
|
|
|
foreach my $config (@vm_configs) { |
38
|
0
|
|
|
|
|
|
my ( $vm, $os, $profile ) = split( /\-/, $config, 3 ); |
39
|
0
|
|
|
|
|
|
$os_types{$os} = 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return keys(%os_types); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |