From 2b8814d0ecbca897f4bcfdf1117e773bc4b45e77 Mon Sep 17 00:00:00 2001 From: Mate Lakat Date: Wed, 25 Sep 2013 17:07:06 +0100 Subject: [PATCH] xenapi: enable user to specify FLAT_NETWORK_BRIDGE install_os_domU.sh failed, if the FLAT_NETWORK_BRIDGE is found in localrc. As nova looks up the network by either name-label or bridge name, it makes sense to enable the user to specify this parameter. As an example, if the user wants to use name-labels to specify networks, and those name-labels could be used in domU to create bridges: VM_BRIDGE_OR_NET_NAME="osvmnet" FLAT_NETWORK_BRIDGE="osvmnet" In this case, the domU will know only about a name label, so it could be decoupled from which xapi bridges used. This change also adds some fixes (missing double quotes). Change-Id: I045e367ef441be20c4e8cb8af3c1149392db796b --- tools/xen/functions | 4 ++-- tools/xen/install_os_domU.sh | 15 +++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/tools/xen/functions b/tools/xen/functions index b0b077d8d1..563303da21 100644 --- a/tools/xen/functions +++ b/tools/xen/functions @@ -137,14 +137,14 @@ function _network_exists() { local name_label name_label=$1 - ! [ -z $(xe network-list name-label="$name_label" --minimal) ] + ! [ -z "$(xe network-list name-label="$name_label" --minimal)" ] } function _bridge_exists() { local bridge bridge=$1 - ! [ -z $(xe network-list bridge="$bridge" --minimal) ] + ! [ -z "$(xe network-list bridge="$bridge" --minimal)" ] } function _network_uuid() { diff --git a/tools/xen/install_os_domU.sh b/tools/xen/install_os_domU.sh index 33dc26f1bb..6ce334bc00 100755 --- a/tools/xen/install_os_domU.sh +++ b/tools/xen/install_os_domU.sh @@ -111,12 +111,15 @@ if is_service_enabled neutron; then fi if parameter_is_specified "FLAT_NETWORK_BRIDGE"; then - cat >&2 << EOF -ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file -This is considered as an error, as its value will be derived from the -VM_BRIDGE_OR_NET_NAME variable's value. + if [ "$(bridge_for "$VM_BRIDGE_OR_NET_NAME")" != "$(bridge_for "$FLAT_NETWORK_BRIDGE")" ]; then + cat >&2 << EOF +ERROR: FLAT_NETWORK_BRIDGE is specified in localrc file, and either no network +found on XenServer by searching for networks by that value as name-label or +bridge name or the network found does not match the network specified by +VM_BRIDGE_OR_NET_NAME. Please check your localrc file. EOF - exit 1 + exit 1 + fi fi if ! xenapi_is_listening_on "$MGT_BRIDGE_OR_NET_NAME"; then @@ -310,7 +313,7 @@ if is_service_enabled neutron; then "xen_integration_bridge=${XEN_INTEGRATION_BRIDGE}" fi -FLAT_NETWORK_BRIDGE=$(bridge_for "$VM_BRIDGE_OR_NET_NAME") +FLAT_NETWORK_BRIDGE="${FLAT_NETWORK_BRIDGE:-$(bridge_for "$VM_BRIDGE_OR_NET_NAME")}" append_kernel_cmdline "$GUEST_NAME" "flat_network_bridge=${FLAT_NETWORK_BRIDGE}" # Add a separate xvdb, if it was requested