[PATCH rhel7-branch] network: don't write HWADDR in ifcfgs generated by kickstart (#1040461)

Vratislav Podzimek vpodzime at redhat.com
Wed Aug 27 07:41:07 UTC 2014


On Tue, 2014-08-26 at 14:24 +0200, Radek Vykydal wrote:
> Having persistent device names now, let's just bind configuration to device
> name (DEVICE) leaving HWADDR out. Having both of them in ifcfg binds device
> name to HWADDR (device is renamed by initscript's 60-net-rules) which is not
> what we want eg in cases when moving or replacing NICs.
> 
> For special case where device renaming is configured by installation ifname=
> dracut boot option we add also the HWADDR into ifcfg file.
> 
> Resolves: rhbz#1040461
> ---
>  dracut/parse-kickstart |  7 +++++--
>  pyanaconda/network.py  | 11 ++++++++---
>  2 files changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
> index a8ece63..47f6e01 100755
> --- a/dracut/parse-kickstart
> +++ b/dracut/parse-kickstart
> @@ -330,7 +330,10 @@ def ksnet_to_ifcfg(net, filename=None):
>          if not os.path.isdir("/tmp/ifcfg"):
>              os.makedirs("/tmp/ifcfg")
>      ifcfg['DEVICE'] = dev
> -    ifcfg['HWADDR'] = readsysfile("/sys/class/net/%s/address" % dev)
> +    hwaddr = readsysfile("/sys/class/net/%s/address" % dev)
> +    if "ifname={0}:{1}".format(dev, hwaddr).upper() in open("/proc/cmdline").read().upper():
> +        # rename by initscript's 60-net-rules on target system after switchroot
> +        ifcfg['HWADDR'] = hwaddr
Is the format really devname:hwaddr with hwaddr containing ':'s? 

>      ifcfg['UUID'] = str(uuid.uuid4())
>      # we set real ONBOOT value in anaconda, here
>      # we use it to activate devcies by NM on start
> @@ -338,7 +341,7 @@ def ksnet_to_ifcfg(net, filename=None):
>  
>      s390cfg = s390_settings(dev)
>      if s390cfg['SUBCHANNELS']:
> -        ifcfg.pop('HWADDR')
> +        ifcfg.pop('HWADDR', None)
>          ifcfg['SUBCHANNELS'] = s390cfg['SUBCHANNELS']
>      if s390cfg['NETTYPE']:
>          ifcfg['NETTYPE'] = s390cfg['NETTYPE']
> diff --git a/pyanaconda/network.py b/pyanaconda/network.py
> index 75d2711..afd1cd2 100644
> --- a/pyanaconda/network.py
> +++ b/pyanaconda/network.py
> @@ -543,11 +543,16 @@ def add_connection_for_ksdata(networkdata, devname):
>          dev_spec = None
>      # type "802-3-ethernet"
>      else:
> +        mac = nm.nm_device_perm_hwaddress(devname)
> +        if flags.cmdline.get("ifname", "").upper() == "{0}:{1}".format(devname, mac).upper():
> +            mac = [int(b, 16) for b in mac.split(":")]
> +            values.append(['802-3-ethernet', 'mac-address', mac, 'ay'])
> +        else:
> +            values.append(['802-3-ethernet', 'name', devname, 's'])
>          values.append(['connection', 'type', '802-3-ethernet', 's'])
>          values.append(['connection', 'id', devname, 's'])
> -        mac = nm.nm_device_perm_hwaddress(devname)
> -        mac = [int(b, 16) for b in mac.split(":")]
> -        values.append(['802-3-ethernet', 'mac-address', mac, 'ay'])
> +        values.append(['connection', 'interface-name', devname, 's'])
> +
>          dev_spec = devname
>  
>      nm.nm_add_connection(values)
If the answer to the above question is yes, this looks good to me.

-- 
Vratislav Podzimek

Anaconda Rider | RHCE | Red Hat, Inc. | Brno - Czech Republic




More information about the anaconda-patches mailing list