mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-25 23:21:29 +03:00
Feature #1279: Update pool monitoring method in sunstone server
This commit is contained in:
parent
bba9e26ee2
commit
4680ba21c7
@ -253,34 +253,29 @@ class SunstoneServer < CloudServer
|
|||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
def get_monitoring(id, resource, monitor_resources, opts={})
|
def get_pool_monitoring(resource, meters)
|
||||||
watch_client = case resource
|
#pool_element
|
||||||
when "vm","VM"
|
pool = case resource
|
||||||
OneWatchClient::VmWatchClient.new
|
when "vm", "VM"
|
||||||
when "host","HOST"
|
VirtualMachinePool.new(@client)
|
||||||
OneWatchClient::HostWatchClient.new
|
when "host", "HOST"
|
||||||
|
HostPool.new(@client)
|
||||||
else
|
else
|
||||||
error = Error.new("Monitoring not supported for this resource: #{resource}")
|
error = Error.new("Monitoring not supported for #{resource}")
|
||||||
return [200, error.to_json]
|
return [200, error.to_json]
|
||||||
end
|
end
|
||||||
|
|
||||||
filter = {}
|
meters_a = meters.split(',')
|
||||||
filter[:uid] = opts[:uid] if opts[:gid]!=0
|
|
||||||
|
|
||||||
columns = monitor_resources.split(',')
|
rc = pool.monitoring(meters_a)
|
||||||
columns.map!{|e| e.to_sym}
|
|
||||||
|
|
||||||
if id
|
if OpenNebula.is_error?(rc)
|
||||||
rc = watch_client.resource_monitoring(id.to_i, columns, filter)
|
error = Error.new(rc,message)
|
||||||
else
|
|
||||||
rc = watch_client.total_monitoring(columns, filter)
|
|
||||||
end
|
|
||||||
|
|
||||||
if rc.nil?
|
|
||||||
error = Error.new("There is no monitoring information for #{resource} #{id}")
|
|
||||||
return [500, error.to_json]
|
return [500, error.to_json]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
rc[:resource] = resource
|
||||||
|
|
||||||
return [200, rc.to_json]
|
return [200, rc.to_json]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -289,12 +289,9 @@ end
|
|||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
get '/:resource/monitor' do
|
get '/:resource/monitor' do
|
||||||
@SunstoneServer.get_monitoring(
|
@SunstoneServer.get_pool_monitoring(
|
||||||
nil,
|
|
||||||
params[:resource],
|
params[:resource],
|
||||||
params[:monitor_resources],
|
params[:monitor_resources])
|
||||||
:uid => session[:user_id].to_i,
|
|
||||||
:gid => session[:user_gid].to_i)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
get '/:resource/:id/monitor' do
|
get '/:resource/:id/monitor' do
|
||||||
|
Loading…
Reference in New Issue
Block a user