diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index d654f50649..70c915798a 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -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 ############################################################################ diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index e941bb6cfa..9207e677e4 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -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