OpenNebula/Image.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 48 CC 2 SCAR 10.3
CC
2
Cov
0%
state
6.0
create
2.0
delete
2.0
CRAP 2.8
1 #
2 # (c) Jan Gehring <jan.gehring@gmail.com>
3 #
4 # vim: set ts=3 sw=3 tw=0:
5 # vim: set expandtab:
6 #
7 use strict;
8 use warnings;
9  
10 package Net::OpenNebula::Image;
11 $Net::OpenNebula::Image::VERSION = '0.317.0';
12 use Net::OpenNebula::RPC;
13 push our @ISA , qw(Net::OpenNebula::RPC);
14  
15 use constant ONERPC => 'image';
16 use constant NAME_FROM_TEMPLATE => 1;
17  
18 # from include/Image.h enum ImageState
19 use constant STATES => qw(INIT READY USED DISABLED LOCKED ERROR CLONE DELETE USED_PERS);
20  
21 sub create {
22 my ($self, $tpl_txt, $datastoreid) = @_;
23 my $id = $self->_onerpc("allocate", [ string => $tpl_txt ], [ int => $datastoreid ]);
24 $self->{data} = $self->_get_info(id => $id);
25 return $id;
26 }
27  
28  
29 sub delete {
30 my ($self) = @_;
31 return $self->_onerpc_id("delete");
32 }
33  
34 # Return the state as string
35 sub state {
36 my ($self) = @_;
37 $self->_get_info(clearcache => 1);
38  
39 my $state = $self->{extended_data}->{STATE}->[0];
40  
41 if(!defined($state)) {
42 $self->warn('Undefined '.ONERPC.'-state for id ', $self->id);
43 return;
44 }
45  
46 return (STATES)[$state];
47 };
48  
49  
50 1;