我正在尝试通过我正在构建的程序的 API 获取我的 Vsphere 版本。问题是我不断收到此错误,即使它以前有效。现在已经停止工作了。
这是我运行的命令,但在 Python django 中:
curl -H "vmware-api-session-id: b00db39f948d13ea1e59b4d6fce56389" https://{api_host}/api/appliance/system/version
错误如下: { “error_type”:“NOT_FOUND”, “消息”:[ { “参数”:[], "default_message": "未找到。", “id”:“com.vmware.vapi.rest.httpNotFound” } ] }
根据您使用的 vSphere 版本,REST API 中存在一个错误,该错误会导致非常类似的错误(不过,我相当肯定错误结果是“未通过身份验证”而不是“未找到”) 。解决方法是重新启动 vAPI 服务,或者在某些情况下重新启动整个 vCenter 设备。我相信该修复已在 6.7U3 和 7.0U1 中引入。
函数 getIpAddress($vm, $server, $id) {
$key = "power_state";
if (isset($vm[$key])) {
$powerState = $vm[$key];
$vmid = $vm['vm'];
print($vmid);
$url = "https://$server/api/vcenter/vm/$vmid/guest/networking/interfaces";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$headers = array(
'Accept: application/json',
'Content-Type: application/json',
"vmware-api-session-id: $id"
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
$result = curl_exec($ch);
echo $result;
curl_close($ch);
if (! $result) {
return false;
}
$json = json_decode(substr($result, 1, -1),true);
if (empty($json) || json_last_error() !== JSON_ERROR_NONE) {
return false;
}
echo $json;
print($json);
}
}
我有相同的错误输出:{“error_type”:“NOT_FOUND”,“messages”:[{“args”:[],“default_message”:“未找到。”,“id”:“com.vmware .vapi .rest.httpNotFound"}]}