aboutsummaryrefslogtreecommitdiffstats
path: root/functest/energy/energy.py
diff options
context:
space:
mode:
authorBenoit HERARD <benoit.herard@orange.com>2017-09-27 14:01:28 +0200
committerBenoit HERARD <benoit.herard@orange.com>2017-09-27 16:15:33 +0200
commit405a0872282f5b29bb9e60ba19b11b17c8047647 (patch)
tree0bb675f7b9d788690c038dae1ad4013bd922a5d2 /functest/energy/energy.py
parent112e652af2b2f61192d3f1bd903522a14be06b94 (diff)
Add log details on SDK first connection.
On first call to energy recording API, if API is unreachable, SDK don't do anything anymore. This change add logs on error for this first connection. Change-Id: I88892c769d6208c6ddf5d714d438ab584826844e Signed-off-by: Benoit HERARD <benoit.herard@orange.com>
Diffstat (limited to 'functest/energy/energy.py')
-rw-r--r--functest/energy/energy.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/functest/energy/energy.py b/functest/energy/energy.py
index 508f18e7..2aabc06d 100644
--- a/functest/energy/energy.py
+++ b/functest/energy/energy.py
@@ -78,7 +78,7 @@ class EnergyRecorder(object):
INITIAL_STEP = "running"
# Default connection timeout
- CONNECTION_TIMOUT = urllib3.Timeout(connect=1, read=3)
+ CONNECTION_TIMEOUT = urllib3.Timeout(connect=1, read=3)
@staticmethod
def load_config():
@@ -122,11 +122,12 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT)
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT)
api_available = json.loads(resp.text)["status"] == "OK"
- except Exception: # pylint: disable=broad-except
- EnergyRecorder.logger.error(
- "Energy recorder API is not available")
+ except Exception as exc: # pylint: disable=broad-except
+ EnergyRecorder.logger.info(
+ "Energy recorder API is not available, cause=%s",
+ exc.message)
api_available = False
# Final config
EnergyRecorder.energy_recorder_api = {
@@ -165,7 +166,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -227,7 +228,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -269,7 +270,7 @@ class EnergyRecorder(object):
headers={
'content-type': 'application/json'
},
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code != 200:
EnergyRecorder.logger.error(
@@ -302,7 +303,7 @@ class EnergyRecorder(object):
response = requests.get(
EnergyRecorder.energy_recorder_api["uri"],
auth=EnergyRecorder.energy_recorder_api["auth"],
- timeout=EnergyRecorder.CONNECTION_TIMOUT
+ timeout=EnergyRecorder.CONNECTION_TIMEOUT
)
if response.status_code == 200:
return_value = json.loads(response.text)