line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Cisco::UCS::Interconnect; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
436
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
600
|
use Cisco::UCS::Common::SwitchCard; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
28
|
|
7
|
1
|
|
|
1
|
|
619
|
use Cisco::UCS::Common::PSU; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
8
|
1
|
|
|
1
|
|
5
|
use Cisco::UCS::Common::Fan; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
9
|
1
|
|
|
1
|
|
562
|
use Cisco::UCS::Interconnect::Stats; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
33
|
|
10
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw(weaken); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
11
|
1
|
|
|
1
|
|
4
|
use Carp qw(croak); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
339
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.50'; |
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
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
452
|
|
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
|
0
|
|
|
|
|
|
attr => $m, |
105
|
|
|
|
|
|
|
self => $self |
106
|
|
|
|
|
|
|
) |
107
|
|
|
|
|
|
|
}; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub stats { |
112
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
return Cisco::UCS::Interconnect::Stats->new( |
115
|
|
|
|
|
|
|
$self->{ucs}->resolve_dn( |
116
|
0
|
|
|
|
|
|
dn => "$self->{dn}/sysstats" |
117
|
|
|
|
|
|
|
) |
118
|
|
|
|
|
|
|
) |
119
|
|
|
|
|
|
|
} |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
1; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
__END__ |