From 1c35ad7980c150614e4f156354a2393e0581250b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Font=C3=A1n=20Mui=C3=B1os?= Date: Tue, 21 Jul 2009 15:23:08 +0000 Subject: [PATCH] Make Oca aware of ONE_LOCATION git-svn-id: http://svn.opennebula.org/one/trunk@712 3034c82b-c49b-4eb3-8279-a7acafdc01c0 --- src/oca/ec2/eco.rb | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/src/oca/ec2/eco.rb b/src/oca/ec2/eco.rb index 5cbc098e5e..091e905dfa 100644 --- a/src/oca/ec2/eco.rb +++ b/src/oca/ec2/eco.rb @@ -1,12 +1,23 @@ + +ONE_LOCATION=ENV["ONE_LOCATION"] + +if !ONE_LOCATION + RUBY_LIB_LOCATION="/usr/lib/one/ruby" +else + RUBY_LIB_LOCATION=ONE_LOCATION+"/lib/ruby" + TEMPLATES_LOCATION=ONE_LOCATION+"/etc/ec2query_templates" + CONF_LOCATION=ONE_LOCATION+"/etc" +end + +$: << RUBY_LIB_LOCATION + + require 'rubygems' require 'sinatra' require 'EC2' require 'time' -$: << './OpenNebulaApi' -$: << './lib' - require 'OpenNebula' require 'repo_manager' require 'OcaConfiguration' @@ -18,8 +29,9 @@ include OpenNebula -CONFIG=OcaConfiguration.new('oca.conf') +CONFIG=OcaConfiguration.new(CONF_LOCATION+'/oca.conf') AUTH="#{CONFIG[:user]}:#{CONFIG[:password]}" +Image.image_dir=CONFIG[:image_dir] INSTANCE_TYPES=Hash.new @@ -159,7 +171,8 @@ def run_instances(params) @vm_info[:instance_type]=instance_type_name - template=ERB.new(File.read("templates/#{instance_type['TEMPLATE']}")) + template=ERB.new(File.read( + TEMPLATES_LOCATION+"/#{instance_type['TEMPLATE']}")) template_text=template.result(binding) pp template_text @@ -279,7 +292,7 @@ __END__ <% vm.info %> <%= vm.id %> - <%= vm.id %> + <%= vm['TEMPLATE/IMAGE_ID'] %> <%= render_state(vm) %>