diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index e194ae532d..730743340a 100644 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -148,6 +148,33 @@ function exec_and_log fi } +# Executes a command, if it fails returns error message and exits. Similar to +# exec_and_log, except that it allows multiline commands. +# If a second parameter is present it is used as the error message when +# the command fails. +function multiline_exec_and_log +{ + message=$2 + + EXEC_LOG_ERR=`bash -s 2>&1 1>/dev/null < :vmm, :action => :attach_nic, - :parameters => [:deploy_id, mac, source, model] + :parameters => [:deploy_id, mac, source, model, net_drv] }, # Execute post-boot networking setup { diff --git a/src/vmm_mad/remotes/kvm/attach_nic b/src/vmm_mad/remotes/kvm/attach_nic index 7c4e539d9d..d37ef7b05e 100755 --- a/src/vmm_mad/remotes/kvm/attach_nic +++ b/src/vmm_mad/remotes/kvm/attach_nic @@ -21,14 +21,36 @@ source $(dirname $0)/../../scripts_common.sh DOMAIN=$1 MAC=$2 -SOURCE=$3 -MODEL=$4 +BRIDGE=$3 +THE_MODEL=$4 +NET_DRV=$5 -ATTACH_ARGS="--domain $DOMAIN --type bridge --source $SOURCE --mac $MAC" - -if [ "$MODEL" != "-" ]; then - ATTACH_ARGS="$ATTACH_ARGS --model $MODEL" +if [ "$THE_MODEL" != "-" ]; then + MODEL="" fi -exec_and_log "virsh --connect $LIBVIRT_URI attach-interface $ATTACH_ARGS" \ - "Could not attach NIC ($MAC) to $DOMAIN" +if [ "$NET_DRV" = "ovswitch" ]; then + VIRTUALPORT="" +fi + +DEVICE=$(cat < + + + $MODEL + $VIRTUALPORT + +EOF +) + +ATTACH_CMD=$(cat <