line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS::Common::SwitchCard; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
701
|
use Cisco::UCS::Common::EthernetPort; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
38
|
|
7
|
1
|
|
|
1
|
|
7
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
8
|
1
|
|
|
1
|
|
5
|
use Carp qw(croak); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
458
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ATTRIBUTES = qw(dn id model operability power presence revision serial |
13
|
|
|
|
|
|
|
state thermal vendor voltage); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our %ATTRIBUTES = ( |
16
|
|
|
|
|
|
|
description => 'descr', |
17
|
|
|
|
|
|
|
num_ports => 'numPorts', |
18
|
|
|
|
|
|
|
performance => 'perf', |
19
|
|
|
|
|
|
|
slot => 'id' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub new { |
24
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
: croak 'dn not defined'; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
defined $args{ucs} |
34
|
|
|
|
|
|
|
? weaken($self->{ucs} = $args{ucs}) |
35
|
0
|
0
|
|
|
|
|
: croak 'ucs not defined'; |
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 } |
|
0
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
|
|
|
return $self; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub eth_port { |
47
|
0
|
|
|
0
|
1
|
|
my ( $self,$id ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
return ( defined $self->{eth_port}->{$id} |
50
|
0
|
0
|
|
|
|
|
? $self->{eth_port}->{$id} |
51
|
|
|
|
|
|
|
: $self->get_eth_port($id) |
52
|
|
|
|
|
|
|
) |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub get_eth_port { |
56
|
0
|
|
|
0
|
1
|
|
my ( $self, $id ) = @_; |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
return ( $id |
59
|
|
|
|
|
|
|
? $self->get_eth_ports($id) |
60
|
|
|
|
|
|
|
: undef |
61
|
|
|
|
|
|
|
) |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub get_eth_ports { |
65
|
0
|
|
|
0
|
1
|
|
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->{id} |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
) |
80
|
0
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
{ |
83
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
236
|
|
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
while ( my ( $pseudo, $attribute ) = each %ATTRIBUTES ) { |
86
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $pseudo } = sub { |
87
|
0
|
|
|
0
|
|
|
my $self = shift; |
88
|
0
|
|
|
|
|
|
return $self->{$attribute} |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
foreach my $attribute ( @ATTRIBUTES ) { |
93
|
|
|
|
|
|
|
*{ __PACKAGE__ . '::' . $attribute } = sub { |
94
|
0
|
|
|
0
|
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
return $self->{$attribute} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
1; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
__END__ |