blob: 2a5a9a8632664002a3ea37e574c7b37e0e89ae09 [file] [log] [blame]
Patrick Williamsb19c34c2017-03-27 14:52:28 -05001#!/bin/env python
2
3import requests
4
5class BMC:
6 def __init__(self, server):
7 self.url = "https://{0}/".format(server)
8 self.session = requests.Session()
9 self.login()
10
11 def login(self):
12 r = self.session.post(self.url + 'login',
13 json={ 'data': [ 'root', '0penBmc']},
14 verify=False)
15 j = r.json()
16 if j['status'] != 'ok':
17 raise Exception("Failed to login: \n" + r.text)
18
Patrick Williamsec472d82017-03-27 15:15:43 -050019 def list_events(self):
20 r = self.session.get(self.url + 'xyz/openbmc_project/logging/entry/',
21 verify=False)
22 j = r.json()
23 if j['status'] != 'ok':
24 raise Exception("Failed to query entries: \n" + r.text)
25
26 events = j['data']
27 events.sort(key=lambda x: int(x.split("/")[-1]))
28
29 return events
Patrick Williamsb19c34c2017-03-27 14:52:28 -050030
31
32s = BMC(server="w50.aus.stglabs.ibm.com")
Patrick Williamsec472d82017-03-27 15:15:43 -050033for e in s.list_events():
34 print(e)