Open muraliselva10 opened 5 years ago
I have executed your code. I do not find any issue as it works as expected. please check 'uuid' parameter and pass appropriate value. if you pass wrong value to uuid parameter, it will give 'none'. In your case, HOST variable carries 'none'
@muraliselva10 I am having the same problem with my code. However looking at your code, your passing "uuid" as a string, I assume you replace this with the actual uuid? With that being said, is vCenter even supported with this module? If I passed vCenter's UUID (which does not work btw) it would only show me alarms for THAT VM (which is vCenter) right? I want to see ALL alarms for ALL objects under vCenter. How can this be accomplished?
Also looking up the UUID and providing it as a parameter, I still get NoneType. It looks like INDEX carries a list of UUIDs, how can I crack open to find out what UUIDs are listed to compare?
Lastly, the instructions to go to the mob link dont work. I get a 503 error for ESXi hosts, and a blank pages for vCenter, again is the alarm module even supported for vCenter, not esxi hosts?
@kumahesh if you are able to get this to work can you provide more details on what you did?
Hello,
I would like to collect all the active alerts from the VCenter.
I tried code like below but it is not working. I initiaited connection using SmartConnectNoSSL for Vcenter Server.
Then i collected the UUID using MOB link below:(instanceUuid)
https://myvcentername/mob/?moid=ServiceInstance&doPath=content%2eabout
Indeed here it throws error.
None File "D:/python/vmware_python/alerts.py", line 20, in
alarm.print_triggered_alarms(entity=HOST)
File "D:\python\vmware_python\tools\alarm.py", line 133, in print_triggered_alarms
alarms = entity.triggeredAlarmState
AttributeError: 'NoneType' object has no attribute 'triggeredAlarmState'
Code tried:
import pyVmomi from vmware import details from pyVmomi import vim from pyVim.connect import SmartConnectNoSSL, Disconnect from datetime import datetime, timedelta from tools import alarm import atexit
hostname = "hostname" si = SmartConnectNoSSL(host=hostname, user="username", pwd="passwoed")
atexit.register(Disconnect, si) INDEX = si.content.searchIndex print(INDEX) if INDEX: HOST = INDEX.FindByUuid(datacenter=None, uuid='uuid', vmSearch=False) alarm.print_triggered_alarms(entity=HOST) else: print("Oops")