本文介绍了vCenter ReST API身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用https://code.vmware.com/apis/62/vcenter-management#/
上的vmware文档,并在使用ReST API时提供哪些标头以对VCenter Server进行身份验证?
I am following vmware documentation at https://code.vmware.com/apis/62/vcenter-management#/
What headers are to be provided to authenticate to VCenter Server while using ReST API?
推荐答案
对于python:
import requests
# https://vdc-download.vmware.com/vmwb-repository/dcr-public/1cd28284-3b72-4885-9e31-d1c6d9e26686/71ef7304-a6c9-43b3-a3cd-868b2c236c81/doc/operations/com/vmware/vcenter/vm.list-operation.html
sess = requests.post("https://XXXXXXXX/rest/com/vmware/cis/session", auth=('USERNAME', 'PASSWORD'), verify=False)
session_id = sess.json()['value']
resp = requests.get("https://XXXXXXXX/rest/vcenter/vm", verify=False, headers={
"vmware-api-session-id": session_id
})
print(u"resp.text = %s" % str(resp.text))
这篇关于vCenter ReST API身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!