line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::freejname; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
68011
|
use strict; |
|
1
|
|
|
|
|
9
|
|
|
1
|
|
|
|
|
32
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
58
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
516
|
use Rex::Logger; |
|
1
|
|
|
|
|
10859
|
|
|
1
|
|
|
|
|
42
|
|
13
|
1
|
|
|
1
|
|
450
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
78964
|
|
|
1
|
|
|
|
|
72
|
|
14
|
1
|
|
|
1
|
|
10
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
1114
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ( $class, $name, %opts ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# set the hard_timeout if needed |
20
|
0
|
|
|
|
|
|
my $lease_time = ''; |
21
|
0
|
0
|
|
|
|
|
if ( defined( $opts{lease_time} ) ) { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# make sure we have a valid value |
24
|
0
|
0
|
|
|
|
|
if ( $opts{lease_time} !~ /^[0123456789]+$/ ) { |
25
|
0
|
|
|
|
|
|
die 'lease_time value,"' . $opts{lease_time} . '", is not numeric'; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
$lease_time = 'lease_time=' . $opts{lease_time}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# make sure we have a |
32
|
0
|
0
|
|
|
|
|
if ( !defined($name) ) { |
33
|
0
|
|
|
|
|
|
die('No VM name defined'); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
Rex::Logger::debug( "CBSD VM stop via freejname default_jailname=" . $name . ' ' . $lease_time ); |
37
|
|
|
|
|
|
|
|
38
|
0
|
|
|
|
|
|
my $returned = i_run( 'cbsd freejname default_jailname=' . $name . ' ' . $lease_time, fail_ok => 1 ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# test after no such as that will also exit non-zero |
41
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
42
|
0
|
|
|
|
|
|
die( "Error running 'cbsd freejname default_jailname='" . $name . " " . $lease_time . "'" ); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# remove colors as needed |
46
|
0
|
|
|
|
|
|
$returned = colorstrip($returned); |
47
|
0
|
|
|
|
|
|
chomp($returned); |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $returned; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |