aboutsummaryrefslogtreecommitdiffstats
path: root/functest/energy/energy.py
diff options
context:
space:
mode:
authorCédric Ollivier <cedric.ollivier@orange.com>2018-02-12 10:04:58 +0100
committerCédric Ollivier <cedric.ollivier@orange.com>2018-02-12 10:12:10 +0100
commitafd36ed11701273fd70843082ca2af593e82ccd8 (patch)
treebe41fe35a2d4c9de8a9385a749da959b2fcd4a7f /functest/energy/energy.py
parenta7bb4ff6481247a33c1f6c4152dc86820332ce9a (diff)
Decrease log level in Energy messages
Energy could be safely disabled if one env var is missing. No error message should be printed in console [1]. It could be enhanced in a second step to print the reasons (missing or incorrect env vars) instead of the full stack. [1] https://build.opnfv.org/ci/view/functest/job/functest-apex-baremetal-daily-master/766/console Change-Id: I9c405edae16d186f02c632113de1317c89703991 Signed-off-by: Cédric Ollivier <cedric.ollivier@orange.com>
Diffstat (limited to 'functest/energy/energy.py')
-rw-r--r--functest/energy/energy.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/functest/energy/energy.py b/functest/energy/energy.py
index c6660406..c7da8f04 100644
--- a/functest/energy/energy.py
+++ b/functest/energy/energy.py
@@ -13,6 +13,7 @@
import json
import logging
import os
+import traceback
from functools import wraps
import requests
@@ -92,12 +93,10 @@ class EnergyRecorder(object):
# Singleton pattern for energy_recorder_api static member
# Load only if not previouly done
if EnergyRecorder.energy_recorder_api is None:
+ assert os.environ['NODE_NAME']
+ assert os.environ["ENERGY_RECORDER_API_URL"]
environment = os.environ['NODE_NAME']
- assert environment
-
- # API URL
energy_recorder_uri = os.environ["ENERGY_RECORDER_API_URL"]
- assert energy_recorder_uri
# Creds
creds_usr = os.environ.get("ENERGY_RECORDER_API_USER", "")
@@ -179,8 +178,9 @@ class EnergyRecorder(object):
except Exception: # pylint: disable=broad-except
# Default exception handler to ensure that method
# is safe for caller
- EnergyRecorder.logger.exception(
- "Error while submitting scenarion to energy recorder API"
+ EnergyRecorder.logger.info(
+ "Error while submitting scenarion to energy recorder API\n%s",
+ traceback.format_exc()
)
return_status = False
return return_status
@@ -205,8 +205,9 @@ class EnergyRecorder(object):
except Exception: # pylint: disable=broad-except
# Default exception handler to ensure that method
# is safe for caller
- EnergyRecorder.logger.exception(
- "Error while starting energy recorder API"
+ EnergyRecorder.logger.info(
+ "Error while starting energy recorder API\n%s",
+ traceback.format_exc()
)
return_status = False
return return_status
@@ -241,8 +242,9 @@ class EnergyRecorder(object):
except Exception: # pylint: disable=broad-except
# Default exception handler to ensure that method
# is safe for caller
- EnergyRecorder.logger.exception(
- "Error while stoping energy recorder API"
+ EnergyRecorder.logger.info(
+ "Error while stoping energy recorder API\n%s",
+ traceback.format_exc()
)
return_status = False
return return_status
@@ -283,8 +285,9 @@ class EnergyRecorder(object):
except Exception: # pylint: disable=broad-except
# Default exception handler to ensure that method
# is safe for caller
- EnergyRecorder.logger.exception(
- "Error while setting step on energy recorder API"
+ EnergyRecorder.logger.info(
+ "Error while setting step on energy recorder API\n%s",
+ traceback.format_exc()
)
return_status = False
return return_status
@@ -323,8 +326,9 @@ class EnergyRecorder(object):
except Exception: # pylint: disable=broad-except
# Default exception handler to ensure that method
# is safe for caller
- EnergyRecorder.logger.exception(
+ EnergyRecorder.logger.info(
"Error while getting current scenario from energy recorder API"
+ "\n%s", traceback.format_exc()
)
return_value = None
return return_value