mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-16 17:53:08 +09:00
vmm_mad: now deployment file copy is logged to vm log file
git-svn-id: http://svn.opennebula.org/one/trunk@252 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
1 parent
e5ec947c95
commit
ae3f6534f6
3 files changed
+40
-10
No files matched your search
@@ -145,5 +145,29 @@ class ONEMad
|
||||
def action_finalize(args)
|
||||
exit(0)
|
||||
end
|
||||
|
||||
# Functions for VM deployment
|
||||
# TODO: Move elsewhere
|
||||
def get_local_deployment_file(remote_deployment_file)
|
||||
local_deployment_file=nil
|
||||
|
||||
one_location=ENV["ONE_LOCATION"]
|
||||
m=remote_deployment_file.match(/.*?\/(\d+)\/images\/(deployment.\d+)$/)
|
||||
local_deployment_file="#{one_location}/var/#{m[1]}/#{m[2]}" if m
|
||||
|
||||
return local_deployment_file
|
||||
end
|
||||
|
||||
def execute_local_command(cmd_string)
|
||||
command=SSHCommand.new(cmd_string)
|
||||
stdout, stderr=command.exec_local_command(cmd_string)
|
||||
exit_code=command.get_exit_code(stderr)
|
||||
if exit_code!=0
|
||||
return stderr
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
@@ -37,7 +37,7 @@ class SSHCommand
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
#private
|
||||
|
||||
# Gets exit code from STDERR
|
||||
def get_exit_code(str)
|
||||
|
||||
@@ -36,26 +36,32 @@ class DM < ONEMad
|
||||
def action_init(args)
|
||||
send_message("INIT", "SUCCESS")
|
||||
end
|
||||
|
||||
|
||||
def action_deploy(args)
|
||||
action_number=args[1]
|
||||
action_host=args[2]
|
||||
remote_deployment_file=args[3]
|
||||
|
||||
# Get local deployment file
|
||||
one_location=ENV["ONE_LOCATION"]
|
||||
m=args[3].match(/.*?\/(\d+)\/images\/(deployment.\d+)$/)
|
||||
local_deployment_file=get_local_deployment_file(remote_deployment_file)
|
||||
|
||||
# If matched the we can read the file and get more configuration values
|
||||
if m
|
||||
local_deployment_file="#{one_location}/var/#{m[1]}/#{m[2]}"
|
||||
|
||||
if local_deployment_file
|
||||
# TODO: review this way of copying files
|
||||
# This command copies deployment file to remote machine
|
||||
# when shared directories are not used
|
||||
copy_deploy="scp #{local_deployment_file} #{args[2]}:#{args[3]}"
|
||||
copy_deploy_exit=system(copy_deploy)
|
||||
copy_deploy="scp #{local_deployment_file} "+
|
||||
"#{action_host}:#{remote_deployment_file}"
|
||||
mad_log("DEPLOY", action_number, "Command: #{copy_deploy}")
|
||||
mad_log("DEPLOY", action_number, "Command finalized: "+copy_deploy_exit.to_s)
|
||||
copy_deploy_exit=execute_local_command(copy_deploy)
|
||||
|
||||
if copy_deploy_exit
|
||||
mad_log("DEPLOY", action_number,
|
||||
"Error: "+copy_deploy_exit.to_s)
|
||||
else
|
||||
mad_log("DEPLOY", action_number,
|
||||
"Copy success")
|
||||
end
|
||||
|
||||
|
||||
# TODO: check for error
|
||||
|
||||
Reference in new issue
Block a user