1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-25 23:21:29 +03:00

B #3373: pass VM template via STDIN (#3583)

This commit is contained in:
Jan Orel 2019-08-12 16:02:25 +02:00 committed by Ruben S. Montero
parent a551326e77
commit 41d9e000ed
8 changed files with 24 additions and 20 deletions

View File

@ -32,7 +32,7 @@ DST_PATH=$3
VMID=$4
DSID=$5
TEMPLATE_64=$6
TEMPLATE_64=$(cat)
#--------------------------------------------------------------------------------
@ -53,8 +53,8 @@ fi
#--------------------------------------------------------------------------------
if [ -n "$7" ]; then
log "Called from tm/$7 but I've nothing to do"
if [ -n "$6" ]; then
log "Called from tm/$6 but I've nothing to do"
exit 0
fi

View File

@ -32,7 +32,7 @@ DST_PATH=$3
VMID=$4
DSID=$5
TEMPLATE_64=$6
TEMPLATE_64=$(cat)
#--------------------------------------------------------------------------------
@ -53,8 +53,8 @@ fi
#--------------------------------------------------------------------------------
if [ -n "$7" ]; then
log "Called from tm/$7 but I've nothing to do"
if [ -n "$6" ]; then
log "Called from tm/$6 but I've nothing to do"
exit 0
fi

View File

@ -30,8 +30,7 @@ DST_HOST="$2"
DST_PATH="$3"
VM_ID="$4"
DS_ID="$5"
TEMPLATE_64="$6"
SYSTEM_MAD="$7"
TEMPLATE_64=$(cat)
#--------------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@ DST_PATH=$3
VMID=$4
DSID=$5
TEMPLATE_64=$6
TEMPLATE_64=$(cat)
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh

View File

@ -32,7 +32,7 @@ DST_PATH=$3
VMID=$4
DSID=$5
TEMPLATE_64=$6
TEMPLATE_64=$(cat)
if [ -z "${ONE_LOCATION}" ]; then
TMCOMMON=/var/lib/one/remotes/tm/tm_common.sh

View File

@ -96,7 +96,8 @@ class TransferManagerDriver < OpenNebulaDriver
# method
# @param id [String] with the OpenNebula ID for the TRANSFER action
# @param command [Array]
def do_transfer_action(id, command)
# @param stdin [String]
def do_transfer_action(id, command, stdin=nil)
cmd = command[0].downcase
tm = command[1]
args = command[2..-1].map{|e| Shellwords.escape(e)}.join(" ")
@ -122,7 +123,7 @@ class TransferManagerDriver < OpenNebulaDriver
end
path << " " << args
rc = LocalCommand.run(path, log_method(id))
rc = LocalCommand.run(path, log_method(id), stdin)
result, info = get_info_from_execution(rc)

View File

@ -115,6 +115,7 @@ function lcm_state
function migrate_other
{
DRIVER_PATH=$(dirname $0)
MAD=${DRIVER_PATH##*/}
@ -123,7 +124,7 @@ function migrate_other
unset i
while IFS= read -r -d '' element; do
XPATH_ELEMENTS[i++]="$element"
done< <("$XPATH" -b "$6" \
done< <(echo $TEMPLATE_64 | base64 -d | "$XPATH" \
/VM/TEMPLATE/CONTEXT/DISK_ID \
%m%/VM/TEMPLATE/DISK/DISK_ID \
%m%/VM/TEMPLATE/DISK/CLONE \
@ -138,7 +139,7 @@ function migrate_other
CLONE_ARRAY=($CLONES)
TM_MAD_ARRAY=($TM_MADS)
if [ -n "$7" ]; then
if [ -n "$6" ]; then
return 0
fi
@ -152,7 +153,7 @@ function migrate_other
# call the other TM_MADs with same arguments
# but mark that it is not SYSTEM_DS
log "Call $TM/${0##*/}"
"${DRIVER_PATH}/../$TM/${0##*/}" "$@" "$MAD"
echo $TEMPLATE_64 | "${DRIVER_PATH}/../$TM/${0##*/}" "$@" "$MAD"
PROCESSED+=" $TM "
fi
done

View File

@ -227,7 +227,7 @@ class VmmAction
result, info = vnm.do_action(@id, step[:action],
:parameters => params)
when :tm
result, info = @tm.do_transfer_action(@id, step[:parameters])
result, info = @tm.do_transfer_action(@id, step[:parameters], stdin=step[:stdin])
else
result = DriverExecHelper.const_get(:RESULT)[:failure]
@ -517,16 +517,17 @@ class ExecDriver < VirtualMachineDriver
post = 'POST'
failed = 'FAIL'
pre << action.data[:tm_command] << ' ' << action.data[:vm]
post << action.data[:tm_command] << ' ' << action.data[:vm]
failed << action.data[:tm_command] << ' ' << action.data[:vm]
pre << action.data[:tm_command]
post << action.data[:tm_command]
failed << action.data[:tm_command]
steps = [
# Execute a pre-migrate TM setup
{
:driver => :tm,
:action => :tm_premigrate,
:parameters => pre.split
:parameters => pre.split,
:stdin => action.data[:vm]
},
# Execute pre-boot networking setup on migrating host
{
@ -544,6 +545,7 @@ class ExecDriver < VirtualMachineDriver
:driver => :tm,
:action => :tm_failmigrate,
:parameters => failed.split,
:stdin => action.data[:vm],
:no_fail => true
}
]
@ -569,6 +571,7 @@ class ExecDriver < VirtualMachineDriver
:driver => :tm,
:action => :tm_postmigrate,
:parameters => post.split,
:stdin => action.data[:vm],
:no_fail => true
}
]