From f8cc7db39dd22fdb6330402a60af7bb30c78449e Mon Sep 17 00:00:00 2001 From: Timothy Day Date: Fri, 31 Mar 2023 04:40:38 +0000 Subject: [PATCH] LU-16694 tests: replace resolveip script The resolveip script can be replaced with a bash one-liner, using getent and awk. Test-Parameters: trivial Signed-off-by: Timothy Day Change-Id: I207ea011e43b7b236d5082994ffb51654d8d782c Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50491 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Alex Deiter Reviewed-by: Oleg Drokin --- lustre/tests/Makefile.am | 1 - lustre/tests/resolveip | 39 --------------------------------------- lustre/tests/test-framework.sh | 3 ++- 3 files changed, 2 insertions(+), 41 deletions(-) delete mode 100755 lustre/tests/resolveip diff --git a/lustre/tests/Makefile.am b/lustre/tests/Makefile.am index c1d2a09..330b403 100644 --- a/lustre/tests/Makefile.am +++ b/lustre/tests/Makefile.am @@ -41,7 +41,6 @@ noinst_SCRIPTS += parallel-scale-nfsv3.sh parallel-scale-nfsv4.sh noinst_SCRIPTS += setup-cifs.sh parallel-scale-cifs.sh noinst_SCRIPTS += posix.sh sanity-scrub.sh scrub-performance.sh ha.sh pjdfstest.sh noinst_SCRIPTS += sanity-lfsck.sh lfsck-performance.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 nobase_noinst_SCRIPTS = cfg/local.sh diff --git a/lustre/tests/resolveip b/lustre/tests/resolveip deleted file mode 100755 index 0e3cfd0..0000000 --- a/lustre/tests/resolveip +++ /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; diff --git a/lustre/tests/test-framework.sh b/lustre/tests/test-framework.sh index 7205ae6..8179fc7 100755 --- a/lustre/tests/test-framework.sh +++ b/lustre/tests/test-framework.sh @@ -7192,7 +7192,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 'NR == 1 { print $1 }') is_local_addr "$host_ip" && eval $is_local=1 fi [[ "${!is_local}" == "1" ]] -- 1.8.3.1