mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-18 02:50:09 +03:00
Feature #1607: New methods to get raw accounting data in sunstone
This commit is contained in:
parent
6cecb17f2d
commit
f377dfd9b6
@ -368,6 +368,30 @@ class SunstoneServer < CloudServer
|
||||
return [200, {:monitoring => result}.to_json]
|
||||
end
|
||||
|
||||
def get_vm_accounting(options)
|
||||
pool = VirtualMachinePool.new(@client)
|
||||
|
||||
filter_flag = options[:userfilter] ? options[:userfilter].to_i : VirtualMachinePool::INFO_ALL
|
||||
start_time = options[:start_time] ? options[:start_time].to_i : -1
|
||||
end_time = options[:end_time] ? options[:end_time].to_i : -1
|
||||
|
||||
acct_options = {
|
||||
:start_time => start_time,
|
||||
:end_time => end_time,
|
||||
:group => options[:group]
|
||||
}
|
||||
|
||||
rc = pool.accounting(filter_flag, acct_options)
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
error = Error.new(rc.message)
|
||||
return [500, error.to_json]
|
||||
end
|
||||
|
||||
return [200, rc.to_json]
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
############################################################################
|
||||
|
@ -595,7 +595,32 @@ var OpenNebula = {
|
||||
callback_error(request, OpenNebula.Error(response)) : null;
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
"accounting": function(params, resource, path){
|
||||
var callback = params.success;
|
||||
var callback_error = params.error;
|
||||
var data = params.data;
|
||||
|
||||
var method = "accounting";
|
||||
var request = OpenNebula.Helper.request(resource,method, data);
|
||||
|
||||
var url = path ? path : resource.toLowerCase() + "/accounting";
|
||||
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function(response){
|
||||
return callback ? callback(request, response) : null;
|
||||
},
|
||||
error: function(response){
|
||||
return callback_error ?
|
||||
callback_error(request, OpenNebula.Error(response)) : null;
|
||||
}
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
"Auth": {
|
||||
@ -984,7 +1009,10 @@ var OpenNebula = {
|
||||
"recover" : function(params){
|
||||
var action_obj = {"with": params.data.extra_param};
|
||||
OpenNebula.Action.simple_action(params,OpenNebula.VM.resource,"recover",action_obj);
|
||||
}
|
||||
},
|
||||
"accounting": function(params){
|
||||
OpenNebula.Action.accounting(params,OpenNebula.VM.resource);
|
||||
},
|
||||
},
|
||||
|
||||
"Group": {
|
||||
|
@ -374,7 +374,7 @@ get '/vm/:id/log' do
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Accounting & Monitoring
|
||||
# Monitoring
|
||||
##############################################################################
|
||||
|
||||
get '/:resource/monitor' do
|
||||
@ -399,6 +399,15 @@ get '/:resource/:id/monitor' do
|
||||
params[:monitor_resources])
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
# Accounting
|
||||
##############################################################################
|
||||
|
||||
get '/vm/accounting' do
|
||||
@SunstoneServer.get_vm_accounting(params)
|
||||
end
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Marketplace
|
||||
##############################################################################
|
||||
|
Loading…
x
Reference in New Issue
Block a user