line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DMTF::CIM::Instance::Method; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use version; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
our $VERSION = qv('0.04'); |
8
|
|
|
|
|
|
|
require DMTF::CIM::_model; |
9
|
1
|
|
|
1
|
|
649
|
use DMTF::CIM::Instance::Method::Parameter; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
25
|
|
10
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
981
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA=qw(DMTF::CIM::_valued); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Module implementation here |
15
|
|
|
|
|
|
|
sub new |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
1
|
|
my $class=shift; |
18
|
0
|
|
|
|
|
|
my %args=@_; |
19
|
0
|
|
|
|
|
|
my $result; |
20
|
0
|
|
|
|
|
|
my $self=DMTF::CIM::_valued::new($class, parent=>$args{parent},data=>$args{method},value=>\$result); |
21
|
0
|
|
0
|
|
|
|
$self->{VALUES}=$args{values} || {}; |
22
|
0
|
|
|
|
|
|
$self->{PARAMETERS}={}; |
23
|
0
|
|
|
|
|
|
return($self); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub parameter |
27
|
|
|
|
|
|
|
{ |
28
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
29
|
0
|
|
|
|
|
|
my $param=shift; |
30
|
|
|
|
|
|
|
|
31
|
0
|
0
|
|
|
|
|
if(!defined $param) { |
32
|
0
|
|
|
|
|
|
carp "No parameter name specified"; |
33
|
0
|
|
|
|
|
|
return; |
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
my $lcp=lc($param); |
36
|
0
|
0
|
|
|
|
|
return $self->{PARAMETERS}{$lcp} if(defined $self->{PARAMETERS}{$lcp}); |
37
|
0
|
|
|
|
|
|
my $paramref=$self->{DATA}{parameters}{$lcp}; |
38
|
0
|
0
|
|
|
|
|
if(!defined $paramref) { |
39
|
0
|
|
|
|
|
|
carp "Parameter $param not specified in model"; |
40
|
0
|
|
|
|
|
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
0
|
|
|
|
|
|
$self->{PARAMETERS}{$lcp}=DMTF::CIM::Instance::Method::Parameter->new(parent=>$self, parameter=>$paramref, value=>\$self->{VALUES}{$paramref->{name}}); |
43
|
0
|
|
|
|
|
|
return $self->{PARAMETERS}{$lcp}; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub in_params |
47
|
|
|
|
|
|
|
{ |
48
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
49
|
0
|
|
|
|
|
|
my @ret; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->{DATA}{parameters}}) { |
|
0
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $param=$self->parameter($key); |
53
|
0
|
0
|
|
|
|
|
next unless defined $param; |
54
|
0
|
0
|
|
|
|
|
push @ret,$param if $param->qualifier('in') eq 'true'; |
55
|
|
|
|
|
|
|
} |
56
|
0
|
|
|
|
|
|
return @ret; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub out_params |
60
|
|
|
|
|
|
|
{ |
61
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
62
|
0
|
|
|
|
|
|
my @ret; |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->{DATA}{parameters}}) { |
|
0
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $param=$self->parameter($key); |
66
|
0
|
0
|
|
|
|
|
next unless defined $param; |
67
|
0
|
0
|
|
|
|
|
push @ret,$param if $param->qualifier('out') eq 'true'; |
68
|
|
|
|
|
|
|
} |
69
|
0
|
|
|
|
|
|
return @ret; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub parameters |
73
|
|
|
|
|
|
|
{ |
74
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
75
|
0
|
|
|
|
|
|
my @ret; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
foreach my $key (keys %{$self->{DATA}{parameters}}) { |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my $param=$self->parameter($key); |
79
|
0
|
0
|
|
|
|
|
push @ret, $param if defined $param; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
|
|
|
|
|
return @ret; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub clear_parameters |
85
|
|
|
|
|
|
|
{ |
86
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
87
|
0
|
|
|
|
|
|
my $result; |
88
|
0
|
|
|
|
|
|
$self->{PARAMETERS}={}; |
89
|
0
|
|
|
|
|
|
$self->{VALUES}={}; |
90
|
0
|
|
|
|
|
|
$self->{VALUE}=\$result; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub invoke |
94
|
|
|
|
|
|
|
{ |
95
|
0
|
|
|
0
|
1
|
|
my $self=shift; |
96
|
0
|
|
|
|
|
|
my $dad=$self->parent; |
97
|
0
|
0
|
|
|
|
|
if(!defined $dad) { |
98
|
0
|
|
|
|
|
|
carp "Unable to get parent instance"; |
99
|
0
|
|
|
|
|
|
return; |
100
|
|
|
|
|
|
|
} |
101
|
0
|
0
|
|
|
|
|
if(!defined $dad->uri) { |
102
|
0
|
|
|
|
|
|
carp "Parent instances does not hve a URI"; |
103
|
0
|
|
|
|
|
|
return; |
104
|
|
|
|
|
|
|
} |
105
|
0
|
|
|
|
|
|
my $grandma=$dad->parent; |
106
|
0
|
0
|
|
|
|
|
if(!defined $grandma) { |
107
|
0
|
|
|
|
|
|
carp "Unable to get grandparent model"; |
108
|
0
|
|
|
|
|
|
return; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
0
|
|
|
|
|
|
my $params={}; |
112
|
0
|
|
|
|
|
|
foreach my $param ($self->in_params) { |
113
|
0
|
0
|
|
|
|
|
if($param->is_array) { |
114
|
0
|
|
|
|
|
|
my $rv=$param->raw_value; |
115
|
0
|
0
|
|
|
|
|
if(defined $rv) { |
116
|
0
|
|
|
|
|
|
my $vals=[]; |
117
|
0
|
|
|
|
|
|
foreach my $value ($param->raw_value) { |
118
|
0
|
0
|
|
|
|
|
push @$vals,$value if defined $value; |
119
|
|
|
|
|
|
|
} |
120
|
0
|
|
|
|
|
|
$params->{$param->name}=$vals; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
else { |
124
|
0
|
|
|
|
|
|
my $rv=$param->raw_value; |
125
|
0
|
0
|
|
|
|
|
$params->{$param->name}=$rv if defined $rv; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
0
|
|
|
|
|
|
my $result=$grandma->InvokeMethod(uri=>$dad->uri,method=>$self->name,params=>$params); |
129
|
0
|
0
|
|
|
|
|
return unless defined $result; |
130
|
0
|
|
|
|
|
|
foreach my $out (keys %$result) { |
131
|
0
|
0
|
|
|
|
|
if($out eq 'ReturnValue') { |
132
|
0
|
|
|
|
|
|
$self->raw_value($result->{$out}); |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
else { |
135
|
0
|
|
|
|
|
|
$self->parameter($out)->raw_value($result->{$out}); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
|
return $result->{ReturnValue}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
142
|
|
|
|
|
|
|
__END__ |