1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-27 14:03:40 +03:00

bug #339: remote scripts directory is defined in oned.conf

This commit is contained in:
Javi Fontan 2010-09-10 16:42:18 +02:00
parent 99e1f565e3
commit 6bb52aeaec
4 changed files with 49 additions and 14 deletions

View File

@ -35,6 +35,8 @@ VM_POLLING_INTERVAL = 600
#VM_DIR=/srv/cloud/one/var
SCRIPTS_REMOTE_DIR=/tmp/one
PORT=2633
DB = [ backend = "sqlite" ]

View File

@ -43,12 +43,14 @@ class InformationManager < OpenNebulaDriver
#---------------------------------------------------------------------------
# Init the driver
#---------------------------------------------------------------------------
def initialize(remote_dir, hypervisor, num)
def initialize(hypervisor, num)
super(num, true)
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = remote_dir
@remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one'
# register actions
register_action(:MONITOR, method("action_monitor"))
end
@ -89,9 +91,6 @@ end
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
remote_dir = ENV["IM_REMOTE_DIR"]
remote_dir = "/tmp/one" if !remote_dir
hypervisor = ARGV[0]||''
im = InformationManager.new(remote_dir, hypervisor, 15)
im = InformationManager.new(hypervisor, 15)
im.start_driver

View File

@ -177,6 +177,40 @@ class ActionManager
private
def read_configuration
one_config=nil
if ENV['ONE_LOCATION']
one_config=ENV['ONE_LOCATION']+'/var/config'
else
one_config='/var/log/one/config'
end
config=Hash.new
cfg=''
begin
open(one_config) do |file|
cfg=file.read
end
cfg.split(/\n/).each do |line|
m=line.match(/^([^=]+)=(.*)$/)
if m
name=m[1].strip.upcase
value=m[2].strip
config[name]=value
end
end
rescue Exception => e
STDERR.puts "Error reading config: #{e.inspect}"
STDERR.flush
end
config
end
def delete_running_action(action_id)
@action_running.delete(action_id)
end

View File

@ -41,10 +41,13 @@ class ShDriver < VirtualMachineDriver
# ------------------------------------------------------------------------ #
# ShDriver constructor #
# ------------------------------------------------------------------------ #
def initialize(hypervisor, remote_dir)
def initialize(hypervisor)
super(15,true)
@remote_dir = remote_dir
@config = read_configuration
@hypervisor = hypervisor
@remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one'
end
# ------------------------------------------------------------------------ #
@ -119,10 +122,7 @@ end
# ---------------------------------------------------------------------------- #
# ShDriver Main program
# ---------------------------------------------------------------------------- #
remote_dir = ENV["VMM_REMOTE_DIR"]
remote_dir = "/tmp/one" if !remote_dir
hypervisor = ARGV[0]
sh_driver = ShDriver.new(hypervisor, remote_dir)
sh_driver = ShDriver.new(hypervisor)
sh_driver.start_driver