Commit 4cc4bd73 by Rahul Dutta

API implementation- system constraints

parent da2ae8b8
......@@ -685,10 +685,37 @@ def fetch_available_Systems_in_baseboard(baseboard):
return available_systems
def fetch_systems_with_HSLLLanes(l_available_Systems):
LOG.error("Not Implemented: fetch_systems_with_HSLLLanes")
def fetch_systems_with_AchievableSpeedMHz(l_available_Systems):
LOG.error("Not Implemented")
def fetch_systems_with_HSLLLanes(maxwidth,available_Systems):
LOG.error("fetch matching systems with maximum requested HSLLLanes")
#Implement systems with HSLL Lanes
matching_systems = []
for system in available_Systems:
response =requests.get(RECS_URL+"Systems/"+system+"/HSLLInterface",headers=headers)
json_data=json.loads(response.text)
l_maxwidth = ast.literal_eval(str(json_data['MaxWidth']))
if int(l_maxwidth) == int(maxwidth):
if check_system_available(system):
matching_systems.append(system)
return matching_systems
def fetch_systems_with_AchievableSpeedMHz(param_speed, available_Systems):
LOG.error("Fetch systems matching with achievable processor speed")
matching_systems = []
for system in available_Systems:
r = requests.get(RECS_URL+"Systems/"+system+"/Processors", headers=headers)
json_data = json.loads(r.text)
j = ast.literal_eval(str(json_data['Members']))
for item in j:
r1 = requests.get(RECS_URL+"Systems/"+system+"/Processors/" +str(item['@odata.id']).split('/')[6], headers=headers)
json_data1 = json.loads(r1.text)
if int(json_data1['MaxSpeedMHz']) == int(param_speed):
if check_system_available(system):
matching_systems.append(system)
return matching_systems
def fetch_systems_with_InstructionSet(l_available_Systems):
LOG.error("Not Implemented :fetch_systems_with_AchievableSpeedMHz")
def fetch_systems_with_Model():
......@@ -709,9 +736,6 @@ def fetch_systems_with_ProcessorArchitecture(arch,available_systems):
matching_systems.append(system)
return matching_systems
def fetch_systems_with_ProcessorType(type,available_systems):
LOG.error("Fetch systems with ProcessorType to match processor type")
get_configuration()
......@@ -728,8 +752,23 @@ def fetch_systems_with_ProcessorType(type,available_systems):
matching_systems.append(system)
return matching_systems
def fetch_systems_with_TotalCores(l_available_Systems):
LOG.error("Not Implemented:fetch_systems_with_TotalCores")
def fetch_systems_with_TotalCores(no_of_core, available_systems):
LOG.error("fetch maching systems with requested TotalCores")
matching_systems = []
for system in available_systems:
r=requests.get(RECS_URL+"Systems/"+system+"/Processors", headers=headers)
json_data = json.loads(r.text)
j = ast.literal_eval(str(json_data['Members']))
for item in j:
r1 = requests.get(RECS_URL+"Systems/"+system+"/Processors/" +str(item['@odata.id']).split('/')[6], headers=headers)
json_data1 = json.loads(r1.text)
if int(json_data1['TotalCores']) == int(no_of_core):
if check_system_available(system):
matching_systems.append(system)
return matching_systems
def fetch_systems_with_TotalProcessorCoreCount(l_available_Systems):
LOG.error("Not Implemented:fetch_systems_with_TotalProcessorCoreCount")
......@@ -810,10 +849,14 @@ def allocate_node(name, description, requirements):
l_available_Systems = available_Systems()
if "HsllLanes" in list_item:
#Call to function which fetch systems, satisfying the critaria
l_available_Systems= fetch_systems_with_HSLLLanes(l_available_Systems)
l_available_Systems= fetch_systems_with_HSLLLanes(list_item['HSLLLanes'], l_available_Systems)
if not len(l_available_Systems):
return "NO Matching systems found for requested HSLLLanes"
if "Processors" in list_item:
if "AchievableSpeedMHz" in list_item["Processors"]:
l_available_Systems = fetch_systems_with_AchievableSpeedMHz(l_available_Systems)
l_available_Systems = fetch_systems_with_AchievableSpeedMHz(list_item["Processors"]['AchievableSpeedMHz'], l_available_Systems)
if not len(l_available_Systems):
return "NO Matching systems found for requested processor speed"
if "InstructionSet" in list_item["Processors"]:
l_available_Systems = fetch_systems_with_InstructionSet(l_available_Systems)
if "Model" in list_item["Processors"]:
......@@ -830,10 +873,13 @@ def allocate_node(name, description, requirements):
return "NO Matching systems found for requested processor Type"
if "TotalCores" in list_item["Processors"]:
l_available_Systems = fetch_systems_with_TotalCores(l_available_Systems)
l_available_Systems = fetch_systems_with_TotalCores(list_item["Processors"]['TotalCores'],l_available_Systems)
if not len(l_available_Systems):
return "NO Matching systems found for requested Total core number"
if "TotalProcessorCoreCount" in list_item:
l_available_Systems = fetch_systems_with_TotalProcessorCoreCount(l_available_Systems)
#Remove all the allocated systems from the available system list
if len(allocated_systems):
for item in allocated_systems:
......
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