change the way to get tunnel device

to set local_ip in osh, you have to use nic name.
but some devices can have different nic name.
so I add new option for getting tunnel device by cidr.

Added value:
network:
  interface:
    tunnel: null
    tunnel_network_cidr: "0/0"

Change-Id: I8bffae640dfe0086de0b5274bb8c3cdce9754160
Signed-off-by: Hyunkook Cho <hk0713.cho@samsung.com>
This commit is contained in:
Hyunkook Cho 2019-03-18 19:14:05 +09:00
parent 19a9026d67
commit 3e67ceadb2
3 changed files with 20 additions and 9 deletions

View File

@ -37,9 +37,14 @@ done
tunnel_interface="{{- .Values.network.interface.tunnel -}}" tunnel_interface="{{- .Values.network.interface.tunnel -}}"
if [ -z "${tunnel_interface}" ] ; then if [ -z "${tunnel_interface}" ] ; then
# search for interface with default routing # search for interface with tunnel network routing
# If there is not default gateway, exit tunnel_network_cidr="{{- .Values.network.interface.tunnel_network_cidr -}}"
tunnel_interface=$(ip -4 route list 0/0 | awk -F 'dev' '{ print $2; exit }' | awk '{ print $1 }') || exit 1 if [ -z "${tunnel_network_cidr}" ] ; then
tunnel_network_cidr="0/0"
fi
# If there is not tunnel network gateway, exit
tunnel_interface=$(ip -4 route list ${tunnel_network_cidr} | awk -F 'dev' '{ print $2; exit }' \
| awk '{ print $1 }') || exit 1
fi fi
# determine local-ip dynamically based on interface provided but only if tunnel_types is not null # determine local-ip dynamically based on interface provided but only if tunnel_types is not null

View File

@ -51,9 +51,14 @@ done
tunnel_interface="{{- .Values.network.interface.tunnel -}}" tunnel_interface="{{- .Values.network.interface.tunnel -}}"
if [ -z "${tunnel_interface}" ] ; then if [ -z "${tunnel_interface}" ] ; then
# search for interface with default routing # search for interface with tunnel network routing
# If there is not default gateway, exit tunnel_network_cidr="{{- .Values.network.interface.tunnel_network_cidr -}}"
tunnel_interface=$(ip -4 route list 0/0 | awk -F 'dev' '{ print $2; exit }' | awk '{ print $1 }') || exit 1 if [ -z "${tunnel_network_cidr}" ] ; then
tunnel_network_cidr="0/0"
fi
# If there is not tunnel network gateway, exit
tunnel_interface=$(ip -4 route list ${tunnel_network_cidr} | awk -F 'dev' '{ print $2; exit }' \
| awk '{ print $1 }') || exit 1
fi fi
# determine local-ip dynamically based on interface provided but only if tunnel_types is not null # determine local-ip dynamically based on interface provided but only if tunnel_types is not null

View File

@ -91,10 +91,11 @@ network:
# debugging. This feature requires mount propagation support. # debugging. This feature requires mount propagation support.
share_namespaces: true share_namespaces: true
interface: interface:
# Tunnel interface will be used for VXLAN tunneling. If null # Tunnel interface will be used for VXLAN tunneling.
# (default) there is a fallback mechanism to search for interface
# with default routing.
tunnel: null tunnel: null
# If tunnel is null there is a fallback mechanism to search
# for interface with routing using tunnel network cidr.
tunnel_network_cidr: "0/0"
sriov: sriov:
# To perform setup of network interfaces using the SR-IOV init # To perform setup of network interfaces using the SR-IOV init
# container you can use a section similar to: # container you can use a section similar to: