line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Zane C. Bowers-Hadley |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Rex::Virtualization::CBSD::bsnapshot_list; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
73418
|
use strict; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
34
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.0.1'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
469
|
use Rex::Logger; |
|
1
|
|
|
|
|
11298
|
|
|
1
|
|
|
|
|
70
|
|
13
|
1
|
|
|
1
|
|
585
|
use Rex::Helper::Run; |
|
1
|
|
|
|
|
83072
|
|
|
1
|
|
|
|
|
78
|
|
14
|
1
|
|
|
1
|
|
12
|
use Term::ANSIColor qw(colorstrip); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2304
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub execute { |
17
|
0
|
|
|
0
|
0
|
|
my ( $class ) = @_; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# put together the command |
20
|
0
|
|
|
|
|
|
my $command |
21
|
|
|
|
|
|
|
= 'cbsd bsnapshot mode=list display=jname,snapname,creation,refer header=0'; |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
Rex::Logger::debug( "Listing VM disk snapshots for CBSD via... " . $command ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $returned = i_run( $command, fail_ok => 1 ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# the output is colorized, if there is an error |
28
|
0
|
|
|
|
|
|
$returned = colorstrip($returned); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# check for this second as no VM will also exit non-zero |
31
|
0
|
0
|
|
|
|
|
if ( $? != 0 ) { |
32
|
0
|
|
|
|
|
|
die( "Error running '" . $command . "'" ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
0
|
|
|
|
|
|
my @snapshots; |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my @returned_split=split(/\n/, $returned); |
38
|
0
|
|
|
|
|
|
foreach my $line (@returned_split) { |
39
|
0
|
|
|
|
|
|
my %snap; |
40
|
0
|
|
|
|
|
|
( $snap{vm}, $snap{name}, $snap{creation}, $snap{refer} )=split(/[\t\ ]+/, $line, 4); |
41
|
0
|
|
|
|
|
|
push( @snapshots, \%snap ); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
return @snapshots; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
1; |