line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::start; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
70865
|
use strict; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
31
|
|
8
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
480
|
use Rex::Logger; |
|
1
|
|
|
|
|
11119
|
|
|
1
|
|
|
|
|
40
|
|
13
|
1
|
|
|
1
|
|
437
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
78541
|
|
|
1
|
|
|
|
|
75
|
|
14
|
1
|
|
|
1
|
|
10
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
2404
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ( $class, $name ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
0
|
0
|
|
|
|
|
if ( !defined($name) ) { |
20
|
0
|
|
|
|
|
|
die('No VM name defined'); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
Rex::Logger::debug( "CBSD VM start via cbsd bstart " . $name ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $returned = i_run( 'cbsd bstart jname=' . $name, fail_ok => 1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# the output is colorized |
28
|
0
|
|
|
|
|
|
$returned = colorstrip($returned); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# check for failures caused by it not existing |
31
|
0
|
0
|
|
|
|
|
if ( $returned =~ /^No\ such/ ) { |
32
|
0
|
|
|
|
|
|
die( '"' . $name . '" does not exist' ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# check for failures caused by it already running |
36
|
0
|
0
|
|
|
|
|
if ( $returned =~ /already\ running/ ) { |
37
|
0
|
|
|
|
|
|
die( '"' . $name . '" is already running' ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# test after no such as that will also exit non-zero |
41
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
42
|
0
|
|
|
|
|
|
die( "Error running 'cbsd bstart " . $name . "'" ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
return 1; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
1; |