File Coverage

lib/Rex/Virtualization/Lxc/info.pm
Criterion Covered Total %
statement 11 26 42.3
branch 0 4 0.0
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 15 36 41.6


line stmt bran cond sub pod time code
1             #
2             # (c) Oleg Hardt
3             #
4              
5             package Rex::Virtualization::Lxc::info;
6              
7 1     1   14 use v5.12.5;
  1         3  
8 1     1   6 use warnings;
  1         2  
  1         53  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   7 use Rex::Logger;
  1         2  
  1         6  
13 1     1   21 use Rex::Helper::Run;
  1         2  
  1         285  
14              
15             sub execute {
16 0     0 0   my ( $class, $arg1 ) = @_;
17 0           my @dominfo;
18              
19 0 0         if ( !$arg1 ) {
20 0           die('Must define container ID');
21             }
22              
23 0           Rex::Logger::debug("Getting lxc-info");
24              
25 0           my @container_info = i_run "lxc-info -n $arg1", fail_ok => 1;
26 0 0         if ( $? != 0 ) {
27 0           die("Error running lxc-info");
28             }
29              
30 0           my %ret;
31 0           for my $line (@container_info) {
32 0           my ( $column, $value ) = split( ':', $line );
33              
34             # Trim white spaces.
35 0           $column =~ s/^\s+|\s+$//g;
36 0           $value =~ s/^\s+|\s+$//g;
37              
38 0           $ret{$column} = $value;
39             }
40              
41 0           return \%ret;
42             }
43              
44             1;