kuryr bind port error with neutron linux bridge driver

When neutron configured with linux bridge driver, kuryr will bind
port error. The linux bridge name should be "brq"+network_id[0,11].

Change-Id: I07be68bbfe7b1384f4e946664aed41546ff9ddce
Closes-bug: #1638041
This commit is contained in:
Liping Mao 2016-10-31 23:47:52 +08:00
parent 31325bd85a
commit d241bbbb2f
2 changed files with 20 additions and 10 deletions

View File

@ -108,9 +108,10 @@ def port_unbind(endpoint_id, neutron_port):
ifname, _ = utils.get_veth_pair_names(port_id) ifname, _ = utils.get_veth_pair_names(port_id)
mac_address = neutron_port['mac_address'] mac_address = neutron_port['mac_address']
network_id = neutron_port['network_id']
stdout, stderr = processutils.execute( stdout, stderr = processutils.execute(
unbinding_exec_path, UNBINDING_SUBCOMMAND, port_id, ifname, unbinding_exec_path, UNBINDING_SUBCOMMAND, port_id, ifname,
endpoint_id, mac_address, vif_details, run_as_root=True) endpoint_id, mac_address, vif_details, network_id, run_as_root=True)
try: try:
utils.remove_device(ifname) utils.remove_device(ifname)
except pyroute2.NetlinkError: except pyroute2.NetlinkError:

View File

@ -12,10 +12,15 @@
# under the License. # under the License.
bind_port() { bind_port() {
echo "plugging veth $2 (Neutron port $1)..." PORT_ID=$1
IFNAME=$2
ENDPOINT_ID=$3
MAC_ADDRESS=$4
NET_ID=$5
echo "plugging veth $IFNAME (Neutron port $PORT_ID)..."
# create a linux bridge # create a linux bridge
br_name="br"${4:0:12} br_name="brq"${NET_ID:0:11}
ip link show $br_name ip link show $br_name
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Bridge $br_name does not exist, create it" echo "Bridge $br_name does not exist, create it"
@ -28,17 +33,21 @@ bind_port() {
fi fi
# connect the veth outside to linux bridge # connect the veth outside to linux bridge
ip link set dev $2 master $br_name ip link set dev $IFNAME master $br_name
ip link set $2 up ip link set $IFNAME up
} }
unbind_port() { unbind_port() {
echo "unplugging veth $1..." PORT_ID=$1
br_name="br"${3:0:12} IFNAME=$2
ENDPOINT_ID=$3
MAC_ADDRESS=$4
VIF_DETAILs=$5
NET_ID=$6
echo "unplugging veth $IFNAME..."
br_name="brq"${NET_ID:0:11}
ip link set dev $2 nomaster ip link set dev $IFNAME nomaster
ip link set $br_name down
ip link delete $br_name type bridge
} }
case $1 in case $1 in