blob: f71eafdfefb879d1e5760d8876ec259baaa8b6fd [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
17# (c) in 2012 by Big Switch Networks - All rights reserved
18#
19# vCenter commands
20#
21"""
22import os
23VCENTER_COMMAND_DESCRIPTION = {
24 'name' : 'vcenter',
25 #'no-help' : 'Remove vcenter configuration',
26 'mode' : 'config*',
27 'feature' : 'experimental',
28 'command-type' : 'config-submode',
29 'short-help' : 'Enter vcenter submode, configure vcenter details',
30 'doc' : 'vcenter|vcenter',
31 'doc-example' : 'vcenter|vcenter-example',
32 'obj-type' : 'vcenter',
33 'parent-field' : None,
34 'current-mode-obj-id' : None,
35 'submode-name' : 'config-vcenter',
36 # 'parent-id' : 'vcenter-name',
37 'args' : (
38 { 'field' : 'vcenter-name',
39 'type' : 'identifier',
40 'completion' : 'complete-object-field',
41 'syntax-help' : 'Enter a vcenter name',
42 }
43 ),
44 'action': 'push-mode-stack',
45 'no-action': (
46 {
47 'proc' : 'confirm',
48 'prompt' : "Deleting a vcenter will cause vcenter" \
49 " DVS's to also be deleted, continue (y or yes)? "
50 },
51 {
52 'proc' : 'delete-objects',
53 }
54 )
55}
56
57
58SHOW_VCENTER_COMMAND_DESCRIPTION = {
59 'name' : 'show',
60 'mode' : 'login',
61 'feature' : 'experimental',
62 'short-help' : 'Show vcenter configurations',
63 'doc' : 'vcenter|show',
64 'doc-example' : 'vcenter|show-example',
65 'obj-type' : 'vcenter',
66 'command-type' : 'display-table',
67
68 'args' : (
69 'vcenter',
70 )
71}
72
73
74SHOW_VCENTER_NAME_COMMAND_DESCRIPTION = {
75 'name' : 'show',
76 'mode' : 'login',
77 'feature' : 'experimental',
78 'short-help' : 'Show vcenter description by name',
79 'doc' : 'vcenter|show-name',
80 'doc-example' : 'vcenter|show-name-example',
81 'obj-type' : 'vcenter',
82 'command-type' : 'display-table',
83 'args' : (
84 'vcenter',
85 {
86 'choices' : (
87 {
88 'field' : 'vcenter-name',
89 'type' : 'identifier',
90 },
91 {
92 'field' : 'vcenter-name',
93 'type' : 'enum',
94 'values' : 'all',
95 'completion' : 'complete-object-field',
96 },
97 )
98 },
99 {
100 'optional' : True,
101 'choices' : (
102 {
103 'field' : 'dvs',
104 'type' : 'enum',
105 'values' : 'dvs',
106 'obj-type' : 'dvs',
107 'action' : 'display-table',
108 'short-help' : 'Select dvs for display',
109 'doc' : 'vcenter|show-name-dvs',
110 },
111 {
112 'field' : 'dvs-port-group',
113 'type' : 'enum',
114 'values' : 'dvs-port-group',
115 'obj-type' : 'dvs-port-group',
116 'action' : 'display-table',
117 'short-help' : 'Select dvs-port-group for display',
118 'doc' : 'vcenter|show-name-dvs-port-group',
119 },
120 {
121 'field' : 'status',
122 'type' : 'enum',
123 'values' : 'status',
124 'action' : 'display-rest',
125 'url' : 'vcenter/status/%(vcenter-name)s/',
126 'format' : 'vcenter-status',
127 'detail' : 'details',
128 'short-help' : 'Display vcenter active state',
129 'doc' : 'vcenter|show-vcenter-status',
130 },
131 {
132 'field' : 'detail',
133 'type' : 'enum',
134 'values' : 'details',
135 }
136 )
137 }
138 )
139}
140
141
142SHOW_VCENTER_NAME_STATUS_COMMAND_DESCRIPTION = {
143 'name' : 'show',
144 'mode' : 'login',
145 'feature' : 'experimental',
146 'short-help' : 'Show vcenter operational status by name',
147 'doc' : 'vcenter|show-vcenter-dvs-status',
148 'doc-example' : 'vcenter|show-vcenter-dvs-status-example',
149 'obj-type' : 'vcenter',
150 'command-type' : 'display-rest',
151 'args' : (
152 'vcenter',
153 {
154 'field' : 'vcenter-name',
155 'type' : 'identifier',
156 'completion' : 'complete-object-field',
157 },
158 {
159 'field' : 'dvs-name',
160 'tag' : 'dvs',
161 'obj-type' : 'dvs',
162 'completion' : 'complete-object-field',
163 },
164 {
165 'field' : 'status',
166 'type' : 'enum',
167 'values' : 'status',
168 'url' : 'vcenter/status/%(vcenter-name)s/%(dvs-name)s',
169 'format' : 'vcenter-dvs-status',
170 'detail' : 'details',
171 'action' : 'display-rest',
172
173 },
174 )
175}
176
177VCENTER_IP_ADDRESS_COMMAND_DESCRIPTION = {
178 'name' : 'ip',
179 'mode' : 'config-vcenter',
180 'short-help' : 'Associate ip address for vcenter connection',
181 'doc' : 'vcenter|ip',
182 'doc-example' : 'vcenter|ip-example',
183 'command-type' : 'config',
184 'no-supported' : True,
185 'fields' : [ 'ip' ], # for field reset
186 'args' : {
187 'choices' : (
188 (
189 'address',
190 {
191 'field' : 'ip',
192 'type' : 'ip-address-not-mask',
193 'optional-for-no' : True,
194 'syntax-help' : 'Enter an IP Address',
195 },
196 ),
197 )
198 }
199}
200
201VCENTER_PORT_COMMAND_DESCRIPTION = {
202 'name' : 'port',
203 'short-help' : 'Associate http port for vcenter connection',
204 'doc' : 'vcenter|port',
205 'doc-example' : 'vcenter|port-example',
206 'command-type' : 'config',
207 'mode' : 'config-vcenter',
208 'no-supported' : False,
209 'args' : (
210 {
211 'field' : 'port',
212 'type' : 'integer',
213 'syntax-help' : 'Enter an http port number',
214 'optional-for-no' : True,
215 }
216 )
217}
218
219VCENTER_DVS_COMMAND_DESCRIPTION = {
220 'name' : 'dvs',
221 'mode' : 'config-vcenter*',
222 'command-type' : 'config-submode',
223 'parent-field' : 'vcenter-name',
224 'obj-type' : 'dvs',
225 'no-supported' : True,
226 'submode-name' : 'config-vcenter-dvs',
227 'short-help' : 'Enter vcenter-dvs submode, describe port groups',
228 'doc' : 'vcenter|dvs',
229 'doc-example' : 'vcenter|dvs-example',
230 'args' : (
231 {
232 'field' : 'datacenter',
233 'tag' : 'datacenter-name',
234 'type' : 'string',
235 'completion' : 'complete-object-field',
236 'syntax-help' : 'Enter the vcenter datacenter name',
237 },
238 {
239 'field' : 'dvs-name',
240 'tag' : 'dvs-name',
241 'type' : 'string',
242 'completion' : 'complete-object-field',
243 'syntax-help' : 'Enter the vcenter dvs name',
244 },
245 {
246 'field' : 'switch-class',
247 'tag' : 'switch-class',
248 'type' : 'string',
249 'optional' : True,
250 'optional-for-no': True,
251 'completion' : 'complete-object-field',
252 'syntax-help' : 'Enter vmware',
253 },
254 ),
255}
256
257SHOW_DVS_COMMAND_DESCRIPTION = {
258 'name' : 'show',
259 'feature' : 'experimental',
260 'mode' : 'login',
261 'short-help' : 'Show vcenter dvs details',
262 'doc' : 'vcenter|show-dvs',
263 'doc-example' : 'vcenter|show-dvs-example',
264 'obj-type' : 'dvs',
265 'command-type' : 'display-table',
266 'args' : (
267 'dvs',
268 {
269 'field' : 'vcenter',
270 'tag' : 'vcenter',
271 'optional' : True,
272 'type' : 'string',
273 },
274 {
275 'field' : 'datacenter',
276 'tag' : 'datacenter',
277 'optional' : True,
278 'type' : 'string',
279 },
280 {
281 'field' : 'dvs',
282 'tag' : 'dvs',
283 'optional' : True,
284 'type' : 'string',
285 },
286 )
287}
288
289VCENTER_PORTGROUP_COMMAND_DESCRIPTION = {
290 'name' : 'portgroup',
291 'mode' : 'config-vcenter-dvs',
292 'short-help' : 'Describe dvs portgroup',
293 'doc' : 'vcenter|dvs-portgroup',
294 'doc-example' : 'vcenter|dvs-portgroup-example',
295 'command-type' : 'config-object',
296 'parent-field' : 'dvs-name',
297 'obj-type' : 'dvs-port-group',
298 'no-supported' : True,
299 'args' : (
300 {
301 'field' : 'portgroup-name',
302 'syntax-help' : 'Enter the vcenter portgroup name for the associated dvs',
303 'optional-for-no' : True
304 }
305 )
306}
307
308
309SHOW_DVS_PORT_GROUP_COMMAND_DESCRIPTION = {
310 'name' : 'show',
311 'feature' : 'experimental',
312 'mode' : 'login',
313 'short-help' : 'Show vcenter dvs port-group details',
314 'doc' : 'vcenter|show-dvs-port-group',
315 'doc-example' : 'vcenter|show-dvs-port-group-example',
316 'obj-type' : 'dvs-port-group',
317 'command-type' : 'display-table',
318 'no-supported' : True,
319 'args' : (
320 'dvs-port-group',
321 {
322 'field' : 'vcenter',
323 'tag' : 'vcenter',
324 'optional' : True,
325 'type' : 'string',
326 },
327 {
328 'field' : 'datacenter',
329 'tag' : 'datacenter',
330 'optional' : True,
331 'type' : 'string',
332 },
333 {
334 'field' : 'dvs',
335 'tag' : 'dvs',
336 'optional' : True,
337 'type' : 'string',
338 },
339 {
340 'field' : 'portgroup',
341 'tag' : 'portgroup',
342 'optional' : True,
343 'type' : 'string',
344 },
345 )
346}
347
348VCENTER_USERNAME_COMMAND_DESCRIPTION = {
349 'name' : 'username',
350 'mode' : 'config-vcenter',
351 'short-help' : 'Configure vcenter username for login',
352 'doc' : 'vcenter|username',
353 'doc-example' : 'vcenter|username-example',
354 'command-type' : 'config',
355 'fields' : [ 'username' ], # for field reset
356 'no-supported' : True,
357 'args' : (
358 {
359 'field' : 'username',
360 'type' : 'string',
361 'syntax-help' : 'Enter the vcenter login username',
362 'optional-for-no' : True,
363 }
364 )
365}
366
367VCENTER_PASSWORD_COMMAND_DESCRIPTION = {
368 'name' : 'password',
369 'mode' : 'config-vcenter',
370 'command-type' : 'config',
371 'short-help' : 'Configure vcenter password for login',
372 'doc' : 'vcenter|password',
373 'doc-example' : 'vcenter|password-example',
374 'fields' : [ 'password' ], # for field reset
375 'no-supported' : True,
376 'args' : (
377 {
378 'field' : 'password',
379 'type' : 'string',
380 'syntax-help' : 'Enter the vcenter login password',
381 'optional-for-no' : True,
382 }
383 )
384}
385
386VCENTER_CONNECT_COMMAND_DESCRIPTION = {
387 'name' : 'connect',
388 'mode' : 'config-vcenter',
389 'short-help' : 'Enable vcenter connect',
390 'doc' : 'vcenter|connect',
391 'doc-example' : 'vcenter|connect-example',
392 'command-type' : 'config',
393 'syntax-help' : 'Enter to attempt a vcenter connect',
394 # 'data' : {'connect' : True },
395 'args' : (),
396 'action': (
397 {
398 'proc' : 'write-fields',
399 'data' : {'connect' : True}
400 },
401 ),
402 'no-action': (
403 {
404 'proc' : 'reset-fields',
405 'fields' : [ 'connect' ]
406 }
407 )
408}
409
410
411#
412# FORMATS
413#
414
415import fmtcnv
416
417
418VCENTER_FORMAT = {
419 'vcenter' : {
420 'field-orderings' : {
421 'default' : [
422 'Idx',
423 'vcenter-name',
424 'ip', 'port',
425 'username', 'password',
426 'connect',
427 ]
428 },
429 'fields' : {
430 'ip' : {
431 },
432 'port' : {
433 },
434 'username' : {
435 },
436 'password' : {
437 },
438 'connect' : {
439 },
440 }
441 },
442}
443
444
445VCENTER_STATUS_FORMAT = {
446 'vcenter-status' : {
447 'field-orderings' : {
448 'default' : [
449 'Idx',
450 'vcenter',
451 'Status',
452 'DvsList',
453 ],
454 'details' : [
455 'vcenter',
456 'Status',
457 'VCenterError',
458 'DvsList',
459 ]
460 },
461
462 'fields' : {
463 'vcenter' : { 'verbose-name' : 'VCenter'
464 },
465 'Status' : { 'verbose-name' : 'Status'
466 },
467 'VCenterError' : { 'verbose-name' : 'VCenter error'
468 },
469 'DvsList' : { 'verbose-name' : 'Dvses',
470 }
471 },
472 },
473}
474
475
476VCENTER_DVS_STATUS_FORMAT = {
477 'vcenter-dvs-status' : {
478 'field-orderings' : {
479 'default' : [
480 'Idx',
481 'vcenter',
482 'dataCenter',
483 'dvs',
484 'portgroups',
485 ],
486 },
487
488 'fields' : {
489 'vcenter' : { 'verbose-name' : 'VCenter'
490 },
491 'dvs' : { 'verbose-name' : 'Dvs Name',
492 },
493 'dataCenter' : { 'verbose-name' : 'Data Center',
494 },
495 'portgroups' : { 'verbose-name' : 'Port Groups Active',
496 },
497 }
498 },
499}
500
501VCENTER_DVS_FORMAT = {
502 'dvs' : {
503 'show-this' : [
504 [ 'dvs', 'default' ],
505 [ 'dvs-port-group', 'scoped' ]
506 ],
507
508 'field-orderings' : {
509 'default' : [ 'vcenter-name',
510 'datacenter',
511 'dvs-name',
512 'switch-class',
513 ]
514 },
515 'fields' : {
516 'vcenter-name' : {
517 },
518 'datacenter' : {
519 },
520 'dvs-name' : {
521 },
522 'switch-class' : {
523 },
524 }
525 },
526}
527
528
529VCENTER_DVS_PORT_GROUP_FORMAT = {
530 'dvs-port-group' : {
531 'field-orderings' : {
532 'default' : [ 'vcenter-name',
533 'datacenter',
534 'dvs-name',
535 'portgroup-name'
536 ],
537 'scoped' : [ 'portgroup-name'
538 ],
539 },
540 'fields' : {
541 'dvs-name' : {
542 },
543 'portgroup-name' : {
544 },
545 },
546
547 },
548}
549"""