From 5d35213a3ae9528a932633a784a4a2d396311218 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Wed, 20 Jun 2018 00:39:49 +0200 Subject: [PATCH] TT#38200 Switch to new perl ngcp.get_firstname() function Change-Id: I0802fa8988d7bf84a1ca8caa3770e86d69ba079a --- lib/NGCP/Template.pm | 19 +++++++++++++++++++ lib/get_firstname | 10 +--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/lib/NGCP/Template.pm b/lib/NGCP/Template.pm index 2f43a3b3..13705833 100644 --- a/lib/NGCP/Template.pm +++ b/lib/NGCP/Template.pm @@ -68,6 +68,20 @@ sub get_peername return $self->{config}{hosts}{$hostname}{peer}; } +sub get_firstname +{ + my ($self, $hostname) = @_; + + if (not defined $self->{config}{hosts}{$hostname}) { + return 'self'; + } else { + my $peername = $self->get_peername($hostname); + my @hosts = ($hostname, $peername); + + return (sort @hosts)[0]; + } +} + 1; __END__ @@ -111,6 +125,11 @@ Returns the nodename of the node calling this function. Returns the peer name for a given $hostname. +=item $firstname = $t->get_firstname($hostname) + +Returns the (alphabetically) first hostname of a node pair for a given +$hostname. + =back =head1 AUTHOR diff --git a/lib/get_firstname b/lib/get_firstname index 528e2078..2d825496 100644 --- a/lib/get_firstname +++ b/lib/get_firstname @@ -6,14 +6,6 @@ # @param argv.host The hostname to get the first name for. # @return out The alphabetically first name. -IF !hosts.${argv.host}.defined; - argv.host = 'self'; -END; - -blktmp.hosts = [argv.host]; -IF hosts.${argv.host}.peer.defined; - blktmp.hosts.push(hosts.${argv.host}.peer); -END; -out = blktmp.hosts.sort.0; +out = ngcp.get_firstname(argv.host); -%]