File Coverage

lib/Rex/Cloud.pm
Criterion Covered Total %
statement 14 31 45.1
branch 0 4 0.0
condition n/a
subroutine 5 8 62.5
pod 0 3 0.0
total 19 46 41.3


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::Cloud;
6              
7 1     1   14 use v5.12.5;
  1         4  
8 1     1   5 use warnings;
  1         8  
  1         46  
9              
10             our $VERSION = '1.14.2.2'; # TRIAL VERSION
11              
12             require Exporter;
13 1     1   5 use base qw(Exporter);
  1         2  
  1         91  
14 1     1   23 use vars qw(@EXPORT);
  1         2  
  1         51  
15              
16 1     1   7 use Rex::Logger;
  1         1  
  1         7  
17              
18             @EXPORT = qw(get_cloud_service);
19              
20             my %CLOUD_SERVICE;
21              
22             sub register_cloud_service {
23 0     0 0   my ( $class, $service_name, $service_class ) = @_;
24 0           $CLOUD_SERVICE{"\L$service_name"} = $service_class;
25 0           return 1;
26             }
27              
28             sub register_cloud_provider {
29 0     0 0   my $class = shift;
30 0           $class->register_cloud_service(@_);
31             }
32              
33             sub get_cloud_service {
34              
35 0     0 0   my ($service) = @_;
36              
37 0 0         if ( exists $CLOUD_SERVICE{"\L$service"} ) {
38 0           eval "use " . $CLOUD_SERVICE{"\L$service"};
39              
40 0           my $mod = $CLOUD_SERVICE{"\L$service"};
41 0           return $mod->new;
42             }
43             else {
44 0           eval "use Rex::Cloud::$service";
45              
46 0 0         if ($@) {
47 0           Rex::Logger::info("Cloud Service $service not supported.");
48 0           Rex::Logger::info($@);
49 0           return 0;
50             }
51              
52 0           my $mod = "Rex::Cloud::$service";
53 0           return $mod->new;
54             }
55              
56             }
57              
58             1;