大家好,
我试图通过使用Karbon API来部署Karbon Development群集,但是我遇到了身份验证的错误。
{“ message_list”:{“未经授权”:“无法获得身份验证信息“},“ status_code”:401}
调用Karbon API的命令是:
curl -k -x post -d @create -cluster -dev.json -header“ content -type:application/json” - -header“ convect:application/json” - 使用$ nutanix_user:$ nutanix_user_pass:https:/https:/https:/https://xxx.xxx.xxx.xxx:9440/karbon/acs/k8s/cluster“
当我尝试在下面的这些命令中使用其他Prism API命令(例如cluster或vm)时,一切正常,因此我认为我的登录/密码不会错。我还没有看到更多的nutanix日志文件,但是也许我正在寻找错误的位置(/数据/日志)。
curl -k -k -x post -d @nutanix-list-cluster.json--header“ content -type:application/json” - -header“ convect:application/json” --user $ nutanix_user:$ nutanix_user_pass_pass'https'https://xxx.xxx.xxx.xxx:9440/api/nutanix/v3/clusters/list“
以前有人遇到过这个错误吗?
最好的答案梅弗海格
I finally resolved the authentication error.<\/p>
The solution was to authenticate a first time to the Prism Central API, and store the cookie session into a variable. Then you can call the Karbon API with adding the cookie to the request, and Voila !<\/p>
I rewrite my code to make the call with ansible, and it\u2019s working. I have some additionnals errors (NTP servers are not properly set, but there are note tied to the authentication and we are currently fixing it).<\/p>
\u00a0<\/p>
For information, here\u2019s my code for ansible call :
\u00a0<\/p>
- name: Check that you can connect (GET) to Nutanix API with your identification
uri:
url: \"https:\/\/{{ prism_central_api_url }}:{{ prism_central_api_port }}\/api\/nutanix\/v3\/clusters\/list\"
user: \"{{ prism_central_user }}\"
password: \"{{ prism_central_password }}\"
method: \"POST\"
body: \"{{ lookup('file', 'nutanix-list-cluster.json') }}\"
body_format: json
force_basic_auth: yes
validate_certs: no
return_content: yes
status_code: 200
register: login
- name: Set fact for Session Cookie
set_fact:
session_cookie: \"{{ login.set_cookie }}\"
- name: Calling Karbon API for bring up the new dev cluster
uri:
url: \"https:\/\/{{ prism_central_api_url }}:{{ prism_central_api_port }}\/karbon\/acs\/k8s\/cluster\"
user: \"{{ prism_central_user }}\"
password: \"{{ prism_central_password }}\"
method: \"POST\"
body: \"{{ lookup('file','create-cluster-dev.json') }}\"
body_format: json
force_basic_auth: yes
return_content: yes
status_code: 200
validate_certs: no
headers:
Cookie: \"{{ login.set_cookie }}\"
register: karbon_response<\/code><\/pre> \u00a0<\/p>
Thanks again @AnishWalia20<\/user-mention> for your time and assistance. :)<\/p> \u00a0<\/p>","className":"post__content__best_answer"}">