| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC |
|
2
|
|
|
|
|
|
|
# |
|
3
|
|
|
|
|
|
|
# All rights reserved. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Redistribution and use in source and binary forms, with or without |
|
6
|
|
|
|
|
|
|
# modification, are permitted provided that the following conditions are met: |
|
7
|
|
|
|
|
|
|
# |
|
8
|
|
|
|
|
|
|
# 1. Redistributions of source code must retain the above copyright notice, |
|
9
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer. |
|
10
|
|
|
|
|
|
|
# |
|
11
|
|
|
|
|
|
|
# 2. Redistributions in binary form must reproduce the above copyright notice, |
|
12
|
|
|
|
|
|
|
# this list of conditions and the following disclaimer in the documentation |
|
13
|
|
|
|
|
|
|
# and/or other materials provided with the distribution. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# 3. Neither the name of the copyright holder nor the names of its |
|
16
|
|
|
|
|
|
|
# contributors may be used to endorse or promote products derived from this |
|
17
|
|
|
|
|
|
|
# software without specific prior written permission. |
|
18
|
|
|
|
|
|
|
# |
|
19
|
|
|
|
|
|
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
|
20
|
|
|
|
|
|
|
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
|
21
|
|
|
|
|
|
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
|
22
|
|
|
|
|
|
|
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
|
23
|
|
|
|
|
|
|
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
24
|
|
|
|
|
|
|
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
25
|
|
|
|
|
|
|
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
26
|
|
|
|
|
|
|
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
27
|
|
|
|
|
|
|
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
28
|
|
|
|
|
|
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
29
|
|
|
|
|
|
|
# THE POSSIBILITY OF SUCH DAMAGE. |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Brocade::BSC::Status |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
Object representing status of an API call. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package Brocade::BSC::Status; |
|
42
|
|
|
|
|
|
|
|
|
43
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
21
|
|
|
44
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
22
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
1
|
|
|
1
|
|
65560
|
use Readonly; |
|
|
1
|
|
|
|
|
5674
|
|
|
|
1
|
|
|
|
|
1439
|
|
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
require Exporter; |
|
49
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
|
50
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
|
51
|
|
|
|
|
|
|
$BSC_OK |
|
52
|
|
|
|
|
|
|
$BSC_CONN_ERROR |
|
53
|
|
|
|
|
|
|
$BSC_DATA_NOT_FOUND |
|
54
|
|
|
|
|
|
|
$BSC_BAD_REQUEST |
|
55
|
|
|
|
|
|
|
$BSC_UNAUTHORIZED_ACCESS |
|
56
|
|
|
|
|
|
|
$BSC_INTERNAL_ERROR |
|
57
|
|
|
|
|
|
|
$BSC_NODE_CONNECTED |
|
58
|
|
|
|
|
|
|
$BSC_NODE_DISCONNECTED |
|
59
|
|
|
|
|
|
|
$BSC_NODE_NOT_FOUND |
|
60
|
|
|
|
|
|
|
$BSC_NODE_CONFIGURED |
|
61
|
|
|
|
|
|
|
$BSC_HTTP_ERROR |
|
62
|
|
|
|
|
|
|
$BSC_MALFORMED_DATA |
|
63
|
|
|
|
|
|
|
$BSC_UNKNOWN |
|
64
|
|
|
|
|
|
|
); |
|
65
|
|
|
|
|
|
|
our %EXPORT_TAGS = (constants => [@EXPORT_OK]); |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Readonly our $BSC_OK => 0; |
|
68
|
|
|
|
|
|
|
Readonly our $BSC_CONN_ERROR => 1; |
|
69
|
|
|
|
|
|
|
Readonly our $BSC_DATA_NOT_FOUND => 2; |
|
70
|
|
|
|
|
|
|
Readonly our $BSC_BAD_REQUEST => 3; |
|
71
|
|
|
|
|
|
|
Readonly our $BSC_UNAUTHORIZED_ACCESS => 4; |
|
72
|
|
|
|
|
|
|
Readonly our $BSC_INTERNAL_ERROR => 5; |
|
73
|
|
|
|
|
|
|
Readonly our $BSC_NODE_CONNECTED => 6; |
|
74
|
|
|
|
|
|
|
Readonly our $BSC_NODE_DISCONNECTED => 7; |
|
75
|
|
|
|
|
|
|
Readonly our $BSC_NODE_NOT_FOUND => 8; |
|
76
|
|
|
|
|
|
|
Readonly our $BSC_NODE_CONFIGURED => 9; |
|
77
|
|
|
|
|
|
|
Readonly our $BSC_HTTP_ERROR => 10; |
|
78
|
|
|
|
|
|
|
Readonly our $BSC_MALFORMED_DATA => 11; |
|
79
|
|
|
|
|
|
|
Readonly our $BSC_UNKNOWN => 12; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Readonly my $BSC_FIRST => $BSC_OK; |
|
82
|
|
|
|
|
|
|
Readonly my $BSC_LAST => $BSC_UNKNOWN; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Readonly my @errmsg => ( |
|
85
|
|
|
|
|
|
|
"Success", # _OK |
|
86
|
|
|
|
|
|
|
"Server connection error", # _CONN_ERROR |
|
87
|
|
|
|
|
|
|
"Requested data not found", # _DATA_NOT_FOUND |
|
88
|
|
|
|
|
|
|
"Bad or invalid data in request", # _BAD_REQUEST |
|
89
|
|
|
|
|
|
|
"Server unauthorized access", # _UNAUTHORIZED_ACCESS |
|
90
|
|
|
|
|
|
|
"Internal server error", # _INTERNAL_ERROR |
|
91
|
|
|
|
|
|
|
"Node is connected", # _NODE_CONNECTED |
|
92
|
|
|
|
|
|
|
"Node is disconnected", # _NODE_DISCONNECTED |
|
93
|
|
|
|
|
|
|
"Node not found", # _NODE_NOT_FOUND |
|
94
|
|
|
|
|
|
|
"Node is configured", # _NODE_CONFIGURED |
|
95
|
|
|
|
|
|
|
"HTTP error", # _HTTP_ERROR |
|
96
|
|
|
|
|
|
|
"Malformed data", # _MALFORMED_DATA |
|
97
|
|
|
|
|
|
|
"Unknown error" # _UNKNOWN (default) |
|
98
|
|
|
|
|
|
|
); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 METHODS |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
# Constructor ========================================================== |
|
105
|
|
|
|
|
|
|
# |
|
106
|
|
|
|
|
|
|
=over 4 |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item B |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Creates a new I object. |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=cut |
|
113
|
|
|
|
|
|
|
# |
|
114
|
|
|
|
|
|
|
# Parameters: may be called with $BSC_XXX constant to initialize code |
|
115
|
|
|
|
|
|
|
# |
|
116
|
|
|
|
|
|
|
sub new { |
|
117
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
|
118
|
0
|
|
|
|
|
|
my $self = { |
|
119
|
|
|
|
|
|
|
code => $BSC_UNKNOWN, |
|
120
|
|
|
|
|
|
|
http_code => 0, |
|
121
|
|
|
|
|
|
|
http_msg => undef |
|
122
|
|
|
|
|
|
|
}; |
|
123
|
0
|
0
|
|
|
|
|
@_ and $self->{code} = $_[0]; |
|
124
|
0
|
|
|
|
|
|
bless ($self, $class); |
|
125
|
|
|
|
|
|
|
} |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# Method =============================================================== |
|
128
|
|
|
|
|
|
|
# status accessors |
|
129
|
|
|
|
|
|
|
# Parameters: none |
|
130
|
|
|
|
|
|
|
# Returns : boolean: is the current status OK (configured, connected)? |
|
131
|
|
|
|
|
|
|
# |
|
132
|
|
|
|
|
|
|
=item B |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
# Returns : true iff the current status is OK. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
sub ok { |
|
138
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
139
|
0
|
|
|
|
|
|
return ($BSC_OK == $self->{code}); |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
=item B |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
# Returns : true if requested data was not found. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
sub no_data { |
|
147
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
148
|
0
|
|
|
|
|
|
return ($BSC_DATA_NOT_FOUND == $self->{code}); |
|
149
|
|
|
|
|
|
|
} |
|
150
|
|
|
|
|
|
|
=item B |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# Returns : true if last API call indicates node connected to controller. |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |
|
155
|
|
|
|
|
|
|
sub connected { |
|
156
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
157
|
0
|
|
|
|
|
|
return ($BSC_NODE_CONNECTED == $self->{code}); |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
=item B |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Returns : true if last API call indicates node is not connected. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
|
164
|
|
|
|
|
|
|
sub disconnected { |
|
165
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
166
|
0
|
|
|
|
|
|
return ($BSC_NODE_DISCONNECTED == $self->{code}); |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
=item B |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
# Returns : true if last API call indicates node is unknown to controller. |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
|
173
|
|
|
|
|
|
|
sub not_found { |
|
174
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
175
|
0
|
|
|
|
|
|
return ($BSC_NODE_NOT_FOUND == $self->{code}); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
=item B |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
# Returns : true if last API call indicates node is configured. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
sub configured { |
|
183
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
184
|
0
|
|
|
|
|
|
return ($BSC_NODE_CONFIGURED == $self->{code}); |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# Method =============================================================== |
|
188
|
|
|
|
|
|
|
# code |
|
189
|
|
|
|
|
|
|
# Parameters: integer code for set |
|
190
|
|
|
|
|
|
|
# none for get |
|
191
|
|
|
|
|
|
|
# Returns : status code |
|
192
|
|
|
|
|
|
|
# |
|
193
|
|
|
|
|
|
|
sub code { |
|
194
|
0
|
|
|
0
|
0
|
|
my ($self, $code) = @_; |
|
195
|
0
|
0
|
|
|
|
|
$self->{code} = (2 == @_) ? $code : $self->{code}; |
|
196
|
|
|
|
|
|
|
} |
|
197
|
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
# Method =============================================================== |
|
199
|
|
|
|
|
|
|
# http_err |
|
200
|
|
|
|
|
|
|
# Parameters: HTTP::Response object |
|
201
|
|
|
|
|
|
|
# Returns : ignore; updates BVCStatus object with values from http response |
|
202
|
|
|
|
|
|
|
# |
|
203
|
|
|
|
|
|
|
sub http_err { |
|
204
|
0
|
|
|
0
|
0
|
|
my ($self, $http_resp) = @_; |
|
205
|
0
|
0
|
|
|
|
|
(2 == @_) or die "missing required argument \$http_resp\n"; |
|
206
|
0
|
|
|
|
|
|
$self->{code} = $BSC_HTTP_ERROR; |
|
207
|
0
|
|
|
|
|
|
$self->{http_code} = $http_resp->code; |
|
208
|
0
|
|
|
|
|
|
$self->{http_msg} = $http_resp->message; |
|
209
|
|
|
|
|
|
|
} |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Method =============================================================== |
|
212
|
|
|
|
|
|
|
# |
|
213
|
|
|
|
|
|
|
=item B |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
# Returns : status string for current status |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=cut |
|
218
|
|
|
|
|
|
|
sub msg { |
|
219
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
220
|
0
|
|
|
|
|
|
my $http_err = ""; |
|
221
|
|
|
|
|
|
|
|
|
222
|
0
|
0
|
0
|
|
|
|
if ($self->{http_code} and defined $self->{http_msg}) { |
|
223
|
0
|
|
|
|
|
|
$http_err = " $self->{http_code} - '$self->{http_msg}'"; |
|
224
|
|
|
|
|
|
|
} |
|
225
|
|
|
|
|
|
|
($self->{code} >= $BSC_FIRST and $self->{code} <= $BSC_LAST) |
|
226
|
0
|
0
|
0
|
|
|
|
and return $errmsg[$self->{code}] . $http_err |
|
|
|
|
0
|
|
|
|
|
|
227
|
|
|
|
|
|
|
or return "Undefined status code $self->{code}"; |
|
228
|
|
|
|
|
|
|
} |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
# Module =============================================================== |
|
232
|
|
|
|
|
|
|
1; |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=back |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
Copyright (c) 2015, BROCADE COMMUNICATIONS SYSTEMS, INC |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
All rights reserved. |