UCS/Common/SwitchCard.pm

filter: Statementstmt 59.1% 29 / 49 Branchbran 16.6% 2 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 50.0% 6 / 12 Podpod 75.0% 3 / 4 totaltotal 51.9% 40 / 77 CC 6 SCAR 19.1
CC
6
Cov
51%
new
20.0
eth_port
6.0
get_eth_port
6.0
CRAP 6.7
« UCS/Common/FanModule.pm ↑ Summary UCS/Common/EthernetPort.pm »
1 package Cisco::UCS::Common::SwitchCard;
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::EthernetPort;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Scalar::Util qw(weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 our $VERSION = '0.51';
11  
12 2 our @ATTRIBUTES = qw(dn id model operability power presence revision serial
13 state thermal vendor voltage);
14  
15 2 our %ATTRIBUTES = (
16 description => 'descr',
17 num_ports => 'numPorts',
18 performance => 'perf',
19 slot => 'id'
20 );
21  
22  
23 0 ▶sub new {
Subroutine new: not called CC=4 SCAR=30.0
Pod undocumented
24 0 my ( $class, %args ) = @_;
25  
26 0 my $self = {};
27 0 bless $self, $class;
28  
29 defined $args{dn}
30 ? $self->{dn} = $args{dn}
31 0 ▶ : croak 'dn not defined';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'dn'} ? : 0 0 0
32  
33 defined $args{ucs}
34 ? weaken($self->{ucs} = $args{ucs})
35 0 ▶ : croak 'ucs not defined';
Branch: 1 branch
BranchTrueFalseTotal
defined $args{'ucs'} ? : 0 0 0
36  
37 0 my %attr = %{ $self->{ucs}->resolve_dn(
38 dn => $self->{dn}
39 0 )->{outConfig}->{equipmentSwitchCard} };
40
41 0 ▶ while ( my ( $k, $v ) = each %attr ) { $self->{$k} = $v }
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %attr) 0 0 0
42
43 0 return $self;
44 }
45  
46 0 ▶sub eth_port {
Subroutine eth_port: not called CC=2 SCAR=17.9
Pod documented
47 0 my ( $self,$id ) = @_;
48  
49 return ( defined $self->{eth_port}->{$id}
50 0 ▶ ? $self->{eth_port}->{$id}
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'eth_port'}{$id} ? : 0 0 0
51 : $self->get_eth_port($id)
52 )
53 }
54  
55 0 ▶sub get_eth_port {
Subroutine get_eth_port: not called CC=2 SCAR=17.9
Pod documented
56 0 my ( $self, $id ) = @_;
57  
58 0 ▶ return ( $id
Branch: 1 branch
BranchTrueFalseTotal
$id ? : 0 0 0
59 ? $self->get_eth_ports($id)
60 : undef
61 )
62 }
63  
64 0 ▶sub get_eth_ports {
Subroutine get_eth_ports: not called CC=1 SCAR=6.9
Pod documented
65 0 my ( $self, $id ) = @_;
66  
67 return $self->{ucs}->_get_child_objects(
68 id => $id,
69 type => 'etherPIo',
70 class => 'Cisco::UCS::Common::EthernetPort',
71 attr => 'eth_port',
72 self => $self,
73 uid => 'portId',
74 class_filter => {
75 classId => 'etherPIo',
76 slotId => $self->{id},
77 switchId => $self->{interconnect_id}
78 }
79 )
80 0 }
81  
82 {
83 2 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
84  
85 2 ▶ while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %Cisco::UCS::Common::SwitchCard::ATTRIBUTES) 8 2 10
86 8 ▶ *{ __PACKAGE__ . '::' . $pseudo } = sub {
Subroutine __ANON__: not called CC=1 SCAR=2.6
87 0 my $self = shift;
88 0 return $self->{$attribute}
89 }
90 8 }
91  
92 2 foreach my $attribute ( @ATTRIBUTES ) {
93 24 ▶ *{ __PACKAGE__ . '::' . $attribute } = sub {
Subroutine __ANON__: not called CC=1 SCAR=2.6
94 0 my $self = shift;
95 0 return $self->{$attribute}
96 }
97 24 }
98  
99 }
100  
101 2 1;
102  
103 __END__
« UCS/Common/FanModule.pm ↑ Summary UCS/Common/EthernetPort.pm »