On 10/01/2010 07:16 PM, Brian C. Lane wrote:
On Fri, Oct 01, 2010 at 06:52:20PM +0200, Radek Vykydal wrote:
On 10/01/2010 06:35 PM, Brian C. Lane wrote:
+ @property
+ def gateway(self):
+ """GATEWAY - last device in list wins"""
+ gw = ""
+ for dev in self.netdevices.values():
+ gw = dev.get('GATEWAY')
+ return gw
Is this a list? why not use self.netdevices.values()[-1]? After checking
to make sure len is> 0 of course.
Aah thanks, stupid me, it should be:
for dev in self.netdevices.values():
if dev.get('GATEWAY'):
gw = dev.get('GATEWAY')
Oh, I see, last entry that has a GATEWAY, and not all entries have it.
Exactly.
It could be simplified with:
gw = dev.get('GATEWAY', gw)
Nice, unfortunately dev is NetworkDevice(IfcfgFile(SimpleConfigFile))
object whose get method would have to be modified,
so I'd stay with the boring if.
Radek
>From 808cc4139c86a64d934baaeb099b6537a0abf751 Mon Sep 17 00:00:00 2001
From: Radek Vykydal <rvykydal@xxxxxxxxxx>
Date: Fri, 1 Oct 2010 17:55:12 +0200
Subject: [PATCH master] Honor selected hostname on Live CD (#638634)
NetworkManager on liveCD doesn't use ifcfg files, so we don't
see any devices to be configured in anaconda (which is OK),
but we still offer hostname choice, so honor it.
---
pyanaconda/network.py | 32 ++++++++++++++++++++++----------
1 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index ae06f1e..50d4e0d 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -446,6 +446,24 @@ class Network:
else:
self.netdevices[device].set(('GATEWAY', gw))
+ @property
+ def gateway(self):
+ """GATEWAY - last device in list wins"""
+ gw = ""
+ for dev in self.netdevices.values():
+ if dev.get('GATEWAY'):
+ gw = dev.get('GATEWAY')
+ return gw
+
+ @property
+ def ipv6_defaultgw(self):
+ """IPV6_DEFAULTGW - last device in list wins"""
+ gw = ""
+ for dev in self.netdevices.values():
+ if dev.get('IPV6_DEFAULTGW'):
+ gw = dev.get('IPV6_DEFAULTGW')
+ return gw
+
def lookupHostname(self):
# can't look things up if they don't exist!
if not self.hostname or self.hostname == "localhost.localdomain":
@@ -630,9 +648,6 @@ class Network:
def copyConfigToPath(self, instPath=''):
- if len(self.netdevices) == 0:
- return
-
# /etc/sysconfig/network-scripts/ifcfg-DEVICE
# /etc/sysconfig/network-scripts/keys-DEVICE
# /etc/dhcp/dhclient-DEVICE.conf
@@ -674,9 +689,6 @@ class Network:
devices = self.netdevices.values()
- if len(devices) == 0:
- return
-
# /etc/sysconfig/network-scripts/ifcfg-*
# /etc/sysconfig/network-scripts/keys-*
for dev in devices:
@@ -707,11 +719,11 @@ class Network:
else:
f.write("localhost.localdomain\n")
- if dev.get('GATEWAY'):
- f.write("GATEWAY=%s\n" % (dev.get('GATEWAY'),))
+ if self.gateway:
+ f.write("GATEWAY=%s\n" % self.gateway)
- if dev.get('IPV6_DEFAULTGW'):
- f.write("IPV6_DEFAULTGW=%s\n" % (dev.get('IPV6_DEFAULTGW'),))
+ if self.ipv6_defaultgw:
+ f.write("IPV6_DEFAULTGW=%s\n" % self.ipv6_defaultgw)
f.close()
shutil.move(newnetwork, networkConfFile)
--
1.7.2
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list