BMC examples
These examples are meant to be run on the device!
If you want to run them from a remote computer, you need to change “localhost” to the IP/hostname.
You will also need to generate an access token and use the “auth basic” method.
You may also want to use the secure protocol https://.
Python examples
Get temperature
Example:
import requests
# For tokens see http://noreya-nexus.local/nexuscontrolui/system/settings#access-token
login=("token", "")
hostname="localhost"
resp = requests.get("http://" + hostname + "/api/bmc/1.0/", auth=login)
if resp.status_code == requests.codes.ok:
response = resp.json()
for device in response['devices']:
print("Temperature values for BMC on slot " + str(device['slot_number']) + ":")
resp = requests.get("http://" + hostname + "/api/bmc/1.0/" + str(device['slot_number']) + "/temperature", auth=login)
if resp.status_code == requests.codes.ok:
response = resp.json()
print("Temperature sensor next to SoC: " + str(response['ntc_0']) + "°C")
print("Temperature sensor ambient: " + str(response['ntc_1']) + "°C")
else:
print("Error response for slot " + str(device['slot_number']))
else:
print("Error response")
Output:
Temperature values for BMC on slot 0:
Temperature sensor next to SoC: 38.674°C
Temperature sensor ambient: 29.638°C
Watchdog configuration
Example:
import requests
import time
# For tokens see http://noreya-nexus.local/nexuscontrolui/system/settings#access-token
login=("token", "")
hostname="localhost"
response = requests.get("http://" + hostname + "/api/bmc/1.0/", auth=login)
if response.status_code == requests.codes.ok:
response = response.json()
for device in response['devices']:
slot_number = device['slot_number']
print("Watchdog config for BMC on slot " + str(slot_number) + ":")
response = requests.get("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/reset", auth=login)
if response.status_code == requests.codes.ok:
print("Successfully reset device") # We do "write" requests so we need to get a defined state
request = {"timeout": 2000 }
response = requests.post("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/watchdog", json=request, auth=login)
if response.status_code == requests.codes.ok:
print("Watchdog enabled with timeout " + str(request['timeout']) + 'ms')
response = requests.get("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/watchdog/alive", auth=login)
if response.status_code == requests.codes.ok:
print("Watchdog updated by /alive")
else:
print("Failed reseting watchdog")
print("Wait a second...")
time.sleep(1)
response = requests.get("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/watchdog", auth=login)
if response.status_code == requests.codes.ok:
response = response.json()
print("Time left until reset: " + str(response['timeout_left']) + ' ms')
else:
print("Failed getting watchdog status")
request = {"timeout": 0 }
response = requests.post("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/watchdog", json=request, auth=login)
if response.status_code == requests.codes.ok:
print("Watchdog disabled")
else:
print("Failed disabling watchdog")
response = requests.get("http://" + hostname + "/api/bmc/1.0/" + str(slot_number) + "/reset", auth=login)
if response.status_code == requests.codes.ok:
print("Successfully reset device after test")
print("")
else:
print("Error response for slot " + str(device['slot_number']))
else:
print("Error response")
Output:
Watchdog config for BMC on slot 0:
Successfully reset device
Watchdog enabled with timeout 2000ms
Watchdog updated by /alive
Wait a second...
Time left until reset: 981 ms
Watchdog disabled
Successfully reset device after test