找回密码
 注册
查看: 2128|回复: 2

使用nova采用tab 补全文件(openstack,nova)

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2021-9-3 09:01:14 | 显示全部楼层 |阅读模式
为了让nova 命令可以补全,因为有些时候,命令可能记不住,可以尝试使用此方法设置,当然自己开发的环境可能就自带:
& m/ k' @4 h% J: x切换到/etc/bash_completion.d目录下:2 V) b- A) r$ a. p) `
& h' }" X+ m# D
创建文件vim  nova.bash_completion # D8 \8 M9 Z/ f4 F. A4 B% [( I8 N

; T; K5 E' W5 c, E. F
7 `1 J- _, `1 s( t4 p- F, Z_nova()
$ T6 _1 K2 A6 _+ Z6 y{5 ?9 W; l  C  J
  local cur prev words
/ R) @6 r, @4 n6 o" m  COMPREPLY=()
4 B8 V! j/ ]: M" i. V, s9 ^  _get_comp_words_by_ref -n : cur prev words
; p" [2 e+ C8 k4 ?8 o, H  # Command data:+ l7 X4 l5 R& j4 l1 n1 {
  cmds='add-secgroup agent-create agent-delete agent-list agent-modify aggregate-add-host aggregate-cache-images aggregate-create aggregate-delete aggregate-list aggregate-remove-host aggregate-set-metadata aggregate-show aggregate-update availability-zone-list backup boot clear-password console-log delete diagnostics evacuate flavor-access-add flavor-access-list flavor-access-remove flavor-create flavor-delete flavor-key flavor-list flavor-show flavor-update force-delete get-mks-console get-password get-rdp-console get-serial-console get-spice-console get-vnc-console host-evacuate host-evacuate-live host-meta host-servers-migrate hypervisor-list hypervisor-servers hypervisor-show hypervisor-stats hypervisor-uptime image-create instance-action instance-action-list instance-usage-audit-log interface-attach interface-detach interface-list keypair-add keypair-delete keypair-list keypair-show limits list list-secgroup live-migration live-migration-abort live-migration-force-complete lock meta migrate migration-list pause quota-class-show quota-class-update quota-defaults quota-delete quota-show quota-update reboot rebuild refresh-network remove-secgroup rescue reset-network reset-state resize resize-confirm resize-revert restore resume server-group-create server-group-delete server-group-get server-group-list server-migration-list server-migration-show server-tag-add server-tag-delete server-tag-delete-all server-tag-list server-tag-set server-topology service-delete service-disable service-enable service-force-down service-list set-password shelve shelve-offload show ssh start stop suspend trigger-crash-dump unlock unpause unrescue unshelve update usage usage-list version-list volume-attach volume-attachments volume-detach volume-update bash-completion help --version --debug --os-cache --timings --os-region-name --service-type --service-name --os-endpoint-type --os-compute-api-version --os-endpoint-override --os-auth-type --insecure --os-cacert --os-cert --os-key --timeout --collect-timing --os-auth-url --os-system-scope --os-domain-id --os-domain-name --os-project-id --os-project-name --os-project-domain-id --os-project-domain-name --os-trust-id --os-default-domain-id --os-default-domain-name --os-user-id --os-username --os-user-domain-id --os-user-domain-name --os-password') M( O: i0 s, T
  cmds_flavor='create delete list set show unset'
6 Y5 T3 ?* ^2 T6 [  cmds_flavor_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --id --ram --disk --ephemeral --swap --vcpus --rxtx-factor --public --private --property --project --description --project-domain'
7 ~1 C5 f0 z3 @# _5 S2 @2 {  cmds_flavor_delete='-h --help'
+ o" Z2 |2 N8 p+ \) i5 l  cmds_flavor_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --public --private --all --long --marker --limit'
& B. F9 N: T/ N6 N  cmds_flavor_set='-h --help --no-property --property --project --description --project-domain'
9 d+ C2 l, _8 N# b4 a. c: [; d, m  cmds_flavor_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
0 o0 a& U6 h- V  cmds_flavor_unset='-h --help --property --project --project-domain'
) V3 Q) V  }5 Z. I- a/ n- p  cmds_floating='ip'- N# r* I1 c: j; m* y: T
  cmds_floating_ip='create delete list pool port set show unset'
