[PATCH master] Take over dhcp connection by NM for network root (eg nfs) (#883451, #893656)
Brian C. Lane
bcl at redhat.com
Sat Jan 12 00:57:36 UTC 2013
On Fri, Jan 11, 2013 at 04:41:34PM +0100, Radek Vykydal wrote:
> We need to pass dhcp lease file to NM's dhclient also in case of
> kickstart installs. For non-kickstart case, this is done in dracut,
> modules.d/45ifcfg/write-ifcfg.sh.
> See dracut's commit 66666c670a462548df4ea4c8069d54b8c309ecf4
> ---
> dracut/parse-kickstart | 13 ++++++++++++-
> 1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/dracut/parse-kickstart b/dracut/parse-kickstart
> index 333849b..24d0488 100755
> --- a/dracut/parse-kickstart
> +++ b/dracut/parse-kickstart
> @@ -267,7 +267,8 @@ def ksnet_to_ifcfg(net, filename=None):
> os.makedirs("/tmp/ifcfg")
> ifcfg['DEVICE'] = dev
> ifcfg['HWADDR'] = readsysfile("/sys/class/net/%s/address" % dev)
> - ifcfg['UUID'] = readsysfile("/proc/sys/kernel/random/uuid")
> + uuid = readsysfile("/proc/sys/kernel/random/uuid")
> + ifcfg['UUID'] = uuid
I know this was pre-existing code, but why read a system-dependent file
instead of using str(uuid.uuid4())?
> # we set real ONBOOT value in anaconda, here
> # we use it to activate devcies by NM on start
> ifcfg['ONBOOT'] = "yes" if net.activate else "no"
> @@ -305,6 +306,15 @@ def ksnet_to_ifcfg(net, filename=None):
>
> # TODO: dhcpclass, ethtool, essid/wepkey/wpakay, etc.
>
> + if net.bootProto == 'dhcp':
> + srcpath = "/tmp/dhclient.%s.lease" % dev
> + dstdir = "/tmp/ifcfg-leases"
> + dstpath = "%s/dhclient-%s-%s.lease" % (dstdir, uuid, dev)
> + if os.path.exists(srcpath):
> + if not os.path.isdir(dstdir):
> + os.makedirs(dstdir)
> + os.system("cp %s %s" % (srcpath, dstpath))
Maybe use shutil.copy2() instead of os.system?
> +
> try:
> log.info("writing ifcfg for %s", dev)
> outf = open(filename, "w")
> @@ -312,6 +322,7 @@ def ksnet_to_ifcfg(net, filename=None):
> for k,v in ifcfg.items():
> outf.write("%s=%s\n" % (k,v))
> outf.close()
> +
> except IOError as e:
> log.error("can't write %s: %s" % (filename, str(e)))
> else:
> --
> 1.7.11.7
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 478 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20130111/82a0b616/attachment.sig>
More information about the anaconda-patches
mailing list