summaryrefslogtreecommitdiffstats
path: root/tests/monitor.py
diff options
context:
space:
mode:
authordongwenjuan <dong.wenjuan@zte.com.cn>2016-12-30 10:23:09 +0800
committerwenjuan dong <dong.wenjuan@zte.com.cn>2017-01-03 07:43:16 +0000
commit836674ae9c96738791463940d713e88d5928f7d8 (patch)
tree20575b92e4d51ac5ec50961488ca8fddf7a82e70 /tests/monitor.py
parentbfd645c60af3bdefae2984636fcb8aae1436b26f (diff)
fix the data which post to sample inspector align to SB API
Change-Id: I18b0703541aa702ec833cd102260e92831a89e3a Signed-off-by: dongwenjuan <dong.wenjuan@zte.com.cn>
Diffstat (limited to 'tests/monitor.py')
-rw-r--r--tests/monitor.py34
1 files changed, 16 insertions, 18 deletions
diff --git a/tests/monitor.py b/tests/monitor.py
index 26c911da..75d82392 100644
--- a/tests/monitor.py
+++ b/tests/monitor.py
@@ -78,33 +78,31 @@ class DoctorMonitorSample(object):
time.sleep(self.interval)
def report_error(self):
+ payload = [
+ {
+ 'id': 'monitor_sample_id1',
+ 'time': datetime.now().isoformat(),
+ 'type': self.event_type,
+ 'details': {
+ 'hostname': self.hostname,
+ 'status': 'down',
+ 'monitor': 'monitor_sample',
+ 'monitor_event_id': 'monitor_sample_event1'
+ },
+ },
+ ]
+ data = json.dumps(payload)
+
if self.inspector_type == 'sample':
- payload = {"type": self.event_type, "hostname": self.hostname}
- data = json.dumps(payload)
headers = {'content-type': 'application/json'}
requests.post(self.inspector_url, data=data, headers=headers)
elif self.inspector_type == 'congress':
- data = [
- {
- 'id': 'monitor_sample_id1',
- 'time': datetime.now().isoformat(),
- 'type': self.event_type,
- 'details': {
- 'hostname': self.hostname,
- 'status': 'down',
- 'monitor': 'monitor_sample',
- 'monitor_event_id': 'monitor_sample_event1'
- },
- },
- ]
-
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'X-Auth-Token':self.session.get_token(),
}
-
- requests.put(self.inspector_url, data=json.dumps(data), headers=headers)
+ requests.put(self.inspector_url, data=data, headers=headers)
def get_args():