File Coverage

lib/Rex/Virtualization/Lxc/start.pm
Criterion Covered Total %
statement 11 21 52.3
branch 0 6 0.0
condition n/a
subroutine 4 5 80.0
pod 0 1 0.0
total 15 33 45.4


line stmt bran cond sub pod time code
1             #
2             # (c) Oleg Hardt
3             #
4              
5             package Rex::Virtualization::Lxc::start;
6              
7 1     1   15 use v5.12.5;
  1         5  
8 1     1   7 use warnings;
  1         2  
  1         43  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12 1     1   6 use Rex::Logger;
  1         4  
  1         6  
13 1     1   21 use Rex::Helper::Run;
  1         12  
  1         200  
14              
15             sub execute {
16 0     0 0   my ( $class, $arg1, %opt ) = @_;
17              
18 0 0         unless ($arg1) {
19 0           die("You have to define the container name!");
20             }
21              
22 0           my $container_name = $arg1;
23 0           Rex::Logger::debug("starting container $container_name");
24              
25 0 0         unless ($container_name) {
26 0           die("VM $container_name not found.");
27             }
28              
29 0           i_run "lxc-start -d -n \"$container_name\"", fail_ok => 1;
30 0 0         if ( $? != 0 ) {
31 0           die("Error starting container $container_name");
32             }
33              
34             }
35              
36             1;