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

B #5361: Use serveradmin client for VMRC

admin permissions needed to request VMRC token
This commit is contained in:
Tino Vazquez 2021-04-26 17:30:05 +02:00 committed by Ruben S. Montero
parent 41caa050b6
commit e42ed54315
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87
2 changed files with 10 additions and 9 deletions

View File

@ -317,7 +317,7 @@ class SunstoneServer < CloudServer
if OpenNebula.is_error?(resource)
return [404, resource.to_json]
end
client = @client
vm_pool = VirtualMachinePool.new(client, -1)
user_pool = UserPool.new(client)
@ -333,21 +333,20 @@ class SunstoneServer < CloudServer
puts rc.message
exit -1
end
return guac.proxy(resource, type_connection)
end
end
########################################################################
# VMRC
########################################################################
def startvmrc(id, vmrc)
def startvmrc(id, vmrc, _client=nil)
resource = retrieve_resource("vm", id)
if OpenNebula.is_error?(resource)
return [404, resource.to_json]
end
client = @client
vm_pool = VirtualMachinePool.new(client, -1)
user_pool = UserPool.new(client)
vm_pool = VirtualMachinePool.new(@client, -1)
user_pool = UserPool.new(@client)
rc = user_pool.info
if OpenNebula.is_error?(rc)
@ -361,6 +360,7 @@ class SunstoneServer < CloudServer
exit -1
end
client = _client.nil? ? @client : _client
return vmrc.proxy(resource, client)
end

View File

@ -381,7 +381,7 @@ helpers do
fireedge_token = ""
res = Net::HTTP.post_form(uri, params)
fireedge_token = JSON.parse(res.body)['data']['token'] if res.is_a?(Net::HTTPSuccess)
response = fireedge_token
rescue StandardError => error
logger.error { "Cannot connect with fireedge: #{error.message}" }
@ -1150,7 +1150,8 @@ end
##############################################################################
post '/vm/:id/startvmrc' do
vm_id = params[:id]
@SunstoneServer.startvmrc(vm_id, $vmrc)
serveradmin_client = $cloud_auth.client(nil, session[:active_zone_endpoint])
@SunstoneServer.startvmrc(vm_id, $vmrc, serveradmin_client)
end
##############################################################################