summaryrefslogtreecommitdiffstats
path: root/tests/inspector.py
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2016-09-20 17:56:28 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2016-12-01 12:03:43 +0800
commitb7b37cfd508ca612c217e802b38b7a50d04e7e7e (patch)
tree0e1da516454affeeff292445959ba6f201adfa18 /tests/inspector.py
parent69264fa32e7885be44667efa34c0c58cc110f5b6 (diff)
remove `Debug = True when run Flask and add logger
JIRA: DOCTOR-79 Change-Id: I9193ec387af3b593b8f19d8f4b72ddec5c759bc0 Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/inspector.py')
-rw-r--r--tests/inspector.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/inspector.py b/tests/inspector.py
index 62614158..129a386a 100644
--- a/tests/inspector.py
+++ b/tests/inspector.py
@@ -12,6 +12,7 @@ import collections
from flask import Flask
from flask import request
import json
+import logger as doctor_log
import os
import time
@@ -19,6 +20,8 @@ import novaclient.client as novaclient
import nova_force_down
+LOG = doctor_log.Logger('doctor_inspector').getLogger()
+
class DoctorInspectorSample(object):
@@ -44,9 +47,9 @@ class DoctorInspectorSample(object):
try:
host=server.__dict__.get('OS-EXT-SRV-ATTR:host')
self.servers[host].append(server)
- app.logger.debug('get hostname=%s from server=%s' % (host, server))
+ LOG.debug('get hostname=%s from server=%s' % (host, server))
except Exception as e:
- app.logger.debug('can not get hostname from server=%s' % server)
+ LOG.error('can not get hostname from server=%s' % server)
def disable_compute_host(self, hostname):
for server in self.servers[hostname]:
@@ -63,15 +66,14 @@ class DoctorInspectorSample(object):
app = Flask(__name__)
-app.debug = True
inspector = DoctorInspectorSample()
@app.route('/events', methods=['POST'])
def event_posted():
- app.logger.debug('event posted at %s' % time.time())
- app.logger.debug('inspector = %s' % inspector)
- app.logger.debug('received data = %s' % request.data)
+ LOG.info('event posted at %s' % time.time())
+ LOG.info('inspector = %s' % inspector)
+ LOG.info('received data = %s' % request.data)
d = json.loads(request.data)
hostname = d['hostname']
event_type = d['type']
@@ -91,5 +93,6 @@ def main():
args = get_args()
app.run(port=args.port)
+
if __name__ == '__main__':
main()