def on_event_vm(self, event, conexion, logger): """ Arg: event (Var from menu) conexion (Var whit a conexion datacenter) logger (Var objet to pass the log) """ fila = self.listadoVM #print (self, event, conexion) for i in range(len(fila)): if logger != None: logger.info(fila[i]) # El 9 elemento es el UUID if logger != None: logger.info(fila[8]) # List about vm detail in dialog box self.my_dialogo_texto = dialogos.Dialogo_texto(None, -1, 'Listados de Eventos VM') vm = conexion.searchIndex.FindByUuid(None, fila[8], True) if logger != None: logger.info('informacion vm: ' + vm.summary.config.name) snaptexto = "=====================\n " snaptexto += 'Maquna vm = ' + fila[1] + '\n' snaptexto += 'Triggerd: ' + str( alarm.print_triggered_alarms(entity=vm)) + '\n' snaptexto += 'Refs: ' + str(alarm.get_alarm_refs(entity=vm)) + '\n' # Since the above method will list all of the triggered alarms we will now # prompt the user for the entity info needed to reset an alarm from red # to green """ if alarm.reset_alarm(entity_moref=HOST._moId, entity_type='HostSystem', alarm_moref=alarm_mor.strip(), service_instance=SI): snaptexto +="Successfully reset alarm {0} to green.".format(alarm_mor)""" snaptexto += "=====================" self.my_dialogo_texto.salida_texto.SetValue(snaptexto) result = self.my_dialogo_texto.ShowModal( ) # pintamos la ventana con la informcion self.my_dialogo_texto.Destroy()
args = parser.get_args() si = service_instance.connect(args) INDEX = si.content.searchIndex if INDEX: if args.uuid: HOST = INDEX.FindByUuid(datacenter=None, uuid=args.uuid, vmSearch=False) elif args.esx_ip: HOST = INDEX.FindByIp(ip=args.esx_ip, vmSearch=False) if HOST is None: raise SystemExit("Unable to locate HostSystem.") alarm.print_triggered_alarms(entity=HOST) # Since the above method will list all of the triggered alarms we will now # prompt the user for the entity info needed to reset an alarm from red # to green try: alarm_mor = input( "Enter the alarm_moref from above to reset the alarm to green: ") except KeyboardInterrupt: # this is useful in case the user decides to quit and hits control-c print() raise SystemExit if alarm_mor: if alarm.reset_alarm(entity_moref=HOST._moId, entity_type='HostSystem', alarm_moref=alarm_mor.strip(), service_instance=si):
def listHostAlarms( self ): sIndex = self._vmConn.content.searchIndex if sIndex: vmHost = sIndex.FindByIp( datacenter=None, ip=self._hostAddr, vmSearch=False ) alarm.print_triggered_alarms( entity=vmHost )
required=True, action="store", help="The UUID of the HostSystem to list triggered alarms" " for.") MY_ARGS = PARSER.parse_args() cli.prompt_for_password(MY_ARGS) SI = SmartConnect(host=MY_ARGS.host, user=MY_ARGS.user, pwd=MY_ARGS.password, port=MY_ARGS.port) atexit.register(Disconnect, SI) INDEX = SI.content.searchIndex if INDEX: HOST = INDEX.FindByUuid(datacenter=None, uuid=MY_ARGS.uuid, vmSearch=False) alarm.print_triggered_alarms(entity=HOST) # Since the above method will list all of the triggered alarms we will now # prompt the user for the entity info needed to reset an alarm from red # to green try: alarm_mor = raw_input("Enter the alarm_moref from above to reset the " "alarm to green: ") except KeyboardInterrupt: # this is useful in case the user decides to quit and hits control-c print() raise SystemExit if alarm_mor: if alarm.reset_alarm(entity_moref=HOST._moId, entity_type='HostSystem', alarm_moref=alarm_mor.strip(), service_instance=SI):