Whamcloud - gitweb
LU-16694 tests: replace resolveip script
authorVitaliy Kuznetsov <vkuznetsov@ddn.com>
Tue, 10 Oct 2023 14:55:34 +0000 (16:55 +0200)
committerAndreas Dilger <adilger@whamcloud.com>
Sat, 21 Oct 2023 17:40:05 +0000 (17:40 +0000)
The resolveip script can be replaced with a bash one-liner,
using getent and awk.

Lustre-change: https://review.whamcloud.com/50491
Lustre-commit: f8cc7db39dd22fdb6330402a60af7bb30c78449e

Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Signed-off-by: Vitaliy Kuznetsov <vkuznetsov@ddn.com>
Change-Id: I207ea011e43b7b236d5082994ffb51654d8d782c
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52781
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/tests/Makefile.am
lustre/tests/resolveip [deleted file]
lustre/tests/test-framework.sh

index ceb267c..e0e5a5d 100644 (file)
@@ -37,7 +37,6 @@ noinst_SCRIPTS += sanity-laudit.sh
 noinst_SCRIPTS += sanity-lfsck.sh lfsck-performance.sh sanity-lipe.sh
 noinst_SCRIPTS += sanity-lipe-find3.sh
 noinst_SCRIPTS += sanity-lipe-scan3.sh
-noinst_SCRIPTS += resolveip
 noinst_SCRIPTS += sanity-hsm.sh sanity-lsnapshot.sh sanity-pfl.sh sanity-flr.sh
 noinst_SCRIPTS += sanity-dom.sh sanity-pcc.sh dom-performance.sh sanity-lnet.sh
 noinst_SCRIPTS += sanity-pumount.sh
diff --git a/lustre/tests/resolveip b/lustre/tests/resolveip
deleted file mode 100755 (executable)
index 0e3cfd0..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-#!/usr/bin/perl
-=pod
-
-=head1 NAME
-
-resolveip - Resolve IP address for given hostname
-
-=head1 DESCRIPTION
-
-Tries to resolve IP address of given hostname and return its value,
-returns empty value if unable to detect it.
-
-=cut
-
-use Socket;
-$hostname = $ARGV[0];
-
-sub resolve_ip {
-       ($hostname) = @_;
-
-       return unless defined $hostname;
-
-       $packed_ip = gethostbyname($hostname);
-       if (defined $packed_ip) {
-               $ip_address = inet_ntoa($packed_ip);
-               return $ip_address;
-       }
-}
-
-$ip = resolve_ip($hostname);
-
-if (not $ip or $ip eq '') {
-       print STDERR "Unable to detect ip address for host: '$hostname'\n";
-       exit 1;
-}
-
-print $ip;
-
-exit 0;
index 57ab271..8c00b08 100755 (executable)
@@ -7203,7 +7203,8 @@ local_node() {
        local is_local="IS_LOCAL_$(host_id $host_name)"
        if [ -z "${!is_local-}" ] ; then
                eval $is_local=0
-               local host_ip=$($LUSTRE/tests/resolveip $host_name)
+               local host_ip=$(getent ahostsv4 $host_name |
+                                       awk '{ print $1; exit; }')
                is_local_addr "$host_ip" && eval $is_local=1
        fi
        [[ "${!is_local}" == "1" ]]