Commit 96746919 by Rahul Dutta

Redfish Changes

parent 1deaa42d
......@@ -30,10 +30,14 @@ import valence.conf
from valence.redfish import tree
CONF = valence.conf.CONF
LOG = logging.getLogger(__name__)
SERVICE_ROOT = None
RECS_URL="http://admin:admin@localhost:8080/redfish/v1/"
#Added for sending request to RECSMaster
headers = {'Content-Type': 'application/json'}
username=admin
......@@ -526,19 +530,19 @@ def _create_compose_request(name, description, requirements):
def available_Systems():
listed_systems = []
available_systems=[]
r = requests.get("http://admin:admin@localhost:8080/redfish/v1/Systems", headers=headers)
r = requests.get(RECS_URL+"Systems", headers=headers)
json_data = json.loads(r.text)
j = ast.literal_eval(str(json_data['Members']))
for item in j:
sys_res = requests.get("http://admin:admin@localhost:8080/redfish/v1/Systems" + str(
sys_res = requests.get(RECS_URL+"Systems" + str(
str(str(str(item).replace("'", "")).split('u@odata.id: u'))[26:])[:-3], headers=headers)
listed_systems.append(str(str(str(str(item).replace("'", "")).split('u@odata.id: u'))[27:])[:-3])
for system in listed_systems:
response = requests.get('http://localhost:8080/redfish/v1/Systems/'+system, headers=headers,
response = requests.get(RECS_URL+'Systems/'+system, headers=headers,
auth=('admin', 'admin'))
json_data = json.loads(response.text)
if json_data[u'Oem'][u'EID_47597'][u'ComposedIn'] is None:
......@@ -550,7 +554,7 @@ def available_Systems():
def checkFPGA(system_id):
response = requests.get('http://localhost:8080/redfish/v1/Systems/' + system_id + '/Processors', headers=headers,
response = requests.get(RECS_URL+'Systems/' + system_id + '/Processors', headers=headers,
auth=('admin', 'admin'))
json_data = json.loads(response.text)
if json_data["ProcessorType"] == "FPGA":
......@@ -561,14 +565,14 @@ def checkFPGA(system_id):
def available_PCIE():
listed_PCIE = []
r = requests.get("http://admin:admin@localhost:8080/redfish/v1/Systems", headers=headers)
r = requests.get(RECS_URL+"Systems", headers=headers)
json_data = json.loads(r.text)
j = ast.literal_eval(str(json_data['Members']))
for item in j:
sys_res = requests.get("http://admin:admin@localhost:8080/redfish/v1/Systems" + str(
str(str(str(item).replace("'", "")).split('u@odata.id: u'))[26:])[:-3], headers=headers)
sys_res = requests.get(RECS_URL+"Systems" + str(
str(str(str(item).replace("'", "")).split('u@odata.id: u'))[26:])[:-3], headers=headers,auth=('admin', 'admin'))
listed_PCIE.append(str(str(str(str(item).replace("'", "")).split('u@odata.id: u'))[27:])[:-3])
......@@ -578,14 +582,14 @@ def available_PCIE():
def available_Switches():
listed_Switches = []
r = requests.get("http://admin:admin@localhost:8080/redfish/v1/Switches", headers=headers)
r = requests.get(RECS_URL+"Switches", headers=headers)
json_data = json.loads(r.text)
j = ast.literal_eval(str(json_data['Members']))
for item in j:
sys_res = requests.get("http://admin:admin@localhost:8080/redfish/v1/Systems" + str(
str(str(str(item).replace("'", "")).split('u@odata.id: u'))[26:])[:-3], headers=headers)
sys_res = requests.get(RECS_URL+"Systems" + str(
str(str(str(item).replace("'", "")).split('u@odata.id: u'))[26:])[:-3], headers=headers,auth=('admin', 'admin'))
listed_Switches.append(str(str(str(str(item).replace("'", "")).split('u@odata.id: u'))[28:])[:-3])
......@@ -594,14 +598,14 @@ def available_Switches():
def get_system_details(system):
response = requests.get('http://localhost:8080/redfish/v1/Systems/' + system + '/Processors', headers=headers,
response = requests.get(RECS_URL+'Systems/' + system + '/Processors', headers=headers,
auth=('admin', 'admin'))
data = json.loads(response.text)
return data["@odata.id"]
def get_switch_details(switch):
response = requests.get('http://localhost:8080/redfish/v1/Switches/' + switch + '/Processors', headers=headers,
response = requests.get(RECS_URL+'Switches/' + switch + '/Processors', headers=headers,
auth=('admin', 'admin'))
data = json.loads(response.text)
return data["@odata.id"]
......@@ -615,7 +619,7 @@ def node_details(node_index, show_detail=True):
headers = {
'Content-Type': 'application/json',
}
response = requests.get('http://localhost:8080/redfish/v1/ComposedNodes/'+node_index, headers=headers,
response = requests.get(RECS_URL+'ComposedNodes/'+node_index, headers=headers,
auth=('admin', 'admin'))
json_data = json.loads(response.text)
......@@ -671,7 +675,7 @@ def allocate_node(name, description, requirements):
allocate_json += ","
payload = '{"Name": "' + name + '",\n"Description": "' + description + '",\n"Systems": [' + allocate_json[:-1] + ']}'
return_value = requests.post('http://192.168.1.103:8080/redfish/v1/ComposedNodes/Actions/ComposedNodeCollection.Allocate',
return_value = requests.post(RECS_URL+'ComposedNodes/Actions/ComposedNodeCollection.Allocate',
headers=headers, data=payload, auth=('admin', 'admin'))
return allocated_details
......@@ -700,7 +704,7 @@ def assemble_node(name, description, requirements):
assemble_load = '{\n"ConnectionSets": [{\n"Connections": [{' + s_json + '\n"Width": ' + str(
width) + '\n}],\n"Description": "' + desc + '",\n"Name": "' + name + '"\n}],\n"ActiveConnectionSet": "' + connSet + '",\n"ResetNetworkSettings": "true"\n} '
response = requests.post('http://localhost:8080/redfish/v1/ComposedNodes/CN_0/Actions/ComposedNode.Assemble',
response = requests.post(RECS_URL+'ComposedNodes/CN_0/Actions/ComposedNode.Assemble',
headers=headers, data=assemble_load, auth=('admin', 'admin'))
node_index='CN_0'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment