def check_results(self, results, device, log): """Check results for errors.""" # If all results are failures we have a problem to report. if len(results) and True not in set(x[0] for x in results): log.error('%s WBEM: %s', device.id, result_errmsg(results[0][1])) # This will allow for an event to be created by the device class. results = "ERROR", result_errmsg(results[0][1]) return results try: results_new = [] for success, instances in results: if success: inst = [] for instance in instances: inst.append(instance.__dict__) results_new.append((success, inst)) else: results_new.append((success, instances)) log.debug('Results: {0}'.format(results_new)) except: pass return results
def check_results(self, results, device, log): """Check results for errors.""" # If all results are failures we have a problem to report. if len(results) and True not in set(x[0] for x in results): log.error('%s WBEM: %s', device.id, result_errmsg(results[0][1])) #This will allow for an event to be created by the device class. results = "ERROR", result_errmsg(results[0][1]) return results return results
def onError(self, result, config): errmsg = 'WBEM: %s' % result_errmsg(result) log.error('%s %s', config.id, errmsg) data = self.new_data() data['events'].append({ 'eventClassKey': 'wbemCollectionError', 'eventKey': 'wbemCollection', 'summary': errmsg, 'device': config.id, }) return data
def onError(self, result, config): errmsg = 'WBEM: %s' % result_errmsg(result) ds0 = config.datasources[0] if isinstance(result, failure.Failure) and isinstance(result.value, defer.CancelledError): errmsg = 'WBEM: %s' % 'request time exceeds value of zWBEMRequestTimeout' log.error('%s %s', config.id, errmsg) data = self.new_data() data['events'].append({ 'eventClassKey': 'wbemCollectionError', 'eventKey': 'wbemCollection', 'summary': errmsg, 'device': config.id, 'severity': ds0.severity, 'eventClass': ds0.eventClass }) return data
def parse_multiple(results): '''Parse multiple WBEM results''' output = {} if len(results) > 0: for result in results: # expecting a boolean, wbem output tuple if len(result) != 2: log.warn("WBEM: Unexpected output ({})".format(result)) continue success, instances = result if not success: msg = result_errmsg(instances) if not 'Connection was closed cleanly' in msg: log.warn('WBEM Query Failed: {}'.format(msg)) continue if not instances: continue klass = instances[0].classname # return a list of dictionaries output[klass] = WBEMParser.parse_results(instances) return output