diff --git a/lib/neutron_plugins/openvswitch_agent b/lib/neutron_plugins/openvswitch_agent index 1d24f3b837..2a05e2dcfa 100644 --- a/lib/neutron_plugins/openvswitch_agent +++ b/lib/neutron_plugins/openvswitch_agent @@ -59,7 +59,7 @@ function neutron_plugin_configure_plugin_agent { OVS_BRIDGE_MAPPINGS=$PHYSICAL_NETWORK:$OVS_PHYSICAL_BRIDGE # Configure bridge manually with physical interface as port for multi-node - sudo ovs-vsctl --no-wait -- --may-exist add-br $OVS_PHYSICAL_BRIDGE + _neutron_ovs_base_add_bridge $OVS_PHYSICAL_BRIDGE fi if [[ "$OVS_BRIDGE_MAPPINGS" != "" ]]; then iniset /$Q_PLUGIN_CONF_FILE ovs bridge_mappings $OVS_BRIDGE_MAPPINGS @@ -92,7 +92,7 @@ function neutron_plugin_configure_plugin_agent { # Set up domU's L2 agent: # Create a bridge "br-$GUEST_INTERFACE_DEFAULT" - sudo ovs-vsctl --no-wait -- --may-exist add-br "br-$GUEST_INTERFACE_DEFAULT" + _neutron_ovs_base_add_bridge "br-$GUEST_INTERFACE_DEFAULT" # Add $GUEST_INTERFACE_DEFAULT to that bridge sudo ovs-vsctl add-port "br-$GUEST_INTERFACE_DEFAULT" $GUEST_INTERFACE_DEFAULT diff --git a/lib/neutron_plugins/ovs_base b/lib/neutron_plugins/ovs_base index 81561d3114..4e750f0932 100644 --- a/lib/neutron_plugins/ovs_base +++ b/lib/neutron_plugins/ovs_base @@ -15,13 +15,21 @@ function is_neutron_ovs_base_plugin { return 0 } +function _neutron_ovs_base_add_bridge { + local bridge=$1 + local addbr_cmd="sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge" + + if [ "$OVS_DATAPATH_TYPE" != "" ] ; then + addbr_cmd="$addbr_cmd -- set Bridge $bridge datapath_type=${OVS_DATAPATH_TYPE}" + fi + + $addbr_cmd +} + function _neutron_ovs_base_setup_bridge { local bridge=$1 neutron-ovs-cleanup - sudo ovs-vsctl --no-wait -- --may-exist add-br $bridge - if [[ $OVS_DATAPATH_TYPE != "" ]]; then - sudo ovs-vsctl set Bridge $bridge datapath_type=${OVS_DATAPATH_TYPE} - fi + _neutron_ovs_base_add_bridge $bridge sudo ovs-vsctl --no-wait br-set-external-id $bridge bridge-id $bridge } @@ -92,7 +100,7 @@ function _neutron_ovs_base_configure_l3_agent { sudo ip link set $Q_PUBLIC_VETH_EX up sudo ip addr flush dev $Q_PUBLIC_VETH_EX else - sudo ovs-vsctl -- --may-exist add-br $PUBLIC_BRIDGE + _neutron_ovs_base_add_bridge $PUBLIC_BRIDGE sudo ovs-vsctl br-set-external-id $PUBLIC_BRIDGE bridge-id $PUBLIC_BRIDGE fi }