Bug 1412897

Summary: system fails to report any FQDN because hostname -I does not work on RHEL5
Product: [Retired] Beaker Reporter: Dan Callaghan <dcallagh>
Component: generalAssignee: Dan Callaghan <dcallagh>
Status: CLOSED CURRENTRELEASE QA Contact: Dan Callaghan <dcallagh>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: developCC: dcallagh, mjia, rjoost
Target Milestone: 24.4Keywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-10-03 03:57:49 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dan Callaghan 2017-01-13 04:43:40 UTC
Version-Release number of selected component (if applicable):
24.0 pre-release

How reproducible:
easily I think

Steps to Reproduce:
1. Run a RHEL5 recipe in OpenStack
2. Look at the serial console

Actual results:
Note that hostname -I errors out, and then install_done fails because the FQDN is empty string (we need to fix both those problems):

++ find_fqdn
++ local fqdn=
+++ hostname -f
++ fqdn=host-192-168-11-5
++ [[ host-192-168-11-5 == *.* ]]
+++ cat /etc/hostname
cat: /etc/hostname: No such file or directory
++ fqdn=
++ [[ '' == *.* ]]
+++ grep '^HOSTNAME=' /etc/sysconfig/network
+++ cut -f2- -d=
++ fqdn=host-192-168-11-5
++ [[ host-192-168-11-5 == *.* ]]
++ hostname -I
hostname: invalid option -- I
Usage: hostname [-v] {hostname|-F file}      set hostname (from file)
       domainname [-v] {nisdomain|-F file}   set NIS domainname (from file)
       hostname [-v] [-d|-f|-s|-a|-i|-y|-n]  display formatted name
       hostname [-v]                         display hostname

       hostname -V|--version|-h|--help       print info and exit

    dnsdomainname=hostname -d, {yp,nis,}domainname=hostname -y

    -s, --short           short host name
    -a, --alias           alias names
    -i, --ip-address      addresses for the hostname
    -f, --fqdn, --long    long host name (FQDN)
    -d, --domain          DNS domain name
    -y, --yp, --nis       NIS/YP domainname
    -F, --file            read hostname or NIS domainname from given file

   This command can read or set the hostname or the NIS domainname. You can
   also read the DNS domain or the FQDN (fully qualified domain name).
   Unless you are using bind or NIS for host lookups you can change the
   FQDN (Fully Qualified Domain Name) and the DNS domain name (which is
   part of the FQDN) in the /etc/hosts file.
++ cut '-d ' -f1
+ REPORTED_FQDN=
+ fetch - http://lab-devel-02.rhts.eng.bos.redhat.com:8000/install_done/17874/
+ curl --retry 20 --remote-time -o - http://lab-devel-02.rhts.eng.bos.redhat.com:8000/install_done/17874/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<title>404 Not Found</title>
<h1>Not Found</h1>
<p>The requested URL was not found on the server.</p><p>If you entered the URL manually please check your spelling and try again.</p>
+ echo 17874

Comment 1 Roman Joost 2017-03-06 03:50:33 UTC
Going to delay this one more milestone. Don't feel confident that I can thoroughly test this.

Comment 2 Dan Callaghan 2017-07-25 06:03:04 UTC
Ideally we would just use hostname -i, which already prints the first IP address, and exists back to RHEL3. Unfortunately on RHEL5 and earlier, it just always prints 127.0.0.1 which is of no help.

Comment 3 Dan Callaghan 2017-07-25 06:21:32 UTC
As a last resort on RHEL5 and earlier we can use a hack like this:

ip addr show | grep -v ' lo' | grep -Po '(?<=inet )[0-9.]+'

tested on RHEL3, RHEL4, and RHEL5.

Comment 4 Dan Callaghan 2017-07-25 06:55:21 UTC
https://gerrit.beaker-project.org/5761 hostname -I option does not exist on older RHELs
https://gerrit.beaker-project.org/5762 accept install_done call with missing fqdn

Comment 7 Dan Callaghan 2017-10-03 03:57:49 UTC
Beaker 24.4 has been released.