line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS::Interconnect; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
26
|
|
4
|
1
|
|
|
1
|
|
2
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
14
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
326
|
use Cisco::UCS::Common::SwitchCard; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
7
|
1
|
|
|
1
|
|
353
|
use Cisco::UCS::Common::PSU; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
21
|
|
8
|
1
|
|
|
1
|
|
3
|
use Cisco::UCS::Common::Fan; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
13
|
|
9
|
1
|
|
|
1
|
|
355
|
use Cisco::UCS::Interconnect::Stats; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
24
|
|
10
|
1
|
|
|
1
|
|
3
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
11
|
1
|
|
|
1
|
|
3
|
use Carp qw(croak); |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
233
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.51'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our @ATTRIBUTES = qw(dn id model operability serial vendor); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
our %ATTRIBUTES = ( |
18
|
|
|
|
|
|
|
memory => 'totalMemory', |
19
|
|
|
|
|
|
|
mgmt_ip => 'oobIfIp', |
20
|
|
|
|
|
|
|
mgmt_gw => 'oobIfGw', |
21
|
|
|
|
|
|
|
mgmt_net => 'oobIfMask', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
sub new { |
40
|
0
|
|
|
0
|
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
|
0
|
|
|
|
|
: croak 'dn not defined'; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
defined $args{ucs} |
50
|
|
|
|
|
|
|
? weaken( $self->{ucs} = $args{ucs} ) |
51
|
0
|
0
|
|
|
|
|
: croak 'ucs not defined'; |
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 } |
|
0
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
0
|
|
|
|
|
|
my ($v) = $self->{ucs}->version =~ /\((.*)\)/; |
60
|
|
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
|
$MMAP{fan}{type} = 'equipmentFanModule' if( $v =~ /^4/); |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
{ |
67
|
1
|
|
|
1
|
|
4
|
no strict 'refs'; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
290
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
while ( my( $pseudo, $attribute ) = each %ATTRIBUTES ) { |
70
|
0
|
|
|
0
|
|
|
*{ __PACKAGE__ .'::'. $pseudo } = sub { return $_[0]->{$attribute} } |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
foreach my $attribute ( @ATTRIBUTES ) { |
74
|
0
|
|
|
0
|
|
|
*{ __PACKAGE__ .'::'. $attribute } = sub { return $_[0]->{$attribute} } |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
foreach my $m ( keys %MMAP ) { # i.e. object |
78
|
|
|
|
|
|
|
my $gm = "get_$m"; # i.e. get_object |
79
|
|
|
|
|
|
|
my $gms = "get_$m".'s'; # i.e. get_objects |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
*{ __PACKAGE__ .'::'. $m } = sub { |
82
|
0
|
|
|
0
|
|
|
my( $self, $id ) = @_; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
return ( |
85
|
|
|
|
|
|
|
defined $self->{$m}->{$id} |
86
|
0
|
0
|
|
|
|
|
? $self->{$m}->{$id} |
87
|
|
|
|
|
|
|
: $self->$gm( $id ) |
88
|
|
|
|
|
|
|
) |
89
|
|
|
|
|
|
|
}; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
*{ __PACKAGE__ .'::'. $gm } = sub { |
92
|
0
|
|
|
0
|
|
|
my( $self, $id ) = @_; |
93
|
|
|
|
|
|
|
|
94
|
0
|
0
|
|
|
|
|
return ( $id ? $self->$gms( $id ) : undef ) |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
*{ __PACKAGE__ .'::'. $gms } = sub { |
98
|
0
|
|
|
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
|
|
|
|
|
|
|
sub stats { |
113
|
0
|
|
|
0
|
1
|
|
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
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |