英文:
VCenter Maintenance mode REST API is not working
问题
我正在尝试使用REST API /api/vcenter/host/maintenance/requests-v1 将ESX主机移至维护模式。POST操作成功。但主机未移至维护模式。
我有一个vSphere v8.0试用版部署,我正在尝试使用维护模式REST API。
我有两个ESX主机,没有集群,没有DRS,没有HA。
我能够从vSphere客户端Web UI将主机移至维护模式。
主机没有运行任何虚拟机。可以移至维护模式。
我尝试在POSTMAN中使用REST API /api/vcenter/host/maintenance/requests-v1,POST操作成功,并且在对上述API的GET调用中看到了请求。
但主机未在V-Sphere Web客户端中设置为维护模式。
我是否缺少任何配置/设置?
任何帮助将不胜感激!
英文:
I am trying to use the REST API /api/vcenter/host/maintenance/requests-v1 to move the ESX host to Maintenance mode. POST action was success. But host does not move to maintenance mode.
I have a vSphere v8.0 Trial version deployment where I am experimenting the Maintenance mode REST API.
I have two ESX hosts and no cluster, no DRS, no HA in the setup.
I was able to move a host to maintenance mode from vSphere client web UI.
The host does not have any VMs running. Ready to be moved to maintenance mode.
I tried to use the REST API /api/vcenter/host/maintenance/requests-v1 from POSTMAN and the POST action was success and I am seeing the requests in the GET call to the above API.
But the host is not setting to maintenance mode in V-Sphere web client.
Am I missing any configurations/settings?
Any help would be really appreciated!
答案1
得分: 0
I found a work around with pyvmomi library. Using host.EnterMaintenanceMode(TIMEOUT) API.
You need to have pyvmomi, requests libraries installed in your .venv.
I disabled SSL verification for my testing.
Posted a sample code to test this.
import requests
import pyVim
from pyVim import connect, task
import ssl
requests.packages.urllib3.disable_warnings()
TIMEOUT =30
context = ssl._create_unverified_context()
my_cluster = connect.SmartConnect(host="{{vcenter_ip}}", port=443, user="{{user}}", pwd="{{pwd}}", sslContext=context)
searcher = my_cluster.content.searchIndex
host = searcher.FindByIp(ip="{{host-ip}}", vmSearch=False)
task1 = host.EnterMaintenanceMode(TIMEOUT)
task.WaitForTask(task1)
print (host.name)
connect.Disconnect(my_cluster)
英文:
I found a work around with pyvmomi library. Using host.EnterMaintenanceMode(TIMEOUT) API.
You need to have pyvmomi, requests libraries installed in your .venv.
I disabled SSL verification for my testing.
Posted a sample code to test this.
import requests
import pyVim
from pyVim import connect, task
import ssl
requests.packages.urllib3.disable_warnings()
TIMEOUT =30
context = ssl._create_unverified_context()
my_cluster = connect.SmartConnect(host="{{vcenter_ip}}", port=443, user="{{user}}", pwd="{{pwd}}", sslContext=context)
searcher = my_cluster.content.searchIndex
host = searcher.FindByIp(ip="{{host-ip}}", vmSearch=False)
task1 = host.EnterMaintenanceMode(TIMEOUT)
task.WaitForTask(task1)
print (host.name)
connect.Disconnect(my_cluster)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论