mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #1076: UI configuration returned as XML
This commit is contained in:
parent
0449177b85
commit
8ecc77cd78
@ -52,9 +52,8 @@
|
||||
:cpu: 8
|
||||
:memory: 8192
|
||||
|
||||
|
||||
#############################################################
|
||||
### SelfService UI Settings
|
||||
# OCCI UI Settings (SelfService)
|
||||
#############################################################
|
||||
|
||||
# Default language setting
|
||||
@ -70,6 +69,7 @@
|
||||
# vnc_proxy_cert: Certificate to encrypt wss connections.
|
||||
# vnc_proxy_key: Key for wss connections. Only necessary if not included in cert.
|
||||
:vnc_enable: no
|
||||
|
||||
:vnc_proxy_base_port: 33876
|
||||
:vnc_proxy_path:
|
||||
:vnc_proxy_support_wss: no
|
||||
|
@ -512,15 +512,13 @@ class OCCIServer < CloudServer
|
||||
############################################################################
|
||||
|
||||
def startvnc(id,config)
|
||||
vm = VirtualMachineOCCI.new(
|
||||
VirtualMachine.build_xml(id),
|
||||
@client)
|
||||
|
||||
vm = VirtualMachineOCCI.new(VirtualMachine.build_xml(id), @client)
|
||||
rc = vm.info
|
||||
|
||||
if OpenNebula.is_error?(rc)
|
||||
error = "Error starting VNC session, "
|
||||
error += "could not retrieve Virtual Machine"
|
||||
return [404,error]
|
||||
error = "Error starting VNC session, "
|
||||
error << "could not retrieve Virtual Machine"
|
||||
return [404, error]
|
||||
end
|
||||
|
||||
vnc_proxy = OpenNebulaVNC.new(config,{:json_errors => false})
|
||||
@ -533,6 +531,7 @@ class OCCIServer < CloudServer
|
||||
rescue Exception => e
|
||||
return [500, e.message]
|
||||
end
|
||||
|
||||
return [200,nil]
|
||||
end
|
||||
end
|
||||
|
@ -306,19 +306,22 @@ get '/user/:id' do
|
||||
end
|
||||
|
||||
##############################################
|
||||
## UI
|
||||
## OCCI UI (Self-Service)
|
||||
##############################################
|
||||
|
||||
get '/ui/config/:opt' do
|
||||
case params[:opt]
|
||||
when "lang" then session[:lang]
|
||||
when "wss"
|
||||
wss = settings.config[:vnc_proxy_support_wss]
|
||||
wss = (wss == true || wss == "yes" || wss == "only" ? "yes" : "no")
|
||||
return wss
|
||||
when "vnc" then settings.config[:vnc_enable] ? "yes" : "no"
|
||||
else [404, "Unknown configuration option"]
|
||||
end
|
||||
get '/ui/config' do
|
||||
wss = settings.config[:vnc_proxy_support_wss]
|
||||
wss = (wss == true || wss == "yes" || wss == "only" ? "yes" : "no")
|
||||
|
||||
vnc = settings.config[:vnc_enable] ? "yes" : "no"
|
||||
|
||||
config = "<UI_CONFIGURARION>"
|
||||
config << " <LANG>#{session[:lang]}</LANG>"
|
||||
congig << " <WSS>#{wss}</WSS>"
|
||||
congig << " <VNC>#{vnc}</VNC>"
|
||||
config << "</UI_CONFIGURARION>"
|
||||
|
||||
return [200, config]
|
||||
end
|
||||
|
||||
post '/ui/config' do
|
||||
@ -333,6 +336,7 @@ post '/ui/config' do
|
||||
when "lang" then session[:lang]=value
|
||||
end
|
||||
end
|
||||
|
||||
return 200
|
||||
end
|
||||
|
||||
@ -374,12 +378,11 @@ post '/ui/startvnc/:id' do
|
||||
return [403, "VNC sessions are disabled"]
|
||||
end
|
||||
|
||||
vm_id = params[:id]
|
||||
|
||||
vm_id = params[:id]
|
||||
vnc_hash = session['vnc']
|
||||
|
||||
if !vnc_hash
|
||||
session['vnc']= {}
|
||||
session['vnc'] = {}
|
||||
elsif vnc_hash[vm_id]
|
||||
#return existing information
|
||||
info = vnc_hash[vm_id].clone
|
||||
@ -395,10 +398,10 @@ post '/ui/startvnc/:id' do
|
||||
session['vnc'][vm_id] = info.clone
|
||||
info.delete(:pipe)
|
||||
|
||||
[200, info.to_json]
|
||||
else
|
||||
rc
|
||||
rc = [200, info.to_json]
|
||||
end
|
||||
|
||||
return rc
|
||||
end
|
||||
|
||||
post '/ui/stopvnc/:id' do
|
||||
@ -406,12 +409,11 @@ post '/ui/stopvnc/:id' do
|
||||
return [403, "VNC sessions are disabled"]
|
||||
end
|
||||
|
||||
vm_id = params[:id]
|
||||
vm_id = params[:id]
|
||||
vnc_hash = session['vnc']
|
||||
|
||||
if !vnc_hash || !vnc_hash[vm_id]
|
||||
msg = "It seems there is no VNC proxy running for this machine"
|
||||
return [403, msg]
|
||||
return [403, "It seems there is no VNC proxy running for this machine"]
|
||||
end
|
||||
|
||||
rc = @occi_server.stopvnc(vnc_hash[vm_id][:pipe])
|
||||
@ -420,5 +422,5 @@ post '/ui/stopvnc/:id' do
|
||||
session['vnc'].delete(vm_id)
|
||||
end
|
||||
|
||||
rc
|
||||
return rc
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user