配置命令和用法

config 命令中还包含不同的命令,使用这些命令可以在 IBM cpdctl 中配置 IBM® watsonx.data 环境。 本主题列出了可以执行的命令和任务简述。

配置命令管理 watsonx.data 的配置文件和用户配置。 在配置和执行操作时,必须在网络浏览器中打开 watsonx.data 实例。

语法:

./cpdctl config [commands]

配置命令支持以下命令:

您可以分别运行这些命令来设置 用户配置文件。 建议使用组合命令,通过一条命令设置配置文件和用户。 更多信息,请参阅 同时使用用户和配置文件命令

为 IBM cpdctl 配置加密密钥

为确保密码和 API 密钥的安全,IBM cpdctl 使用 AES-256 加密。 您可以使用自定义加密密钥或 IBM cpdctl 提供的默认硬编码密钥。

通过设置指向加密密钥文件保存目录路径的 CPDCTL_ENCRYPTION_KEY_PATH 环境变量,可以为 AES-256 提供自定义加密密钥。 如果未设置该环境变量,cpdctl 将使用自己的硬编码加密密钥。

用于 macOS 和 Linux:

export CPDCTL_ENCRYPTION_KEY_PATH=/path/cpdctl.key

对于 Windows 命令提示符:

set CPDCTL_ENCRYPTION_KEY_PATH=/path/cpdctl.key

适用于 Windows PowerShell:

$env:CPDCTL_ENCRYPTION_KEY_PATH = "/path/cpdctl.key"

用户

user 命令管理 watsonx.data 中的用户。

语法:

./cpdctl config user [commands]

user 命令还支持以下命令:

用户支持的命令
选项 描述
./cpdctl config user set [commands] 在 cpdctl 配置中为用户设置连接 watsonx.data 实例的凭据。
./cpdctl config user list 列出存储在 cpdctl 配置中用于连接 watsonx.data 实例的凭证。
./cpdctl config user get <username> 获取存储在 cpdctl 配置中用于连接 watsonx.data 实例的用户凭据。
./cpdctl config user unset <username> 从 watsonx.data 实例的 cpdctl 配置中删除当前设置的用户名。

./cpdctl config user set [commands] 还支持以下命令作为设置证书的选项:

--apikey (string) : Set user apikey

--password (string) : Set user password

--token-file (string) : Set location of a file that contains user token

--username (string) : Set user name

在云实例中设置用户的示例:

./cpdctl config user set <user> --username <saas_username> --apikey <APIKEY>
./cpdctl config user set user2 --username user@ibm.com --apikey APIKEY

对于 IBM Cloud 上的 watsonx.data,建议使用 --username--apikey,它们用于登录控制台。 更多信息,请参阅 获取 API 密钥

概要文件

profile 命令管理 watsonx.data 中的配置文件。

已在 cpdctl 配置中启用单点登录 (SSO)。

语法:

./cpdctl config profile [commands]

profile 命令支持以下命令:

各配置文件支持的命令
选项 描述
./cpdctl config profile set [commands] 在 cpdctl 配置中设置 watsonx.data 环境配置文件。
./cpdctl config profile list 列出 cpdctl 配置中设置的所有 watsonx.data 环境配置文件。
./cpdctl config profile get <profilename> 从 cpdctl 配置中获取 watsonx.data 环境配置文件的详细信息。
./cpdctl config profile unset <profilename> 从 cpdctl 配置中删除 watsonx.data 环境配置文件。
./cpdctl config profile current 从 cpdctl 配置中获取当前使用的 watsonx.data 环境配置文件的详细信息。
./cpdctl config profile use <profilename> 使用 cpdctl 配置中的特定 watsonx.data 环境配置文件。

./cpdctl config profile set [commands] 还支持以下命令作为设置证书的选项:

--apikey (string) : Create a user having this API key and associate it with the profile. Used for SaaS and Onprem. Recommended to use for SaaS instance.

--common-services-url (string) : Set Common Services URL for the profile

--iam-integration-enabled () : Set if IAM integration is enabled on CP4D

--ibmcloud (string) : Connect the profile to IBM Cloud CLI session metadata. Flag value specifies IBM Cloud CLI configuration directory. If no value is given, default IBM Cloud CLI configuration directory is assumed.

--password (string) : Create a user having this password and associate it with the profile. Used for Onprem. Recommended to use for Onprem instance.

--region (string) : IBM cloud region.

--token-file (string) : Create a user having this token location and associate it with the profile.

--url (string) : Set URL for the profile

--user (string) : Set user for the profile

--username (string) : Create a user having this name and associate it with the profile.

使用早先在云实例中设置的 user 配置设置配置文件的示例:

./cpdctl config profile set <profile_name> --user <user> --url <profile_url> --region <region_name>
./cpdctl config profile set saas --user user2 --url https://cloud.ibm.com/ --region us-south

同时使用命令 user 和 profile

您可以在 cpdctl 配置中将 user 和 profile 这两条命令结合起来配置实例配置文件。 下面提供了一个如何使用组合的示例:

设置云实例配置文件:

语法:

cpdctl config profile set <profile_name> --username <saas_username> --apikey <APIKEY> --url <saas_url> --region <region_name> \
--env "WATSONX_DATA_INSTANCE_ID=<crn>" \
--env "WATSONX_DATA_URL=<WXD-base-url>"

示例:

./cpdctl config profile set saas --username user@ibm.com --apikey APIKEY --url https://cloud.ibm.com/ --region us-south \
--env "WATSONX_DATA_INSTANCE_ID=crn:v1:staging:public:lakehouse:us-south:a/781f752068d44638a3b2a13de58d3cfe:2c590eda-8d51-4269-86ce-a6dfb84c8267::" \
--env "WATSONX_DATA_URL=https://us-south.lakehouse.dev.cloud.ibm.com/"

对于 IBM Cloud 上的 watsonx.data,建议使用 --username--apikey,它们用于登录控制台。 更多信息,请参阅 获取 API 密钥

将实例 ID 设置为环境变量

从 cpdctl 版本 1.8.5 开始,用户不再需要将 instance ID 设置为环境变量。 该方法已被弃用,并将在以后的版本中完全删除。 instance ID 相反,您必须使用 概要文件 命令 中所述

您必须设置一个实例 ID 才能访问相应的环境来运行 cpdctl 命令。 要设置实例 ID,可以使用 WX_DATA_INSTANCE_ID 环境变量。 这样就可以避免在每条命令中指定实例 ID。

要设置变量,请在 macOS 和 Linux 中运行以下命令:

export WX_DATA_INSTANCE_ID=<instance-id_value>

其中,<instance-id_value> 是 watsonx.data 软件实例的实例 ID 或您在 IBM Cloud 上 watsonx.data 实例的 CRN,可通过单击主页上的 i 图标访问。

要设置该变量,请在 Windows 命令提示符中运行以下命令:

set WX_DATA_INSTANCE_ID=<instance-id_value>

要设置变量,请在 Windows 中运行以下命令 PowerShell:

$env:WX_DATA_INSTANCE_ID = "<instance-id_value>"