From b7dde202625a32cf76ec9c19f30c54b896f51691 Mon Sep 17 00:00:00 2001 From: Florent BENOIT Date: Wed, 22 Feb 2017 17:32:08 +0100 Subject: [PATCH] Add search algorithm for host ip with fedora enp* network interfaces #4020 Change-Id: I6b65eba02eaab76260d33ffb323fe7413d5ee162 Signed-off-by: Florent BENOIT --- dockerfiles/ip/src/library.sh | 2 +- .../ip/tests/ip-results/fedora-native.expected | 1 + .../tests/ip-results/fedora-native.interface | 1 + .../ip/tests/ip-results/fedora-native.output | 18 ++++++++++++++++++ .../ip/tests/ip-results/fedora-native.uname | 1 + dockerfiles/ip/tests/library_tests.bats | 4 ++++ 6 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 dockerfiles/ip/tests/ip-results/fedora-native.expected create mode 100644 dockerfiles/ip/tests/ip-results/fedora-native.interface create mode 100644 dockerfiles/ip/tests/ip-results/fedora-native.output create mode 100644 dockerfiles/ip/tests/ip-results/fedora-native.uname diff --git a/dockerfiles/ip/src/library.sh b/dockerfiles/ip/src/library.sh index 94ef3c3226a..a5eb6cb6e49 100644 --- a/dockerfiles/ip/src/library.sh +++ b/dockerfiles/ip/src/library.sh @@ -90,7 +90,7 @@ find_network_interface() { # native mode if test -z ${NETWORK_IF}; then for i in $(get_network_interfaces_list); do - if [ ${i:0:3} = eth ] || [ ${i:0:3} = ens ] || [ ${i:0:4} = wlan ] ;then + if [ ${i:0:3} = eth ] || [ ${i:0:3} = enp ] || [ ${i:0:3} = ens ] || [ ${i:0:4} = wlan ] ;then if has_ip_on_network_interface $i; then NETWORK_IF=$i break diff --git a/dockerfiles/ip/tests/ip-results/fedora-native.expected b/dockerfiles/ip/tests/ip-results/fedora-native.expected new file mode 100644 index 00000000000..a4fe0c380c5 --- /dev/null +++ b/dockerfiles/ip/tests/ip-results/fedora-native.expected @@ -0,0 +1 @@ +192.168.0.209 diff --git a/dockerfiles/ip/tests/ip-results/fedora-native.interface b/dockerfiles/ip/tests/ip-results/fedora-native.interface new file mode 100644 index 00000000000..21132a33870 --- /dev/null +++ b/dockerfiles/ip/tests/ip-results/fedora-native.interface @@ -0,0 +1 @@ +enp2s0 diff --git a/dockerfiles/ip/tests/ip-results/fedora-native.output b/dockerfiles/ip/tests/ip-results/fedora-native.output new file mode 100644 index 00000000000..83d4fa1042f --- /dev/null +++ b/dockerfiles/ip/tests/ip-results/fedora-native.output @@ -0,0 +1,18 @@ +1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1 + link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 + inet 127.0.0.1/8 scope host lo + valid_lft forever preferred_lft forever + inet6 ::1/128 scope host + valid_lft forever preferred_lft forever +2: enp2s0: mtu 1500 qdisc fq_codel state UP qlen 1000 + link/ether 90:e6:ba:52:f3:20 brd ff:ff:ff:ff:ff:ff + inet 192.168.0.209/24 brd 192.168.0.255 scope global dynamic enp2s0 + valid_lft 863569sec preferred_lft 863569sec + inet6 fe80::7d9:e299:80c2:e75b/64 scope link + valid_lft forever preferred_lft forever +3: docker0: mtu 1500 qdisc noqueue state DOWN + link/ether 02:42:57:71:98:fb brd ff:ff:ff:ff:ff:ff + inet 172.17.0.1/16 scope global docker0 + valid_lft forever preferred_lft forever + inet6 fe80::42:57ff:fe71:98fb/64 scope link + valid_lft forever preferred_lft forever diff --git a/dockerfiles/ip/tests/ip-results/fedora-native.uname b/dockerfiles/ip/tests/ip-results/fedora-native.uname new file mode 100644 index 00000000000..3514b906cd0 --- /dev/null +++ b/dockerfiles/ip/tests/ip-results/fedora-native.uname @@ -0,0 +1 @@ +4.4.0-21-generic diff --git a/dockerfiles/ip/tests/library_tests.bats b/dockerfiles/ip/tests/library_tests.bats index 95266c9220b..b07db9f58fd 100644 --- a/dockerfiles/ip/tests/library_tests.bats +++ b/dockerfiles/ip/tests/library_tests.bats @@ -60,6 +60,10 @@ check_ip_result() { check_ip_result "ubuntu-native" } +@test "Get ip based on ip a show interface (fedora/native)" { + check_ip_result "fedora-native" +} + @test "Get ip based on ip a show interface (fedora/multiple-ips)" { check_ip_result "fedora-multiple-ips" }