diff --git a/src/cloud/occi/lib/OCCIServer.rb b/src/cloud/occi/lib/OCCIServer.rb index 841f45fa49..1f537ca902 100755 --- a/src/cloud/occi/lib/OCCIServer.rb +++ b/src/cloud/occi/lib/OCCIServer.rb @@ -504,4 +504,43 @@ class OCCIServer < CloudServer return to_occi_xml(user, 200) end + + ############################################################################ + ############################################################################ + # BonFIRE Specific + ############################################################################ + ############################################################################ + def get_computes_types + etc_location=ONE_LOCATION ? ONE_LOCATION+"/etc" : "/etc/one" + begin + xml_response = "\n" + + Dir[etc_location + "/occi_templates/**"].each{| filename | + next if File.basename(filename) == "common.erb" + xml_response += "\t" + xml_response += "\t\t#{File.basename(filename)[0..-5]}" + file = File.open(filename, "r") + file.each_line{|line| + next if line.match(/^#/) + match=line.match(/^(.*)=(.*)/) + next if !match + case match[1].strip + when "NAME" + xml_response += "\t\t#{match[2].strip}" + when "CPU" + xml_response += "\t\t#{match[2].strip}" + when "MEMORY" + xml_response += "\t\t#{match[2].strip}" + end + } + xml_response += "\t" + } + + xml_response += "" + + return xml_response, 200 + rescue Exception => e + return "Error getting the instance types. Reason: #{e.message}", 500 + end + end end diff --git a/src/cloud/occi/lib/occi-server.rb b/src/cloud/occi/lib/occi-server.rb index 86f9a1959b..ba0199f584 100755 --- a/src/cloud/occi/lib/occi-server.rb +++ b/src/cloud/occi/lib/occi-server.rb @@ -172,7 +172,11 @@ end ################################################### get '/compute/:id' do - result,rc = @occi_server.get_compute(request, params) + if params[:id] == "types" # Specific BonFIRE functionality + result,rc = @occi_server.get_computes_types + else + result,rc = @occi_server.get_compute(request, params) + end treat_response(result,rc) end @@ -219,4 +223,4 @@ end get '/user/:id' do result,rc = @occi_server.get_user(request, params) treat_response(result,rc) -end \ No newline at end of file +end