pyvmomi-community-samples
pyvmomi-community-samples copied to clipboard
Help using tools/alarm.py
Hi, I'm trying to use the alarm.py tool to clear alarms from a specific VM and I'm not able to do so. I also tried using the list_host_alarms.py script with no luck.
list_host_alarm.py I have to run this script with the -nossl option because I have no trusted certificate installed, but I get the following error after setting the alarm_moref:
/home/cecuser/vmw/lib/python3.8/site-packages/urllib3/connectionpool.py:1013: InsecureRequestWarning: Unverified HTTPS request is being made to host '172.16.87.91'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
warnings.warn(
False
I tried to use the alarm.py tool to build a simple script to clear VM alarms as follows:
from tools import alarm, service_instance
from pyVim.connect import SmartConnect
si = SmartConnect(host="<vcenter_ip>", user="[email protected]", pwd="<vcenter_pwd>", disableSslCertValidation=True)
INDEX = si.content.searchIndex
VM = INDEX.FindByIp(ip='<vm_ip>', vmSearch=True)
alarm.print_triggered_alarms(entity=VM)
alarm.reset_alarm(entity_moref=VM._moId,entity_type="Vm",alarm_moref='alarm-514',service_instance=si)
In this case I can get the the triggered alarms, but when running the reset_alarm function I get the same error.
Can this be because I have no trusted SSL certs? Is there a way to make pyvmomi trust self-signed certificates?
Any advise will help greatly.
Thanks in advance