1package Cisco::UCS::Common::PSU;
2
3use warnings;
4use strict;
5
6use Carp qw(croak);
7use Scalar::Util qw(weaken);
8
9our $VERSION = '0.51';
10
11our @ATTRIBUTES	= qw(dn id model operability power presence revision serial
12thermal vendor voltage);
13
14our %ATTRIBUTES	= (
15	operational	=> 'operState',
16	performance	=> 'perf'
17);
18
19#our
20#	'outputCurrentMin' => '10.000000',
21#	'input210vAvg' => '239.000000',
22#	'outputPowerAvg' => '120.869995',
23#	'outputCurrent' => '10.000000',
24#	'ambientTemp' => '26.000000',
25#	'psuTemp1' => '0.000000',
26#	'output12vAvg' => '12.087000',
27#	'output12vMin' => '12.087000',
28#	'outputCurrentMax' => '10.000000',
29#	'output12v' => '12.087000',
30#	'timeCollected' => '2012-10-19T13:07:33.952',
31#	'outputCurrentAvg' => '10.000000',
32#	'psuTemp2' => '0.000000',
33#	'suspect' => 'no',
34#	'thresholded' => '',
35#	'ambientTempMin' => '26.000000',
36#	'ambientTempMax' => '26.000000',
37#	'output3v3Max' => '3.048000',
38#	'output12vMax' => '12.087000',
39#	'outputPowerMin' => '120.869995',
40#	'input210v' => '239.000000',
41#	'outputPowerMax' => '120.869995',
42#	'input210vMin' => '239.000000',
43#	'ambientTempAvg' => '26.000000',
44#	'outputPower' => '120.869995',
45#	'output3v3Avg' => '3.048000',
46#	'intervals' => '58982460',
47#	'output3v3' => '3.048000',
48#	'update' => '131073',
49#	'dn' => 'sys/chassis-1/psu-1/stats',
50#	'input210vMax' => '239.000000',
51#	'output3v3Min' => '3.048000'
52
53
54
55sub new {
56        my ( $class, %args ) = @_;
57
58        my $self = {};
59        bless $self, $class;
60
61        defined $args{dn}
62		? $self->{dn} = $args{dn}
63		: croak 'dn not defined';
64
65        defined $args{ucs}
66		? weaken($self->{ucs} = $args{ucs})
67		: croak 'ucs not defined';
68
69        my %attr = %{ $self->{ucs}->resolve_dn(
70					dn => $self->{dn}
71				)->{outConfig}->{equipmentPsu} };
72
73        while ( my ($k, $v) = each %attr ) { $self->{$k} = $v }
74
75        return $self;
76}
77
78{
79        no strict 'refs';
80
81        while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) {
82                *{ __PACKAGE__ . '::' . $pseudo } = sub {
83			return $_[0]->{$attribute}
84		}
85        }
86
87        foreach my $attribute (@ATTRIBUTES) {
88                *{ __PACKAGE__ . '::' . $attribute } = sub {
89			return $_[0]->{$attribute}
90		}
91        }
92}
93
941;
95
96__END__
97
98=pod
99
100=head1 NAME
101
102Cisco::UCS::Common::PSU - Class for operations with a Cisco UCS PSU.
103
104=head1 SYNOPSIS
105
106    foreach my $psu (sort $ucs->chassis(1)->get_psus) {
107      print 'PSU ' . $psu->id . ' voltage: ' . $psu->voltage . "\n"
108    }
109
110    # PSU 1 voltage: ok
111    # PSU 2 voltage: ok
112    # PSU 3 voltage: ok
113    # PSU 4 voltage: ok
114
115=head1 DESCRIPTION
116
117Cisco::UCS::Common::PSU is a class providing common operations with a Cisco
118UCS PSU.
119
120Note that you are not supposed to call the constructor yourself, rather a
121Cisco::UCS::Common::PSU object is created for you automatically by query
122methods in other classes like L<Cisco::UCS::Chassis>.
123
124=head1 METHODS
125
126=head3 id
127
128Returns the ID of the PSU.
129
130=head3 dn
131
132Returns the distinguished name of the PSU.
133
134=head3 serial
135
136Returns the serial number of the PSU.
137
138=head3 model
139
140Returns the model number of the PSU.
141
142=head3 revision
143
144Returns the hardware revision number of the PSU.
145
146=head3 vendor
147
148Returns the vendor name of the PSU.
149
150=head3 presence
151
152Returns the presence status of the PSU.
153
154=head3 operability
155
156Returns the operability status of the PSU.
157
158=head3 voltage
159
160Returns the voltage status of the PSU.
161
162=head3 power
163
164Returns the power status of the PSU.
165
166=head3 thermal
167
168Returns the thermal status of the PSU.
169
170=head3 operational
171
172Returns the operational status of the PSU.
173
174=head3 performance
175
176Returns the performance status of the PSU.
177
178=head1 AUTHOR
179
180Luke Poskitt, C<< <ltp at cpan.org> >>
181
182=head1 BUGS
183
184Some methods may return undefined, empty or not yet implemented values.  This
185is dependent on the software and firmware revision level of UCSM and
186components of the UCS cluster.  This is not a bug but is a limitation of UCSM.
187
188Please report any bugs or feature requests to
189C<bug-cisco-ucs-common-psu at rt.cpan.org>, or through the web interface at
190L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Cisco-UCS-Common-PSU>.  I
191will be notified, and then you'll automatically be notified of progress on
192your bug as I make changes.
193
194=head1 SUPPORT
195
196You can find documentation for this module with the perldoc command.
197
198    perldoc Cisco::UCS::Common::PSU
199
200
201You can also look for information at:
202
203=over 4
204
205=item * RT: CPAN's request tracker
206
207L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Cisco-UCS-Common-PSU>
208
209=item * AnnoCPAN: Annotated CPAN documentation
210
211L<http://annocpan.org/dist/Cisco-UCS-Common-PSU>
212
213=item * CPAN Ratings
214
215L<http://cpanratings.perl.org/d/Cisco-UCS-Common-PSU>
216
217=item * Search CPAN
218
219L<http://search.cpan.org/dist/Cisco-UCS-Common-PSU/>
220
221=back
222
223=head1 LICENSE AND COPYRIGHT
224
225Copyright 2012 Luke Poskitt.
226
227This program is free software; you can redistribute it and/or modify it
228under the terms of either: the GNU General Public License as published
229by the Free Software Foundation; or the Artistic License.
230
231See http://dev.perl.org/licenses/ for more information.
232
233=cut
234