| Patrick Williams | b19c34c | 2017-03-27 14:52:28 -0500 | [diff] [blame^] | 1 | #!/bin/env python |
| 2 | |||||
| 3 | import requests | ||||
| 4 | |||||
| 5 | class 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 | |||||
| 19 | |||||
| 20 | |||||
| 21 | s = BMC(server="w50.aus.stglabs.ibm.com") | ||||