設定指令與用法

config 指令內部還有不同的指令,您可以使用這些指令在 IBM cpdctl 中設定 IBM® watsonx.data 環境。 本主題列出可執行任務的命令及簡要說明。

config 指令管理 watsonx.data 的設定檔和使用者設定。 配置和執行操作時,watsonx.data 實例必須在 Web 瀏覽器中打開。

語法:

./cpdctl config [commands]

config 指令支援下列指令:

您可以分別執行這些指令來設定 使用者設定檔。 建議使用合併指令,透過單一指令設定設定檔和使用者。 如需詳細資訊,請參閱 同時使用使用者和設定檔指令

設定 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 Command Prompt:

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 中的設定檔。

單一登入 (SSO) 已在 cpdctl 設定中啟用。

語法:

./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

同時使用使用者和設定檔指令

您可以在 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 設定 設定檔 指令,如在 一起使用指令 user 和 profile 中所述

您必須設定一個實體 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 Command Prompt 中執行下列指令:

set WX_DATA_INSTANCE_ID=<instance-id_value>

若要設定變數,請在 Windows 中執行下列指令 PowerShell:

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