summaryrefslogtreecommitdiffstats
path: root/doctor_tests/monitor
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2017-11-27 17:42:17 +0800
committerdongwenjuan <dong.wenjuan@zte.com.cn>2017-12-11 15:21:00 +0800
commit9e36d918fef054b8d23692c0ec8c25d7b0640c07 (patch)
tree11c25b259e8c53342153df2964aba76ce4d329ee /doctor_tests/monitor
parentf71afa73f5a56474036215b598e45123578c38d9 (diff)
support vitrage inspector for local installer
JIRA: DOCTOR-122 Change-Id: I771f778767a204e809d892c70603e479c1ed2f5c Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'doctor_tests/monitor')
-rw-r--r--doctor_tests/monitor/sample.py31
1 files changed, 14 insertions, 17 deletions
diff --git a/doctor_tests/monitor/sample.py b/doctor_tests/monitor/sample.py
index 7a463048..4dc5e603 100644
--- a/doctor_tests/monitor/sample.py
+++ b/doctor_tests/monitor/sample.py
@@ -13,6 +13,7 @@ import socket
from threading import Thread
import time
+from doctor_tests.common.constants import Inspector
from doctor_tests.identity_auth import get_session
from doctor_tests.monitor.base import BaseMonitor
@@ -38,19 +39,16 @@ class SampleMonitor(BaseMonitor):
def report_error(self, hostname):
self.log.info('sample monitor report error......')
- data = [
- {
- 'id': 'monitor_sample_id1',
- 'time': datetime.now().isoformat(),
- 'type': self.event_type,
- 'details': {
- 'hostname': hostname,
- 'status': 'down',
- 'monitor': 'monitor_sample',
- 'monitor_event_id': 'monitor_sample_event1'
- },
+ data = {
+ 'time': datetime.now().isoformat(),
+ 'type': self.event_type,
+ 'details': {
+ 'hostname': hostname,
+ 'status': 'down',
+ 'monitor': 'monitor_sample',
+ 'monitor_event_id': 'monitor_sample_event1'
},
- ]
+ }
auth_token = self.session.get_token() if \
self.conf.inspector.type != 'sample' else None
@@ -59,11 +57,10 @@ class SampleMonitor(BaseMonitor):
'Accept': 'application/json',
'X-Auth-Token': auth_token,
}
-
- url = '%s%s' % (self.inspector_url, 'events') \
- if self.inspector_url.endswith('/') else \
- '%s%s' % (self.inspector_url, '/events')
- requests.put(url, data=json.dumps(data), headers=headers)
+ if self.conf.inspector.type != Inspector.VITRAGE:
+ requests.put(self.inspector_url, data=json.dumps([data]), headers=headers)
+ else:
+ requests.post(self.inspector_url, data=json.dumps(data), headers=headers)
class Pinger(Thread):