Show Table of Contents
1.4. 运行 CLI
使用以下命令启动 CLI 应用程序:
# ovirt-shell
ovirt-shell 应用程序是一个用来和 Red Hat Virtualization 环境进行交流的、交换式的 shell。
用来和 Red Hat Virtualization Manager 进行连接的 URL、用户名、证书颁发机构文件和密码可以在
.rhevmshellrc 文件中进行配置。ovirt-shell 命令使用这个文件中的参数来与 Manager 进行连接,因此用户无需每次都指定这些选项。
另外,用户也可以使用以下选项来自动连接到 Red Hat Virtualization Manager:
# ovirt-shell -c -l "https://[server]/api" -P [port] -u "[user@domain]" -A "[certificate]"
包括在方括号中的值需要根据您的实际情况进行替换:
- server - Red Hat Virtualization Manager 的主机名或 IP 地址。CLI 使用 REST API 连接到 Red Hat Virtualization Manager。
- user@domain - 登录到 Red Hat Virtualization Manager 的用户的用户名和所在的目录服务域名。
- certificate - 证书授权文件的路径名。
shell 会提示您输入密码。如果没有提供用户名和 Red Hat Virtualization Manager 的 URL,它还会要求您输入它们。
注意
如果您已经在
.rhevmshellrc 文件中配置了用户名、密码、URL 和证书颁发文件,您将不需要指定额外的选项。
注意
以上示例中的选项只有“certificate"是必须指定的,其它的选项都可以在 shell 的提示下输入。您可以使用 '--insecure' 选项而不再需要指定“certificate",这将可以在不使用证书的情况下进行连接,但是,这会使"中间人(man-in-the-middle - MITM)”袭击有机可乘,因此我们不推荐使用这个方法。
ovirt-shell 的选项
- -h, --help
- 显示
ovirt-shell的帮助信息。 - -d, --debug
- 启用调试模式
- -l URL, --url=URL
- 指定 API 进入点 URL。
- -u USERNAME, --username=USERNAME
- 以指定的用户帐号连接。
- -K KEY_FILE, --key-file=KEY_FILE
- 指定密钥文件。
- -C CERT_FILE, --cert-file=CERT_FILE
- 指定证书文件。
- -A CA_FILE, --ca-file=CA_FILE
- 指定服务器证书授权文件。
- -I, --insecure
- 允许 CLI 不使用证书来通过 SSL 进行连接。因为这个方法可能会遭到“中间人(man-in-the-middle -MITM)”袭击,因此在使用时应格外小心。
- -F, --filter
- 根据用户的权限启用过滤功能。
- -P PORT, --port=PORT
- 指定端口。
- -T TIMEOUT, --timeout=TIMEOUT
- 指定超时时间。
- -c, --connect
- 自动连接。
- -e, --extended-prompt
- 启用扩展的 shell 提示符。使用这个选项后,shell 的提示符将包括环境的主机名。它的默认值是 'false'。
- -E "command resource", --execute-command="command resource"
- 连接到 Manager 后只执行指定的命令(指定命令的格式是 "command resource;command resource"),并把命令的输出打印到 STDIO。
- -f FILE, --file=FILE
- 从指定的文件而不是 stdin 中读取命令。
- --kerberos
- 使用有效 Kerberos ticket 验证与 shell 的连接。
注意
使用非交换式 shell 的用户可以通过在 shell 中使用 --password 选项来与 Red Hat Virtualization Manager 进行连接。

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.