mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #720: Update sunstone-server to use the new watch client
This commit is contained in:
parent
31fe71dc34
commit
5f3ffac529
@ -294,28 +294,26 @@ class SunstoneServer
|
||||
#
|
||||
############################################################################
|
||||
|
||||
def get_monitoring(id, resource, monitor_resources)
|
||||
watch_client = OneWatchClient::WatchClient.new
|
||||
columns = monitor_resources.split(',')
|
||||
|
||||
rc = case resource
|
||||
def get_monitoring(id, resource, monitor_resources, gid)
|
||||
watch_client = case resource
|
||||
when "vm","VM"
|
||||
if id
|
||||
watch_client.vm_monitoring(id, columns)
|
||||
else
|
||||
watch_client.vm_total(columns)
|
||||
end
|
||||
OneWatchClient::VmWatchClient.new
|
||||
when "host","HOST"
|
||||
if id
|
||||
watch_client.host_monitoring(id, columns)
|
||||
else
|
||||
watch_client.host_total(columns)
|
||||
end
|
||||
OneWatchClient::HostWatchClient.new
|
||||
else
|
||||
error = Error.new("Monitoring not supported for this resource: #{resource}")
|
||||
error = Error.new("Monitoring not supported for this resource: #{resource}")
|
||||
return [200, error.to_json]
|
||||
end
|
||||
|
||||
columns = monitor_resources.split(',')
|
||||
columns.map!{|e| e.to_sym}
|
||||
|
||||
if id
|
||||
rc = watch_client.resource_monitoring(id.to_i, columns)
|
||||
else
|
||||
rc = watch_client.total_monitoring(columns)
|
||||
end
|
||||
|
||||
if rc.nil?
|
||||
error = Error.new("There is no monitoring information for #{resource} #{id}")
|
||||
return [500, error.to_json]
|
||||
|
@ -179,14 +179,16 @@ get '/:resource/monitor' do
|
||||
@SunstoneServer.get_monitoring(
|
||||
nil,
|
||||
params[:resource],
|
||||
params[:monitor_resources])
|
||||
params[:monitor_resources],
|
||||
session[:user_gid])
|
||||
end
|
||||
|
||||
get '/:resource/:id/monitor' do
|
||||
@SunstoneServer.get_monitoring(
|
||||
params[:id],
|
||||
params[:resource],
|
||||
params[:monitor_resources])
|
||||
params[:monitor_resources],
|
||||
session[:user_gid])
|
||||
end
|
||||
|
||||
|
||||
@ -195,8 +197,7 @@ end
|
||||
##############################################################################
|
||||
get '/:pool' do
|
||||
@SunstoneServer.get_pool(params[:pool],
|
||||
session[:user_gid],
|
||||
settings.config[:pool_filter])
|
||||
session[:user_gid])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user