Merge branch 'bug-2172' into one-4.4

This commit is contained in:
Ruben S. Montero committed 2013-11-11 23:03:50 +01:00
commit 7420927e24
4 files changed
+66 -10

No files matched your search

+27
View File
@@ -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 <<EOF
export LANG=C
export LC_ALL=C
$1
EOF`
EXEC_LOG_RC=$?
if [ $EXEC_LOG_RC -ne 0 ]; then
log_error "Command \"$1\" failed: $EXEC_LOG_ERR"
if [ -n "$2" ]; then
error_message "$2"
else
error_message "Error executing $1: $EXEC_LOG_ERR"
fi
exit $EXEC_LOG_RC
fi
}
# Like exec_and_log but does not exit on failure. Just sets the variable
# ERROR to the error message.
function exec_and_set_error
+8 -1
View File
@@ -772,6 +772,13 @@ class ExecDriver < VirtualMachineDriver
model = model.strip if !model.nil?
model = "-" if model.nil?
net_drv = xml_data.elements["NET_DRV"]
net_drv = net_drv.text if !net_drv.nil?
net_drv = net_drv.strip if !net_drv.nil?
net_drv = "-" if net_drv.nil?
action = VmmAction.new(self, id, :attach_nic, drv_message)
steps=[
@@ -784,7 +791,7 @@ class ExecDriver < VirtualMachineDriver
{
:driver => :vmm,
:action => :attach_nic,
:parameters => [:deploy_id, mac, source, model]
:parameters => [:deploy_id, mac, source, model, net_drv]
},
# Execute post-boot networking setup
{
+30 -8
View File
@@ -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="<model type='$THE_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="<virtualport type='openvswitch'/>"
fi
DEVICE=$(cat <<EOF
<interface type='bridge'>
<source bridge='$BRIDGE'/>
<mac address='$MAC'/>
$MODEL
$VIRTUALPORT
</interface>
EOF
)
ATTACH_CMD=$(cat <<EOF
virsh --connect $LIBVIRT_URI attach-device $DOMAIN <(
cat <<EOT
$DEVICE
EOT
)
EOF
)
multiline_exec_and_log "$ATTACH_CMD" \
"Could not attach $SOURCE ($TARGET) to $DOMAIN"
+1 -1
View File
@@ -33,7 +33,7 @@ deploy_id = ARGV[0]
mac = ARGV[1]
bridge = ARGV[2]
model = ARGV[3]
host = ARGV[5]
host = ARGV[6]
VIDriver::initialize(host, false)