f844afc49b
- Uses tortilla lib to wrap the REST API (dep) - Uses python requests to manage login/logout (dep) - Provides 2 functional working examples with Redfish simulator and ProLiant server or Moonshot Server - Remove OpenStack deps as this code has to be usable outside of OpenStack - Provides a configuration file to handle credentials and connection URL - Provides a mapping class to handle multiple versions of Redfish (in this version, 0.95.0 for ProLiant and 1.0.0 for mockup) - Provides a first action reset_server to ... reset system The action is commented into simple-proliant.py to not do unexpected reset. - Provides a first retrieving function get_bios_version to get the BIOS version of a system. - Add basic logging capability - Clean up to meet pep8 and doc strings (in progress).
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
# coding=utf-8
|
|
|
|
""" Simple example to use python-redfish with DMTF simulator """
|
|
|
|
import os
|
|
import sys
|
|
import json
|
|
import redfish
|
|
|
|
# Get $HOME environment.
|
|
HOME = os.getenv('HOME')
|
|
|
|
if HOME == '':
|
|
print("$HOME environment variable not set, please check your system")
|
|
sys.exit(1)
|
|
|
|
try:
|
|
with open(HOME + "/.redfish.conf") as json_data:
|
|
config = json.load(json_data)
|
|
json_data.close()
|
|
except IOError as e:
|
|
print("Please create a json configuration file")
|
|
print(e)
|
|
sys.exit(1)
|
|
|
|
URL = config["Nodes"]["default"]["url"]
|
|
USER_NAME = config["Nodes"]["default"]["login"]
|
|
PASSWORD = config["Nodes"]["default"]["password"]
|
|
|
|
''' remoteMgmt is a redfish.RedfishConnection object '''
|
|
remote_mgmt = redfish.connect(URL, USER_NAME, PASSWORD,
|
|
simulator=True, enforceSSL=False)
|
|
|
|
print ("Redfish API version : {} \n".format(remote_mgmt.get_api_version()))
|
|
print ("UUID : {} \n".format(remote_mgmt.Root.get_api_UUID()))
|
|
print ("Bios version : {}\n".format(remote_mgmt.Systems.systems_list[0].get_bios_version()))
|
|
|
|
#print remoteMgmt.get_api_link_to_server()
|