mirror of
https://github.com/OpenNebula/one.git
synced 2025-04-01 06:50:25 +03:00
Co-authored-by: Vlastimil Holer <vholer@opennebula.io>
This commit is contained in:
parent
ce9b4c7126
commit
011e66b64e
@ -429,6 +429,8 @@ IM_MAD = [
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate=migrate_local,save"
|
||||
# -d <actions> comma separated list of actions which forward SSH agent
|
||||
# from frontend to remote host (default migrate)
|
||||
# -p more than one action per host in parallel, needs support from hypervisor
|
||||
# -s <shell> to execute remote commands, bash by default
|
||||
# -w Timeout in seconds to execute external commands (default unlimited)
|
||||
@ -459,6 +461,8 @@ VM_MAD = [
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate=migrate_local,save"
|
||||
# -d <actions> comma separated list of actions which forward SSH agent
|
||||
# from frontend to remote host (default migrate)
|
||||
# -p more than one action per host in parallel, needs support from hypervisor
|
||||
# -s <shell> to execute remote commands, bash by default
|
||||
# -w Timeout in seconds to execute external commands (default unlimited)
|
||||
@ -485,6 +489,8 @@ VM_MAD = [
|
||||
# overridden for each action.
|
||||
# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll
|
||||
# An example: "-l migrate=migrate_local,save"
|
||||
# -d <actions> comma separated list of actions which forward SSH agent
|
||||
# from frontend to remote host (default migrate)
|
||||
# -p more than one action per host in parallel, needs support from hypervisor
|
||||
# -s <shell> to execute remote commands, bash by default
|
||||
# -w Timeout in seconds to execute external commands (default unlimited)
|
||||
|
@ -22,6 +22,8 @@ class SshStream
|
||||
attr_reader :stream_out, :stream_err, :stdin
|
||||
attr_reader :out, :err
|
||||
|
||||
attr_accessor :forward
|
||||
|
||||
#
|
||||
#
|
||||
EOF_ERR = "EOF_ERR"
|
||||
@ -38,6 +40,7 @@ class SshStream
|
||||
@host = host
|
||||
@shell = shell
|
||||
@timeout = timeout
|
||||
@forward = false
|
||||
end
|
||||
|
||||
def opened?
|
||||
@ -50,7 +53,7 @@ class SshStream
|
||||
|
||||
def open
|
||||
@stdin, @stdout, @stderr, @wait_thr = Open3::popen3(
|
||||
"#{SSH_CMD} #{@host} #{@shell} -s ; echo #{SSH_RC_STR} $? 1>&2",
|
||||
"#{ssh_cmd} #{@host} #{@shell} -s ; echo #{SSH_RC_STR} $? 1>&2",
|
||||
:pgroup => true
|
||||
)
|
||||
|
||||
@ -181,6 +184,16 @@ class SshStream
|
||||
exec(command)
|
||||
wait_for_command
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ssh_cmd
|
||||
if @forward
|
||||
SSH_CMD + ' -o ForwardAgent=yes'
|
||||
else
|
||||
SSH_CMD
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -227,6 +240,10 @@ class SshStreamCommand < RemotesCommand
|
||||
def close
|
||||
@stream.close
|
||||
end
|
||||
|
||||
def set_forward(forward)
|
||||
@stream.forward = forward
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
@ -68,6 +68,9 @@ class VmmAction
|
||||
|
||||
@data = {}
|
||||
|
||||
# Check if SSH Forward Agent should be activated
|
||||
forward = @vmm.options[:delegate_actions].key?(action.to_s.upcase)
|
||||
|
||||
get_data(:host)
|
||||
get_data(:deploy_id)
|
||||
get_data(:checkpoint_file)
|
||||
@ -91,6 +94,10 @@ class VmmAction
|
||||
|
||||
# Initialize streams and vnm
|
||||
@ssh_src = @vmm.get_ssh_stream(action, @data[:host], @id)
|
||||
|
||||
# Activate SSH Forward Agent
|
||||
@ssh_src.set_forward(forward)
|
||||
|
||||
@vnm_src = VirtualNetworkDriver.new(src_drvs,
|
||||
:local_actions => @vmm.options[:local_actions],
|
||||
:message => src_xml.to_s,
|
||||
@ -100,6 +107,10 @@ class VmmAction
|
||||
dst_drvs, dst_xml = get_vnm_drivers(vm_template)
|
||||
|
||||
@ssh_dst = @vmm.get_ssh_stream(action, @data[:dest_host], @id)
|
||||
|
||||
# Activate SSH Forward Agent
|
||||
@ssh_dst.set_forward(forward)
|
||||
|
||||
@vnm_dst = VirtualNetworkDriver.new(dst_drvs,
|
||||
:local_actions => @vmm.options[:local_actions],
|
||||
:message => dst_xml.to_s,
|
||||
@ -1284,6 +1295,7 @@ opts = GetoptLong.new(
|
||||
['--retries', '-r', GetoptLong::OPTIONAL_ARGUMENT],
|
||||
['--threads', '-t', GetoptLong::OPTIONAL_ARGUMENT],
|
||||
['--local', '-l', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--delegate', '-d', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--shell', '-s', GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--parallel', '-p', GetoptLong::NO_ARGUMENT],
|
||||
['--timeout', '-w', GetoptLong::OPTIONAL_ARGUMENT]
|
||||
@ -1294,6 +1306,7 @@ retries = 0
|
||||
threads = 15
|
||||
shell = 'bash'
|
||||
local_actions = {}
|
||||
delegate_actions = OpenNebulaDriver.parse_actions_list('migrate')
|
||||
single_host = true
|
||||
timeout = nil
|
||||
|
||||
@ -1306,6 +1319,8 @@ begin
|
||||
threads = arg.to_i
|
||||
when '--local'
|
||||
local_actions = OpenNebulaDriver.parse_actions_list(arg)
|
||||
when '--delegate'
|
||||
delegate_actions = OpenNebulaDriver.parse_actions_list(arg)
|
||||
when '--shell'
|
||||
shell = arg
|
||||
when '--parallel'
|
||||
@ -1328,6 +1343,7 @@ exec_driver = ExecDriver.new(hypervisor,
|
||||
:concurrency => threads,
|
||||
:retries => retries,
|
||||
:local_actions => local_actions,
|
||||
:delegate_actions => delegate_actions,
|
||||
:shell => shell,
|
||||
:single_host => single_host,
|
||||
:timeout => timeout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user