-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathbash_completion
More file actions
executable file
·956 lines (904 loc) · 27.7 KB
/
bash_completion
File metadata and controls
executable file
·956 lines (904 loc) · 27.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
# -------------------------------------------------------------------------- #
# Copyright 2002-2025, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
# shellcheck disable=SC2148
# shellcheck disable=SC2207
COL_NAME="name"
################################################################################
# Helpers
################################################################################
# 1 -> cmd
# 2 -> column
# 3 -> filter
_complete() {
mapfile -t patterns < <( _one_list "$1" "$2" "$3" )
mapfile -t COMPREPLY < <( compgen -W "$( printf '%q ' "${patterns[@]}" )" -- "$cur")
compopt -o filenames
}
_one_list() {
if [ -z "$2" ]; then
col="$COL_NAME"
else
col=$2
fi
if [ -n "$3" ]; then
$1 list --no-header --csv -f "$3" -l "$col"
else
$1 list --no-header --csv -l "$col"
fi
}
_one_simple() {
COMPREPLY=()
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${1}" -- "${cur}") )
return 0
fi
}
_one_owner_update() {
case "$1" in
chgrp)
_complete onegroup
;;
chown)
_complete oneuser
;;
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
}
_one_template() {
local cur prev
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|instantiate|chgrp|chown|chmod|update|rename|show|lock|unlock)
_complete "$cmd"
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
################################################################################
# Services
################################################################################
_one() {
_one_simple "start stop restart start-sched stop-sched restart-sched"
}
_oneflow_server() {
_one_simple "start stop"
}
_oneform_server() {
_one_simple "start stop"
}
_onehem_server() {
_one_simple "start stop"
}
_onegate_server() {
_one_simple "start stop restart"
}
_sunstone_server() {
_one_simple "start stop restart start-sunstone stop-sunstone restart-sunstone"
}
complete -F _one one
complete -F _oneflow_server oneflow-server
complete -F _oneform_server oneform-server
complete -F _onehem_server onehem-server
complete -F _onegate_server onegate-server
complete -F _sunstone_server sunstone-server
################################################################################
# Commands
################################################################################
_oneacl() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="create delete list"
cmd=oneacl
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete)
_complete $cmd
;;
esac
fi
}
_onebackupjob() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show lock unlock chgrp chown chmod rename
update execute cancel sched-delete sched-update"
cmd=onebackupjob
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|lock|unlock|chgrp|chown|chmod|rename| \
update|execute|cancel|sched-update|sched-delete)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onecluster() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show addhost delhost adddatastore deldatastore
addvnet delvnet update rename"
cmd=onecluster
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|addhost|delhost|adddatastore|deldatastore|addvnet| \
delvnet|update|rename)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addhost|delhost)
_complete onehost
;;
adddatastore|deldatastore)
_complete onedatastore
;;
addvnet|delvnet)
_complete onevnet
;;
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onedatastore() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete chgrp chown chmod list show update rename enable disable"
cmd=onedatastore
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|chgrp|chown|chmod|show|update|rename|enable|disable)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onedb() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="backup version history restore upgrade fsck patch
sqlite2mysql purge-history purge-done change-body change-history
update-body update-history show-body show-history create-index"
cmd=onedb
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
restore|patch)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_oneflow() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="list top show delete recover scale chgrp chown chmod rename action"
cmd=oneflow
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|delete|recover|scale|chgrp|chown|chmod|rename|action)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_oneflow_template() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="list top show create delete instantiate chgrp chown chmod clone rename update"
cmd=oneflow-template
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|delete|instantiate|chgrp|chown|chmod|clone|rename|update)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onegroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update delete list show addadmin deladmin quota batchquota defaultquota"
cmd=onegroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|delete|show|addadmin|deladmin|quota|batchquota)
_complete $cmd
;;
defaultquota)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addadmin|deladmin)
_complete oneuser
;;
update|quota|batchquota)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onehook() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete update rename list show top lock unlock retry log"
cmd=onehook
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|update|rename|show|lock|unlock|retry)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onehost() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete enable disable offline update sync list show top flush
rename forceupdate monitoring"
cmd=onehost
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|disable|offline|update|sync|show|flush|rename| \
forceupdate|monitoring)
_complete $cmd
;;
enable)
mapfile -t patterns < <( onehost list -f "stat=off,stat=dsbl" --operator OR --no-header --csv -l $COL_NAME )
mapfile -t COMPREPLY < <( compgen -W "$( printf '%q ' "${patterns[@]}" )" -- "$cur")
compopt -o filenames
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_oneimage() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create clone delete persistent nonpersistent update enable chtype
disable chgrp chown chmod rename snapshot-delete snapshot-revert
snapshot-flatten resize list show top lock unlock orphans restore"
cmd=oneimage
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|persistent|nonpersistent|update|chtype|chgrp|chown|chmod| \
rename|snapshot-delete|snapshot-revert|snapshot-flatten|show|lock|unlock)
_complete $cmd
;;
enable)
_complete $cmd $COL_NAME "stat=disa"
;;
disable)
_complete $cmd $COL_NAME "stat=rdy"
;;
restore)
_complete $cmd $COL_NAME "type=BK"
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onemarket() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete chgrp chown chmod list show update rename enable disable"
cmd=onemarket
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|chgrp|chown|chmod|show|update|rename)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onemarketapp() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create export download delete update chgrp chown chmod rename list show
enable disable lock unlock"
cmd=onemarketapp
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
export|download|delete|update|chgrp|chown|chmod|rename|show|lock|unlock)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
enable)
_complete $cmd $COL_NAME "stat=dis"
;;
disable)
_complete $cmd $COL_NAME "stat=rdy"
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_oneform()
{
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneform
opts="list top show sync enable disable"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|enable|disable|create)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_oneprovision() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneprovision
opts="list top show create update rename chgrp chown chmod retry add-host del-host add-ip del-ip deprovision delete logs"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|update|rename|chgrp|chown|chmod|delete|retry)
_complete $cmd ID
;;
create)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_oneprovider() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
cmd=oneprovider
opts="list top show create update rename chgrp chown chmod delete"
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
show|update|rename|chgrp|chown|chmod|delete|retry)
_complete $cmd ID
;;
create)
local drivers
drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')"
COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") )
return 0
;;
esac
fi
}
_onesecgroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create clone delete chgrp chown chmod update rename commit list show"
cmd=onesecgroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
clone|delete|chgrp|chown|chmod|update|rename|commit|show)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_oneshowback() {
local opts
opts="list calculate"
_one_simple
}
_onetemplate() {
opts="create clone delete instantiate chgrp chown chmod update rename list show
top lock unlock"
cmd=onetemplate
_one_template
}
_oneuser() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update quota batchquota defaultquota umask login key delete
passwd chgrp addgroup delgroup chauth list show encode passwdsearch
token-create token-set token-delete token-delete-all"
cmd=oneuser
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|quota|batchquota|umask|delete|passwd|chgrp|addgroup| \
delgroup|chauth|show)
_complete $cmd
;;
defaultquota)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
chgrp|addgroup|delgroup)
_complete onegroup
;;
update|quota|batchquota)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onevdc() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create rename update delete addgroup delgroup addcluster delcluster
addhost delhost adddatastore deldatastore addvnet delvnet list show"
cmd=onevdc
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
rename|update|delete|addgroup|delgroup|addcluster|delcluster|addhost| \
delhost|adddatastore|deldatastore|addvnet|delvnet)
_complete $cmd
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addgroup|delgroup)
_complete onegroup
;;
addcluster|delcluster)
_complete onecluster
;;
addhost|delhost)
_complete onehost
;;
adddatastore|deldatastore)
_complete onedatastore
;;
addvnet|delvnet)
_complete onevnet
;;
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
_onevm() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create update hold release disk-saveas terminate undeploy poweroff
reboot deploy migrate stop suspend resume recover disk-attach
disk-detach nic-attach nic-detach chgrp chown chmod resched unresched
rename snapshot-create snapshot-revert snapshot-delete snapshot-list
disk-snapshot-create disk-snapshot-revert disk-snapshot-delete
disk-snapshot-rename disk-snapshot-list disk-resize list show top
resize save updateconf lock unlock create-chart delete-chart
update-chart backup restore ssh port-forward backupmode"
cmd=onevm
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
update|hold|release|disk-saveas|terminate|show|delete|resume|recover| \
disk-attach|disk-detach|nic-attach|nic-detach|chgrp|chown|chmod|resched| \
unresched|rename|snapshot-create|snapshot-revert|snapshot-delete|snapshot-list| \
disk-snapshot-create|disk-snapshot-delete|disk-snapshot-revert| \
disk-snapshot-rename|disk-snapshot-list|disk-resize|save|updateconf|lock|unlock| \
create-chart|delete-chart|update-chart|backup|restore|ssh|port-forward|backupmode)
_complete $cmd
;;
undeploy|poweroff|reboot|shutdown|suspend|stop|migrate)
_complete $cmd $COL_NAME "stat=runn"
;;
deploy)
_complete $cmd $COL_NAME "stat=pend"
;;
resize)
_complete $cmd $COL_NAME "stat=poff"
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
deploy|migrate)
_complete onehost $COL_NAME "stat=on"
;;
esac
_one_owner_update "$pprev"
fi
}
_onevmgroup() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete list show chgrp chown chmod update rename lock unlock"
cmd=onevmgroup
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|show|chgrp|chown|chmod|update|rename|lock|unlock)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onevnet() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create delete addar addleases rmar rmleases free hold release release
chgrp chown chmod list show update updatear rename lock unlock orphans"
cmd=onevnet
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
delete|addar|addleases|rmar|rmleases|free|hold|release|reserve|chgrp| \
chown|chmod|show|update|updatear|rename|lock|unlock)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
addar|update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
_one_owner_update "$pprev"
fi
}
_onevntemplate() {
local opts cmd
opts="create clone delete instantiate chgrp chown chmod update rename list show
top lock unlock"
cmd=onevntemplate
_one_template
}
_onevrouter() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create instantiate delete chgrp chown chmod update rename nic-attach
nic-detach list show top lock unlock"
cmd=onevrouter
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
instantiate|delete|chgrp|chown|chmod|update|rename|nic-attach| \
nic-detach|show|lock|unlock)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
_one_owner_update "$pprev"
fi
}
_onezone() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${#COMP_WORDS[@]}" -gt "2" ]; then
pprev="${COMP_WORDS[COMP_CWORD-2]}"
fi
opts="create rename server-add server-del server-reset update delete list show set serversync"
cmd=onezone
if [ "$COMP_CWORD" == 1 ]; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0
elif [ "$COMP_CWORD" == 2 ]; then
case "$prev" in
rename|server-add|server-del|server-reset|update|delete|show|set)
_complete $cmd
;;
create)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
elif [ "$COMP_CWORD" == 3 ]; then
case "$pprev" in
update)
COMPREPLY=( $(compgen -A file -- "${cur}") )
return 0
;;
esac
fi
}
complete -F _oneacl oneacl
complete -F _onebackupjob onebackupjob
complete -F _onecluster onecluster
complete -F _onedatastore onedatastore
complete -F _onedb onedb
complete -F _oneflow oneflow
complete -F _oneflow_template oneflow-template
complete -F _onegroup onegroup
complete -F _onehook onehook
complete -F _onehost onehost
complete -F _oneimage oneimage
complete -F _onemarket onemarket
complete -F _onemarketapp onemarketapp
complete -F _oneform oneform
complete -F _oneprovision oneprovision
complete -F _oneprovider oneprovider
complete -F _onesecgroup onesecgroup
complete -F _oneshowback oneshowback
complete -F _onetemplate onetemplate
complete -F _oneuser oneuser
complete -F _onevdc onevdc
complete -F _onevm onevm
complete -F _onevmgroup onevmgroup
complete -F _onevnet onevnet
complete -F _onevntemplate onevntemplate
complete -F _onevrouter onevrouter
complete -F _onezone onezone