| 1 | package Cisco::UCS::Interconnect; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 2 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 2 | ▶ | use Cisco::UCS::Common::SwitchCard; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 2 | ▶ | use Cisco::UCS::Common::PSU; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use Cisco::UCS::Common::Fan; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 2 | ▶ | use Cisco::UCS::Interconnect::Stats; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 2 | ▶ | use Scalar::Util qw(weaken); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 2 | ▶ | use Carp qw(croak); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | 2 | our $VERSION = '0.51'; | |||||||||
| 14 | |||||||||||
| 15 | 2 | our @ATTRIBUTES = qw(dn id model operability serial vendor); | |||||||||
| 16 | |||||||||||
| 17 | 2 | our %ATTRIBUTES = ( | |||||||||
| 18 | memory => 'totalMemory', | ||||||||||
| 19 | mgmt_ip => 'oobIfIp', | ||||||||||
| 20 | mgmt_gw => 'oobIfGw', | ||||||||||
| 21 | mgmt_net => 'oobIfMask', | ||||||||||
| 22 | ); | ||||||||||
| 23 | |||||||||||
| 24 | 2 | my %MMAP = ( | |||||||||
| 25 | card => { | ||||||||||
| 26 | type => 'equipmentSwitchCard', | ||||||||||
| 27 | class => 'Cisco::UCS::Common::SwitchCard', | ||||||||||
| 28 | }, | ||||||||||
| 29 | fan => { | ||||||||||
| 30 | type => 'equipmentFan', | ||||||||||
| 31 | class => 'Cisco::UCS::Common::Fan' | ||||||||||
| 32 | }, | ||||||||||
| 33 | psu => { | ||||||||||
| 34 | type => 'equipmentPsu', | ||||||||||
| 35 | class => 'Cisco::UCS::Common::PSU' | ||||||||||
| 36 | }, | ||||||||||
| 37 | ); | ||||||||||
| 38 | |||||||||||
| 39 | 0 | ▶ | sub new { | ||||||||
|
Subroutine
new: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 40 | 0 | my ( $class, %args ) = @_; | |||||||||
| 41 | |||||||||||
| 42 | 0 | my $self = {}; | |||||||||
| 43 | 0 | bless $self, $class; | |||||||||
| 44 | |||||||||||
| 45 | defined $args{dn} | ||||||||||
| 46 | ? $self->{dn} = $args{dn} | ||||||||||
| 47 | 0 | ▶ | : croak 'dn not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 48 | |||||||||||
| 49 | defined $args{ucs} | ||||||||||
| 50 | ? weaken( $self->{ucs} = $args{ucs} ) | ||||||||||
| 51 | 0 | ▶ | : croak 'ucs not defined'; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | |||||||||||
| 53 | 0 | my %attr = %{ $self->{ucs}->resolve_dn( | |||||||||
| 54 | dn => $self->{dn} | ||||||||||
| 55 | 0 | )->{outConfig}->{networkElement} }; | |||||||||
| 56 | |||||||||||
| 57 | 0 | ▶ | while ( my( $k, $v ) = each %attr ) { $self->{$k} = $v } | ||||||||
|
Branch: 1 branch
| |||||||||||
| 58 | |||||||||||
| 59 | 0 | my ($v) = $self->{ucs}->version =~ /\((.*)\)/; | |||||||||
| 60 | |||||||||||
| 61 | 0 | ▶ | $MMAP{fan}{type} = 'equipmentFanModule' if( $v =~ /^4/); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | |||||||||||
| 63 | 0 | return $self; | |||||||||
| 64 | } | ||||||||||
| 65 | |||||||||||
| 66 | { | ||||||||||
| 67 | 2 | ▶ | no strict 'refs'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 68 | |||||||||||
| 69 | 2 | ▶ | while ( my( $pseudo, $attribute ) = each %ATTRIBUTES ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 70 | 0 | ▶ | *{ __PACKAGE__ .'::'. $pseudo } = sub { return $_[0]->{$attribute} } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 71 | 8 | } | |||||||||
| 72 | |||||||||||
| 73 | 2 | foreach my $attribute ( @ATTRIBUTES ) { | |||||||||
| 74 | 0 | ▶ | *{ __PACKAGE__ .'::'. $attribute } = sub { return $_[0]->{$attribute} } | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 75 | 12 | } | |||||||||
| 76 | |||||||||||
| 77 | 2 | foreach my $m ( keys %MMAP ) { # i.e. object | |||||||||
| 78 | 6 | my $gm = "get_$m"; # i.e. get_object | |||||||||
| 79 | 6 | my $gms = "get_$m".'s'; # i.e. get_objects | |||||||||
| 80 | |||||||||||
| 81 | 6 | ▶ | *{ __PACKAGE__ .'::'. $m } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
| |||||||||||
| 82 | 0 | my( $self, $id ) = @_; | |||||||||
| 83 | |||||||||||
| 84 | return ( | ||||||||||
| 85 | defined $self->{$m}->{$id} | ||||||||||
| 86 | 0 | ▶ | ? $self->{$m}->{$id} | ||||||||
|
Branch: 1 branch
| |||||||||||
| 87 | : $self->$gm( $id ) | ||||||||||
| 88 | ) | ||||||||||
| 89 | 6 | }; | |||||||||
| 90 | |||||||||||
| 91 | 6 | ▶ | *{ __PACKAGE__ .'::'. $gm } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=14.0
| |||||||||||
| 92 | 0 | my( $self, $id ) = @_; | |||||||||
| 93 | |||||||||||
| 94 | 0 | ▶ | return ( $id ? $self->$gms( $id ) : undef ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 95 | 6 | }; | |||||||||
| 96 | |||||||||||
| 97 | 6 | ▶ | *{ __PACKAGE__ .'::'. $gms } = sub { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||
| 98 | 0 | my( $self, $id ) = @_; | |||||||||
| 99 | |||||||||||
| 100 | return $self->{ucs}->_get_child_objects( | ||||||||||
| 101 | id => $id, | ||||||||||
| 102 | type => $MMAP{$m}{type}, | ||||||||||
| 103 | class => $MMAP{$m}{class}, | ||||||||||
| 104 | attr => $m, | ||||||||||
| 105 | self => $self, | ||||||||||
| 106 | eattrs => { interconnect_id => $self->{ id } } | ||||||||||
| 107 | ) | ||||||||||
| 108 | 0 | }; | |||||||||
| 109 | } | ||||||||||
| 110 | } | ||||||||||
| 111 | |||||||||||
| 112 | 0 | ▶ | sub stats { | ||||||||
|
Subroutine
stats: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||
| 113 | 0 | my $self = shift; | |||||||||
| 114 | |||||||||||
| 115 | return Cisco::UCS::Interconnect::Stats->new( | ||||||||||
| 116 | $self->{ucs}->resolve_dn( | ||||||||||
| 117 | 0 | dn => "$self->{dn}/sysstats" | |||||||||
| 118 | ) | ||||||||||
| 119 | ) | ||||||||||
| 120 | } | ||||||||||
| 121 | |||||||||||
| 122 | 2 | 1; | |||||||||
| 123 | |||||||||||
| 124 | __END__ | ||||||||||