| 1 | package Cisco::UCS::MgmtEntity; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 2 | our $VERSION = '0.51'; | |||||||||
| 10 | |||||||||||
| 11 | 2 | our @ATTRIBUTES = qw(chassis1 chassis2 chassis3 dn id leadership state); | |||||||||
| 12 | |||||||||||
| 13 | 2 | our %ATTRIBUTES = ( | |||||||||
| 14 | chassis1_device_io_state => 'chassisDeviceIoState1', | ||||||||||
| 15 | chassis2_device_io_state => 'chassisDeviceIoState2', | ||||||||||
| 16 | chassis3_device_io_state => 'chassisDeviceIoState3', | ||||||||||
| 17 | ha_failure_reason => 'haFailureReason', | ||||||||||
| 18 | ha_readiness => 'haReadiness', | ||||||||||
| 19 | ha_ready => 'haReady', | ||||||||||
| 20 | mgmt_services_state => 'mgmtServicesState', | ||||||||||
| 21 | umbilical_state => 'umbilicalState', | ||||||||||
| 22 | version_mismatch => 'versionMismatch' | ||||||||||
| 23 | ); | ||||||||||
| 24 | |||||||||||
| 25 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||
| 26 | 0 | my ( $class, %args ) = @_; | |||||||||
| 27 | |||||||||||
| 28 | 0 | my $self = {}; | |||||||||
| 29 | 0 | bless $self, $class; | |||||||||
| 30 | |||||||||||
| 31 | defined $args{dn} | ||||||||||
| 32 | ? $self->{dn} = $args{dn} | ||||||||||
| 33 | 0 | ▶ | : croak 'dn not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | |||||||||||
| 35 | defined $args{ucs} | ||||||||||
| 36 | ? weaken($self->{ucs} = $args{ucs}) | ||||||||||
| 37 | 0 | ▶ | : croak 'dn not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 38 | |||||||||||
| 39 | 0 | my %attr = %{ $self->{ucs}->resolve_dn( | |||||||||
| 40 | dn => $self->{dn} | ||||||||||
| 41 | 0 | )->{outConfig}->{mgmtEntity} }; | |||||||||
| 42 | |||||||||||
| 43 | 0 | ▶ | while ( my ($k, $v) = each %attr ) { $self->{$k} = $v } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | |||||||||||
| 45 | 0 | return $self | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | { | ||||||||||
| 49 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 50 | |||||||||||
| 51 | 2 | ▶ | while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | 18 | ▶ | *{ __PACKAGE__ . '::' . $pseudo } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||
| 53 | 0 | my $self = shift; | |||||||||
| 54 | 0 | return $self->{$attribute} | |||||||||
| 55 | } | ||||||||||
| 56 | 18 | } | |||||||||
| 57 | |||||||||||
| 58 | 2 | foreach my $attribute ( @ATTRIBUTES ) { | |||||||||
| 59 | 14 | ▶ | *{ __PACKAGE__ . '::' . $attribute } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=2.6
| |||||||||||
| 60 | 0 | my $self = shift; | |||||||||
| 61 | 0 | return $self->{$attribute} | |||||||||
| 62 | } | ||||||||||
| 63 | 14 | } | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | 2 | 1; | |||||||||
| 67 | |||||||||||
| 68 | __END__ | ||||||||||