Browse code

Merge "Always add OVS port in _move_neutron_addresses_route"

Jenkins authored on 2015/08/25 02:08:35
Showing 1 changed files
... ...
@@ -795,7 +795,8 @@ function stop_neutron {
795 795
 }
796 796
 
797 797
 # _move_neutron_addresses_route() - Move the primary IP to the OVS bridge
798
-# on startup, or back to the public interface on cleanup
798
+# on startup, or back to the public interface on cleanup. If no IP is
799
+# configured on the interface, just add it as a port to the OVS bridge.
799 800
 function _move_neutron_addresses_route {
800 801
     local from_intf=$1
801 802
     local to_intf=$2
... ...
@@ -808,7 +809,8 @@ function _move_neutron_addresses_route {
808 808
         # on configure we will also add $from_intf as a port on $to_intf,
809 809
         # assuming it is an OVS bridge.
810 810
 
811
-        local IP_BRD=$(ip -f $af a s dev $from_intf | awk '/inet/ { print $2, $3, $4; exit }')
811
+        local IP_ADD=""
812
+        local IP_DEL=""
812 813
         local DEFAULT_ROUTE_GW=$(ip r | awk "/default.+$from_intf/ { print \$3; exit }")
813 814
         local ADD_OVS_PORT=""
814 815
 
... ...
@@ -828,7 +830,12 @@ function _move_neutron_addresses_route {
828 828
             ADD_OVS_PORT="sudo ovs-vsctl --may-exist add-port $to_intf $from_intf"
829 829
         fi
830 830
 
831
-        sudo ip addr del $IP_BRD dev $from_intf; sudo ip addr add $IP_BRD dev $to_intf; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE
831
+        if [[ "$IP_BRD" != "" ]]; then
832
+            IP_ADD="sudo ip addr del $IP_BRD dev $from_intf"
833
+            IP_DEL="sudo ip addr add $IP_BRD dev $to_intf"
834
+        fi
835
+
836
+        $IP_ADD; $IP_DEL; $ADD_OVS_PORT; $ADD_DEFAULT_ROUTE
832 837
     fi
833 838
 }
834 839
 
... ...
@@ -836,9 +843,7 @@ function _move_neutron_addresses_route {
836 836
 # runs that a clean run would need to clean up
837 837
 function cleanup_neutron {
838 838
 
839
-    if [[ $(ip -f inet a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then
840
-        _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet"
841
-    fi
839
+    _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet"
842 840
 
843 841
     if [[ $(ip -f inet6 a s dev "$OVS_PHYSICAL_BRIDGE" | grep -c 'global') != 0 ]]; then
844 842
         _move_neutron_addresses_route "$OVS_PHYSICAL_BRIDGE" "$PUBLIC_INTERFACE" False "inet6"
... ...
@@ -1023,9 +1028,7 @@ function _configure_neutron_l3_agent {
1023 1023
 
1024 1024
     neutron_plugin_configure_l3_agent
1025 1025
 
1026
-    if [[ $(ip -f inet a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then
1027
-        _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True "inet"
1028
-    fi
1026
+    _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" True "inet"
1029 1027
 
1030 1028
     if [[ $(ip -f inet6 a s dev "$PUBLIC_INTERFACE" | grep -c 'global') != 0 ]]; then
1031 1029
         _move_neutron_addresses_route "$PUBLIC_INTERFACE" "$OVS_PHYSICAL_BRIDGE" False "inet6"