/ j. W8 K  G1 Q# ^  cmds_floating_ip_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --subnet --port --floating-ip-address --fixed-ip-address --qos-policy --description --project --dns-domain --dns-name --project-domain --tag --no-tag'
; h  X: J0 J4 j$ l3 ?! H; \  cmds_floating_ip_delete='-h --help'  k6 C1 }$ ^1 ]1 ?) v4 g4 m3 m
  cmds_floating_ip_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --network --port --fixed-ip-address --floating-ip-address --long --status --project --project-domain --router --tags --any-tags --not-tags --not-any-tags'+ r* j  E! n# G9 x+ G8 F
  cmds_floating_ip_pool='list'
) E0 S0 g# c7 n" M  cmds_floating_ip_pool_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column'
) o" H; c3 q- u% y4 n) n  cmds_floating_ip_port='forwarding'( @0 ]" O( b- R' `- P% v0 Y
  cmds_floating_ip_port_forwarding='create delete list set show'
2 ?0 a6 r4 n$ F  cmds_floating_ip_port_forwarding_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --internal-ip-address --port --internal-protocol-port --external-protocol-port --protocol'
' K6 s/ j$ @  O  cmds_floating_ip_port_forwarding_delete='-h --help'
( ^# |6 H4 }& a  cmds_floating_ip_port_forwarding_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --port --external-protocol-port --protocol'" V9 `7 ^9 a! o0 K+ e
  cmds_floating_ip_port_forwarding_set='-h --help --port --internal-ip-address --internal-protocol-port --external-protocol-port --protocol'7 @2 _% V) A  B& Z
  cmds_floating_ip_port_forwarding_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix', B+ r  I! J5 y, x  f2 {/ ^  y1 b
  cmds_floating_ip_set='-h --help --port --fixed-ip-address --description --qos-policy --no-qos-policy --tag --no-tag'
, T; w( a9 L/ T1 y# W/ @, |1 ]7 t  cmds_floating_ip_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
  w) l* y, j: a8 {  cmds_floating_ip_unset='-h --help --port --qos-policy --tag --all-tag'  y% d1 L& b8 i0 q3 \
  cmds_hypervisor='list show stats'
* i+ R$ t/ ?0 w8 w" u5 Q6 y  cmds_hypervisor_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --matching --long'" O, N: x, V6 k0 g
  cmds_hypervisor_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
! z0 V. E% C% ^: M4 C0 i' K/ |  cmds_hypervisor_stats='show'0 i5 o3 h5 |& M2 i( T% L
  cmds_hypervisor_stats_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
7 X: j- c  P. ]1 _1 O) R/ u  cmds_image='add create delete list member remove save set show unset'! Y! K2 ]' R, P- o
  cmds_image_add='project'
( E0 U5 K& B5 Q# U- M0 }. O" N* t& W  cmds_image_add_project='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --project-domain'
+ f7 r3 T( S  z+ b& o  cmds_image_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --id --container-format --disk-format --min-disk --min-ram --file --volume --force --sign-key-path --sign-cert-id --protected --unprotected --public --private --community --shared --property --tag --project --project-domain --size --location --copy-from --checksum --store'
" q# R, f+ s; N  cmds_image_delete='-h --help'
% Z' F, E% p0 S3 B) C  cmds_image_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --public --private --community --shared --property --name --status --member-status --tag --long --page-size --sort --limit --marker'2 I  y: f% r2 t6 ]7 V' `" J7 c
  cmds_image_member='list'+ x8 y. |9 O7 g* W
  cmds_image_member_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --project-domain'2 j  m' M2 Z# r( p7 G
  cmds_image_remove='project'
0 W5 A3 W1 @" ]4 u4 x+ v  cmds_image_remove_project='-h --help --project-domain'' Q4 i( r3 g  t- {3 N; a; b
  cmds_image_save='-h --help --file'; N5 L0 t2 O3 f( G3 _: x
  cmds_image_set='-h --help --name --min-disk --min-ram --container-format --disk-format --protected --unprotected --public --private --community --shared --property --tag --architecture --instance-id --instance-uuid --kernel-id --os-distro --os-version --ramdisk-id --deactivate --activate --project --project-domain --visibility --accept --reject --pending'
/ x, i' H2 z0 ?+ |  cmds_image_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --human-readable'
  a! b' r6 q. J1 S/ M6 x; ^' }& l  cmds_image_unset='-h --help --tag --property'
/ n/ [+ H/ A5 l: V4 p5 j' M  cmds_server_delete='-h --help --wait'* ?( U% F0 U, p
  cmds_server_dump='create'
- g# A) p$ w: w  ~/ U; y% E) c. \; G  cmds_server_dump_create='-h --help'7 l" ?' w7 _: ^" T' C
  cmds_server_event='list show'
+ n+ ?/ Y- l5 e' d# F3 `  cmds_server_event_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'! _+ X% R2 `  o
  cmds_server_event_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
+ j2 |  g' G1 M9 o# E; T* q  cmds_server_group='create delete list show'4 r  r- J$ \8 i
  cmds_server_group_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --policy'
( R# \" {' r5 \3 X  cmds_server_group_delete='-h --help'& L: x: U: T& f
  cmds_server_group_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --all-projects --long'4 Q; ~5 s2 Z+ d5 B6 Q
  cmds_server_group_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'  F- ^5 a, p& v( D
  cmds_server_image='create'- N+ o) y4 T- B; m8 f7 |
  cmds_server_image_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --name --wait'4 W$ N  A3 |& l6 C; A
  cmds_server_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --reservation-id --ip --ip6 --name --instance-name --status --flavor --image --host --all-projects --project --project-domain --user --user-domain --long -n --no-name-lookup --name-lookup-one-by-one --marker --limit --deleted --changes-before --changes-since --locked --unlocked'
% ]# ^* j8 W0 O. k- C( v+ x7 T  cmds_server_lock='-h --help --reason'; Q& `) I  B) H* _- T6 }6 d0 J
  cmds_server_migrate='-h --help --live-migration --live --host --shared-migration --block-migration --disk-overcommit --no-disk-overcommit --wait'
