Cisco-UCS
view release on metacpan or search on metacpan
lib/Cisco/UCS/Chassis/PSU.pm view on Meta::CPAN
package Cisco::UCS::Chassis::PSU;
use warnings;
use strict;
use Carp qw(croak);
use Scalar::Util qw(weaken);
use Cisco::UCS::Chassis::PSU::Stats;
our $VERSION = '0.51';
our %ATTRIBUTES = (
id => 'id',
model => 'model',
operability => 'operability',
operational => 'operState',
performance => 'perf',
power => 'power',
presence => 'presence',
revision => 'revision',
serial => 'serial',
thermal => 'thermal',
vendor => 'vendor',
voltage => 'voltage',
);
{
no strict 'refs';
while ( my ($pseudo, $attribute) = each %ATTRIBUTES ) {
*{ __PACKAGE__ . '::' . $pseudo } = sub {
return $_[0]->{$attribute}
}
}
}
sub new {
my ( $class, %args ) = @_;
my $self = {};
bless $self, $class;
defined $args{dn}
? $self->{dn} = $args{dn}
: croak 'dn not defined';
defined $args{ucs}
? weaken($self->{ucs} = $args{ucs})
: croak 'ucs not defined';
my %attr = %{ $self->{ucs}->resolve_dn(
dn => $self->{dn}
)->{outConfig}->{equipmentPsu}};
while ( my ($k, $v) = each %attr ) { $self->{$k} = $v }
return $self;
}
sub stats {
my $self = shift;
return Cisco::UCS::Chassis::PSU::Stats->new(
$self->{ucs}->resolve_dn(
dn => "$self->{dn}/stats"
)->{outConfig}->{equipmentPsuStats} )
}
1;
__END__
=pod
=head1 NAME
Cisco::UCS::Common::PSU - Class for operations with a Cisco UCS PSU.
=head1 SYNOPSIS
foreach my $psu (sort $ucs->chassis(1)->get_psus) {
print 'PSU ' . $psu->id . ' voltage: ' . $psu->voltage . "\n"
}
# PSU 1 voltage: ok
# PSU 2 voltage: ok
# PSU 3 voltage: ok
# PSU 4 voltage: ok
=head1 DESCRIPTION
Cisco::UCS::Common::PSU is a class providing common operations with a Cisco
UCS PSU.
Note that you are not supposed to call the constructor yourself, rather a
Cisco::UCS::Common::PSU object is created for you automatically by query
methods in other classes like L<Cisco::UCS::Chassis>.
=head1 METHODS
=head3 id
Returns the ID of the PSU.
=head3 dn
Returns the distinguished name of the PSU.
=head3 serial
( run in 2.538 seconds using v1.01-cache-2.11-cpan-99c4e6809bf )