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

feature #763: Add configuration parameter to Sunstone; list group or mine (FILTER_POOL)

This commit is contained in:
Daniel Molina 2011-08-04 13:49:03 +02:00
parent 3470ecf7e1
commit 4c739e9d79
3 changed files with 28 additions and 16 deletions

View File

@ -6,3 +6,7 @@ PORT=9869
VNC_PROXY_BASE_PORT=29876
NOVNC_PATH=
# FLAG that will filter the elements retrieved from the Pools
# MINE : Connected user's resources
# GROUP : Connected user's and his group's resources
POOL_FILTER = "GROUP"

View File

@ -56,25 +56,31 @@ class SunstoneServer
############################################################################
#
############################################################################
def get_pool(kind,gid)
def get_pool(kind,gid,filter)
if gid == "0"
user_flag = Pool::INFO_ALL
else
user_flag = case filter
when "MINE" then Pool::INFO_MINE
when "GROUP" then Pool::INFO_GROUP
else Pool::INFO_GROUP
end
end
pool = case kind
when "group" then GroupPoolJSON.new(@client)
when "host" then HostPoolJSON.new(@client)
when "image" then ImagePoolJSON.new(@client)
when "template" then TemplatePoolJSON.new(@client)
when "vm" then VirtualMachinePoolJSON.new(@client)
when "vnet" then VirtualNetworkPoolJSON.new(@client)
when "image" then ImagePoolJSON.new(@client, user_flag)
when "template" then TemplatePoolJSON.new(@client, user_flag)
when "vm" then VirtualMachinePoolJSON.new(@client, user_flag)
when "vnet" then VirtualNetworkPoolJSON.new(@client, user_flag)
when "user" then UserPoolJSON.new(@client)
else
error = Error.new("Error: #{kind} resource not supported")
return [404, error.to_json]
end
rc = case kind
when "group","host","user" then pool.info
else
gid != "0" ? pool.info_group : pool.info_all
end
rc = pool.info
if OpenNebula.is_error?(rc)
return [500, rc.to_json]

View File

@ -183,16 +183,14 @@ get '/:resource/monitor' do
@SunstoneServer.get_monitoring(
nil,
params[:resource],
params[:monitor_resources]
)
params[:monitor_resources])
end
get '/:resource/:id/monitor' do
@SunstoneServer.get_monitoring(
params[:id],
params[:resource],
params[:monitor_resources]
)
params[:monitor_resources])
end
@ -200,7 +198,9 @@ end
# GET Pool information
##############################################################################
get '/:pool' do
@SunstoneServer.get_pool(params[:pool],session[:user_gid])
@SunstoneServer.get_pool(params[:pool],
session[:user_gid],
settings.config[:pool_filter])
end
##############################################################################
@ -283,5 +283,7 @@ end
# Perform an action on a Resource
##############################################################################
post '/:resource/:id/action' do
@SunstoneServer.perform_action(params[:resource], params[:id], request.body.read)
@SunstoneServer.perform_action(params[:resource],
params[:id],
request.body.read)
end