* F; R0 ~) X: _+ v' }; l( W0 N  cmds_server_pause='-h --help'
' N* |9 I% Z' b: C$ ?  cmds_server_reboot='-h --help --hard --soft --wait'
! m+ a% y7 \5 y' @) [# e2 ~# ~  cmds_server_rebuild='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --image --password --property --description --wait --key-name --key-unset'
- Q' `+ y% _9 Q  cmds_server_remove='fixed floating network port security volume'( [' s4 V" ~1 O
  cmds_server_remove_fixed='ip'
& F# n6 q) I( _! f  cmds_server_remove_fixed_ip='-h --help'
" \6 N1 t9 [& F. D; y3 A* z# `0 |  cmds_server_remove_floating='ip'2 a' M4 x" V# r
  cmds_server_remove_floating_ip='-h --help'# f8 d% o+ S" G7 m% K1 W
  cmds_server_remove_network='-h --help'
1 \; q6 |# K' M6 N- Z4 E( }0 M  cmds_server_remove_port='-h --help'. ^4 D" E- k% u6 y" v3 G
  cmds_server_remove_security='group': p0 @: R+ k9 Q) ^% m, ]/ q! `
  cmds_server_remove_security_group='-h --help'8 B' P# w5 f2 q/ _* ~) l
  cmds_server_remove_volume='-h --help'2 O) L( g: n( ~2 e
  cmds_server_rescue='-h --help --image --password') g( N0 ^- L1 C; v, y+ f
  cmds_server_resize='-h --help --flavor --confirm --revert --wait revert confirm'& }+ k3 Z) I0 |; G
  cmds_server_resize_confirm='-h --help'
% F# l6 B( o) E2 z4 p1 T# _  cmds_server_resize_revert='-h --help'
7 W+ [; O; R5 q" I0 l" s  cmds_server_restore='-h --help'
/ M& V9 x" q. M* j/ U* d$ B( `  cmds_server_resume='-h --help'
& g6 S5 _: I/ H) z  L  cmds_server_set='-h --help --name --root-password --property --state --description'/ g/ |& @; R1 B  k$ c, r
  cmds_server_shelve='-h --help'
/ S, T" T7 J' I. `  cmds_server_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --diagnostics': {6 k- \! n3 Y$ _- |' @
  cmds_server_ssh='-h --help --login -l --port -p --identity -i --option -o -4 -6 --public --private --address-type -v'
