Show Table of Contents
1.5. CLI との対話
CLI は、コマンドラインから Red Hat Virtualization 環境を制御する対話型シェルです。必要なコマンドと追加のパラメーターを入力します。
例1.1 シェルコマンドの入力手順
[RHEVM shell (connected)]# show vm --name desktop_vms
コマンドとパラメーターの適切な組み合わせを入力するため、CLI には bash シェルと同様に
TAB キーを 2 回押してコマンドとパラメーターを表示し、自動補完する機能が含まれています。
例1.2 コマンドとパラメーターの表示と自動補完
空のプロンプトで
TAB を 2 回押すと利用可能なコマンドがすべて表示されます。
[RHEVM shell (connected)]# TAB TAB
EOF clear echo history remove summary
action connect exit info shell update
add console file list show
capabilities disconnect help ping status
コマンドを選択して
TAB を 2 回押すと、次にそのコマンドで利用可能なパラメーターが表示されます。show の場合は、全リソースを表示します。
[RHEVM shell (connected)]# show TAB TAB
brick datacenter event group nic
quota statistic template vmpool cdrom
disk file host permission role
storagedomain user cluster domain glustervolume
network permit snapshot tag vm
また、
TAB を 2 回押すと、コマンドやパラメーターが補完されます。
[RHEVM shell (connected)]# show vmTAB TABkwargs name show-all storagedomain [RHEVM shell (connected)]# show vm naTAB TAB[RHEVM shell (connected)]# show vm --name
また、
TAB を 2 回押すと、na が --name パラメーターに自動変換されます。この補完は接頭辞にも対応しています。
未完のパラメーターに複数のパラメーターがマッチする場合には、
TAB を 2 回押すことでそれらの該当パラメーターが表示されます。
[RHEVM shell (connected)]# show vTAB TAB
vmpool vm
CLI には、
shell コマンドと感嘆符 (!) のいずれかを使用して Linux コマンドを実行できる機能が含まれています。
例1.3 Linux シェルコマンドの実行
shell コマンドを使います。
[RHEVM shell (connected)]# shell ls -la
または感嘆符 (
!) を使います。
[RHEVM shell (connected)]# !ls -la
Linux シェルと同様に、CLI でデータを他のコマンドやソースにパイプすることができます。
例1.4 CLI コマンドのパイプ
CLI データを Linux シェルコマンドにパイプします。
[RHEVM shell (connected)]# list vms --show-all | grep "Example" name : Example1 name : Example2 name : ExampleEngineering description : An Example description name : BestExampleVM
CLI データをファイルにパイプします。
[RHEVM shell (connected)]# list vms --show-all > list vms --show-all > VM_List.txt
CLI にはオンラインヘルプシステムも含まれており、
help コマンドで各コマンドの説明や構文が提供されます。
例1.5 show コマンドのオンラインヘルプの利用
[RHEVM shell (connected)]# help show
Linx シェルから Manager に接続して、「command resource」の形式で指定のコマンドを実行して STDIO に出力することも可能です。
例1.6 Manager に接続して指定のコマンドを実行する手順
--execute または -E パラメーターを使用して、Manager に実行し指定のコマンドを実行します。
# ovirt-shell -c -l "https://[server]/api" -P [port] -u "[user@domain]" -A "[certificate]" -E "list vms;list hosts" [RHEVM shell (connected)]# list vms id : 9e6977f4-4351-4feb-bba0-dc7c22adec30 name : desktop-01 id : 60b12e28-7965-4296-86bf-c991aa32c2d5 name : server-01 [RHEVM shell (connected)]# list hosts id : 3598cdb9-d21b-49bd-9491-59faff89b113 name : Gluster id : a0c384f9-0940-4562-9c42-4ceaadf8f1f1 name : Host-01 id : 593ec966-c3ea-4bdc-84ad-5dc3f9fe64c7 name : Host-03

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.