line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS::Blade; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
4
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
3
|
use Carp qw(croak); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
3
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
343
|
use Cisco::UCS::Blade::Adaptor; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
9
|
1
|
|
|
1
|
|
335
|
use Cisco::UCS::Blade::CPU; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
375
|
use Cisco::UCS::Blade::PowerBudget; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
18
|
|
11
|
1
|
|
|
1
|
|
377
|
use Cisco::UCS::Common::PowerStats; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
174
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ATTRIBUTES = qw(association availability discovery dn model name |
16
|
|
|
|
|
|
|
operability presence revision serial uuid vendor); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our %ATTRIBUTES = ( |
19
|
|
|
|
|
|
|
admin_state => 'adminState', |
20
|
|
|
|
|
|
|
assignment => 'assignedToDn', |
21
|
|
|
|
|
|
|
conn_path => 'connPath', |
22
|
|
|
|
|
|
|
conn_status => 'connStatus', |
23
|
|
|
|
|
|
|
cores_enabled => 'numOfCoresEnabled', |
24
|
|
|
|
|
|
|
chassis => 'chassisId', |
25
|
|
|
|
|
|
|
checkpoint => 'checkPoint', |
26
|
|
|
|
|
|
|
description => 'descr', |
27
|
|
|
|
|
|
|
id => 'slotId', |
28
|
|
|
|
|
|
|
managing_instance => 'managingInst', |
29
|
|
|
|
|
|
|
memory_speed => 'memorySpeed', |
30
|
|
|
|
|
|
|
memory_available => 'availableMemory', |
31
|
|
|
|
|
|
|
memory_total => 'totalMemory', |
32
|
|
|
|
|
|
|
num_adaptors => 'numOfAdaptors', |
33
|
|
|
|
|
|
|
num_cores => 'numOfCores', |
34
|
|
|
|
|
|
|
num_cpus => 'numOfCpus', |
35
|
|
|
|
|
|
|
num_eth_ifs => 'numOfEthHostIfs', |
36
|
|
|
|
|
|
|
num_fc_ifs => 'numOfFcHostIfs', |
37
|
|
|
|
|
|
|
num_threads => 'numOfThreads', |
38
|
|
|
|
|
|
|
oper_power => 'operPower', |
39
|
|
|
|
|
|
|
oper_state => 'operState', |
40
|
|
|
|
|
|
|
server_id => 'serverId', |
41
|
|
|
|
|
|
|
slot_id => 'slotId', |
42
|
|
|
|
|
|
|
user_label => 'usrLbl', |
43
|
|
|
|
|
|
|
uuid_original => 'originalUuid' |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub new { |
47
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_; |
48
|
0
|
|
|
|
|
|
my $self = {}; |
49
|
0
|
|
|
|
|
|
bless $self, $class; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
defined $args{dn} |
52
|
|
|
|
|
|
|
? $self->{dn} = $args{dn} |
53
|
0
|
0
|
|
|
|
|
: croak 'dn not defined'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
defined $args{ucs} |
56
|
|
|
|
|
|
|
? weaken($self->{ucs} = $args{ucs}) |
57
|
0
|
0
|
|
|
|
|
: croak 'dn not defined'; |
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my %attr = %{ $self->{ucs}->resolve_dn( |
60
|
|
|
|
|
|
|
dn => $self->{dn})->{outConfig}->{computeBlade} |
61
|
0
|
|
|
|
|
|
}; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
while ( my ($k, $v) = each %attr ) { $self->{$k} = $v } |
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
return $self |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
{ |
69
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
649
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) { |
72
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $pseudo } = sub { |
73
|
0
|
|
|
0
|
|
|
my $self = shift; |
74
|
0
|
|
|
|
|
|
return $self->{$attribute} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
foreach my $attribute ( @ATTRIBUTES ) { |
79
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
80
|
0
|
|
|
0
|
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
return $self->{$attribute} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub led { |
87
|
0
|
|
|
0
|
1
|
|
my ( $self, $state ) = @_; |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
$state = lc $state; |
90
|
0
|
0
|
0
|
|
|
|
$state eq 'on' || $state eq 'off' or return; |
91
|
0
|
|
|
|
|
|
my $req = <
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
dn="sys/chassis-$self->{chassisId}/blade-$self->{slotId}/locator-led" |
97
|
|
|
|
|
|
|
id="1" name="" > |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
XML |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
my $xml = $self->{ucs}->_ucsm_request( $req ); |
105
|
|
|
|
|
|
|
|
106
|
0
|
0
|
|
|
|
|
if ( defined $xml->{'errorCode'} ) { |
107
|
|
|
|
|
|
|
my $self->{error} = |
108
|
|
|
|
|
|
|
( defined $xml->{'errorDescr'} |
109
|
0
|
0
|
|
|
|
|
? $xml->{'errorDescr'} |
110
|
|
|
|
|
|
|
: "Unspecified error" |
111
|
|
|
|
|
|
|
); |
112
|
|
|
|
|
|
|
|
113
|
0
|
|
|
|
|
|
print "got error: $self->{error}\n"; |
114
|
|
|
|
|
|
|
return |
115
|
0
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
0
|
|
|
|
|
|
return 1 |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub power_stats { |
121
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
return Cisco::UCS::Common::PowerStats->new( |
124
|
|
|
|
|
|
|
$self->{ucs}->resolve_dn( |
125
|
|
|
|
|
|
|
dn => "$self->{dn}/board/power-stats" |
126
|
|
|
|
|
|
|
)->{outConfig}->{computeMbPowerStats} |
127
|
|
|
|
|
|
|
) |
128
|
0
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub power_budget { |
131
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
return Cisco::UCS::Blade::PowerBudget->new( |
134
|
|
|
|
|
|
|
$self->{ucs}->resolve_dn( |
135
|
|
|
|
|
|
|
dn => "$self->{dn}/budget" |
136
|
|
|
|
|
|
|
)->{outConfig}->{powerBudget} |
137
|
|
|
|
|
|
|
) |
138
|
0
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
sub cpu { |
141
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
return ( |
144
|
|
|
|
|
|
|
defined $self->{cpu}->{$id} |
145
|
0
|
0
|
|
|
|
|
? $self->{cpu}->{$id} |
146
|
|
|
|
|
|
|
: $self->get_cpus( $id ) |
147
|
|
|
|
|
|
|
) |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub get_cpu { |
151
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
return ( |
154
|
0
|
0
|
|
|
|
|
$id ? $self->get_cpus( $id ) |
155
|
|
|
|
|
|
|
: undef |
156
|
|
|
|
|
|
|
) |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
sub get_cpus { |
160
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
my $cpus = $self->{ucs}->resolve_children( |
163
|
|
|
|
|
|
|
dn => "$self->{dn}/board" |
164
|
0
|
|
|
|
|
|
)->{outConfigs}->{processorUnit}; |
165
|
0
|
|
|
|
|
|
my @cpus; |
166
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
while ( my ( $cid, $cpu ) = each %$cpus ) { |
168
|
0
|
|
|
|
|
|
$cpu->{id} = $cid; |
169
|
0
|
|
|
|
|
|
$cpu = Cisco::UCS::Blade::CPU->new( $self->{ucs}, $cpu ); |
170
|
0
|
|
|
|
|
|
push @cpus, $cpu; |
171
|
0
|
|
|
|
|
|
$self->{cpu}->{$cid} = $cpu; |
172
|
0
|
0
|
0
|
|
|
|
return $cpu if ( defined $id and $cid == $id ) |
173
|
|
|
|
|
|
|
} |
174
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
return @cpus; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub adaptor { |
179
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
return ( |
182
|
|
|
|
|
|
|
defined $self->{adaptor}->{$id} |
183
|
0
|
0
|
|
|
|
|
? $self->{adaptor}->{$id} |
184
|
|
|
|
|
|
|
: $self->get_adaptors( $id ) |
185
|
|
|
|
|
|
|
) |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub get_adaptor { |
189
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
return ( |
192
|
0
|
0
|
|
|
|
|
$id ? $self->get_adaptors( $id ) |
193
|
|
|
|
|
|
|
: undef |
194
|
|
|
|
|
|
|
) |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub get_adaptors { |
199
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
my $adaptors = $self->{ucs}->resolve_children( |
202
|
|
|
|
|
|
|
dn => "$self->{dn}" |
203
|
0
|
|
|
|
|
|
)->{outConfigs}->{adaptorUnit}; |
204
|
0
|
|
|
|
|
|
my @adaptors; |
205
|
|
|
|
|
|
|
|
206
|
0
|
|
|
|
|
|
while ( my ( $aid, $adaptor ) = each %$adaptors ) { |
207
|
0
|
|
|
|
|
|
$adaptor->{id} = $aid; |
208
|
0
|
|
|
|
|
|
$adaptor = Cisco::UCS::Blade::Adaptor->new( $self->{ucs}, $adaptor ); |
209
|
0
|
|
|
|
|
|
push @adaptors, $adaptor; |
210
|
0
|
|
|
|
|
|
$self->{adaptor}->{$aid} = $adaptor; |
211
|
0
|
0
|
0
|
|
|
|
return $adaptor if ( defined $id and $aid == $id ) |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
0
|
|
|
|
|
|
return @adaptors; |
215
|
|
|
|
|
|
|
} |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
1; |
218
|
|
|
|
|
|
|
__END__ |