1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-24 21:34:01 +03:00

feature #1279: Update SunstonServer to make use of the new OCA monitoring methods (resource)

This commit is contained in:
Ruben S. Montero 2012-05-18 17:37:37 +02:00
parent 8b46745a8a
commit 895890f898
2 changed files with 30 additions and 5 deletions

View File

@ -284,6 +284,34 @@ class SunstoneServer < CloudServer
return [200, rc.to_json]
end
def get_resource_monitoring(id, resource, meters)
pool_element = case resource
when "vm", "VM"
VirtualMachine.new_with_id(id, @client)
when "host", "HOST"
Host.new_with_id(id, @client)
else
error = Error.new("Monitoring not supported for #{resource}")
return [200, error.to_json]
end
meters_a = meters.split(',')
rc = pool_element.monitoring(meters_a)
if OpenNebula.is_error?(rc)
error = Error.new(rc,message)
return [500, error.to_json]
end
meters_h = Hash.new
meters_h[:resource] = resource
meters_h[:id] = id
meters_h[:monitoring] = rc
return [200, meters_h.to_json]
end
private
############################################################################

View File

@ -298,15 +298,12 @@ get '/:resource/monitor' do
end
get '/:resource/:id/monitor' do
@SunstoneServer.get_monitoring(
@SunstoneServer.get_resource_monitoring(
params[:id],
params[:resource],
params[:monitor_resources],
:uid => session[:user_id].to_i,
:gid => session[:user_gid].to_i)
params[:monitor_resources])
end
##############################################################################
# GET Pool information
##############################################################################