diff mbox

[OSSTEST,02/15] TestSupport: Provide controller_ipaddr

Message ID 1498054447-11281-3-git-send-email-ian.jackson@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Ian Jackson June 21, 2017, 2:13 p.m. UTC
Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
---
 Osstest/TestSupport.pm | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index ce9ffaa..8f8013e 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -92,7 +92,7 @@  BEGIN {
                       git_massage_url
 
                       sshopts authorized_keys
-                      cfg_tftp_di_version
+                      cfg_tftp_di_version controller_ipaddr
                       remote_perl_script_open remote_perl_script_done
                       host_reboot target_reboot target_reboot_hard            
                       target_choose_vg target_umount_lv target_await_down
@@ -2401,6 +2401,15 @@  sub cfg_tftp_di_version ($) {
     return $c{"TftpDiVersion_$suite"} // $c{TftpDiVersion};
 }
 
+sub controller_ipaddr () {
+    my $addr = $c{ControllerIpAddress};
+    return $addr if defined $addr;
+    $?=$!=0; my $hn = `hostname -f` // die "$? $!";
+    chomp $hn;
+    my $ip = gethostbyname($hn) // die "$hn ?";
+    return inet_ntoa($ip);
+}
+
 #---------- webspace for installer ----------
 
 sub await_webspace_fetch_byleaf ($$$$$) {