From bb9caeae00bb9e4654838f782d2e07331f4ecae4 Mon Sep 17 00:00:00 2001 From: Brian Haley Date: Mon, 16 Nov 2015 17:18:42 -0500 Subject: [PATCH] Consolidate two /sbin/ip commands into a single one When determining the primary IP/IPv6 addresses on a system, we can use the /sbin/ip command to filter them for us. The resulting address is parsed the same way for both address families, so we can use just a single command. Change-Id: I0471ff5a258a16a23061941ac38063dbf3d7c233 --- lib/neutron-legacy | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/neutron-legacy b/lib/neutron-legacy index 85f7fc0a7c..978943dae2 100644 --- a/lib/neutron-legacy +++ b/lib/neutron-legacy @@ -801,13 +801,7 @@ function _move_neutron_addresses_route { DEFAULT_ROUTE_GW=$(ip -f $af r | awk "/default.+$from_intf/ { print \$3; exit }") local ADD_OVS_PORT="" - if [[ $af == "inet" ]]; then - IP_BRD=$(ip -f $af a s dev $from_intf | grep inet | awk '{ print $2, $3, $4; exit }') - fi - - if [[ $af == "inet6" ]]; then - IP_BRD=$(ip -f $af a s dev $from_intf | grep 'scope global' | sed '/temporary/d' | awk '{ print $2, $3, $4; exit }') - fi + IP_BRD=$(ip -f $af a s dev $from_intf scope global primary | grep inet | awk '{ print $2, $3, $4; exit }') if [ "$DEFAULT_ROUTE_GW" != "" ]; then ADD_DEFAULT_ROUTE="sudo ip -f $af r replace default via $DEFAULT_ROUTE_GW dev $to_intf"