File Coverage

lib/Rex/Virtualization/LibVirt/clone.pm
Criterion Covered Total %
statement 17 24 70.8
branch 0 4 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 23 36 63.8


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Virtualization::LibVirt::clone;
6              
7 1     1   15 use v5.12.5;
  1         3  
8 1     1   6 use warnings;
  1         2  
  1         41  
9              
10             our $VERSION = '1.14.2.3'; # TRIAL VERSION
11              
12 1     1   6 use Rex::Logger;
  1         2  
  1         7  
13 1     1   35 use Rex::Helper::Run;
  1         2  
  1         55  
14              
15 1     1   7 use XML::Simple;
  1         2  
  1         19  
16              
17 1     1   90 use Data::Dumper;
  1         3  
  1         161  
18              
19             sub execute {
20 0     0 0   my ( $class, $vmname, $newname ) = @_;
21              
22 0 0         unless ($vmname) {
23 0           die("You have to define the vm name!");
24             }
25              
26 0 0         unless ($newname) {
27 0           die("You have to define the new vm name!");
28             }
29              
30 0           my $connect = Rex::Config->get('virtualization')->{connect};
31              
32 0           i_run
33             "/usr/bin/virt-clone --connect '$connect' -o '$vmname' -n '$newname' --auto-clone";
34             }
35              
36             1;