2 {7 J' {8 h" g( m) a# U: `- H  cmds_server_start='-h --help'
: D* g+ d1 ]( X2 @! m  cmds_server_stop='-h --help'
9 C: z$ w/ i& r" B  cmds_server_suspend='-h --help'
3 F! ]9 s1 B' m4 {: q% R  cmds_server_unlock='-h --help'; @* U* @) }: k4 m8 ]# T
  cmds_server_unpause='-h --help'4 f( \) u" K( p
  cmds_server_unrescue='-h --help') v9 O( U( e" W, z5 ?' g0 x
  cmds_server_unset='-h --help --property --description'
: Z4 N& x, T/ ~( `* E( M+ c  cmds_server_unshelve='-h --help --availability-zone'
8 d6 f" h% ~7 T, p! K1 J" J1 H  cmds_service='create delete list provider set show'1 o6 B6 x  o- [- ?; |1 ]# B
  cmds_service_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --name --description --enable --disable'0 r. ]+ n: h% h3 a/ O/ @9 n
  cmds_service_delete='-h --help'/ O" H+ x1 c1 J( z) ]  `
  cmds_service_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'8 _6 r* U7 y3 n. D
  cmds_service_provider='create delete list set show'5 T$ \( l, L$ }0 r% R( t
  cmds_service_provider_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --auth-url --description --service-provider-url --enable --disable': H+ n( _0 p0 U$ M7 ~. b7 Q1 p1 J
  cmds_service_provider_delete='-h --help'2 l$ z, I) e4 F# d( j2 o) }
  cmds_service_provider_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column'% O+ x3 V: s9 A) G& \: ]3 G# ^7 V
  cmds_service_provider_set='-h --help --auth-url --description --service-provider-url --enable --disable'5 C# z1 P3 d3 ^. o! y
  cmds_service_provider_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'9 o+ C3 G  a' k1 L% i6 V- I) A
  cmds_service_set='-h --help --type --name --description --enable --disable'
5 G4 c# g3 ]/ X  S/ t  cmds_service_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'# U6 k) W0 N3 {  M7 @% t0 o
  cmds_sfc='flow port service'
9 _/ y! V% o$ U5 \' @+ s7 F  cmds_sfc_flow='classifier'
' r& J1 W, f' y' e9 a  cmds_sfc_flow_classifier='create delete list set show'
5 j% d1 N. c. A$ ~# t$ y- U) a  cmds_sfc_flow_classifier_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --protocol --ethertype --source-port --destination-port --source-ip-prefix --destination-ip-prefix --logical-source-port --logical-destination-port --l7-parameters'
3 N- T# v4 m/ ~: m4 x  cmds_sfc_flow_classifier_delete='-h --help'
+ |* K/ A6 u+ g  cmds_sfc_flow_classifier_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'
1 r" X$ w0 f3 J  a. u( h- G  cmds_sfc_flow_classifier_set='-h --help --name --description'
; s- A, J4 U8 F1 K/ A! o" m2 q  cmds_sfc_flow_classifier_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
6 ]9 I6 q: b5 n' R% V9 ]  cmds_sfc_port='chain pair'
1 J% Q8 u: a; M7 S4 j' J  cmds_sfc_port_chain='create delete list set show unset'2 u4 l* @) D4 h3 t5 h
  cmds_sfc_port_chain_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --flow-classifier --chain-parameters --port-pair-group'
" z  j% T9 U9 q9 l: i. O  cmds_sfc_port_chain_delete='-h --help'
7 Q- L1 `8 S" M4 J& ?  cmds_sfc_port_chain_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'+ Z1 h/ m) p  r2 A
  cmds_sfc_port_chain_set='-h --help --name --description --flow-classifier --no-flow-classifier --port-pair-group --no-port-pair-group'7 m( f# l3 N4 K, u  t
  cmds_sfc_port_chain_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
1 e. P+ c) w7 z  cmds_sfc_port_chain_unset='-h --help --flow-classifier --all-flow-classifier --port-pair-group'
! q/ x$ B! Y8 R+ T+ G  cmds_sfc_port_pair='create delete group list set show'
; p5 X, z6 t; N- v' n+ M  cmds_sfc_port_pair_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --service-function-parameters --ingress --egress'
5 a4 M+ @0 C; d. p  cmds_sfc_port_pair_delete='-h --help'
/ o: X/ s1 o& R7 @1 t" o% Y# P9 s0 M  cmds_sfc_port_pair_group='create delete list set show unset'" L9 C9 n( l# W" O. ]9 f% g
  cmds_sfc_port_pair_group_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --port-pair --enable-tap --disable-tap --port-pair-group-parameters'
$ E/ a  e" h2 W; X  cmds_sfc_port_pair_group_delete='-h --help'
8 U8 E1 i8 Q, N& U8 N6 x' @  cmds_sfc_port_pair_group_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'% Y5 U; o. q7 |8 T% N) g, X
  cmds_sfc_port_pair_group_set='-h --help --name --description --port-pair --no-port-pair'
+ ^& {4 E+ W; L& Y0 d% C  cmds_sfc_port_pair_group_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
0 E" c6 T  q9 J% I  cmds_sfc_port_pair_group_unset='-h --help --port-pair --all-port-pair'
( |4 ?6 W" @* u" ]- f  cmds_sfc_port_pair_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'. n# H4 H7 }5 [& [! L( x
  cmds_sfc_port_pair_set='-h --help --name --description'
; |- k$ J% q% t) ~4 D  cmds_sfc_port_pair_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'7 ~4 ?' t& g9 s3 ]
  cmds_sfc_service='graph'
5 b% X1 C* s* f! L6 G3 @  cmds_sfc_service_graph='create delete list set show'( R6 s& P; L; D6 B! G2 a
  cmds_sfc_service_graph_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --branching-point'
& y$ }4 k+ N3 v1 H) y, P& q  cmds_sfc_service_graph_delete='-h --help'
7 S6 [' F7 ^; E: {" a" Z  cmds_sfc_service_graph_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long'2 `0 y% x- E* N
  cmds_sfc_service_graph_set='-h --help --name --description'
" ]# E; J- a  o9 @  cmds_sfc_service_graph_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
' N* c( k/ ~; P; n5 Y  cmds_subnet='create delete list pool set show unset'& g. r; L' S0 r! k
  cmds_subnet_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --project --project-domain --subnet-pool --use-prefix-delegation --use-default-subnet-pool --prefix-length --subnet-range --dhcp --no-dhcp --dns-publish-fixed-ip --no-dns-publish-fixed-ip --gateway --ip-version --ipv6-ra-mode --ipv6-address-mode --network-segment --network --description --allocation-pool --dns-nameserver --host-route --service-type --tag --no-tag'
1 l; e" H- Z$ |. ^  cmds_subnet_delete='-h --help'* ?( Q9 {' B1 t, q% b0 |* B! L3 f
  cmds_subnet_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long --ip-version --dhcp --no-dhcp --service-type --project --project-domain --network --gateway --name --subnet-range --tags --any-tags --not-tags --not-any-tags'
" U2 z. s5 H3 d, q! [  cmds_subnet_pool='create delete list set show unset'
% g4 x. ~0 D/ N8 x9 q* `5 Y  cmds_subnet_pool_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --pool-prefix --default-prefix-length --min-prefix-length --max-prefix-length --project --project-domain --address-scope --default --no-default --share --no-share --description --default-quota --tag --no-tag'
( v: J" a) b5 x7 P  cmds_subnet_pool_delete='-h --help'
; R9 q  n% ]/ z7 f% y. p  cmds_subnet_pool_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long --share --no-share --default --no-default --project --project-domain --name --address-scope --tags --any-tags --not-tags --not-any-tags'
1 W# ]0 f! R3 i  cmds_subnet_pool_set='-h --help --name --pool-prefix --default-prefix-length --min-prefix-length --max-prefix-length --address-scope --no-address-scope --default --no-default --description --default-quota --tag --no-tag'' Q" {- \5 R* e# c& m" C
  cmds_subnet_pool_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
7 c% `1 o- ?+ v8 `* G  cmds_subnet_pool_unset='-h --help --tag --all-tag'6 b, r# S/ E- m. e' y8 g: U
  cmds_subnet_set='-h --help --name --dhcp --no-dhcp --dns-publish-fixed-ip --no-dns-publish-fixed-ip --gateway --network-segment --description --tag --no-tag --allocation-pool --no-allocation-pool --dns-nameserver --no-dns-nameservers --host-route --no-host-route --service-type'2 _* D* T" f! j
  cmds_subnet_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
0 Q& l0 p% i; X3 T  cmds_subnet_unset='-h --help --allocation-pool --dns-nameserver --host-route --service-type --tag --all-tag'
8 B6 c" x# A8 s) |" o- |# w  cmds_volume='backup create delete host list migrate qos service set show snapshot transfer type unset'' X* g* W1 x1 }  E1 C
  cmds_volume_backup='create delete list restore set show'
! C3 j7 _4 x2 ]& N* k  cmds_volume_backup_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --name --description --container --snapshot --force --incremental'9 m! p  A2 r4 C* w
  cmds_volume_backup_delete='-h --help --force': j5 Y. `" A7 H3 K, i4 Y
  cmds_volume_backup_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long --name --status --volume --marker --limit --all-projects'1 t# i; g& i" h5 n. w: ]6 U
  cmds_volume_backup_restore='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
2 P( T+ F) |7 a! H9 D  R: O  cmds_volume_backup_set='-h --help --name --description --state'+ X+ C9 A* ]& z" z2 E
  cmds_volume_backup_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'4 D2 w( S7 O: u+ o8 {
  cmds_volume_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --size --type --image --snapshot --source --source-replicated --description --availability-zone --consistency-group --property --hint --bootable --non-bootable --read-only --read-write'3 m/ o! @0 U  K
  cmds_volume_delete='-h --help --force --purge'
