Bug 691417

Summary: Koan bug provisioning with a static IP address
Product: Red Hat Satellite 5 Reporter: Karl Abbott <kabbott>
Component: ProvisioningAssignee: Tomas Lestach <tlestach>
Status: CLOSED ERRATA QA Contact: Jiří Mikulka <jmikulka>
Severity: high Docs Contact:
Priority: high    
Version: 540CC: cperry, csuleski, jmikulka, jwest, mminar, mzazrivec
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: spacewalk-koan-0.2.7-8 Doc Type: Bug Fix
Doc Text:
When parsing the /etc/resolv.conf configuration file, the previous version of the spacewalk-koan package did not permit extra spaces after a nameserver's IP address. Consequently, an attempt to perform kickstart installation by using the "Static Interface" option failed with a traceback. This update adapts spacewalk-koan to tolerate extra spaces after nameserver's IP address so that such kickstart installations no longer fail.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-09-22 10:34:48 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 715348    

Description Karl Abbott 2011-03-28 14:15:27 UTC
I would like to get a bugzilla filed on spacewalk-koan.

spacewalk-koan

spacewalk-koan-0.1.11-13.el5sat.noarch

Description of problem:  If there is trailing whitespace after the IP address in /etc/resolv.conf, then when attempting to provision a kickstart using ""Use Static Interface" option, client execution returned "Kickstart failed. Koan error.: File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 101, in initiate update_static_device_records(kickstart_host, static_device) File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 85, in update_static_device_records raise Exception(msg % (key, pprint.pformat(data))) " (code 1) 

From the Satellite interface, I click on Systems->System Name{netmgt-dbtest01}->Provisioning. I select the Kickstart profile->Create Cobbler Record, Then I select Advanced Configuration. From Advanced Configuration, I select Network Connection "Use static interface" and select eth0. Eth0 is the only active, with link, at the time, and the system has eth0 through eth5. From this screen, I select "Schedule Kickstart and Finish".

Actual result:  client execution returned "Kickstart failed. Koan error.: File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 101, in initiate update_static_device_records(kickstart_host, static_device) File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 85, in update_static_device_records raise Exception(msg % (key, pprint.pformat(data))) " (code 1) 

Expected result:  successful Kickstart

Additional info:

Looking at /usr/share/rhn/spacewalkkoan/spacewalkkoan.py :

***
def update_static_device_records(kickstart_host, static_device):
    client = xmlrpclib.Server("https://" + kickstart_host + "/rpc/api")
    data = {"gateway": find_gateway(),\
            "nameservers": find_name_servers(),\
            "hostname": find_host_name(),\
            "device" :  static_device,\
            "ip": find_ip(static_device),\
            "netmask": find_netmask(static_device)}
    msg = """Unable to retrieve the '%s' information needed to update static network configuration information.
             Details:\n %s"""
    for key, value in data.items():
        if not value:
            raise Exception(msg % (key, pprint.pformat(data)))
    client.system.setup_static_network(getSystemId(), data)
***

The exception is raised if one of the pieces of information cannot be determined (gateway, nameservers, hostname, device, ip, or netmask). The "device" is specified by the user, so that is already pre-determined. The other values are determined by running commands on the client system at the time the script is executed:

***
def find_host_name():
    return execute("hostname")[0]

def find_netmask(device):
    return execute("ifconfig %s | perl -lne '/Mask:([\d.]+)/ and print $1'" % device)[0]

def find_ip(device):
    return execute("ifconfig %s | perl -lne '/inet addr:([\d.]+)/ and print $1'" % device)[0]

def find_name_servers():
    servers = execute("cat /etc/resolv.conf | perl -lne '/^nameserver\s+(\S+)$/ and print $1'")
    ret = []
    for s in servers:
        if s != "127.0.0.1":
            ret.append(s)
    return ret

def find_gateway():
    response = execute("route -n | awk '/^0\.0\.0\.0/ {print $2}'")
    return response[0]
***

Running through these commands on the client sosreport, I see that find_name_servers does not return a nameserver:

# cat etc/resolv.conf | perl -lne '/^nameserver\s+(\S+)$/ and print $1'
# 

The problem appears to be due to an extra space after the nameserver IP:

# cat -A etc/resolv.conf|grep nameserver
nameserver 161.173.7.10 $

Removing the extra space resolves the issue:

# cat -A etc/resolv.conf.test|grep nameserver
nameserver 161.173.7.10$

# cat etc/resolv.conf.test | perl -lne '/^nameserver\s+(\S+)$/ and print $1'
161.173.7.10

Comment 3 Tomas Lestach 2011-07-07 09:56:32 UTC
I prefer changing the regexp just to: /^nameserver\s+(\S+)/

spacewalk.git: 510a30175ec99a524e63d625c7e356c761d75eeb

Comment 6 Tomas Lestach 2011-08-24 11:44:20 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
No extra whitespace was allowed behind nameserver IP when parsing /etc/resolv.conf file
Consequence:
When trying to kickstart a system using the "Static Interface" option, client execution failed.
Result:
Now, it's possible to kickstart a system using the "Static Interface" option.

Comment 8 Jaromir Hradilek 2011-08-25 14:25:30 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,6 +1 @@
-Cause:
+When parsing the /etc/resolv.conf configuration file, the previous version of the spacewalk-koan package did not permit extra spaces after a nameserver's IP address. Consequently, an attempt to perform kickstart installation by using the "Static Interface" option failed with a traceback. This update adapts spacewalk-koan to tolerate extra spaces after nameserver's IP address so that such kickstart installations no longer fail.-No extra whitespace was allowed behind nameserver IP when parsing /etc/resolv.conf file
-Consequence:
-When trying to kickstart a system using the "Static Interface" option, client execution failed.
-Result:
-Now, it's possible to kickstart a system using the "Static Interface" option.

Comment 10 errata-xmlrpc 2011-09-22 10:34:48 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2011-1331.html