blob: c4a1cbff2d19e4ccfb349da39bb23df4cbd69356 [file] [log] [blame]
Srikanth Vavilapalli1725e492014-12-01 17:50:52 -08001#
2# Copyright (c) 2013 Big Switch Networks, Inc.
3#
4# Licensed under the Eclipse Public License, Version 1.0 (the
5# "License"); you may not use this file except in compliance with the
6# License. You may obtain a copy of the License at
7#
8# http://www.eclipse.org/legal/epl-v10.html
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13# implied. See the License for the specific language governing
14# permissions and limitations under the License.
15#
16
17import fmtcnv
18
19TEST_PACKET_IN_COMMAND_DESCRIPTION = {
20 'name' : 'test',
21 'mode' : 'login',
22 'no-supported' : False,
23 'obj-type' : 'test-command', # fake obj-type, legacy-cli descriminator
24 'short-help' : 'Perform various tests on the network',
25 'doc' : 'test|test',
26 'doc-example' : 'test|test-packet-in-example',
27 'action' : 'legacy-cli',
28 'args' : (
29 {
30 'field' : 'test-type',
31 'type' : 'enum',
32 'values' : 'packet-in',
33 'doc' : 'test|test-packet-in',
34 },
35 {
36 # src-host
37 'field' : 'src-host',
38 'tag' : 'src-host',
39 'type' : 'host',
40 'completion' : 'complete-from-another',
41 'other' : 'host|mac',
42 'data-handler' : 'alias-to-value',
43 'doc' : 'test|test-packet-in-mac',
44 },
45 {
46 # dst-host
47 'field' : 'dst-host',
48 'tag' : 'dst-host',
49 'type' : 'host',
50 'completion' : 'complete-from-another',
51 'other' : 'host|mac',
52 'data-handler' : 'alias-to-value',
53 'doc' : 'test|test-packet-in-mac',
54 },
55 {
56 # src-switch
57 'optional' : True,
58 'args' : (
59 {
60 'field' : 'src-switch',
61 'tag' : 'src-switch',
62 'type' : 'dpid',
63 'completion' : 'complete-from-another',
64 'other' : 'switches|dpid', # field isn't dpid
65 'data-handler' : 'alias-to-value',
66 'doc' : 'test|test-packet-in-dpid',
67 },
68 {
69 'field' : 'src-switch-port',
70 'type' : 'string',
71 'completion' : 'complete-from-another',
72 'other' : 'interfaces|portName',
73 'scoped' : 'src-switch',
74 'data-handler' : 'convert-interface-to-port',
75 'doc' : 'test|test-packet-in-if',
76 },
77 ),
78 },
79 {
80 'field' : 'vlan',
81 'tag' : 'vlan',
82 'base-type' : 'integer',
83 'range' : (0,4095),
84 'optional' : True,
85 'doc' : 'test|test-packet-in-vlan',
86 },
87 # currently ether-type isn't implemented
88 #{
89 #'optional' : True,
90 #'choices' : (
91 #{
92 #'field' : 'ether-type',
93 #'tag' : 'ether-type',
94 #'base-type' : 'hex-or-decimal-integer',
95 #'range' : (1536,65536),
96 #'data-handler' : 'hex-to-integer',
97 #},
98 #{
99 #'field' : 'ether-type',
100 #'tag' : 'ether-type',
101 #'type' : 'enum',
102 #'values' : fmtcnv.ether_type_to_number_dict,
103 #},
104 #),
105 #},
106 {
107 'field' : 'priority',
108 'tag' : 'priority',
109 'base-type' : 'integer',
110 'range' : (0,7),
111 'optional' : True,
112 'doc' : 'test|test-packet-in-priority',
113 },
114 {
115 'field' : 'src-ip-address',
116 'tag' : 'src-ip-address',
117 'type' : 'ip-address-not-mask',
118 'optional' : True,
119 'doc' : 'test|test-packet-in-ip',
120 },
121 {
122 'field' : 'dst-ip-address',
123 'tag' : 'dst-ip-address',
124 'type' : 'ip-address-not-mask',
125 'optional' : True,
126 'doc' : 'test|test-packet-in-ip',
127 },
128 {
129 'field' : 'protocol',
130 'tag' : 'protocol',
131 'base-type' : 'integer',
132 'range' : (1,255),
133 'optional' : True,
134 'doc' : 'test|test-packet-in-proto',
135 },
136 {
137 'field' : 'tos',
138 'tag' : 'tos',
139 'base-type' : 'integer',
140 'range' : (1,255),
141 'optional' : True,
142 'doc' : 'test|test-packet-in-tos',
143 },
144 {
145 'field' : 'src-port',
146 'tag' : 'src-port',
147 'base-type' : 'integer',
148 'range' : (0,65535),
149 'optional' : True,
150 'doc' : 'test|test-packet-in-port',
151 },
152 {
153 'field' : 'dst-port',
154 'tag' : 'dst-port',
155 'base-type' : 'integer',
156 'range' : (0,65535),
157 'optional' : True,
158 'doc' : 'test|test-packet-in-port',
159 },
160 ),
161}
162
163TEST_PATH_COMMAND_DESCRIPTION = {
164 'name' : 'test',
165 'mode' : 'login',
166 'no-supported' : False,
167 'obj-type' : 'test-command', # fake obj-type, legacy-cli descriminator
168 'short-help' : 'Perform various tests on the network',
169 'doc' : 'test|test',
170 'doc-example' : 'test|test-path-example',
171 'action' : (
172 # collect the entries
173 {
174 'proc' : 'legacy-cli',
175 },
176 # join the interface names, possibly add stats?
177 {
178 'proc' : 'join-table',
179 'obj-type' : 'interfaces',
180 'key' : 'switch|portNumber',
181 'join-field' : 'switch|port',
182 'add-field' : 'portName|portName',
183 },
184 # add basic interface's stats
185 {
186 'proc' : 'join-rest',
187 'url' : 'realtimestats/port/%(switch)s/',
188 'rest-type' : 'dict-of-list-of-switch|portNumber',
189 'key' : 'switch|portNumber',
190 'join-field' : 'switch|port'
191 },
192 # display the result
193 {
194 'proc' : 'display',
195 'format' : 'test-path',
196 }
197 ),
198 'args' : (
199 {
200 'field' : 'test-type',
201 'type' : 'enum',
202 'values' : 'path',
203 'doc' : 'test|test-path',
204 },
205 {
206 'choices' : (
207 # source device (need address space, vlan)
208 {
209 'field' : 'src-host',
210 'tag' : 'src-host',
211 'type' : 'host',
212 'completion' : 'complete-from-another',
213 'other' : 'host|mac',
214 'data-handler' : 'alias-to-value',
215 'doc' : 'test|test-path-host',
216 },
217 # source ip
218 {
219 'field' : 'src-ip',
220 'tag' : 'src-ip',
221 'type' : 'ip-address',
222 'completion' : 'complete-from-another',
223 'other' : 'host-network-address|ip-address',
224 'doc' : 'test|test-path-ip',
225 },
226 # source attachment point
227 (
228 {
229 'field' : 'src-switch',
230 'tag' : 'src-switch',
231 'type' : 'dpid',
232 'completion' : 'complete-from-another',
233 'other' : 'switches|dpid', # field isn't dpid
234 'data-handler' : 'alias-to-value',
235 'doc' : 'test|test-path-switch',
236 },
237 {
238 'field' : 'src-switch-port',
239 'type' : 'string',
240 'completion' : 'complete-from-another',
241 'other' : 'interfaces|portName',
242 'scoped' : 'src-switch',
243 'data-handler' : 'convert-interface-to-port',
244 'doc' : 'test|test-path-if',
245 },
246 ),
247 )
248 },
249 {
250 'choices' : (
251 # dest mac (need address space, vlan)
252 {
253 'field' : 'dst-host',
254 'tag' : 'dst-host',
255 'type' : 'host',
256 'completion' : 'complete-from-another',
257 'other' : 'host|mac',
258 'data-handler' : 'alias-to-value',
259 'doc' : 'test|test-path-host',
260 },
261 # dest ip (need address space, vlan)
262 {
263 'field' : 'dst-ip',
264 'tag' : 'dst-ip',
265 'type' : 'ip-address',
266 'completion' : 'complete-from-another',
267 'other' : 'host-network-address|ip-address',
268 'doc' : 'test|test-path-ip',
269 },
270 # dest attachment point
271 (
272 {
273 'field' : 'dst-switch',
274 'tag' : 'dst-switch',
275 'type' : 'dpid',
276 'completion' : 'complete-from-another',
277 'other' : 'switches|dpid', # field isn't dpid
278 'data-handler' : 'alias-to-value',
279 'doc' : 'test|test-path-switch',
280 },
281 {
282 'field' : 'dst-switch-port',
283 'type' : 'string',
284 'completion' : 'complete-from-another',
285 'other' : 'interfaces|portName',
286 'scoped' : 'dst-switch',
287 'data-handler' : 'convert-interface-to-port',
288 'doc' : 'test|test-path-if',
289 },
290 ),
291 )
292 },
293 ),
294}
295
296TEST_PATH_FORMAT = {
297 'test-path' : {
298 'field-orderings' : {
299 'default' : [ 'Idx', 'switch', 'portName',
300 'receiveBytes', 'receivePackets', 'receiveErrors',
301 'transmitBytes', 'transmitPackets', 'transmitErrors',
302 ]
303 },
304 'fields' : {
305 'switch' : {
306 'verbose-name' : 'Switch',
307 'formatter' : fmtcnv.replace_switch_with_alias
308 },
309 'portName' : {
310 'verbose-name' : 'IF',
311 },
312 'receiveBytes' : {
313 'verbose-name' : 'Rx Bytes',
314 },
315 'receivePackets' : {
316 'verbose-name' : 'Rx Pkts',
317 },
318 'receiveErrors' : {
319 'verbose-name' : 'Rx Errs',
320 },
321 'transmitBytes' : {
322 'verbose-name' : 'Tx Bytes',
323 },
324 'transmitPackets' : {
325 'verbose-name' : 'Tx Pkts',
326 },
327 'transmitErrors' : {
328 'verbose-name' : 'Tx Errs',
329 },
330 },
331 },
332}