( {) H4 @) ]5 J7 s% J5 J  cmds_volume_host='set'
4 [: Y& l& P: |! ^. B; L  cmds_volume_host_set='-h --help --disable --enable'
& T5 M* L/ v% v! \  cmds_volume_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --project --project-domain --user --user-domain --name --status --all-projects --long --marker --limit'
- _0 D) Q2 \: z& h. y  cmds_volume_migrate='-h --help --host --force-host-copy --lock-volume'
# K7 i4 C; n4 C9 V+ K* O1 W- b" A  cmds_volume_qos='associate create delete disassociate list set show unset'
5 n, P. l) K4 l' ~5 V  cmds_volume_qos_associate='-h --help'
6 Y6 b6 u; i' X5 J- E  cmds_volume_qos_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --consumer --property'
; t$ p- J8 s) b7 o  cmds_volume_qos_delete='-h --help --force'
* h  E! Y4 G8 q7 p5 }  cmds_volume_qos_disassociate='-h --help --volume-type --all'$ S% l, g  }% ?, V! ]
  cmds_volume_qos_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column'9 d1 \8 ]: N' U+ w% i
  cmds_volume_qos_set='-h --help --property'
3 _+ l8 I6 C  V  cmds_volume_qos_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
, H; u* |  u' V+ H* D3 \$ m  cmds_volume_qos_unset='-h --help --property'  F) b6 P7 d3 s  N
  cmds_volume_service='list set'
# f* V' a, I% K8 v  cmds_volume_service_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --host --service --long'
1 }9 M# \6 f: {  x% u  cmds_volume_service_set='-h --help --enable --disable --disable-reason'+ n( z% C2 v% j! o' v  \
  cmds_volume_set='-h --help --name --size --description --no-property --property --image-property --state --attached --detached --type --retype-policy --bootable --non-bootable --read-only --read-write'
9 {, v# ?7 o  k: F3 p  cmds_volume_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'9 M) ]# |  U" Z: h) W, o& ]
  cmds_volume_snapshot='create delete list set show unset'* i7 w+ D$ K2 o
  cmds_volume_snapshot_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --volume --description --force --property --remote-source'( l# M* Q  \. I$ i# ?' o- z
  cmds_volume_snapshot_delete='-h --help --force'% e& ~3 W; k8 J2 T
  cmds_volume_snapshot_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --all-projects --project --project-domain --long --marker --limit --name --status --volume', u- N- a1 i* D4 @2 m# w8 W7 W* k5 T
  cmds_volume_snapshot_set='-h --help --name --description --no-property --property --state'( E: b5 G& ]7 Q! }% y) d1 u
  cmds_volume_snapshot_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
- w$ l1 L# A/ R  cmds_volume_snapshot_unset='-h --help --property'
" g7 ^' j7 ]& [) j4 Q" L* X  cmds_volume_transfer='request'" _9 f1 W2 K: T
  cmds_volume_transfer_request='accept create delete list show'
% Y7 R4 L) a9 k) J! U: T" m5 k4 g  cmds_volume_transfer_request_accept='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --auth-key'  M. U8 X0 |3 j; }7 i
  cmds_volume_transfer_request_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --name'/ Z, R7 g2 G( e( H1 W; r* k
  cmds_volume_transfer_request_delete='-h --help'
