1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-22 18:50:08 +03:00

feature #696: Update Sunstone for the new acct/monitoring

This commit is contained in:
Daniel Molina 2011-07-06 18:49:42 +02:00
parent c4b15d56fb
commit ff9e27ec5d
2 changed files with 29 additions and 16 deletions

View File

@ -17,7 +17,7 @@
require 'OpenNebulaJSON'
include OpenNebulaJSON
require 'OneMonitorClient'
require 'acct/WatchClient'
class SunstoneServer
def initialize(username, password)
@ -280,22 +280,28 @@ class SunstoneServer
#
############################################################################
def get_log(params)
resource = params[:resource]
id = params[:id]
id = "global" unless id
def get_monitoring(id, resource, monitoring_resources)
watch_client = OneWatchClient::WatchClient.new
columns = params['monitor_resources'].split(',')
history_length = params['history_length']
log_file_folder = case resource
when "vm","VM"
VM_LOG_FOLDER
when "host","HOST"
HOST_LOG_FOLDER
end
rc = case resource
when "vm","VM"
if id
watch_client.vm_monitoring(id, columns)
else
watch_client.vm_total(columns)
end
when "host","HOST"
if id
watch_client.host_monitoring(id, columns)
else
watch_client.host_total(columns)
end
else
return [200, nil]
end
monitor_client = OneMonitorClient.new(id,log_file_folder)
return monitor_client.get_data_for_id(id,columns,history_length).to_json
return [200, rc.to_json]
end
############################################################################

View File

@ -167,11 +167,18 @@ end
##############################################################################
get '/:resource/monitor' do
@SunstoneServer.get_log(params)
@SunstoneServer.get_monitoring(
params[:id],
params[:resource],
params[:monitoring_resources]
)
end
get '/:resource/:id/monitor' do
@SunstoneServer.get_log(params)
@SunstoneServer.get_monitoring(
params[:resource],
params[:monitoring_resources]
)
end