diff --git a/src/cloud/ec2/lib/EC2QueryServer.rb b/src/cloud/ec2/lib/EC2QueryServer.rb index 5240d73be8..0783f3da34 100644 --- a/src/cloud/ec2/lib/EC2QueryServer.rb +++ b/src/cloud/ec2/lib/EC2QueryServer.rb @@ -137,10 +137,10 @@ class EC2QueryServer < CloudServer # Get the instance type and path if params['InstanceType'] != nil instance_type_name = params['InstanceType'] - instance_type = @config[:instance_types][instance_type_name] + instance_type = @config[:instance_types][instance_type_name.to_sym] if instance_type != nil - path = @config[:template_location] + "/#{instance_type['TEMPLATE']}" + path = @config[:template_location] + "/#{instance_type[:template]}" end end diff --git a/src/cloud/ec2/lib/econe-server.rb b/src/cloud/ec2/lib/econe-server.rb index def4803bb5..a3f9da84e7 100644 --- a/src/cloud/ec2/lib/econe-server.rb +++ b/src/cloud/ec2/lib/econe-server.rb @@ -46,34 +46,34 @@ require 'Configuration' include OpenNebula +############################################################################## +# Parse Configuration file +############################################################################## begin - config = Configuration.new(CONFIGURATION_FILE) - config.add_configuration_value("TEMPLATE_LOCATION", TEMPLATE_LOCATION) - config.add_configuration_value("VIEWS", VIEWS_LOCATION) - - instance_types = CloudServer.get_instance_types(config) - config.add_configuration_value("INSTANCE_TYPES", instance_types) - - CloudServer.print_configuration(config) - - set :config, config + conf = YAML.load_file(CONFIGURATION_FILE) rescue Exception => e - puts "Error starting server: #{e}" - exit(-1) + puts "Error parsing config file #{CONFIGURATION_FILE}: #{e.message}" + exit 1 end -if CloudServer.is_port_open?(settings.config[:server], - settings.config[:port]) - puts "Port busy, please shutdown the service or move econe server port." - exit -end +conf[:template_location] = TEMPLATE_LOCATION +conf[:views] = VIEWS_LOCATION + +CloudServer.print_configuration(conf) ############################################################################## # Sinatra Configuration ############################################################################## +set :config, conf set :host, settings.config[:server] set :port, settings.config[:port] +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 +end + ############################################################################## # Actions ############################################################################## diff --git a/src/cloud/occi/etc/occi-server.conf b/src/cloud/occi/etc/occi-server.conf index a92f46ce2a..ec74643b19 100644 --- a/src/cloud/occi/etc/occi-server.conf +++ b/src/cloud/occi/etc/occi-server.conf @@ -14,23 +14,29 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# OpenNebula server contact information -ONE_XMLRPC=http://localhost:2633/RPC2 +# OpenNebula sever contact information +:one_xmlrpc: http://localhost:2633/RPC2 -# Host and port where the occi server will run -SERVER= -PORT=4567 +# Host and port where econe server will run +:server: localhost +:port: 4567 # SSL proxy that serves the API (set if is being used) -#SSL_SERVER=https://localhost:443 - -AUTH=basic +#:ssl_server: fqdm.of.the.server # Configuration for OpenNebula's Virtual Networks -BRIDGE= +#:bridge: +:bridge: vbr1 + +:auth: basic # VM types allowed and its template file (inside templates directory) -VM_TYPE=[NAME=custom, TEMPLATE=custom.erb] -VM_TYPE=[NAME=small, TEMPLATE=small.erb] -VM_TYPE=[NAME=medium, TEMPLATE=medium.erb] -VM_TYPE=[NAME=large, TEMPLATE=large.erb] +:instance_types: + :custom: + :template: custom.erb + :small: + :template: small.erb + :medium: + :template: medium.erb + :large: + :template: large.erb