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

feature #924: Add Logger to EC2

This commit is contained in:
Daniel Molina 2012-02-29 15:58:37 +01:00
parent 52ab2afea6
commit 4fd1a87e66
4 changed files with 25 additions and 14 deletions

View File

@ -34,6 +34,9 @@
# x509, for x509 certificate encryption of tokens
:core_auth: cipher
# 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
:debug_level: 3
# VM types allowed and its template file (inside templates directory)
:instance_types:
:m1.small:

View File

@ -61,8 +61,8 @@ class EC2QueryServer < CloudServer
###########################################################################
def initialize(client, config)
super(config)
def initialize(client, config, logger)
super(config, logger)
@client = client
end

View File

@ -33,6 +33,7 @@ end
VIEWS_LOCATION = RUBY_LIB_LOCATION + "/cloud/econe/views"
EC2_AUTH = VAR_LOCATION + "/.one/ec2_auth"
EC2_LOG = VAR_LOCATION + "/econe.log"
$: << RUBY_LIB_LOCATION
$: << RUBY_LIB_LOCATION+"/cloud"
@ -57,12 +58,13 @@ include OpenNebula
begin
conf = YAML.load_file(CONFIGURATION_FILE)
rescue Exception => e
puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}"
STDERR.puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}"
exit 1
end
conf[:template_location] = TEMPLATE_LOCATION
conf[:views] = VIEWS_LOCATION
conf[:debug_level] ||= 3
CloudServer.print_configuration(conf)
@ -70,21 +72,28 @@ CloudServer.print_configuration(conf)
# Sinatra Configuration
##############################################################################
set :config, conf
set :bind, settings.config[:server]
set :port, settings.config[:port]
include CloudLogger
enable_logging EC2_LOG, settings.config[:debug_level].to_i
if CloudServer.is_port_open?(settings.config[:server],
settings.config[:port])
puts "Port busy, please shutdown the service or move econe server port."
exit 1
settings.logger.error {
"Port #{settings.config[:port]} busy, please shutdown " <<
"the service or move occi server port."
}
exit -1
end
set :bind, settings.config[:server]
set :port, settings.config[:port]
begin
ENV["ONE_CIPHER_AUTH"] = EC2_AUTH
cloud_auth = CloudAuth.new(settings.config)
cloud_auth = CloudAuth.new(settings.config, settings.logger)
rescue => e
puts "Error initializing authentication system"
puts e.message
settings.logger.error {"Error initializing authentication system"}
settings.logger.error {e.message}
exit -1
end
@ -116,6 +125,7 @@ before do
params['econe_path'] = settings.econe_path
username = settings.cloud_auth.auth(request.env, params)
rescue Exception => e
logger.error {e.message}
error 500, error_xml("AuthFailure", 0)
end
@ -123,7 +133,7 @@ before do
error 401, error_xml("AuthFailure", 0)
else
client = settings.cloud_auth.client(username)
@econe_server = EC2QueryServer.new(client, settings.config)
@econe_server = EC2QueryServer.new(client, settings.config, settings.logger)
end
end
@ -179,6 +189,7 @@ def do_http_request(params)
end
if OpenNebula::is_error?(result)
logger.error(result.message)
error rc, error_xml(result.message, 0)
end

View File

@ -34,9 +34,6 @@
# x509, for x509 certificate encryption of tokens
:core_auth: cipher
# Life-time in seconds for token renewal (that used to handle OpenNebula auths)
:token_expiration_delta: 1800
# 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
:debug_level: 3