diff --git a/src/authm_mad/one_auth_mad.rb b/src/authm_mad/one_auth_mad.rb index 81ea494ecf..7a244519e9 100755 --- a/src/authm_mad/one_auth_mad.rb +++ b/src/authm_mad/one_auth_mad.rb @@ -111,7 +111,8 @@ class AuthDriver < OpenNebulaDriver command = File.join(authN_path,ACTION[:authN].downcase) command << ' ' << user << ' ' << password << ' ' << secret - local_action(command, request_id, ACTION[:authN]) + do_action(command, request_id, nil, ACTION[:authN], + :local => true) end # Authenticate a user based in a string of the form user:secret when using the @@ -141,7 +142,8 @@ class AuthDriver < OpenNebulaDriver command = @authZ_cmd.clone command << ' ' << user_id << ' ' << requests.join(' ') - local_action(command, request_id, ACTION[:authZ]) + do_action(command, request_id, nil, ACTION[:authZ], + :local => true) end end end diff --git a/src/image_mad/one_image.rb b/src/image_mad/one_image.rb index 72bb6fbbbe..358972a879 100755 --- a/src/image_mad/one_image.rb +++ b/src/image_mad/one_image.rb @@ -69,19 +69,23 @@ class ImageDriver < OpenNebulaDriver # Image Manager Protocol Actions (generic implementation def mv(id, src, dst) - local_action("#{@actions_path}/mv #{src} #{dst} #{id}",id,ACTION[:mv]) + do_action("#{@actions_path}/mv #{src} #{dst} #{id}", id, nil, + ACTION[:mv], :local => true) end def cp(id, src) - local_action("#{@actions_path}/cp #{src} #{id}",id,ACTION[:cp]) + do_action("#{@actions_path}/cp #{src} #{id}", id, nil, ACTION[:cp], + :local => true) end def rm(id, dst) - local_action("#{@actions_path}/rm #{dst} #{id}",id,ACTION[:rm]) + do_action("#{@actions_path}/rm #{dst} #{id}", id, nil, ACTION[:rm], + :local => true) end def mkfs(id, fs, size) - local_action("#{@actions_path}/mkfs #{fs} #{size} #{id}",id,ACTION[:mkfs]) + do_action("#{@actions_path}/mkfs #{fs} #{size} #{id}", id, nil, + ACTION[:mkfs], :local => true) end end diff --git a/src/mad/ruby/OpenNebulaDriver.rb b/src/mad/ruby/OpenNebulaDriver.rb index 6129795d3a..d69d616456 100644 --- a/src/mad/ruby/OpenNebulaDriver.rb +++ b/src/mad/ruby/OpenNebulaDriver.rb @@ -141,21 +141,43 @@ class OpenNebulaDriver < ActionManager def do_action(parameters, id, host, aname, ops={}) options={ :stdin => nil, - :script_name => nil + :script_name => nil, + :respond => true }.merge(ops) params=parameters+" #{id} #{host}" command=action_command_line(aname, params, options[:script_name]) - if action_is_local? aname - local_action(command, id, aname) + if ops[:local] || action_is_local? aname + execution=local_action(command, id, aname) else - remotes_action(command, id, host, aname, @remote_scripts_base_path, - options[:stdin]) + execution=remotes_action(command, id, host, aname, + @remote_scripts_base_path, options[:stdin]) + end + + if ops[:respond] + send_message_from_execution(aname, id, execution) + else + execution end end + def send_message_from_execution(aname, id, command_exe) + if command_exe.code == 0 + result = RESULT[:success] + info = command_exe.stdout + else + result = RESULT[:failure] + info = command_exe.get_error_message + end + + info = "-" if info == nil || info.empty? + + send_message(aname,result,id,info) + end + + # Given the action name and the parameter returns full path of the script # and appends its parameters. It uses @local_actions hash to know if the # actions is remote or local. If the local actions has defined an special @@ -213,17 +235,6 @@ class OpenNebulaDriver < ActionManager log_method(id), std_in, @retries) - if command_exe.code == 0 - result = RESULT[:success] - info = command_exe.stdout - else - result = RESULT[:failure] - info = command_exe.get_error_message - end - - info = "-" if info == nil || info.empty? - - send_message(aname,result,id,info) end # Execute a command associated to an action and id on localhost @@ -233,18 +244,6 @@ class OpenNebulaDriver < ActionManager # @param [String, Symbol] aname name of the action def local_action(command, id, aname) command_exe = LocalCommand.run(command, log_method(id)) - - if command_exe.code == 0 - result = RESULT[:success] - info = command_exe.stdout - else - result = RESULT[:failure] - info = command_exe.get_error_message - end - - info = "-" if info == nil || info.empty? - - send_message(aname,result,id,info) end # Sends a log message to ONE. The +message+ can be multiline, it will