[master 5/7] Add a script to print an IP address for the host.

dashea installerbot-noreply at redhat.com
Thu Sep 3 22:08:49 UTC 2015


From: David Shea <dshea at redhat.com>

Python's server address determination depends on the hostname, which is
not particularly reliable, so grep through ip addr output to find an
address that is actually configured. It doesn't matter which one, since
the virt guest will have the host as the default route, and, barring any
weird firewall configurations, once the host gets the packet it will
know that it's local.
---
 tests/kickstart_tests/scripts/find-ip | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100755 tests/kickstart_tests/scripts/find-ip

diff --git a/tests/kickstart_tests/scripts/find-ip b/tests/kickstart_tests/scripts/find-ip
new file mode 100755
index 0000000..5ec2447
--- /dev/null
+++ b/tests/kickstart_tests/scripts/find-ip
@@ -0,0 +1,26 @@
+#!/bin/bash
+#
+# Copyright (C) 2015  Red Hat, Inc.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions of
+# the GNU General Public License v.2, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY expressed or implied, including the implied warranties of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+# Public License for more details.  You should have received a copy of the
+# GNU General Public License along with this program; if not, write to the
+# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
+# source code or documentation are not subject to the GNU General Public
+# License and may only be used or replicated with the express permission of
+# Red Hat, Inc.
+#
+# Red Hat Author(s): David Shea <dshea at redhat.com>
+
+# Print something that looks like an externally accessible IPv4 address.
+
+ip addr list | \
+    grep '^[[:space:]]*inet\>.*scope global' | \
+    head -1 | \
+    sed 's/^[[:space:]]*inet \([[:digit:].]*\).*/\1/'


-- 
To view this commit on github, visit https://github.com/rhinstaller/anaconda/commit/90abe1a3628d39a0ef40ad0d71f7413d9a765eb9


More information about the anaconda-patches mailing list