2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-09-06 10:18:20 +00:00
Files
xcat-core/xCAT-genesis-scripts/usr/sbin/enableipmiusingredfish.py
Jarrod Johnson 4a459177e1 Implement IPMI enablement through redfish
Newer firmware will disable IPMI by default.

If a user is using bmcsetup, they are preparing explictly
to use with IPMI, so use redfish to turn on the IPMI.
2019-08-21 16:23:49 -04:00

27 lines
970 B
Python
Executable File

#!/usr/bin/python
import base64
import httplib
import os
import subprocess
import ssl
iface = os.environ['INTERFACE']
# This should be run in an isolated context. Since cert validation
# is currently not in the cards, we are realistically at the mercy
# of the OS routing table
subprocess.check_call(['/sbin/ip', 'link', 'set', iface, 'up'])
subprocess.check_call(['/sbin/ip', 'addr', 'add', 'dev', iface, '169.254.95.120/24'])
subprocess.check_call(['/sbin/ip', 'route', 'add', '169.254.95.0/24', 'dev', iface])
client = httplib.HTTPSConnection('169.254.95.118', context=ssl._create_unverified_context())
headers = {
'Authorization': 'Basic {0}'.format(base64.b64encode(':'.join((os.environ['user'], os.environ['bmcp'])))),
'Content-Type': 'application/json',
'Host': '169.254.95.118',
}
client.request('PATCH', '/redfish/v1/Managers/1/NetworkProtocol', '{"IPMI": {"ProtocolEnabled": true}}', headers)
rsp = client.getresponse()
rsp.read()