blob: 0e6e6599ddbb93a88278d3c00bb0ec540303a0fe [file] [log] [blame]
srikanth116e6e82014-08-19 07:22:37 -07001#
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#
srikanth116e6e82014-08-19 07:22:37 -070016SWITCH_SUBMODE_COMMAND_DESCRIPTION = {
17 'name' : 'switch',
18 'short-help' : 'Enter switch submode, configure switch details',
19 'mode' : 'config*',
20 'obj-type' : 'switch-config',
21 'command-type' : 'config-submode',
22 'parent-field' : None,
23 'submode-name' : 'config-switch',
24 'doc' : 'switch|switch',
25 'doc-example' : 'switch|switch-example',
26 'args' : (
27 {
28 'field' : 'dpid',
29 'type' : 'dpid',
30 'other' : 'switches|dpid',
31 'completion' : [
32 'complete-alias-choice',
33 'complete-from-another',
34 ],
35 'data-handler' : 'alias-to-value',
36 'syntax-help' : 'Configure a new switch with dpid',
37 }
38 )
39}
srikanth116e6e82014-08-19 07:22:37 -070040#
41# ------------------------------------------------------------------------------
42# show switch
43#
44
45show_switch_pipeline = (
46 {
47 'proc' : 'query-table',
48 'obj-type' : 'switches', # synthetic, supported by rest_to_model
49 'key' : 'dpid',
50 },
51 {
52 'proc' : 'join-table',
53 'obj-type' : 'switch-alias',
54 'key' : 'switch',
55 'join-field' : '@',
56 'add-field' : 'switch-alias|id',
57 },
58 {
59 'proc' : 'join-rest',
60 'url' : 'tunnel-manager/all',
61 'rest-type' : 'dict-of-dict-of-switch',
62 'key' : 'switch',
63 'join-field' : '@',
64 },
65 {
66 'proc' : 'display',
67 'format' : 'switch',
68 },
69)
70
71SWITCH_SHOW_COMMAND_DESCRIPTION = {
72 'name' : 'show',
73 'mode' : 'login',
74 'command-type' : 'display-table',
75 'all-help' : 'Show switch information',
76 'short-help' : 'Show switch summary',
77 'obj-type' : 'switches',
78 'doc' : 'switch|show',
79 'doc-example' : 'switch|show-example',
80 'args' : (
81 {
82 'token' : 'switch',
83 'action' : show_switch_pipeline,
84 'doc' : 'switch|show',
85 },
86 )
87}
88
89SWITCH_SHOW_WITH_DPID_COMMAND_DESCRIPTION = {
90 'name' : 'show',
91 'mode' : 'login',
92 'short-help' : 'Show switch details via query',
93 'no-supported' : False,
94 'parent-field' : None,
95 'obj-type' : 'switches',
96 'args' : (
97 {
98 'token' : 'switch',
99 'obj-type' : 'switches',
100 'command-type' : 'display-table',
101 # 'command-type' : 'display-rest',
102 'action' : show_switch_pipeline,
103 },
104 {
105 'choices' : (
106 {
107 'field' : 'dpid',
108 'completion' : 'complete-alias-choice',
109 'type' : 'dpid',
110 'help-name' : 'switch dpid or alias',
111 'data-handler' : 'alias-to-value',
112 },
113 {
114 'token' : 'all',
115 },
116 ),
117 },
118 {
119 'optional' : True,
120 'choices' : (
121 (
122 {
123 'token' : 'by',
124 'doc' : 'switch|show-switch-order',
125 },
126 {
127 'choices' : (
128 {
129 'token' : 'ip-address',
130 'sort' : 'ip-address',
131 'action' : 'display-table',
132 'short-help' : 'Sort by ip-address',
133 },
134 {
135 'token' : 'connect-time',
136 'sort' : '-connected-since',
137 'action' : 'display-table',
138 'short-help' : 'Sort by connect time',
139 },
140 )
141 }
142 ),
143 )
144 },
145 {
146 'field' : 'detail',
147 'type' : 'enum',
148 'values' : ('details','brief'),
149 'optional' : True,
150 'doc' : 'switch|show-switch-format-+',
151 },
152 )
153}
srikanth116e6e82014-08-19 07:22:37 -0700154SWITCH_SHOW_REALTIME_STATS_COMMAND_DESCRIPTION = {
155 'name' : 'show',
156 'mode' : 'login',
157 'short-help' : 'Show switch stats via direct query to switch',
158 'no-supported' : False,
159 'short-help' : 'Show realtime stats for switch',
160 'parent-field' : None,
161 'obj-type' : 'switches',
162 'args' : (
163 {
164 'token' : 'switch',
165 'obj-type' : 'switches',
166 'command-type' : 'display-table',
167 # 'command-type' : 'display-rest',
168 },
169 {
170 'choices' : (
171 {
172 'field' : 'dpid',
173 'completion' : 'complete-alias-choice',
174 'type' : 'dpid',
175 'help-name' : 'switch dpid or alias',
176 'data-handler' : 'alias-to-value',
177 'data' : { 'detail' : 'scoped' },
178 },
179 {
180 'token' : 'all',
181 'doc' : 'reserved|all',
182 },
183 ),
184 },
185 {
186 'choices' : (
187 (
188 {
189 'field' : 'realtimestats',
190 'type' : 'enum',
191 'values' : ('aggregate',
192 'flow',
193 'port',
194 'table',
195 'desc',
196 'queue',
197 ),
198 'action' : 'display-rest',
199 'url' : [
200 'realtimestats/%(realtimestats)s/%(dpid)s/',
201 'realtimestats/%(realtimestats)s/all/',
202 ],
203 'rest-type' : 'dict-of-list-of-switch',
204 'format' : 'realtime_%(realtimestats)s',
205 'short-help' : 'Show requested item by querying switch',
206 'doc' : 'switch|realtime-+',
207 },
208 {
209 'field' : 'detail',
210 'optional' : True,
211 'type' : 'enum',
212 'values' : ('details','brief'),
213 'doc' : 'format|+',
214 },
215 ),
216 (
217 {
218 'field' : 'realtimestats',
219 'type' : 'enum',
220 'values' : 'features',
221 'action' : 'display-rest',
222 'url' : [
223 'realtimestats/%(realtimestats)s/%(dpid)s/',
224 'realtimestats/%(realtimestats)s/all/',
225 ],
226 'rest-type' : 'dict-of-dict-of-switch|ports',
227 'format' : 'realtime_%(realtimestats)s',
228 'doc' : 'switch|realtime_features',
229 },
230 {
231 'field' : 'detail',
232 'optional' : True,
233 'type' : 'enum',
234 'values' : ('details','brief'),
235 'doc' : 'format|+',
236 },
237 ),
238 )
239 }
240 )
241}
242
243SWITCH_SHOW_STATS_COMMAND_DESCRIPTION = {
244 'name' : 'show',
245 'mode' : 'login',
246 'short-help' : 'Show switch stats',
247 'short-help' : 'show stats for selected switch',
248 'no-supported' : False,
249 'parent-field' : None,
250 'obj-type' : 'switches',
251 'args' : (
252 {
253 'token' : 'switch',
254 # 'command-type' : 'display-rest',
255 },
256 {
257 'field' : 'dpid',
258 'completion' : 'complete-alias-choice',
259 'type' : 'dpid',
260 'help-name' : 'switch dpid or alias',
261 'data-handler' : 'alias-to-value',
262 },
263 {
264 'token' : 'stats',
265 'action' : 'legacy-cli',
266 'obj-type' : 'switch-stats',
267 },
268 )
269}
270
271SWITCH_SHOW_STATS_OBJECT_DETAILS_COMMAND_DESCRIPTION = {
272 'name' : 'show',
273 'mode' : 'login',
274 'short-help' : 'Show statistics for a given switch',
275 'no-supported' : False,
276 'parent-field' : None,
277 'obj-type' : 'switches',
278 'args' : (
279 {
280 'token' : 'switch',
281 # 'command-type' : 'display-rest',
282 },
283 {
284 'field' : 'dpid',
285 'completion' : 'complete-alias-choice',
286 'type' : 'dpid',
287 'help-name' : 'switch dpid or alias',
288 'data-handler' : 'alias-to-value',
289 },
290 {
291 'token' : 'stats',
292 'action' : 'legacy-cli',
293 'obj-type' : 'switch-stats',
294 },
295 {
296 'field' : 'stats-type',
297 'type' : 'enum',
298 'values' : (
299 'OFActiveFlow',
300 'OFFlowMod',
301 'OFPacketIn',
302 ),
303 },
304 {
305 'field' : 'start-time',
306 'tag' : 'start-time',
307 'type' : 'date',
308 'data-handler' : 'date-to-integer',
309 'short-help' : 'Start time for displaying the stats',
310 'optional' : True,
311 },
312 {
313 'field' : 'end-time',
314 'tag' : 'end-time',
315 'type' : 'date',
316 'data-handler' : 'date-to-integer',
317 'short-help' : 'End time for displaying the stats',
318 'optional' : True,
319 },
320 {
321 'field' : 'duration',
322 'tag' : 'duration',
323 'type' : 'duration',
324 'short-help' : 'Duration from the start or end for displaying the stats',
325 'optional' : True,
326 },
327 {
328 'field' : 'sample-interval',
329 'tag' : 'sample-interval',
330 'type' : 'integer',
331 'short-help' : 'Spacing between sampling windows',
332 'optional' : True,
333 },
334 {
335 'field' : 'sample-count',
336 'tag' : 'sample-count',
337 'type' : 'integer',
338 'short-help' : 'Number of samples in each window',
339 'optional' : True,
340 },
341 {
342 'field' : 'sample-window',
343 'tag' : 'sample-window',
344 'type' : 'integer',
345 'short-help' : 'Window length for sampling',
346 'optional' : True,
347 },
348 {
349 'field' : 'data-format',
350 'tag' : 'data-format',
351 'type' : 'enum',
352 'values' : ('value', 'rate',),
353 'short-help' : 'Whether to display as a raw value or rate',
354 'optional' : True,
355 },
356 {
357 'field' : 'display',
358 'tag' : 'display',
359 'type' : 'enum',
360 'values' : ('latest-value', 'graph', 'table'),
361 'short-help' : 'Display the latest value, a graph, or a table',
362 'optional' : True,
363 },
364 ),
365}
366
367
368show_switch_interfaces_pipeline = (
369 {
370 'proc' : 'query-table',
371 'obj-type' : 'interfaces',
372 'key' : 'id',
373 },
374 {
375 'proc' : 'query-table-append',
376 'obj-type' : 'switch-interface-config',
377 'key' : 'id',
378 },
379 {
380 'proc' : 'join-rest',
381 'url' : [
382 # this is using 'switch' from previous results,
383 # not from the data items
384 'realtimestats/port/%(switch)s/',
385 ],
386 'rest-type' : 'dict-of-list-of-switch|portNumber',
387 'key' : 'switch|portNumber',
388 'join-field' : 'switch|portNumber'
389 },
390 {
391 'proc' : 'display',
392 'sort' : ['switch', 'portName'],
393 'format' : 'switch-interfaces',
394 },
395)
396
397SWITCH_SHOW_SWITCH_DPID_INTERFACES_COMMAND_DESCRIPTION = {
398 'name' : 'show',
399 'mode' : 'login',
400 'no-supported' : False,
401 'short-help' : 'Show interfaces for selected switch',
402 'parent-field' : None,
403 'obj-type' : 'switches',
404 'args' : (
405 {
406 'token' : 'switch',
407 'command-type' : 'display-table',
408 },
409 {
410 'choices' : (
411 {
412 'field' : 'dpid',
413 'completion' : 'complete-alias-choice',
414 'type' : 'dpid',
415 'help-name' : 'switch dpid or alias',
416 'data-handler' : 'alias-to-value',
417 },
418 {
419 'field' : 'dpid',
420 'type' : 'enum',
421 'values' : 'all',
422 'short-help' : 'Show interfaces for all switches',
423 },
424 ),
425 },
426 {
427 'choices' : (
428 (
429 {
430 'token' : 'interfaces',
431 'action' : 'legacy-cli',
432 'obj-type' : 'switch-interfaces',
433 'action' : show_switch_interfaces_pipeline,
434 'short-help' : 'Show interfaces for switches',
435 'doc' : 'switch|show-interfaces',
436 },
437 {
438 'token' : 'stats',
439 'action' : 'display-rest',
440 'url' : 'realtimestats/port/%(dpid)s/',
441 'rest-type' : 'dict-of-list-of-switch',
442 'format' : 'realtime_port',
443 'rest-type' : 'dict-of-list-of-switch',
444 'optional' : True,
445 'short-help' : 'Show interfaces stats for switches',
446 },
447 {
448 'token' : 'alias',
449 'action' : 'display-table',
450 'obj-type' : 'switch-interface-alias',
451 'optional' : True,
452 'short-help' : 'Show interface aliases for switches',
453 'scoped' : True,
454 'doc' : 'switch|show-interfaces-alias',
455 }
456 ),
457 {
458 'field' : 'vns',
459 'type' : 'enum',
460 'values' : 'vns',
461 'action' : 'legacy-cli',
462 'obj-type' : 'switch-ports-vns'
463 },
464 {
465 'field' : 'alias',
466 'type' : 'enum',
467 'values' : 'alias',
468 'obj-type' : 'switch-alias',
469 'action' : 'display-table',
470 'doc' : 'switch|show-switch-alias',
471 },
472 )
473 },
474 {
475 'optional' : True,
476 'field' : 'detail',
477 'type' : 'enum',
478 'values' : ('details', 'brief',),
479 'short-help' : 'Show switch output format level',
480 }
481 )
482}
483
srikanth116e6e82014-08-19 07:22:37 -0700484SWITCH_SUBMODE_SHOW_INTERFACE_COMMAND_DESCRIPTION = {
485 'name' : 'show',
486 'mode' : 'config-switch*',
487 'command-type' : 'display-table',
488 'obj-type' : 'switch-interfaces',
489 'short-help' : 'Show interfaces for switch associated with current submode',
490 'args' : (
491 {
492 'token' : 'interfaces',
493 'action' : 'legacy-cli',
494 'scoped' : True,
495 'action' : show_switch_interfaces_pipeline,
496 },
497 )
498}
499
500
501SWITCH_SHOW_TCPDUMP_COMMAND_DESCRIPTION = {
502 'name' : 'show',
503 'mode' : 'login',
504 'short-help' : 'Show switch tcpdump via controller',
505 'no-supported' : False,
506 'parent-field' : None,
507 'current-mode-obj-id' : None,
508 'obj-type' : 'switches',
509 'args' : (
510 {
511 'token' : 'switch',
512 'obj-type' : 'switches',
513 },
514 {
515 'field' : 'dpid',
516 'optional' : False,
517 'completion' : 'complete-alias-choice',
518 'type' : 'dpid',
519 'help-name' : 'switch dpid or alias',
520 'data-handler' : 'alias-to-value',
521 },
522 {
523 'field' : 'tcpdump',
524 'optional' : False,
525 'type' : 'enum',
526 'values' : 'trace',
527 'obj-type' : 'switch-tcpdump',
528 'action' : 'legacy-cli',
529 },
530 {
531 'field' : 'oneline',
532 'type' : 'enum',
533 'values' : 'oneline',
534 'optional' : True,
535 },
536 {
537 'field' : 'single_session',
538 'type' : 'enum',
539 'values' : 'single-session',
540 'optional' : True,
541 },
542 {
543 'field' : 'echo_reply',
544 'type' : 'enum',
545 'values' : 'echo-reply',
546 'optional' : True,
547 'permute' : 'skip',
548 },
549 {
550 'field' : 'echo_request',
551 'type' : 'enum',
552 'values' : 'echo-request',
553 'optional' : True,
554 'permute' : 'skip',
555 },
556 {
557 'field' : 'features_rep',
558 'type' : 'enum',
559 'values' : 'features-rep',
560 'optional' : True,
561 'permute' : 'skip',
562 },
563 {
564 'field' : 'flow_mod',
565 'type' : 'enum',
566 'values' : 'flow-mod',
567 'optional' : True,
568 'permute' : 'skip',
569 },
570 {
571 'field' : 'flow_removed',
572 'type' : 'enum',
573 'values' : 'flow-removed',
574 'optional' : True,
575 'permute' : 'skip',
576 },
577 {
578 'field' : 'get_config_rep',
579 'type' : 'enum',
580 'values' : 'get-config-rep',
581 'optional' : True,
582 'permute' : 'skip',
583 },
584 {
585 'field' : 'hello',
586 'type' : 'enum',
587 'values' : 'hello',
588 'optional' : True,
589 'permute' : 'skip',
590 },
591 {
592 'field' : 'packet_in',
593 'type' : 'enum',
594 'values' : 'packet-in',
595 'optional' : True,
596 'permute' : 'skip',
597 },
598 {
599 'field' : 'packet_out',
600 'type' : 'enum',
601 'values' : 'packet-out',
602 'optional' : True,
603 'permute' : 'skip',
604 },
605 {
606 'field' : 'port_status',
607 'type' : 'enum',
608 'values' : 'port-status',
609 'optional' : True,
610 'permute' : 'skip',
611 },
612 {
613 'field' : 'set_config',
614 'type' : 'enum',
615 'values' : 'set-config',
616 'optional' : True,
617 'permute' : 'skip',
618 },
619 {
620 'field' : 'stats_reply',
621 'type' : 'enum',
622 'values' : 'stats-reply',
623 'optional' : True,
624 'permute' : 'skip',
625 },
626 {
627 'field' : 'stats_request',
628 'type' : 'enum',
629 'values' : 'stats-request',
630 'optional' : True,
631 'permute' : 'skip',
632 },
633 {
634 'field' : 'detail',
635 'type' : 'enum',
636 'values' : 'detail',
637 'optional' : True,
638 },
639 )
640}
Srikanth Vavilapalli6f606d92014-10-01 08:49:50 -0700641"""
srikanth116e6e82014-08-19 07:22:37 -0700642#
643# ------------------------------------------------------------------------------
644# SWITCH_TUNNEL_SHOW_COMMAND_DESCRIPTION
645#
646
647show_tunnel_pipeline = (
648 {
649 'proc' : 'query-rest',
650 'url' : [
651 'tunnel-manager/%(dpid)s',
652 'tunnel-manager/all',
653 ],
654 'rest-type' : 'dict-of-dict-of-dpid',
655 },
656 {
657 'proc' : 'join-table',
658 'obj-type' : 'interfaces',
659 'key' : 'switch|portName',
660 'join-field' : 'hexDpid|tunnelEndPointIntfName',
661 'add-field' : 'portNumber|portNumber',
662 },
663 {
664 'proc' : 'join-rest',
665 'url' : 'realtimestats/port/%(dpid)s/',
666 'rest-type' : 'dict-of-list-of-switch|portNumber',
667 'key' : 'switch|portNumber',
668 'join-field' : 'hexDpid|portNumber',
669 },
670 {
671 'proc' : 'display',
672 'format' : 'tunnel-pipeline',
673 }
674)
srikanthf2c888b2014-08-20 10:46:55 -0700675"""
srikanth116e6e82014-08-19 07:22:37 -0700676import fmtcnv
srikanthf2c888b2014-08-20 10:46:55 -0700677"""
srikanth116e6e82014-08-19 07:22:37 -0700678TUNNEL_PIPELINE_FORMAT = {
679 'tunnel-pipeline' : {
680 'field-orderings' : {
681 'default' : [ 'Idx',
682 'dpid',
683 'tunnelCapable',
684 'tunnelEnabled',
685 'tunnelEndPointIntfName',
686 'tunnelIPAddr',
687 'tunnelState',
688 'receivePackets',
689 'receiveBytes',
690 'transmitPackets',
691 'transmitBytes',
692 ]
693 },
694
695 'fields' : {
696 'dpid' : {
697 'verbose-name' : 'Switch DPID',
698 'primary_key': True,
699 'formatter' : fmtcnv.replace_switch_with_alias,
700 },
701 'tunnelCapable' : {
702 'verbose-name' : 'Capable',
703 },
704 'tunnelEnabled' : {
705 'verbose-name' : 'Enabled',
706 },
707 'tunnelEndPointIntfName' : {
708 'verbose-name' : 'IF Name',
709 },
710 'tunnelIPAddr' : {
711 'verbose-name' : 'IP Address',
712 },
713 'tunnelState' : {
714 'verbose-name' : 'State',
715 },
716 'receivePackets' : {
717 'verbose-name' : 'Rx Pkts',
718 },
719 'receiveBytes' : {
720 'verbose-name' : 'Rx Bytes',
721 },
722 'transmitPackets' : {
723 'verbose-name' : 'Tx Pkts',
724 },
725 'transmitBytes' : {
726 'verbose-name' : 'Tx Bytes',
727 },
728 },
729 },
730}
731
732
733
734SWITCH_TUNNEL_SHOW_COMMAND_DESCRIPTION = {
735 'name' : 'show',
736 'mode' : 'login',
737 'feature' : 'vns',
738 'short-help' : 'Show tunnels for all switches',
739 'command-type' : 'display-rest',
740 'url' : 'tunnel-manager/all',
741 'obj-type' : 'switch',
742 'action' : show_tunnel_pipeline,
743 'args' : (
744 'tunnel',
745 ),
746}
747
748
749SWITCH_TUNNEL_SHOW_WITH_DPID_COMMAND_DESCRIPTION = {
750 'name' : 'show',
751 'mode' : 'login',
752 'feature' : 'vns',
753 'short-help' : 'Show tunnels for selected switches',
754 'command-type' : 'display-rest',
755 'obj-type' : 'switch',
756 'url' : 'tunnel-manager/%(dpid)s',
757 'format' : 'tunnel-details',
758 'action' : show_tunnel_pipeline,
759 'args' : (
760 'tunnel',
761 {
762 'choices' : (
763 {
764 'field' : 'dpid',
765 'type' : 'enum',
766 'values' : 'all',
767 },
768 {
769 'field' : 'dpid',
770 'completion' : 'complete-object-field',
771 'type' : 'dpid',
772 },
773 ),
774 },
775 ),
776}
Srikanth Vavilapalli6f606d92014-10-01 08:49:50 -0700777"""
srikanth116e6e82014-08-19 07:22:37 -0700778#
779# ------------------------------------------------------------------------------
780# SWITCH_CORE_SWITCH_TERMINATION_COMMAND_DESCRIPTION
781#
782
783SWITCH_CORE_SWITCH_COMMAND_DESCRIPTION = {
784 'name' : 'core-switch',
785 'short-help' : 'Enable core-switch property for this switch',
786 'mode' : 'config-switch',
787 'parent-field' : 'dpid',
788 'obj-type' : 'switch-config',
789 'doc' : 'switch|core-switch',
790 'doc-example' : 'switch|core-switch-example',
791 'args' : (),
792 'action': (
793 {
794 'proc' : 'update-config',
795 'data' : {'core-switch' : True}
796 },
797 ),
798 'no-action': (
799 {
800 'proc' : 'update-config',
801 'data' : {'core-switch' : False},
802 }
803 )
804}
Srikanth Vavilapalli6f606d92014-10-01 08:49:50 -0700805"""
srikanth116e6e82014-08-19 07:22:37 -0700806#
807# ------------------------------------------------------------------------------
808# SWITCH_TUNNEL_TERMINATION_COMMAND_DESCRIPTION
809#
810
811SWITCH_TUNNEL_TERMINATION_COMMAND_DESCRIPTION = {
812 'name' : 'tunnel',
813 'short-help' : 'Enable/Disable tunnel creation for this switch',
814 'mode' : 'config-switch',
815 'command-type' : 'update-config',
816 'parent-field' : 'dpid',
817 'obj-type' : 'switch-config',
818 'doc' : 'switch|tunnel',
819 'doc-example' : 'switch|tunnel-example',
820 'data' : { 'tunnel-termination' : 'default' }, # for no command
821 'args' : (
822 'termination',
823 {
824 'field' : 'tunnel-termination',
825 'type' : 'enum',
826 'values' : ( "enabled", "disabled" ),
827 'optional-for-no' : True,
828 }
829 )
830}
Srikanth Vavilapalli6f606d92014-10-01 08:49:50 -0700831"""
srikanth116e6e82014-08-19 07:22:37 -0700832#
833# ------------------------------------------------------------------------------
834# SWITCH_ALIAS_COMMAND_DESCRIPTION
835#
836
837SWITCH_SWITCH_ALIAS_COMMAND_DESCRIPTION = {
838 'name' : 'switch-alias',
839 'mode' : 'config-switch',
840 'short-help' : 'Attach alias to switch',
841 'doc' : 'switch|alias',
842 'doc-example' : 'switch|alias-example',
843 'command-type' : 'manage-alias',
844 'obj-type' : 'switch-alias',
845 'scoped' : True,
846 'args' : (
847 {
848 'field' : 'id',
849 'optional-for-no' : False,
850 'completion' : 'complete-object-field',
851 }
852 )
853}
854
855#
856# ------------------------------------------------------------------------------
857# SWITCH_INTERFACE_COMMAND_DESCRIPTION
858# enter config-switch-if submode
859#
860
861SWITCH_INTERFACE_COMMAND_DESCRIPTION = {
862 'name' : 'interface',
863 'mode' : 'config-switch*',
864 'short-help' : 'Enter switch-if submode, configure switch interface',
865 'command-type' : 'config-submode',
866 'obj-type' : 'switch-interface-config',
867 'parent-field' : 'switch',
868 'current-mode-obj-id' : 'switch',
869 'submode-name' : 'config-switch-if',
870 'syntax-help' : 'Enter an interface name',
871 'doc' : 'switch|interface',
872 'doc-example' : 'switch|interface-example',
873 'args' : (
874 {
875 'field' : 'name',
876 'completion' : [ 'complete-object-field',
877 'complete-from-another',
878 ],
879 'other' : 'interfaces|portName',
880 'scoped' : 'dpid',
881 'data-handler' : 'warn-missing-interface',
882 }
883 )
884}
885
886#
887# ------------------------------------------------------------------------------
888# SWITCHPORT_COMMAND_DESCRIPTION
889# 'switchport mode external'
890# 'no switchport mode external'
891#
892
893SWITCHPORT_COMMAND_DESCRIPTION = {
894 'name' : 'switchport',
895 'short-help' : 'Configure interface as connected to an external network',
896 'mode' : 'config-switch-if',
897 'command-type' : 'config',
898 'obj-type' : 'switch-interface-config',
899 'fields' : ('broadcast', 'mode',),
900 'action' : 'write-fields',
901 'no-action' : 'reset-fields',
902 'doc' : 'switch|switchport',
903 'doc-example' : 'switch|switchport-example',
904 'args' : (
905 'mode',
906 {
907 'field' : 'mode',
908 'type' : 'enum',
909 'values' : 'external',
910 'help-name' : 'interface connects to external network',
911 'short-help' : 'interface connects to external network',
912 'syntax-help' : 'external'
913 },
914 )
915}
916
917#
918# ------------------------------------------------------------------------------
919#
920
921
922SWITCH_INTERFACE_INTERFACE_ALIAS_COMMAND_DESCRIPTION = {
923 'name' : 'interface-alias',
924 'mode' : 'config-switch-if',
925 'short-help' : 'Attach alias to switch interface',
926 'command-type' : 'manage-alias',
927 'obj-type' : 'switch-interface-alias',
928 'scoped' : True,
929 'doc' : 'switch|interface-alias',
930 'doc-example' : 'switch|interface-alias-example',
931 'args' : (
932 {
933 'field' : 'id',
934 'optional-for-no' : False,
935 'completion' : 'complete-object-field',
936 'short-help' : 'Alias string',
937 }
938 )
939}
srikanth116e6e82014-08-19 07:22:37 -0700940#
941# FORMATS
942#
943
944
945SWITCH_FORMAT = {
946 'switch' : {
947 'field-orderings' : {
948 'default' : [ 'Idx', '@', 'switch-alias', 'connected-since',
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700949 'ip-address', 'type', 'controller'],
srikanth116e6e82014-08-19 07:22:37 -0700950 'details' : [ 'Idx','@', 'switch-alias', 'connected-since',
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700951 'ip-address', 'type', 'controller'],
952 'brief' : [ 'Idx', '@', 'switch-alias', 'controller'],
srikanth116e6e82014-08-19 07:22:37 -0700953 },
954 'fields' : {
955 '@' : {
956 'verbose-name' : 'Switch DPID',
957 },
958 'active' : {
959 },
960 'core-switch' : {
961 'verbose-name' : 'Core Switch',
962 'validate' : 'validate_switch_core_switch',
963 },
964 'connected-since' : {
965 'verbose-name' : 'Connected Since',
srikanthf2c888b2014-08-20 10:46:55 -0700966 #'formatter' : fmtcnv.timestamp_to_local_timestr,
srikanth116e6e82014-08-19 07:22:37 -0700967 },
968 'capabilities' : {
969 'formatter' : fmtcnv.decode_switch_capabilities,
970 },
971 'actions' : {
972 'formatter' : fmtcnv.decode_switch_actions,
973 },
974 'ip-address' : {
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700975 'verbose-name' : 'Connected At',
srikanth116e6e82014-08-19 07:22:37 -0700976 },
977 'socket-address' : {
978 },
979 'buffers' : {
980 },
981 'controller' : {
Fahad Naeem Khan1f8fb2e2014-09-25 16:39:18 -0700982 'verbose-name' : 'Controller',
srikanth116e6e82014-08-19 07:22:37 -0700983 },
984 'tables' : {
985 },
986 'switch-alias' : {
987
988 'verbose-name' : 'Alias'
989 },
990 'tunnelCapable' : {
991 'verbose-name' : 'Tun Capable',
992 },
993 'tunnelEnabled' : {
994 'verbose-name' : '-Enabled',
995 },
996 'tunnelState' : {
997 'verbose-name' : '-State',
998 },
999 'dp-desc' : {
1000 },
1001 'hw-desc' : {
1002 },
1003 'sw-desc' : {
1004 },
1005 'serial-num' : {
1006 },
srikanthf2c888b2014-08-20 10:46:55 -07001007 'type' : {
1008 },
srikanth116e6e82014-08-19 07:22:37 -07001009 }
1010 },
1011}
1012
srikanth116e6e82014-08-19 07:22:37 -07001013SWITCH_CONFIG_FORMAT = {
1014 'switch-config' : {
1015 'field-orderings' : {
1016 'default' : [
1017 'Idx',
1018 'dpid',
1019 'tunnel-termination',
1020 'core-switch',
1021 ],
1022 },
1023 },
1024}
1025
1026
1027SWITCH_ALIAS_FORMAT = {
1028 'switch-alias' : {
1029 'field-orderings' : {
1030 'default' : [ 'Idx', 'id', 'switch' ],
1031 'brief' : [ 'Idx', 'id', 'switch' ],
1032 },
1033 },
1034}
1035
1036
1037SWITCH_INTERFACE_CONFIG_FORMAT = {
1038 'switch-interface-config' : {
1039 'field-orderings' : {
1040 'default' : [ 'Idx', 'if-name', 'mode' ]
1041 },
1042 'fields' : {
1043 'broadcast' : {
1044 },
1045 'name' : {
1046 },
1047 'mode' : {
1048 'verbose-name' : 'Switchport Mode',
1049 },
1050 },
1051 },
1052}
1053
1054
1055SWITCH_INTERFACE_ALIAS_FORMAT = {
1056 'switch-interface-alias' : {
1057 'field-orderings' : {
1058 'default' : [ 'Idx', 'id', 'switch', 'name' ]
1059 },
1060 'fields' : {
1061 'id' : { 'verbose-name' : 'Alias',
1062 }
1063 }
1064 },
1065}
srikanth116e6e82014-08-19 07:22:37 -07001066
1067SWITCH_INTERFACES_FORMAT = {
1068 'switch-interfaces' : {
1069 'field-orderings' : {
1070 'default' : [ 'Idx', 'switch', 'portName', 'state', 'config',
1071 'receiveBytes', 'receivePackets', 'receiveErrors',
1072 'transmitBytes', 'transmitPackets', 'transmitErrors',
1073 'mode', 'broadcast',
1074 ],
1075 'details' : [ 'Idx', 'switch', 'portName', 'hardwareAddress',
1076 'config', 'stp-state', 'state', 'currentFeatures',
1077 'advertisedFeatures', 'supportedFeatures',
1078 'peer-features', 'mode', 'broadcast',
1079 ],
1080 'brief' : [ 'Idx', 'switch', 'portName', 'state', 'config' ],
1081 },
1082
1083 'fields' : {
1084 'id' : {
1085 },
1086 'switch' : { 'formatter' : fmtcnv.replace_switch_with_alias
1087 },
1088 'portName' : { 'verbose-name' : 'IF',
1089 },
1090 'hardwareAddress' : { 'verbose-name' : 'MAC Address'
1091 },
1092 'config' : {
1093 'formatter' : fmtcnv.decode_port_config
1094 },
1095 'state' : { 'verbose-name' : 'Link',
1096 'formatter' : fmtcnv.decode_port_up_down,
1097 },
1098 'stp-state' : {
1099 'formatter' : lambda i, data :
1100 fmtcnv.decode_port_stp_state(data['state'],
1101 data),
1102 },
1103 'currentFeatures' : { 'verbose-name' : 'Curr Features',
1104 'formatter' : fmtcnv.decode_port_features
1105 },
1106 'advertisedFeatures' : { 'verbose-name' : 'Adv Features',
1107 'formatter' : fmtcnv.decode_port_features
1108 },
1109 'supportedFeatures' : { 'verbose-name' : 'Supp Features',
1110 'formatter' : fmtcnv.decode_port_features
1111 },
1112 'peer-features' : { 'verbose-name' : 'Peer Features',
1113 'formatter' : fmtcnv.decode_port_features
1114 },
1115 'receiveBytes' : { 'verbose-name' : 'Rcv Bytes',
1116 'formatter' : fmtcnv.decode_port_counter},
1117 'receivePackets' : { 'verbose-name' : 'Rcv Pkts',
1118 'formatter' : fmtcnv.decode_port_counter},
1119 'receiveErrors' : { 'verbose-name' : 'Rcv Errs',
1120 'formatter' : fmtcnv.decode_port_counter},
1121 'transmitBytes' : { 'verbose-name' : 'Xmit Bytes',
1122 'formatter' : fmtcnv.decode_port_counter},
1123 'transmitPackets' : { 'verbose-name' : 'Xmit Pkts',
1124 'formatter' : fmtcnv.decode_port_counter},
1125 'transmitErrors' : { 'verbose-name' : 'Xmit Errs',
1126 'formatter' : fmtcnv.decode_port_counter},
1127 },
1128 },
1129}
Srikanth Vavilapalli0c870f82014-09-28 22:45:06 -07001130"""
srikanth116e6e82014-08-19 07:22:37 -07001131TUNNEL_DETAILS_FORMAT = {
1132 'tunnel-details' : {
1133 'field-orderings' : {
1134 'default' : [ 'Idx', 'dpid', 'localTunnelIPAddr',
1135 'tunnelPorts',
1136 ]
1137 },
1138
1139 'fields' : {
1140 'dpid' : {
1141 'verbose-name' : 'Switch DPID',
1142 'primary_key': True,
1143 'formatter' : fmtcnv.replace_switch_with_alias,
1144 },
1145 'localTunnelIPAddr' : {
1146 'verbose-name' : 'Local tunnel IP',
1147 },
1148 'tunnelPorts' : {
1149 'verbose-name' : 'Remote tunnel IP',
1150 },
1151 },
1152 },
1153}
srikanthf2c888b2014-08-20 10:46:55 -07001154"""