diff --git a/tools/load_generator/load_generator.py b/tools/load_generator/load_generator.py index a7cfd68b5..01aee4d77 100644 --- a/tools/load_generator/load_generator.py +++ b/tools/load_generator/load_generator.py @@ -107,8 +107,8 @@ class StressNotificationsService(cotyledon.Service): {}, notification_type, payload) - except Exception as e: - LOG.exception('Cannot notify - %s - %s', notification_type, e) + except Exception: + LOG.exception('Cannot notify - %s', notification_type) def create_port(port_num, instance_id, host_id, net_id): diff --git a/vitrage/api/controllers/v1/alarm.py b/vitrage/api/controllers/v1/alarm.py index ae6c559b5..2f258ed04 100755 --- a/vitrage/api/controllers/v1/alarm.py +++ b/vitrage/api/controllers/v1/alarm.py @@ -56,7 +56,7 @@ class AlarmsController(RootRestController): return self._get_alarms(vitrage_id, all_tenants) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get alarms %s', to_unicode) + LOG.exception('Failed to get alarms.') abort(404, to_unicode) @staticmethod @@ -73,7 +73,7 @@ class AlarmsController(RootRestController): except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to open file %s ', to_unicode) + LOG.exception('Failed to open file.') abort(404, to_unicode) @pecan.expose('json') @@ -89,7 +89,7 @@ class AlarmsController(RootRestController): return self._show_alarm(vitrage_id) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to load json %s ', to_unicode) + LOG.exception('Failed to load JSON.') abort(404, to_unicode) @staticmethod @@ -105,5 +105,5 @@ class AlarmsController(RootRestController): except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to load json %s ', to_unicode) + LOG.exception('Failed to load JSON.') abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/count.py b/vitrage/api/controllers/v1/count.py index 0100c73d2..5f95f5c41 100755 --- a/vitrage/api/controllers/v1/count.py +++ b/vitrage/api/controllers/v1/count.py @@ -52,5 +52,5 @@ class CountsController(RootRestController): except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get alarm counts %s', to_unicode) + LOG.exception('failed to get alarm count.') abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/rca.py b/vitrage/api/controllers/v1/rca.py index 1d49f453f..efe192de4 100644 --- a/vitrage/api/controllers/v1/rca.py +++ b/vitrage/api/controllers/v1/rca.py @@ -61,5 +61,5 @@ class RCAController(RootRestController): except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get rca %s ', to_unicode) + LOG.exception('Failed to get RCA.') abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/resource.py b/vitrage/api/controllers/v1/resource.py index 60e189cb6..0a1fff5ba 100644 --- a/vitrage/api/controllers/v1/resource.py +++ b/vitrage/api/controllers/v1/resource.py @@ -48,7 +48,7 @@ class ResourcesController(RootRestController): return self._get_resources(resource_type, all_tenants) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to list resources %s', to_unicode) + LOG.exception('Failed to list resources.') abort(404, to_unicode) @staticmethod @@ -66,7 +66,7 @@ class ResourcesController(RootRestController): return resources except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get resources %s ', to_unicode) + LOG.exception('Failed to get resources.') abort(404, to_unicode) @pecan.expose('json') @@ -96,6 +96,6 @@ class ResourcesController(RootRestController): return json.loads(resource) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to show resource with vitrage_id(%s),' - 'Exception: %s', vitrage_id, to_unicode) + LOG.exception('failed to show resource with vitrage_id(%s).', + vitrage_id) abort(404, to_unicode) diff --git a/vitrage/api/controllers/v1/template.py b/vitrage/api/controllers/v1/template.py index b5eb54ed7..db2e899ae 100644 --- a/vitrage/api/controllers/v1/template.py +++ b/vitrage/api/controllers/v1/template.py @@ -44,7 +44,7 @@ class TemplateController(RootRestController): return self._get_templates() except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get template list %s', to_unicode) + LOG.exception('failed to get template list.') abort(404, to_unicode) @pecan.expose('json') @@ -61,9 +61,8 @@ class TemplateController(RootRestController): return self._show_template(template_uuid) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to show template %s --> %s', - template_uuid, - to_unicode) + LOG.exception('Failed to show template %s.', + template_uuid) abort(404, to_unicode) @pecan.expose('json') @@ -78,7 +77,7 @@ class TemplateController(RootRestController): try: return self._delete(uuid) except Exception as e: - LOG.exception('failed to delete template %s', e) + LOG.exception('Failed to delete template.') abort(404, str(e)) @pecan.expose('json') @@ -95,7 +94,7 @@ class TemplateController(RootRestController): try: return self._add(templates, template_type) except Exception as e: - LOG.exception('failed to add template %s', e) + LOG.exception('Failed to add template.') abort(404, str(e)) @pecan.expose('json') @@ -115,7 +114,7 @@ class TemplateController(RootRestController): return self._validate(templates, template_type) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to validate template(s) %s', to_unicode) + LOG.exception('Failed to validate template(s).') abort(404, to_unicode) @classmethod @@ -127,7 +126,7 @@ class TemplateController(RootRestController): return [cls._db_template_to_dict(t) for t in templates] except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get template list %s ', to_unicode) + LOG.exception('Failed to get template list.') abort(404, to_unicode) @staticmethod @@ -139,7 +138,7 @@ class TemplateController(RootRestController): return templates[0].file_content except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to show template with uuid: %s ', to_unicode) + LOG.exception('Failed to show template with uuid: %s ', uuid) abort(404, to_unicode) @staticmethod @@ -153,7 +152,7 @@ class TemplateController(RootRestController): return json.loads(result_json) except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to open template file(s) %s ', to_unicode) + LOG.exception('Failed to open template file(s).') abort(404, to_unicode) @classmethod @@ -166,7 +165,7 @@ class TemplateController(RootRestController): template_type=template_type) return results except Exception as e: - LOG.exception('failed to add template file %s ', e) + LOG.exception('Failed to add template file.') abort(404, str(e)) @staticmethod @@ -189,5 +188,5 @@ class TemplateController(RootRestController): uuids=uuid) return results except Exception as e: - LOG.exception('failed to delete template %s ', e) + LOG.exception('Failed to delete template.') abort(404, str(e)) diff --git a/vitrage/api/controllers/v1/topology.py b/vitrage/api/controllers/v1/topology.py index 4de4ae04f..705ef28c3 100644 --- a/vitrage/api/controllers/v1/topology.py +++ b/vitrage/api/controllers/v1/topology.py @@ -91,7 +91,7 @@ class TopologyController(RootRestController): except Exception as e: to_unicode = encodeutils.exception_to_unicode(e) - LOG.exception('failed to get topology %s ', to_unicode) + LOG.exception('failed to get topology.') abort(404, to_unicode) @staticmethod diff --git a/vitrage/api/controllers/v1/webhook.py b/vitrage/api/controllers/v1/webhook.py index d5abc9da2..48c66ab64 100644 --- a/vitrage/api/controllers/v1/webhook.py +++ b/vitrage/api/controllers/v1/webhook.py @@ -46,7 +46,7 @@ class WebhookController(RootRestController): try: return self._get_all(all_tenants) except Exception as e: - LOG.exception('failed to list webhooks %s', e) + LOG.exception('Failed to list webhooks.') abort(404, str(e)) @staticmethod @@ -68,7 +68,7 @@ class WebhookController(RootRestController): try: return self._get(id) except Exception as e: - LOG.exception('Failed to get webhooks %s', e) + LOG.exception('Failed to get webhooks.') abort(404, str(e)) @staticmethod @@ -91,7 +91,7 @@ class WebhookController(RootRestController): try: return self._post(**kwargs) except Exception as e: - LOG.exception('Failed to add webhooks %s', e) + LOG.exception('Failed to add webhooks.') abort(400, str(e)) @staticmethod @@ -125,8 +125,7 @@ class WebhookController(RootRestController): try: return self._delete_registration(id) except Exception as e: - LOG.exception('Failed to delete webhook %s: ' - '%s' % (id, str(e))) + LOG.exception('Failed to delete webhook "%s"', id) abort(404, str(e)) @staticmethod diff --git a/vitrage/datasources/aodh/driver.py b/vitrage/datasources/aodh/driver.py index 4783c52fa..c1141f096 100644 --- a/vitrage/datasources/aodh/driver.py +++ b/vitrage/datasources/aodh/driver.py @@ -91,8 +91,8 @@ class AodhDriver(AlarmDriverBase): aodh_alarms = self.client.alarm.list() return [self._convert_alarm(alarm) for alarm in aodh_alarms if alarm is not None] - except Exception as e: - LOG.exception("Failed to get all alarms, Exception: %s", e) + except Exception: + LOG.exception("Failed to get all alarms.") return [] def _is_erroneous(self, alarm): @@ -289,9 +289,8 @@ class AodhDriver(AlarmDriverBase): entity = old_alarm.copy() try: entity[AodhProps.STATE] = event[AodhProps.DETAIL][AodhProps.STATE] - except Exception as e: - LOG.exception("Failed to Convert alarm state" - " transition event - %s", e) + except Exception: + LOG.exception("Failed to Convert alarm state transition event.") return self._filter_and_cache_alarm(entity, old_alarm, self._filter_get_change, diff --git a/vitrage/datasources/ceilometer/driver.py b/vitrage/datasources/ceilometer/driver.py index 6b841cb5c..7ea0d7f77 100644 --- a/vitrage/datasources/ceilometer/driver.py +++ b/vitrage/datasources/ceilometer/driver.py @@ -61,8 +61,8 @@ class CeilometerDriver(AlarmDriverBase): aodh_alarms = self.client.alarms.list() return [self._convert_alarm(alarm) for alarm in aodh_alarms if alarm is not None] - except Exception as e: - LOG.exception("Failed to get all alarms, Exception: %s", e) + except Exception: + LOG.exception("Failed to get all alarms.") return [] def _is_erroneous(self, alarm): @@ -358,9 +358,8 @@ class CeilometerDriver(AlarmDriverBase): entity = old_alarm.copy() try: entity[CeilProps.STATE] = event[CeilProps.DETAIL][CeilProps.STATE] - except Exception as e: - LOG.exception("Failed to Convert alarm state" - " transition event - %s", e) + except Exception: + LOG.exception("Failed to Convert alarm state transition event.") return self._filter_and_cache_alarm(entity, old_alarm, self._filter_get_change, diff --git a/vitrage/datasources/collectd/driver.py b/vitrage/datasources/collectd/driver.py index 163201752..947f20960 100644 --- a/vitrage/datasources/collectd/driver.py +++ b/vitrage/datasources/collectd/driver.py @@ -75,8 +75,8 @@ class CollectdDriver(AlarmDriverBase): LOG.debug('collectd mappings: %s', str(mappings)) return mappings - except Exception as e: - LOG.exception('failed in init %s ', e) + except Exception: + LOG.exception('Failed in init.') return {} def enrich_event(self, event, event_type): diff --git a/vitrage/datasources/collector_notifier.py b/vitrage/datasources/collector_notifier.py index 54da41429..4296593f7 100644 --- a/vitrage/datasources/collector_notifier.py +++ b/vitrage/datasources/collector_notifier.py @@ -53,6 +53,6 @@ class CollectorNotifier(object): try: self.oslo_notifier.info({}, '', enriched_event) - except Exception as e: - LOG.exception('Datasource event cannot be notified - %s\n' - 'Error - %s', enriched_event, e) + except Exception: + LOG.exception('Datasource event cannot be notified - %s.', + enriched_event) diff --git a/vitrage/datasources/kubernetes/driver.py b/vitrage/datasources/kubernetes/driver.py index 44c26732a..5fcb888cd 100644 --- a/vitrage/datasources/kubernetes/driver.py +++ b/vitrage/datasources/kubernetes/driver.py @@ -51,8 +51,8 @@ class KubernetesDriver(DriverBase): return return k8s_client - except Exception as e: - LOG.exception('Create k8s client - Got Exception: %s', e) + except Exception: + LOG.exception('Create k8s client - Got Exception') def get_all(self, datasource_action): return self.make_pickleable(self._prepare_entities( diff --git a/vitrage/datasources/nagios/config.py b/vitrage/datasources/nagios/config.py index 9ff084d8b..f54a5ee55 100644 --- a/vitrage/datasources/nagios/config.py +++ b/vitrage/datasources/nagios/config.py @@ -35,8 +35,8 @@ class NagiosConfig(object): nagios = nagios_config[NAGIOS] # nagios root in the yaml file self.mappings = [self._create_mapping(config) for config in nagios] - except Exception as e: - LOG.exception('failed in init %s ', e) + except Exception: + LOG.exception('Failed in init.') self.mappings = [] @staticmethod diff --git a/vitrage/datasources/nagios/parser.py b/vitrage/datasources/nagios/parser.py index 8c401923d..54ec5b26c 100644 --- a/vitrage/datasources/nagios/parser.py +++ b/vitrage/datasources/nagios/parser.py @@ -37,9 +37,8 @@ class NagiosParser(object): return self._parse_services(status_tables) - except Exception as e: - LOG.exception('Failed to get nagios services %s', e) - return None + except Exception: + LOG.exception('Failed to get nagios services.') def _parse_services(self, status_tables): LOG.debug('Start parsing Nagios status') diff --git a/vitrage/datasources/rpc_service.py b/vitrage/datasources/rpc_service.py index 29da16d66..8655c36cc 100644 --- a/vitrage/datasources/rpc_service.py +++ b/vitrage/datasources/rpc_service.py @@ -79,12 +79,11 @@ class DriversEndpoint(object): fault_interval = self.conf.datasources.snapshot_interval_on_fault def run_driver(driver): - ok = True try: - return ok, driver.get_all(action) - except Exception as e: - LOG.exception('driver failed %s', e) - return not ok, driver + return True, driver.get_all(action) + except Exception: + LOG.exception('Driver failed') + return False, driver result = list(self.pool.map(run_driver, drivers)) failed_drivers = [driver for success, driver in result if not success] diff --git a/vitrage/datasources/zabbix/driver.py b/vitrage/datasources/zabbix/driver.py index 8280088d4..0d448759e 100644 --- a/vitrage/datasources/zabbix/driver.py +++ b/vitrage/datasources/zabbix/driver.py @@ -60,8 +60,8 @@ class ZabbixDriver(AlarmDriverBase): self._client.login( self.conf.zabbix.user, self.conf.zabbix.password) - except Exception as e: - LOG.exception('pyzabbix.ZabbixAPI %s', e) + except Exception: + LOG.exception('pyzabbix.ZabbixAPI error occurred.') self._client = None def _vitrage_type(self): @@ -168,8 +168,8 @@ class ZabbixDriver(AlarmDriverBase): } return mappings - except Exception as e: - LOG.exception('failed in init %s ', e) + except Exception: + LOG.exception('Failed in init.') return {} def enrich_event(self, event, event_type): diff --git a/vitrage/entity_graph/consistency/consistency_enforcer.py b/vitrage/entity_graph/consistency/consistency_enforcer.py index 5a1e4edcd..73b4c5fdf 100644 --- a/vitrage/entity_graph/consistency/consistency_enforcer.py +++ b/vitrage/entity_graph/consistency/consistency_enforcer.py @@ -60,9 +60,8 @@ class ConsistencyEnforcer(object): stale_entities) self._push_events_to_queue(stale_entities, GraphAction.DELETE_ENTITY) - except Exception as e: - LOG.exception( - 'Error in deleting vertices from entity_graph: %s', e) + except Exception: + LOG.exception('Error in deleting vertices from entity_graph.') def _find_placeholder_entities(self): vitrage_sample_tstmp = str(utcnow() - timedelta( diff --git a/vitrage/entity_graph/datasource_rpc.py b/vitrage/entity_graph/datasource_rpc.py index c638bf71c..3796c4ff3 100644 --- a/vitrage/entity_graph/datasource_rpc.py +++ b/vitrage/entity_graph/datasource_rpc.py @@ -49,8 +49,8 @@ def get_all(rpc_client, events_coordination, driver_names, action, events = _call(client) else: events = _call(rpc_client) - except oslo_messaging.MessagingTimeout as e: - LOG.exception('Got MessagingTimeout %s', e) + except oslo_messaging.MessagingTimeout: + LOG.exception('Got MessagingTimeout') events = _call(rpc_client) if retry_on_fault else [] t2 = time.time() events_coordination.handle_multiple_low_priority(events) diff --git a/vitrage/entity_graph/graph_init.py b/vitrage/entity_graph/graph_init.py index cc6f44c4d..83e1e20f3 100644 --- a/vitrage/entity_graph/graph_init.py +++ b/vitrage/entity_graph/graph_init.py @@ -85,8 +85,8 @@ class EventsCoordination(object): def do_work(event): try: return do_work_func(event) - except Exception as e: - LOG.exception('Got Exception %s for event %s', e, str(event)) + except Exception: + LOG.exception('Got Exception for event %s', str(event)) self._do_work_func = do_work @@ -146,5 +146,5 @@ class PushNotificationsEndpoint(object): def info(self, ctxt, publisher_id, event_type, payload, metadata): try: self.process_event_callback(payload) - except Exception as e: - LOG.exception(e) + except Exception: + LOG.exception('Failed to process event callback.') diff --git a/vitrage/entity_graph/mappings/datasource_info_mapper.py b/vitrage/entity_graph/mappings/datasource_info_mapper.py index 3fb63c4d6..b6032042f 100644 --- a/vitrage/entity_graph/mappings/datasource_info_mapper.py +++ b/vitrage/entity_graph/mappings/datasource_info_mapper.py @@ -124,11 +124,10 @@ class DatasourceInfoMapper(object): self.OPERATIONAL_VALUES: operational_values, self.PRIORITY_VALUES: priority_values } - except Exception as e: - LOG.exception("Exception: %s", e) + except Exception: datasource = os.path.splitext(file_name)[0] - LOG.error('erroneous data sources is %s', - erroneous_datasources_conf.append(datasource)) + erroneous_datasources_conf.append(datasource) + LOG.exception('Erroneous data source is %s', datasource) self._check_value_confs_exists( [key for key in valid_datasources_conf.keys()], diff --git a/vitrage/entity_graph/processor/notifier.py b/vitrage/entity_graph/processor/notifier.py index 1f6b19984..253d7468e 100644 --- a/vitrage/entity_graph/processor/notifier.py +++ b/vitrage/entity_graph/processor/notifier.py @@ -97,8 +97,8 @@ class GraphNotifier(object): {}, notification_type, curr.properties) - except Exception as e: - LOG.exception('Cannot notify - %s - %s', notification_type, e) + except Exception: + LOG.exception('Cannot notify - %s.', notification_type) def _get_notification_type(before, current, is_vertex): diff --git a/vitrage/entity_graph/processor/processor.py b/vitrage/entity_graph/processor/processor.py index ea89e8a81..0b7efbd10 100644 --- a/vitrage/entity_graph/processor/processor.py +++ b/vitrage/entity_graph/processor/processor.py @@ -317,8 +317,8 @@ class Processor(processor.ProcessorBase): return None self.info_mapper.vitrage_aggregate_values(vertex, graph_vertex) - except Exception as e: - LOG.exception("Calculate aggregated state failed - %s", e) + except Exception: + LOG.exception("Calculate aggregated state failed.") def _enrich_event(self, event): attr = self.transformer_manager.get_enrich_query(event) diff --git a/vitrage/entity_graph/processor/transformer_manager.py b/vitrage/entity_graph/processor/transformer_manager.py index 8a3232a6b..0db831078 100644 --- a/vitrage/entity_graph/processor/transformer_manager.py +++ b/vitrage/entity_graph/processor/transformer_manager.py @@ -50,9 +50,9 @@ class TransformerManager(object): conf[datasource_type].transformer, transformers, conf) - except Exception as e: - LOG.exception('Failed to register transformer %s. ' - 'Exception: %s', datasource_type, e) + except Exception: + LOG.exception('Failed to register transformer %s.', + datasource_type) transformers[VITRAGE_DATASOURCE] = importutils.import_object( "%s.%s" % (EvaluatorEventTransformer.__module__, diff --git a/vitrage/entity_graph/scheduler.py b/vitrage/entity_graph/scheduler.py index b6779cef2..c2052bb5f 100644 --- a/vitrage/entity_graph/scheduler.py +++ b/vitrage/entity_graph/scheduler.py @@ -59,8 +59,8 @@ class Scheduler(object): if self.graph_persistor: try: self.graph_persistor.store_graph(graph=self.graph) - except Exception as e: - LOG.exception('persist failed %s', e) + except Exception: + LOG.exception('Persist failed.') self.periodic.add(persist_periodic) LOG.info("added persist_periodic (spacing=%s)", spacing) @@ -72,8 +72,8 @@ class Scheduler(object): def consistency_periodic(): try: self.consistency.periodic_process() - except Exception as e: - LOG.exception('run_consistency failed %s', e) + except Exception: + LOG.exception('run_consistency failed.') self.periodic.add(consistency_periodic) LOG.info("added consistency_periodic (spacing=%s)", spacing) @@ -89,8 +89,8 @@ class Scheduler(object): self.events_coordination, self.conf.datasources.types, DatasourceAction.SNAPSHOT) - except Exception as e: - LOG.exception('get_all_periodic failed %s', e) + except Exception: + LOG.exception('get_all_periodic failed.') self.periodic.add(get_all_periodic) LOG.info("added get_all_periodic (spacing=%s)", spacing) @@ -106,9 +106,9 @@ class Scheduler(object): ds_rpc.get_changes(rpc_client, self.events_coordination, driver_name) - except Exception as e: - LOG.exception('get_changes_periodic %s failed %s', - driver_name, e) + except Exception: + LOG.exception('get_changes_periodic "%s" failed.', + driver_name) self.periodic.add(get_changes_periodic) LOG.info("added get_changes_periodic %s (spacing=%s)", diff --git a/vitrage/entity_graph/workers.py b/vitrage/entity_graph/workers.py index cf30e5036..ca71b1c33 100644 --- a/vitrage/entity_graph/workers.py +++ b/vitrage/entity_graph/workers.py @@ -232,8 +232,8 @@ class GraphCloneWorkerBase(cotyledon.Service): try: next_task = self._task_queue.get() self.do_task(next_task) - except Exception as e: - LOG.exception("Graph may not be in sync: exception %s", e) + except Exception: + LOG.exception("Graph may not be in sync.") self._task_queue.task_done() def do_task(self, task): diff --git a/vitrage/evaluator/actions/notifier.py b/vitrage/evaluator/actions/notifier.py index 4871d8ea6..195516184 100644 --- a/vitrage/evaluator/actions/notifier.py +++ b/vitrage/evaluator/actions/notifier.py @@ -72,7 +72,6 @@ class EvaluatorNotifier(object): {}, NotifierEventTypes.EXECUTE_EXTERNAL_ACTION, properties) - except Exception as e: - LOG.exception('Cannot notify - %s - %s', - NotifierEventTypes.EXECUTE_EXTERNAL_ACTION, - e) + except Exception: + LOG.exception('Cannot notify - %s.', + NotifierEventTypes.EXECUTE_EXTERNAL_ACTION) diff --git a/vitrage/evaluator/scenario_evaluator.py b/vitrage/evaluator/scenario_evaluator.py index 6764e9ca2..151ec566c 100644 --- a/vitrage/evaluator/scenario_evaluator.py +++ b/vitrage/evaluator/scenario_evaluator.py @@ -133,10 +133,9 @@ class ScenarioEvaluator(object): actions_to_preform = [] try: actions_to_preform = self._analyze_and_filter_actions(actions) - except Exception as e: - LOG.error("Evaluator error, will not execute actions %s", - str(actions)) - LOG.exception("Caught: %s", e) + except Exception: + LOG.exception("Evaluator error, will not execute actions %s", + str(actions)) for action in actions_to_preform: LOG.info('Action: %s', self._action_str(action)) diff --git a/vitrage/machine_learning/plugins/jaccard_correlation/accumulation_persistor_utils.py b/vitrage/machine_learning/plugins/jaccard_correlation/accumulation_persistor_utils.py index 87ba13140..f3fad09bb 100644 --- a/vitrage/machine_learning/plugins/jaccard_correlation/accumulation_persistor_utils.py +++ b/vitrage/machine_learning/plugins/jaccard_correlation/accumulation_persistor_utils.py @@ -49,11 +49,11 @@ def save_accumulated_data(data_manager): try: with open(ACTIVITY_PATH, 'wb') as activity_f: pickle.dump(activity, activity_f) - except Exception as e: - LOG.exception('Cannot save alarms_intersect - %s', e) + except Exception: + LOG.exception('Cannot save alarms_intersect.') try: with open(INTERSECT_PATH, 'wb') as intersect_f: pickle.dump(intersects, intersect_f) - except Exception as e: - LOG.exception('Cannot save alarms_intersect - %s', e) + except Exception: + LOG.exception('Cannot save alarms_intersect.') diff --git a/vitrage/machine_learning/plugins/jaccard_correlation/correlation_manager.py b/vitrage/machine_learning/plugins/jaccard_correlation/correlation_manager.py index 2e7f87e9d..e4bef33c3 100644 --- a/vitrage/machine_learning/plugins/jaccard_correlation/correlation_manager.py +++ b/vitrage/machine_learning/plugins/jaccard_correlation/correlation_manager.py @@ -105,8 +105,8 @@ class CorrelationManager(object): alarm[0][0] + " <-> alarm " + alarm[0][3] + " on " + alarm[0][2] + " with score " + str(alarm[1]) + "\n") - except Exception as e: - LOG.exception('Cannot save correlations - %s', e) + except Exception: + LOG.exception('Cannot save correlations.') if os.path.isfile(self.last_written_file): os.remove(self.last_written_file) diff --git a/vitrage/messaging.py b/vitrage/messaging.py index 46e230e92..622edd965 100644 --- a/vitrage/messaging.py +++ b/vitrage/messaging.py @@ -78,7 +78,7 @@ class VitrageNotifier(object): if self.notifier: try: self.notifier.info({}, event_type, data) - except Exception as e: - LOG.exception('Notifier cannot notify - %e', e) + except Exception: + LOG.exception('Notifier cannot notify.') else: LOG.error('Notifier cannot notify') diff --git a/vitrage/notifier/plugins/aodh/aodh_notifier.py b/vitrage/notifier/plugins/aodh/aodh_notifier.py index 415da7ae5..05d38028a 100644 --- a/vitrage/notifier/plugins/aodh/aodh_notifier.py +++ b/vitrage/notifier/plugins/aodh/aodh_notifier.py @@ -63,9 +63,8 @@ class AodhNotifier(NotifierBase): try: LOG.info('Aodh Alarm - Activate: ' + str(alarm_request)) return self.client.alarm.create(alarm_request) - except Exception as e: - LOG.exception('Failed to activate Aodh Alarm Got Exception: %s', e) - return + except Exception: + LOG.exception('Failed to activate Aodh Alarm. Got Exception.') def _update_aodh_alarm(self, alarm, state): aodh_id = alarm.get(VProps.ID) @@ -74,9 +73,8 @@ class AodhNotifier(NotifierBase): alarm_update = {AodhState: state} return self.client.alarm.update(alarm_id=aodh_id, alarm_update=alarm_update) - except Exception as e: - LOG.exception('Failed to update Aodh Alarm Got Exception: %s', e) - return + except Exception: + LOG.exception('Failed to update Aodh Alarm. Got Exception.') def _alarm_request(data, state): diff --git a/vitrage/notifier/plugins/nova/nova_notifier.py b/vitrage/notifier/plugins/nova/nova_notifier.py index 32b0aa1b7..17f2070de 100644 --- a/vitrage/notifier/plugins/nova/nova_notifier.py +++ b/vitrage/notifier/plugins/nova/nova_notifier.py @@ -61,8 +61,8 @@ class NovaNotifier(NotifierBase): response = self.client.services.force_down( host_id, 'nova-compute', is_down) LOG.info('RESPONSE %s', str(response.to_dict())) - except Exception as e: - LOG.exception('Failed to services.force_down - %s', e) + except Exception: + LOG.exception('Failed to services.force_down.') def _reset_instance_state(self, server_id, is_down): state = InstanceState.ERROR if is_down else InstanceState.ACTIVE @@ -71,5 +71,5 @@ class NovaNotifier(NotifierBase): str(server_id), str(state)) response = self.client.servers.reset_state(server_id, state) LOG.info('RESPONSE %s', str(response)) - except Exception as e: - LOG.exception('Failed to execute servers.reset_state - %s', e) + except Exception: + LOG.exception('Failed to execute servers.reset_state.') diff --git a/vitrage/notifier/plugins/snmp/snmp_notifier.py b/vitrage/notifier/plugins/snmp/snmp_notifier.py index d94ee6857..d7d8f3432 100644 --- a/vitrage/notifier/plugins/snmp/snmp_notifier.py +++ b/vitrage/notifier/plugins/snmp/snmp_notifier.py @@ -42,10 +42,8 @@ class SnmpNotifier(NotifierBase): try: self.snmp_sender.send_snmp(self._parse_alarm_data(data)) - except Exception as e: - LOG.exception('Vitrage snmp Error: ' - 'Failed to send SNMP trap: %s', e) - return + except Exception: + LOG.exception('Vitrage SNMP Error: Failed to send SNMP trap.') @staticmethod def _parse_alarm_data(data): diff --git a/vitrage/notifier/plugins/webhook/webhook.py b/vitrage/notifier/plugins/webhook/webhook.py index 3157afa4a..0561b727c 100644 --- a/vitrage/notifier/plugins/webhook/webhook.py +++ b/vitrage/notifier/plugins/webhook/webhook.py @@ -113,9 +113,8 @@ class Webhook(NotifierBase): LOG.info('posted %s to %s. Response status %s, reason %s', str(webhook_data), str(webhook[URL]), resp.status_code, resp.reason) - except Exception as e: - LOG.exception("Could not post to webhook %s %s" % ( - str(webhook['id']), str(e))) + except Exception: + LOG.exception("Could not post to webhook '%s'", str(webhook['id'])) def _load_webhooks(self): db_webhooks = self._db.webhooks.query() diff --git a/vitrage/os_clients.py b/vitrage/os_clients.py index 9e0240337..6af5567ec 100644 --- a/vitrage/os_clients.py +++ b/vitrage/os_clients.py @@ -57,8 +57,8 @@ def aodh_client(conf): session=keystone_client.get_session(conf)) LOG.info('Aodh client created') return client - except Exception as e: - LOG.exception('Create Aodh client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Aodh client - Got Exception.') def ceilometer_client(conf): @@ -71,8 +71,8 @@ def ceilometer_client(conf): ) LOG.info('Ceilometer client created') return client - except Exception as e: - LOG.exception('Create Ceilometer client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Ceilometer client - Got Exception.') def nova_client(conf): @@ -85,8 +85,8 @@ def nova_client(conf): ) LOG.info('Nova client created') return client - except Exception as e: - LOG.exception('Create Nova client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Nova client - Got Exception.') def cinder_client(conf): @@ -99,8 +99,8 @@ def cinder_client(conf): ) LOG.info('Cinder client created') return client - except Exception as e: - LOG.exception('Create Cinder client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Cinder client - Got Exception.') def glance_client(conf): @@ -113,8 +113,8 @@ def glance_client(conf): ) LOG.info('Glance client created') return client - except Exception as e: - LOG.exception('Create Glance client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Glance client - Got Exception') def neutron_client(conf): @@ -126,8 +126,8 @@ def neutron_client(conf): ) LOG.info('Neutron client created') return client - except Exception as e: - LOG.exception('Create Neutron client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Neutron client - Got Exception.') def heat_client(conf): @@ -140,8 +140,8 @@ def heat_client(conf): ) LOG.info('Heat client created') return client - except Exception as e: - LOG.exception('Create Heat client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Heat client - Got Exception.') def mistral_client(conf): @@ -153,5 +153,5 @@ def mistral_client(conf): ) LOG.info('Mistral client created') return client - except Exception as e: - LOG.exception('Create Mistral client - Got Exception: %s', e) + except Exception: + LOG.exception('Create Mistral client - Got Exception.')