From bb760948911694e10fce69f8664ed043df28dbc9 Mon Sep 17 00:00:00 2001 From: Daniel Molina Date: Tue, 22 Feb 2011 19:07:22 +0100 Subject: [PATCH] feature #495: Check user for GET log action --- src/sunstone/models/SunstoneServer.rb | 28 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index fe2b9efa25..d42a10fceb 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -150,7 +150,11 @@ class SunstoneServer ############################################################################ # ############################################################################ - def get_configuration + def get_configuration(user_id) + if user_id != "0" + return [401, ""] + end + one_config = VAR_LOCATION + "/config" config = Hash.new @@ -178,17 +182,21 @@ class SunstoneServer # ############################################################################ def get_vm_log(id) - id = id.to_s - vm_log_file = VAR_LOCATION + "/#{id}/vm.log" + resource = retrieve_resource("vm", id) + if OpenNebula.is_error?(resource) + return [404, nil] + else + vm_log_file = VAR_LOCATION + "/#{id}/vm.log" - begin - log = File.read(vm_log_file) - rescue Exception => e - error = Error.new("Error: log for VM #{id} not available") - return [500, error.to_s] + begin + log = File.read(vm_log_file) + rescue Exception => e + error = Error.new("Error: log for VM #{id} not available") + return [500, error.to_s] + end + + return [200, log] end - - return [200, log] end private