Bug 691417 - Koan bug provisioning with a static IP address
Summary: Koan bug provisioning with a static IP address
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: Provisioning
Version: 540
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Tomas Lestach
QA Contact: Jiří Mikulka
URL:
Whiteboard:
Depends On:
Blocks: sat54-blockers
TreeView+ depends on / blocked
 
Reported: 2011-03-28 14:15 UTC by Karl Abbott
Modified: 2018-11-14 14:07 UTC (History)
6 users (show)

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.
Clone Of:
Environment:
Last Closed: 2011-09-22 10:34:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1331 0 normal SHIPPED_LIVE RHN Tools bug fix update 2011-09-22 10:34:36 UTC

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


Note You need to log in before you can comment on or make changes to this bug.