6 f$ Z6 H& d) ?4 h- G- b3 ~* V  cmds_volume_transfer_request_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --all-projects'
5 {7 H( w& n2 Z3 `' r" N  cmds_volume_transfer_request_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix'
* R' u2 U7 ]6 O1 [' O$ D  cmds_volume_type='create delete list set show unset'7 m3 |3 w1 f0 j; \, B0 ]8 a4 F
  cmds_volume_type_create='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --description --public --private --property --project --encryption-provider --encryption-cipher --encryption-key-size --encryption-control-location --project-domain'1 ?( I' h, U3 E" {$ q
  cmds_volume_type_delete='-h --help'
5 L; |+ c' S/ E( K: g: E" `  cmds_volume_type_list='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --quote --sort-column --long --default --public --private --encryption-type'
& K0 F  Z/ P6 D( S8 @) Y  cmds_volume_type_set='-h --help --name --description --property --project --project-domain --encryption-provider --encryption-cipher --encryption-key-size --encryption-control-location'! Q( y* d- R( s9 D  x$ u1 H) z
  cmds_volume_type_show='-h --help -f --format -c --column --max-width --fit-width --print-empty --noindent --variable --prefix --encryption-type'
* ~* `" z1 t3 J" B  cmds_volume_type_unset='-h --help --property --project --project-domain --encryption-type') H5 ~6 B% S' k: P/ b* Y
  cmds_volume_unset='-h --help --property --image-property'* [6 V$ C, a2 z: A5 x* U
  dash=-
/ D2 H) h3 r5 @- ?2 x; t  underscore=_
; G" F8 c: L0 U2 f& Y0 p4 z  cmd=""" e9 T0 {$ ~/ `. G( W) @" k2 p4 s0 V
  words[0]=""
; v3 ^# l4 _0 C. B; g  completed="${cmds}"
4 @6 t; a  X# L3 _* h  for var in "${words[@]:1}": Q  i4 L+ u8 z- a* Y0 Y
  do+ \) `1 R+ S# k0 f% \
    if [[ ${var} == -* ]] ; then1 X% X* Q2 m$ M" M
      break
) I) V+ P" p/ }4 f# r    fi
/ B4 C. |' w6 X5 E' P0 l( o* H    if [ -z "${cmd}" ] ; then+ G+ Y6 k( \. n6 q/ o( U4 A
      proposed="${var}"6 b, K- ^- {6 r: }+ Z1 X
    else7 }4 g$ z  u& ^: y! L7 N
      proposed="${cmd}_${var}"
2 `2 }' V; p5 {: ]9 i: @- t    fi: n4 A# s% ~, n. Q3 L3 O
    local i="cmds_${proposed}"& A1 A) O% c' H1 Z+ t% [0 X  Y& E
    i=${i//$dash/$underscore}2 Q2 c( e: e* S! T
    local comp="${!i}"2 M* J* f& g# }' z1 t9 V1 k
    if [ -z "${comp}" ] ; then
, V( S+ O2 T: M      break
7 t' A" U8 ]$ u0 `/ J& o; n    fi
5 [9 `7 X' M0 c/ |- |% ]; r8 u5 ^    if [[ ${comp} == -* ]] ; then
  s- U6 w0 N$ w& U2 T      if [[ ${cur} != -* ]] ; then! v1 t4 _. ?8 J( e- G# O
        completed=""- W$ X. c1 \% B. x
        break7 |$ g3 W4 e3 r. L# q. A
      fi
8 E3 C4 v! J5 ^# y9 ]( X* b. ~    fi) y' c* r) A1 @. a
    cmd="${proposed}"
7 F0 |- U3 w' `& B9 V    completed="${comp}"4 x- |: L" }7 I: p, b% H: Z
  done, @6 r. L9 z/ ?1 m/ Y/ W( \( X
  if [ -z "${completed}" ] ; then
8 c  M8 R& j/ ^, N    COMPREPLY=( $( compgen -f -- "$cur" ) $( compgen -d -- "$cur" ) )5 W7 p9 f: u# u  D4 L* `  P
  else
: E+ A* I0 c/ \, ]0 [1 ]    COMPREPLY=( $(compgen -W "${completed}" -- ${cur}) )
' j- }* k, I" M- O. q# F- c, E  fi
  E! Y4 l  v- X; q9 O8 x  return 0
8 S, w, m( W( n8 d}7 V& d9 x; L& I! b9 J3 I! U
complete -F _nova nova3 D* k0 Z8 T' t- S8 \
& G! u. _* g, \9 x- q

2 \' X, \# @9 O/ P0 g! e- s# r
" ~3 X1 S7 I/ |3 r& l" S保存退出后:
0 K$ S% {1 i' T; A
, |$ T: N. B% ?/ _6 m3 w; Pecho "source /etc/bash_completion.d/nova.bash_completion" >>~/.bashrc 5 C" g. g8 r: @4 |8 o6 E" }

, \1 I/ j1 ^1 ^3 a' c2 {' x" t/ L1 M. m+ |4 ^
然后加载bashrc的文件:- k: E9 {6 Z0 N4 E6 I
[root@controller1 ~]# source ~/.bashrc2 B$ a' C/ V( j' W  x
% J6 b2 ?$ m1 C! ]
' J5 d% d6 a  D4 M, E

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-9-3 09:02:25 | 显示全部楼层
测试结果如下:  D& ?  l6 m. b4 {4 l
[root@controller1 bash_completion.d]# nova
$ J. Z+ n" b, R$ m" w9 uDisplay all 160 possibilities? (y or n)
9 n6 s" I  f* ]+ J8 c- G; ^: w  j4 V2 Yadd-secgroup                   flavor-access-remove           instance-action-list           --os-domain-id                 remove-secgroup                --service-type5 W* @# P, a* y3 O( J( @5 N
agent-create                   flavor-create                  instance-usage-audit-log       --os-domain-name               rescue                         set-password
8 [  p0 a* {& g& H- N, j. eagent-delete                   flavor-delete                  interface-attach               --os-endpoint-override         reset-network                  shelve
( p/ R1 |8 V4 }* G* magent-list                     flavor-key                     interface-detach               --os-endpoint-type             reset-state                    shelve-offload- ^- ~, z, s2 ?6 C# z' `0 f6 l% w
agent-modify                   flavor-list                    interface-list                 --os-key                       resize                         show
% y, [1 t6 b6 N. k* aaggregate-add-host             flavor-show                    keypair-add                    --os-password                  resize-confirm                 ssh
7 H% O& J  p; W7 j2 W  r$ Baggregate-cache-images         flavor-update                  keypair-delete                 --os-project-domain-id         resize-revert                  start
3 J+ v  Y9 Y6 xaggregate-create               force-delete                   keypair-list                   --os-project-domain-name       restore                        stop
: Z1 s3 N3 A* Iaggregate-delete               get-mks-console                keypair-show                   --os-project-id                resume                         suspend4 f5 J  @- q8 ~) {- ?3 R
aggregate-list                 get-password                   limits                         --os-project-name              server-group-create            --timeout4 c1 B5 F6 s. T$ l1 R' x8 l
aggregate-remove-host          get-rdp-console                list                           --os-region-name               server-group-delete            --timings
1 x. j4 l! E+ u$ [/ e$ r' s  Waggregate-set-metadata         get-serial-console             list-secgroup                  --os-system-scope              server-group-get               trigger-crash-dump( }; E; ]) b- K- |& U7 A/ J
aggregate-show                 get-spice-console              live-migration                 --os-trust-id                  server-group-list              unlock
) n! X" j5 L( c/ g" }4 d8 f  Iaggregate-update               get-vnc-console                live-migration-abort           --os-user-domain-id            server-migration-list          unpause
5 a9 R2 D  t* Y; z% u, g, ?# ?# N. v; Savailability-zone-list         help                           live-migration-force-complete  --os-user-domain-name          server-migration-show          unrescue
4 M% b4 m' e! K/ F* e* d; nbackup                         host-evacuate                  lock                           --os-user-id                   server-tag-add                 unshelve
9 Z% ?+ D; a- t" L5 ^7 @bash-completion                host-evacuate-live             meta                           --os-username                  server-tag-delete              update
6 G4 }- `7 R3 w# G# H* z% zboot                           host-meta                      migrate                        pause                          server-tag-delete-all          usage) a8 P6 Y* n( ^# H' X/ Y
clear-password                 host-servers-migrate           migration-list                 quota-class-show               server-tag-list                usage-list
! ^* M. m/ J/ |% Z( J9 e' h. I3 }--collect-timing               hypervisor-list                --os-auth-type                 quota-class-update             server-tag-set                 --version7 T7 @7 r( k% a0 k& |
console-log                    hypervisor-servers             --os-auth-url                  quota-defaults                 server-topology                version-list- n5 i, i3 i) N* x4 [+ Z  l; I; y
--debug                        hypervisor-show                --os-cacert                    quota-delete                   service-delete                 volume-attach4 ?8 n; }2 _6 N& [& T
delete                         hypervisor-stats               --os-cache                     quota-show                     service-disable                volume-attachments. j6 B1 _- b6 R) E! X# X
diagnostics                    hypervisor-uptime              --os-cert                      quota-update                   service-enable                 volume-detach: j' Z# d% W4 y$ @  Z
evacuate                       image-create                   --os-compute-api-version       reboot                         service-force-down             volume-update/ P3 t8 R- T0 R' }6 Y+ A. Z4 r; g! X' T
flavor-access-add              --insecure                     --os-default-domain-id         rebuild                        service-list                  
7 z; x/ Q) \& Dflavor-access-list             instance-action                --os-default-domain-name       refresh-network                --service-name                 , m5 N, l) R, U) u+ M& u. H8 _' ~

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2021-9-8 16:14:41 | 显示全部楼层
经过精简的版本:
8 q4 t: p, ~) d5 `; U) ^' h; Tcat nova.bash_completion
4 K% C* T- @5 L. @6 r6 D" E! N_nova()8 Y( ]( \7 T% `
{
  B3 {8 S+ ~! Y1 t) }! E2 Z2 v   local cur prev words! w9 Z- `2 a8 a( q- L2 x- t( T
   COMPREPLY=()
$ ]7 B3 x" Z4 l# E) c2 ]   _get_comp_words_by_ref -n : cur prev words
2 `/ c: u% E8 ?, E! ?: o   # Command data:
( G" n( D1 f+ E1 z   cmds='add-secgroup agent-create agent-delete agent-list agent-modify aggregate-add-host aggregate-cache-images aggregate-create aggregate-delete aggregate-list aggregate-remove-host aggregate-set-metadata aggregate-show aggregate-update availability-zone-list backup boot clear-password console-log delete diagnostics evacuate flavor-access-add flavor-access-list flavor-access-remove flavor-create flavor-delete flavor-key flavor-list flavor-show flavor-update force-delete get-mks-console get-password get-rdp-console get-serial-console get-spice-console get-vnc-console host-evacuate host-evacuate-live host-meta host-servers-migrate hypervisor-list hypervisor-servers hypervisor-show hypervisor-stats hypervisor-uptime image-create instance-action instance-action-list instance-usage-audit-log interface-attach interface-detach interface-list keypair-add keypair-delete keypair-list keypair-show limits list list-secgroup live-migration live-migration-abort live-migration-force-complete lock meta migrate migration-list pause quota-class-show quota-class-update quota-defaults quota-delete quota-show quota-update reboot rebuild refresh-network remove-secgroup rescue reset-network reset-state resize resize-confirm resize-revert restore resume server-group-create server-group-delete server-group-get server-group-list server-migration-list server-migration-show server-tag-add server-tag-delete server-tag-delete-all server-tag-list server-tag-set server-topology service-delete service-disable service-enable service-force-down service-list set-password shelve shelve-offload show ssh start stop suspend trigger-crash-dump unlock unpause unrescue unshelve update usage usage-list version-list volume-attach volume-attachments volume-detach volume-update bash-completion help --version --debug --os-cache --timings --os-region-name --service-type --service-name --os-endpoint-type --os-compute-api-version --os-endpoint-override --os-auth-type --insecure --os-cacert --os-cert --os-key --timeout --collect-timing --os-auth-url --os-system-scope --os-domain-id --os-domain-name --os-project-id --os-project-name --os-project-domain-id --os-project-domain-name --os-trust-id --os-default-domain-id --os-default-domain-name --os-user-id --os-username --os-user-domain-id --os-user-domain-name --os-password'3 G1 E; k% B4 L$ A$ A* J1 U& @
  dash=-
& o7 I  k- S4 r) |  underscore=_
' Z& h$ y# W3 c+ X7 ]: s   cmd="", F. x+ L! O) M& c
   words[0]=""9 h- U! e: ?& M/ X
   completed="${cmds}", Q5 A, V# Z" ]7 F3 {+ j
   for var in "${words[@]:1}"
8 i" r: P: s* A; f( r   do+ D0 l/ x/ z) N3 g: y
     if [[ ${var} == -* ]] ; then
" p: |# y) q  j0 ^) T       break
5 L/ j% X  J* |: C! b0 v! H     fi9 T+ F8 U. _% _
     if [ -z "${cmd}" ] ; then
: ]2 j% O  X( A       proposed="${var}"
4 R4 I- ~) h) R% |- f% b     else
& k( b4 a: s+ @  {: P1 O       proposed="${cmd}_${var}". V* W' F4 p! }# U0 ^3 z% w
     fi9 t; a0 a. t# _* [1 M: j# c
     local i="cmds_${proposed}"; T3 N7 O1 m5 s& R
     i=${i//$dash/$underscore}
( W- O1 d( ^, c9 v+ j     local comp="${!i}"
4 k6 Y1 z3 y# n' f) i* t2 d- b1 [     if [ -z "${comp}" ] ; then6 C0 D6 d- C4 T3 d/ Y
       break
9 \9 O" X- L6 h/ Y) ~     fi0 [4 S$ {) f( a4 W
     if [[ ${comp} == -* ]] ; then  Y$ D2 g3 _( R, g" R+ d$ j
       if [[ ${cur} != -* ]] ; then) V8 E8 R' q1 A
         completed=""( I' |  ?/ p- r* N! d
         break' ~! h# q: c7 q; L
       fi
% k  L+ b7 f: g5 s( [1 ~* R     fi
7 L# b( W) K0 }! ~# l- d3 J  H% P     cmd="${proposed}"$ M! u$ k8 S  b2 n* B7 }. e5 ?' I
     completed="${comp}"
( h0 p$ P+ _1 U5 b( c  h5 S  t! X   done
, ?# Z3 J. `/ f5 H; O4 M   if [ -z "${completed}" ] ; then$ p  k, a/ W8 R: X' ~; h
     COMPREPLY=( $( compgen -f -- "$cur" ) $( compgen -d -- "$cur" ) )
" Y% W( }7 {8 L6 R  z   else, W! \0 f! Y! H" a
     COMPREPLY=( $(compgen -W "${completed}" -- ${cur}) )4 l8 a) O# w# ]- V/ s/ v
   fi- F8 N' \- g+ c" U8 J8 x! |
   return 0' M9 h" L' z6 y4 O
}
" V/ Z* Q8 j# @) R6 v complete -F _nova nova
8 E+ J) T/ `+ S1 M' b
, _% Q& H1 I- c( ~+ t  I, r9 D; q0 q+ m; e0 M0 g* ]

) A) Y0 T/ u2 U# N' {7 _加入到/etc/proflie文件中,所有的用户都可以tab补全。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 02:19 , Processed in 0.017675 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表