vmware/pyvmomi-community-samples

Active alerts from VCenter

Open

#526 aberto em 9 de nov. de 2018

Ver no GitHub
 (2 comments) (0 reactions) (0 assignees)Python (914 forks)batch import
help wanted

Métricas do repositório

Stars
 (972 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

Description

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")

Guia do colaborador