blob: 4c71c5ba270a58bd78d47c204332eae3958fe35f [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 command
18import fmtcnv
19"""
20CONTROLLER_NODE_FORMAT = {
21 'controller-node' : {
22 'field-orderings' : {
23 'default' : [
24 'Idx',
25 'alias',
26 'me',
27 'ha-role',
28 'change-date-time',
29 'change-description',
30 'status',
31 'uptime',
32 'errors'
33 #'domain-lookups-enabled',
34 #'logging-enabled',
35 ],
36 'brief' : [
37 'Idx',
38 'alias',
39 'me',
40 'ha-role',
41 'change-date-time',
42 'change-description',
43 'status',
44 'uptime',
45 'errors',
46 ],
47 'details' : [
48 'Idx',
49 'alias',
50 'id',
51 'me',
52 'ha-role',
53 'change-date-time',
54 'change-description',
55 'status',
56 'uptime',
57 'errors',
58 'domain-lookups-enabled', 'domain-name-servers',
59 'domain-name', 'default-gateway',
60 'ntp-server', 'time-zone',
61 'logging-enabled', 'logging-server',
62 ],
63 'without-vns' : [
64 'Idx',
65 'id',
66 'me',
67 'alias',
68 'ha-role',
69 'change-date-time',
70 'change-description',
71 'uptime',
72 'domain-lookups-enabled', 'domain-name-servers',
73 'domain-name', 'default-gateway',
74 'ntp-server', 'time-zone',
75 'logging-enabled', 'logging-server', 'logging-level',
76 ]
77 },
78 'fields': {
79 'id' : {
80 'verbose-name' : 'Controller ID',
81 },
82 'me' : {
83 'verbose-name' : '@',
84 'formatter' : fmtcnv.controller_node_me,
85 'entry-formatter' : fmtcnv.controller_node_me_entry
86 },
87 'domain-lookups-enabled' : {
88 'verbose-name' : 'DNS',
89 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
90 },
91 'domain-name-servers' : {
92 'verbose-name' : 'DNS Servers',
93 'formatter' : fmtcnv.print_domain_name_servers,
94 'entry-formatter' : fmtcnv.print_all_domain_name_servers,
95 },
96 'domain-name' : {
97 },
98 'default-gateway' : {
99 },
100 'ntp-server' : {
101 },
102 'time-zone' : {
103 },
104 'logging-enabled' : { 'verbose-name' : 'Logging',
105 'formatter' : fmtcnv.replace_boolean_with_enable_disable,
106 },
107 'logging-server' : {
108 },
109 'logging-level' : {
110 },
111 'ha-role' : {
112 'verbose-name' : 'HA Role',
113 },
114 'change-date-time' : {
115 'verbose-name' : 'HA Last Change Time',
116 'formatter' : fmtcnv.print_time_since_utc_timestr,
117 },
118 'change-description' : {
119 'verbose-name' : 'HA Change Reason',
120 },
121 'uptime' : {
122 'verbose-name' : 'Uptime',
123 'formatter' : fmtcnv.print_timesince_msec_since
124 },
125 },
126 },
127}
128
129controller_node_show_actions = (
130 {
131 'proc' : 'query-table',
132 },
133 {
134 'proc' : 'join-table',
135 'obj-type' : 'controller-alias',
136 'key' : 'controller',
137 'join-field' : 'id', # field in queried items
138 },
139 {
140 'proc' : 'join-rest',
141 'url' : 'system/controller',
142 'rest-type' : 'dict-with-id',
143 'key' : 'id',
144 'join-field' : 'id',
145 'add-field' : 'me',
146 },
147 # need a description mechanism to join ha-role, which
148 # needs to send urls to controller-node interfaces
149 # ie: the rest actions alwaus use the local controller
150 # (uptime has the same issue)
151 {
152 'proc' : 'display',
153 'format' : 'controller-node',
154 },
155),
156
157
158CONTROLLER_NODE_SHOW_COMMAND_DESCRIPTION = {
159 'name' : 'show',
160 'obj-type' : 'controller-node',
161 'mode' : 'login',
162 'command-type' : 'display-table',
163 'all-help' : 'Show controller node information',
164 'short-help' : 'Show controller nodes summaries',
165 'doc' : 'controller|show',
166 'args' : (
167 {
168 'token' : 'controller-node',
169 'action' : controller_node_show_actions,
170 }
171 ),
172}
173CONTROLLER_NODE_INTERFACE_FORMAT = {
174 'controller-interface' : {
175 'field-orderings': {
176 'default' : ['Idx',
177 'controller',
178 'type',
179 'number',
180 'mode',
181 'ip',
182 'discovered-ip',
183 'netmask',
184 'mac',
185 'firewall']
186 },
187 'fields' : {
188 'controller' : {
189 'formatter' : fmtcnv.replace_controller_node_with_alias,
190 },
191 'number' : {
192 },
193 'ifname' : {
194 'formatter' : lambda i, data: '%s%s' % (data['type'],
195 data['number'])
196 },
197 'ip' : {
198 },
199 'discovered-ip' : { 'verbose-name' : 'Found IP',
200 },
201 'mode' : {
202 },
203 'netmask' : {
204 },
205 'type' : {
206 },
207 'firewall' : {
208 'verbose-name' : 'Firewall',
209 },
210 }
211 },
212}
213
214
215CONTROLLER_NODE_SUMMARY_FORMAT = {
216 'controller-summary' : {
217 'field-orderings' : {
218 'default' : [
219 '# inter-switch links',
220 '# hosts',
221 '# attachment points',
222 '# IP Addresses',
223 '# VNSes',
224 '# Access Control Lists',
225 '# VNS Interfaces with ACL applied',
226 '# VNS Interfaces',
227 ]
228 },
229
230 'fields' : {
231 '# Access Control Lists' : { 'verbose-name' : 'Access Control Lists'
232 },
233 '# VNS Interfaces' : { 'verbose-name' : 'VNS Interfaces'
234 },
235 '# hosts' : { 'verbose-name' : 'Hosts'
236 },
237 '# VNSes' : { 'verbose-name' : 'VNSesx'
238 },
239 '# attachment points' : { 'verbose-name' : 'Attachment Points'
240 },
241 '# inter-switch links' : { 'verbose-name' : 'Links'
242 },
243 '# IP Addresses' : { 'verbose-name' : 'Ip Addresses'
244 },
245 '# VNS Interfaces with ACL applied' : { 'verbose-name' : 'VNS If with Acl Applied'
246 },
247 },
248 },
249}
250
251
252COTROLLER_NODE_SWITCHES_FORMAT = {
253 'controller-switches' : {
254 'field-orderings' : {
255 'default' : [
256 'Idx', 'dpid',
257 ],
258 },
259 'fields' : {
260 'dpid' : { 'primary_key' : True,
261 'verbose-name': 'Connected Switches',
262 'formatter' : fmtcnv.print_switch_and_alias }
263 }
264 },
265
266}
267
268
269CONTROLLER_NODE_FIREWALL_RULE_FORMAT = {
270 'firewall-rule' : {
271
272 'field-orderings': {
273 'default' : ['Idx',
274 'controller',
275 'type',
276 'number',
277 'src-ip',
278 'vrrp-ip',
279 'port',
280 'proto',
281 'rule']
282 },
283 'fields' : {
284
285 'controller' : {
286 'formatter' : fmtcnv.replace_controller_node_with_alias,
287 },
288 'interface' : {
289 },
290 'port' : {
291 },
292 'proto' : {
293 },
294 'rule' : {
295 'verbose-name' : 'Firewall Rule'
296 },
297 }
298 },
299}
300
301
302def controller_completion_add_localhost(completions, prefix):
303 if completions == None:
304 completions = {}
305 if not 'localhost ' in completions and 'localhost'.startswith(prefix) :
306 completions['localhost '] = 'Select currently logged in controller'
307
308
309command.add_completion('controller-add-localhost', controller_completion_add_localhost,
310 {'kwargs': { 'completions' : '$completions',
311 'prefix' : '$text',
312 }})
313
314CONTROLLER_NODE_SHOW_ID_COMMAND_DESCRIPTION = {
315 'name' : 'show',
316 'obj-type' : 'controller-node',
317 'mode' : 'login',
318 'short-help' : 'Show controller-node associated details by name',
319 'no-supported' : False,
320 'action' : controller_node_show_actions,
321 'doc' : 'controller|show-details',
322 'args' : (
323 'controller-node',
324 {
325 'choices' : (
326 {
327 'field' : 'id',
328 'type' : 'identifier',
329 'completion' : [
330 'complete-object-field',
331 'controller-add-localhost',
332 ],
333 'data-handler' : 'alias-to-value',
334 'action' : controller_node_show_actions,
335 'doc' : 'controller|show-id',
336 },
337 {
338 'token' : 'all',
339 'doc' : 'reserved|all',
340 }
341 ),
342
343 },
344 {
345 'optional' : True,
346 'choices' : (
347 {
348 'token' : 'interfaces',
349 'obj-type' : 'controller-interface',
350 'action' : 'display-table',
351 'short-help' : 'Show network interface information for controller node',
352 'doc' : 'controller|show-interfaces',
353 },
354 {
355 'token' : 'firewall',
356 'obj-type' : 'firewall-rule',
357 'action' : 'display-table',
358 'short-help' : 'Show firewall rules for controller node',
359 'doc' : 'controller|show-firewall',
360 },
361 {
362 'token' : 'summary',
363 'action' : 'display-rest',
364 'url' : 'controller/summary',
365 'rest-type' : 'dict',
366 'format' : 'controller-summary',
367 'short-help' : 'Show a summary of configuration for controller node',
368 'doc' : 'controller|show-summary',
369 },
370 {
371 'token' : 'switches',
372 'action' : 'display-rest',
373 'url' : 'controller/stats/switches',
374 'format' : 'controller-switches',
375 'short-help' : 'Show switches connected to controller node',
376 'doc' : 'controller|show-switches',
377 },
378 {
379 'token' : 'alias',
380 'action' : 'display-table',
381 'obj-type' : 'controller-alias',
382 'short-help' : 'Show the alias for controller node',
383 'doc' : 'controller|show-alias',
384 },
385 )
386 },
387 {
388 'optional' : True,
389 'field' : 'detail',
390 'type' : 'enum',
391 'values' : ('details','brief'),
392 'doc' : 'controller|show-detail',
393 }
394 ),
395}
396
397CONTROLLER_NODE_SHOW_STATS_COMMAND_DESCRIPTION = {
398 'name' : 'show',
399 'obj-type' : 'controller-node',
400 'mode' : 'login',
401 'short-help' : 'Show statistics for a given controller node',
402 'command-type' : 'display-table',
403 'doc' : 'show-stats',
404 'args' : (
405 'controller-node',
406 {
407 'choices' : (
408 {
409 'field' : 'id',
410 'type' : 'identifier',
411 'completion' : [
412 'complete-object-field',
413 'controller-add-localhost',
414 ],
415 'action' : 'display-table',
416 'data-handler' : 'alias-to-value',
417 'doc' : 'controller|id',
418 },
419 {
420 'field' : 'id',
421 'type' : 'enum',
422 'values' : 'all',
423 'doc' : 'reserved|all',
424 }
425 ),
426 },
427 {
428 'field' : 'stats',
429 'type' : 'enum',
430 'values' : 'stats',
431 'obj-type' : 'controller-stats',
432 'action' : 'legacy-cli',
433 },
434 ),
435}
436
437CONTROLLER_NODE_SHOW_OBJECT_STATS_COMMAND_DESCRIPTION = {
438 'name' : 'show',
439 'obj-type' : 'controller-node',
440 'mode' : 'login',
441 'short-help' : 'Show detailed controller-node related statistics',
442 'command-type' : 'display-table',
443 'args' : (
444 'controller-node',
445 {
446 'choices' : (
447 {
448 'field' : 'id',
449 'type' : 'identifier',
450 'completion' : [
451 'complete-object-field',
452 'controller-add-localhost',
453 ],
454 'action' : 'display-table',
455 'data-handler' : 'alias-to-value',
456 },
457 {
458 'field' : 'id',
459 'type' : 'enum',
460 'values' : 'all',
461 'doc' : 'reserved|all',
462 }
463 ),
464 },
465 {
466 'field' : 'stats',
467 'type' : 'enum',
468 'values' : 'stats',
469 'obj-type' : 'controller-stats',
470 'action' : 'legacy-cli',
471 },
472 {
473 'field' : 'stats-type',
474 'type' : 'enum',
475 'values' : (
476 'cpu-user',
477 'disk-root',
478 'mem-used',
479 'mem-free',
480 'cli-cpu',
481 'database-cpu',
482 'swap-used',
483 'disk-boot',
484 'statd-cpu',
485 'cpu-system',
486 'cpu-idle',
487 'apache-cpu',
488 'cpu-nice',
489 'disk-log',
490 'sdnplatform-cpu'
491 ),
492 'doc' : 'controller|show-stats-type',
493 },
494 {
495 'field' : 'start-time',
496 'tag' : 'start-time',
497 'type' : 'string',
498 'short-help' : 'Start time for displaying the stats',
499 'optional' : True,
500 'doc' : 'controller|show-stats-start-time',
501 },
502 {
503 'field' : 'end-time',
504 'tag' : 'end-time',
505 'type' : 'string',
506 'short-help' : 'End time for displaying the stats',
507 'optional' : True,
508 'doc' : 'controller|show-stats-end-time',
509 },
510 {
511 'field' : 'duration',
512 'tag' : 'duration',
513 'type' : 'string',
514 'short-help' : 'Duration from the start or end for displaying the stats',
515 'optional' : True,
516 'doc' : 'controller|show-stats-duration',
517 },
518 {
519 'field' : 'sample-interval',
520 'tag' : 'sample-interval',
521 'type' : 'integer',
522 'short-help' : 'Spacing between sampling windows',
523 'optional' : True,
524 'doc' : 'controller|show-stats-sample-interval',
525 },
526 {
527 'field' : 'sample-count',
528 'tag' : 'sample-count',
529 'type' : 'integer',
530 'short-help' : 'Number of samples to show',
531 'optional' : True,
532 'doc' : 'controller|show-stats-sample-count',
533 },
534 {
535 'field' : 'sample-window',
536 'tag' : 'sample-window',
537 'type' : 'integer',
538 'optional' : True,
539 'short-help' : 'Number of raw sample values to average around each down-sampled data point',
540 'doc' : 'controller|show-stats-sample-window',
541 },
542 {
543 'field' : 'data-format',
544 'tag' : 'data-format',
545 'type' : 'enum',
546 'values' : ('value', 'rate'),
547 'short-help' : 'Whether to display as a raw value or rate',
548 'optional' : True,
549 'doc' : 'controller|show-stats-data-format',
550 },
551 {
552 'field' : 'display',
553 'tag' : 'display',
554 'type' : 'enum',
555 'values' : ('latest-value',
556 'graph',
557 'table',
558 ),
559 'short-help' : 'Display the latest value, a graph, or a table',
560 'optional' : True,
561 'doc' : 'controller|show-stats-display',
562 },
563 ),
564}
565
566CONTROLLER_INTERFACES_SHOW_COMMAND_DESCRIPTION = {
567 'name' : 'show',
568 'obj-type' : 'controller-interface',
569 'short-help' : 'Show controller-node associated interfaces',
570 'mode' : 'config-controller',
571 'command-type' : 'display-table',
572 'scoped' : True, # entries displayed filtered by pushed obj id
573 'doc' : 'controller|show-interfaces',
574 'args' : (
575 'interfaces',
576 {
577 'field' : 'type',
578 'tag' : 'type',
579 'type' : 'string',
580 'optional' : True,
581 'doc' : 'controller|show-interfaces-type',
582 },
583 {
584 'field' : 'number',
585 'tag' : 'number',
586 'type' : 'integer',
587 'optional' : True,
588 'doc' : 'controller|show-interfaces-number',
589 },
590 )
591}
592
593
594CONTROLLER_NODE_SUBMODE_COMMAND_DESCRIPTION = {
595 'name' : 'controller-node',
596 'obj-type' : 'controller-node',
597 'mode' : 'config*',
598 'short-help' : 'Enter configuration submode for controller-nodes',
599 'no-supported' : False, # don't allow removal of controller-nodes
600 # 'create' : False, # don't allow creation of new controller-nodes
601 'command-type' : 'config-submode',
602 'parent-field' : None,
603 'current-mode-obj-id' : None,
604 'submode-name' : 'config-controller',
605 'doc' : 'controller|controller-node',
606 'doc-example' : 'controller|controller-node-example',
607 'args' : (
608 {
609 'field' : 'id',
610 'type' : 'identifier',
611 'completion' : [
612 'complete-alias-choice',
613 'controller-add-localhost',
614 ],
615 'data-handler' : 'alias-to-value',
616 'optional-for-no' : False,
617 'doc' : 'controller|controller-node-name',
618 }
619 )
620}
621
622
623CONTROLLER_NODE_ALIAS_COMMAND_DESCRIPTION = {
624 'name' : 'controller-alias',
625 'mode' : 'config-controller',
626 'short-help' : 'Attach alias to controller',
627 'command-type' : 'manage-alias',
628 'obj-type' : 'controller-alias',
629 'scoped' : True,
630 'reserved' : 'localhost',
631 'doc' : 'controller|alias',
632 'args' : (
633 {
634 'field' : 'alias',
635 'optional-for-no' : True,
636 'completion' : 'complete-object-field',
637 'doc' : 'controller|alias-name',
638 'action' : (
639 {
640 'proc' : 'create-alias',
641 },
642 {
643 'proc' : 'prompt-update',
644 },
645 ),
646 'no-action' : (
647 {
648 'proc' : 'delete-alias',
649 },
650 {
651 'proc' : 'prompt-update',
652 },
653 )
654 }
655 )
656}
657
658
659CONTROLLER_NODE_INTERFACE_COMMAND_DESCRIPTION = {
660 'name' : 'interface',
661 'new-style' : True,
662 'mode' : 'config-controller*',
663 'short-help' : 'Enter interface submode, configure controller interface',
664 'command-type': 'config-submode',
665 'submode-name': 'config-controller-if',
666 'obj-type': 'controller-interface',
667 'parent-field': 'controller',
668 'doc' : 'controller|interface',
669 'args': (
670 {
671 'field' : 'type',
672 'help-name' : 'interface-type',
673 'type' : 'enum',
674 'values' : ('Ethernet',),
675 'syntax-help' : 'Enter the interface type (e.g. Ethernet)',
676 'doc' : 'controller|interface-type',
677 },
678 {
679 'field' : 'number',
680 'help-name' : 'interface-number',
681 'base-type' : 'integer',
682 'range' : (0,1000000),
683 #'completion' : 'complete-object-field',
684 'syntax-help' : 'Enter the interface number, a small non-negative number (e.g. 0 or 1)',
685 'doc' : 'controller|interface-number',
686 }
687 ),
688 'no-action': ('begin-default-gateway-check', 'delete-objects', 'end-default-gateway-check'),
689}
690
691CONTROLLER_NODE_DOMAIN_NAME_SERVER_FORMAT = {
692 'controller-domain-name-server' : {
693 'field-orderings': {
694 'default' : ['Idx', 'id', 'controller', 'priority', 'ip']
695 },
696 'fields' : {
697 'ip' : {
698 },
699 'controller' : {
700 'formatter' : fmtcnv.replace_controller_node_with_alias,
701 },
702 }
703 },
704}
705
706CONTROLLER_IP_COMMAND_DESCRIPTION = {
707 'name' : 'ip',
708 'mode' : 'config-controller',
709 'short-help' : 'Associate dns, default gateway with the controller node',
710 'doc' : 'controller|ip',
711 'args' : {
712 'choices': (
713 {
714 'command-type': 'config',
715 'obj-type': 'controller-node',
716 'doc': 'controller|ip-domain',
717 'args': (
718 'domain',
719 {
720 'choices': (
721 {
722 'field' : 'domain-lookups-enabled',
723 'token' : 'lookup',
724 'type' : 'boolean',
725 'doc' : 'controller|ip-domain-lookups',
726 'no-action' : {
727 'proc' : 'write-fields',
728 'data' : {
729 'domain-lookups-enabled' : False,
730 },
731 },
732 },
733 {
734 'field': 'domain-name',
735 'tag': 'name',
736 'type': 'domain-name',
737 'syntax-help': "Enter the network's domain name",
738 'default-for-no': 'xyz.com',
739 'doc': 'controller|ip-domain-name',
740 },
741 ),
742 },
743 ),
744 },
745 (
746 {
747 'command-type': 'config-object',
748 'obj-type': 'controller-domain-name-server',
749 'parent-field': 'controller',
750 'doc': 'controller|ip-name-server',
751 'args': (
752 {
753 'tag' : 'name-server',
754 'field' : 'ip',
755 'type' : 'ip-address-not-mask',
756 'syntax-help' : 'Enter the IP address of the domain name server',
757 'doc' : 'controller|ip-name-server-value',
758 },
759 ),
760 },
761 ),
762 {
763 'field': 'default-gateway',
764 'command-type': 'config-with-default-gateway-check',
765 'obj-type': 'controller-node',
766 'doc': 'controller|ip-default-gateway',
767 'args': {
768 'tag': 'default-gateway',
769 'field': 'default-gateway',
770 'type': 'ip-address-not-mask',
771 'syntax-help': 'Enter the IP address of the default gateway',
772 'default-for-no': '10.10.10.10',
773 'doc': 'controller|ip-default-gateway-value',
774 },
775 },
776 ),
777 },
778}
779
780INTERFACE_IP_COMMAND_DESCRIPTION = {
781 'name' : 'ip',
782 'mode' : 'config-controller-if',
783 'command-type' : 'config-with-default-gateway-check',
784 'obj-type' : 'controller-interface',
785 'short-help' : 'Associate ip address with interface',
786 'doc' : 'controller|ip',
787 'args' : {
788 'choices' : (
789 {
790 'fields': ('ip', 'netmask'),
791 'doc': 'controller|ip-address',
792 'args': (
793 'address',
794 {
795 'choices': (
796 (
797 {
798 'field': 'ip',
799 'help-name': 'ip-address',
800 'type': 'ip-address-not-mask',
801 'syntax-help': 'Enter an IP or CIDR address',
802 'default-for-no' : '10.10.10.10',
803 'doc': 'controller|ip-address-value',
804 },
805 {
806 'field': 'netmask',
807 'type': 'netmask',
808 'syntax-help': 'Enter a netmask',
809 'default-for-no' : '0.0.0.0',
810 'doc': 'controller|ip-address-netmask',
811 }
812 ),
813 {
814 'field': 'cidr',
815 'help-name': 'cidr-address',
816 'type': 'cidr-range',
817 'data-handler': 'split-cidr-data',
818 'completion-text': None,
819 'dest-ip': 'ip',
820 'dest-mask': 'mask',
821 'doc': 'controller|ip-address-cidr',
822 }
823 )
824 },
825 ),
826 },
827 {
828 'args': {
829 'tag': 'mode',
830 'field': 'mode',
831 'type': 'enum',
832 'values': ('dhcp', 'static'),
833 'syntax-help': 'Enter the IP address configuration mode, either "dhcp" or "static"',
834 'default-for-no': 'static',
835 'doc': 'controller|ip-mode',
836 },
837 },
838 ),
839 }
840}
841
842NTP_COMMAND_DESCRIPTION = {
843 'name' : 'ntp',
844 'mode' : 'config-controller',
845 'short-help' : 'Configure ntp for controller-node',
846 'command-type': 'config',
847 'obj-type' : 'controller-node',
848 'doc' : 'controller|ntp',
849 'doc-example' : 'controller|ntp-example',
850 'args': {
851 'tag' : 'server',
852 'field' : 'ntp-server',
853 'type' : 'ip-address-or-domain-name',
854 'syntax-help' : 'Enter the IP address or domain name of the NTP server',
855 'short-help' : 'Configure the NTP server name',
856 'default-for-no': 'xyz.com',
857 'completion' : 'complete-object-field',
858 'doc' : 'controller|ntp-server',
859 }
860}
861
862LOGGING_COMMAND_DESCRIPTION = {
863 'name' : 'logging',
864 'short-help' : 'Configure logging (syslog) for controller-node',
865 'mode' : 'config-controller',
866 'command-type': 'config',
867 'obj-type' : 'controller-node',
868 'doc' : 'controller|logging',
869 'doc-example' : 'controller|logging-example',
870 'args': {
871 'choices': (
872 {
873 'field' : 'logging-enabled',
874 'token' : 'on',
875 'type' : 'boolean',
876 'short-help' : 'Enable remote logging',
877 'doc' : 'controller|logging-enable',
878 },
879 (
880 {
881 'token' : 'server',
882 'short-help' : 'Set the remote syslog server name',
883 'doc' : 'controller|logging-server',
884 },
885 {
886 'field' : 'logging-server',
887 'help-name' : 'server-ip-or-domain',
888 'type' : 'ip-address-or-domain-name',
889 'syntax-help' : 'Enter the IP address or domain name of the syslog server',
890 'completion' : 'complete-object-field',
891 'match-for-no' : 'logging-server',
892 'no-action' : 'reset-fields',
893 },
894 {
895 'field' : 'logging-level',
896 'tag' : 'level',
897 'short-help' : 'Set the logging level for remote syslog',
898 'type' : 'enum',
899 'optional' : True,
900 'values' : ('emerg', 'alert', 'crit', 'err',
901 'warning', 'notice', 'info', 'debug',
902 '0', '1', '2', '3', '4', '5', '6', '7'
903 ),
904 'doc' : 'controller|logging-level',
905 }
906 ),
907 )
908 }
909}
910
911FIREWALL_COMMAND_DESCRIPTION = {
912 'name' : 'firewall',
913 'short-help' : 'Configure firewall rule for controller-node',
914 'command-type' : 'config-object',
915 'mode' : 'config-controller-if',
916 'obj-type' : 'firewall-rule',
917 'doc' : 'controller|firewall',
918 'parent-field' : 'interface',
919 'args': (
920 # This arg/token is really just syntactic sugar for the command.
921 # There's no 'deny' value, because things are denied by default.
922 # Instead you just use a 'no' command to delete the firewall rule.
923 {
924 'token' : 'allow',
925 'short-help' : 'Allow a given set of traffic',
926 'doc' : 'controller|firewall-allow',
927 },
928 {
929 'field' : 'src-ip',
930 'tag' : 'from',
931 'type' : 'ip-address',
932 'optional' : True,
933 'optional-for-no' : True,
934 'match-for-no' : True,
935 'doc' : 'controller|firewall-src-ip',
936 },
937 {
938 'field' : 'vrrp-ip',
939 'tag' : 'local-ip',
940 'type' : 'ip-address',
941 'optional' : True,
942 'optional-for-no' : True,
943 'match-for-no' : True,
944 'doc' : 'controller|firewall-local-ip',
945 },
946 {
947 'choices' : (
948 {
949 'field' : 'port',
950 'type' : 'enum',
951 'short-help' : 'Configure rule for a specific service port',
952 'doc' : 'controller|firewall-port',
953 'data' : { 'proto' : 'tcp' },
954 'values': {
955 'openflow' : 6633,
956 'web' : 80,
957 'ssl' : 443,
958 'ssh' : 22
959 },
960 'match-for-no' : True,
961 'doc' : 'controller|firewall-+',
962 },
963 (
964 {
965 'field' : 'proto',
966 'type' : 'enum',
967 'short-help' : 'Configure rule for protocol (TCP, UDP)',
968 'values' : ('udp', 'tcp'),
969 'doc' : 'controller|firewall-+',
970 'match-for-no' : True,
971 },
972 {
973 'optional-for-no' : False,
974 'choices': (
975 {
976 'field' : 'port',
977 'type' : 'enum',
978 'short-help' : 'Configure rule for a specific service port',
979 'doc': 'controller|firewall-port',
980 'values': {
981 'openflow' : 6633,
982 'web' : 80,
983 'ssl' : 443,
984 'ssh' : 22
985 },
986 'match-for-no' : True,
987 'doc' : 'controller|firewall-+',
988 },
989 {
990 'field' : 'port',
991 'base-type' : 'integer',
992 'range' : (0, 65535),
993 'completion-text' : '0-65535',
994 'doc' : 'controller|firewall-port',
995 'match-for-no' : True,
996 },
997 )
998 },
999 ),
1000 {
1001 'field' : 'proto',
1002 'type' : 'enum',
1003 'short-help' : 'Configure rule for protocol (TCP, UDP)',
1004 'values' : 'vrrp',
1005 'doc' : 'controller|firewall-+',
1006 'match-for-no' : True,
1007 },
1008 ),
1009 },
1010 )
1011}
1012
1013MONTH_NAMES = ('January', 'February', 'March', 'April', 'May', 'June',
1014 'July', 'August', 'September', 'October', 'November', 'December')
1015
1016
1017
1018CLOCK_TIMEZONE_COMMAND_DESCRIPTION = {
1019 'name' : 'clock',
1020 'mode' : 'config-controller',
1021 'short-help' : 'Configure time zone',
1022 'doc' : 'controller|clock-timezone',
1023 'doc-example' : 'controller|clock-timezone-example',
1024 'command-type' : 'config',
1025 'obj-type' : 'controller-node',
1026 'args' : {
1027 'tag' : 'timezone',
1028 'field' : 'time-zone',
1029 'type' : 'string',
1030 'default-for-no' : 'UTC',
1031 'completion' : 'time-zone-completion',
1032 'validation' : 'time-zone-validation',
1033 'syntax-help' : 'Enter the time zone',
1034 'short-help' : 'Configure the time zone',
1035 }
1036}
1037
1038CLOCK_SET_COMMAND_DESCRIPTION = {
1039 'name' : 'clock',
1040 'mode' : 'config-controller',
1041 'no-supported' : False,
1042 'short-help' : 'Set clock',
1043 'doc' : 'controller|clock-set',
1044 'doc-example' : 'controller|clock-set-example',
1045 'command-type' : 'realtime',
1046 'action' : 'set-clock',
1047 'args' : (
1048 {
1049 'token' : 'set',
1050 'short-help' : 'Set the current time and date'
1051 },
1052 {
1053 'field' : 'time',
1054 'base-type' : 'string',
1055 'pattern' : '^[0-9]{1,2}:[0-9]{1,2}:[0-9]{2}$',
1056 'syntax-help' : 'Enter the time (HH:MM:SS)'
1057 },
1058 {
1059 'field' : 'day-of-month',
1060 'base-type' : 'integer',
1061 'range' : (1,31),
1062 'syntax-help' : 'Enter the day of the month (1-31)'
1063 },
1064 {
1065 'field' : 'month',
1066 'type' : 'enum',
1067 'values' : MONTH_NAMES,
1068 'syntax-help' : 'Enter the month (e.g. January, March)'
1069 },
1070 {
1071 'field' : 'year',
1072 'base-type' : 'integer',
1073 'range' : (0,10000),
1074 'syntax-help' : 'Enter the year'
1075 },
1076 )
1077}
1078"""