summaryrefslogtreecommitdiffstats
path: root/network.py
diff options
context:
space:
mode:
authorMike Fulbright <msf@redhat.com>2003-07-09 22:47:32 +0000
committerMike Fulbright <msf@redhat.com>2003-07-09 22:47:32 +0000
commit1def62d877bd7f8efff3ef59109bbc7b70810a6f (patch)
tree01c0458eee5047debc37658145a7d10133534427 /network.py
parent65070a7aa694663f234a8d1fa70a74aee78c6f8f (diff)
downloadanaconda-1def62d877bd7f8efff3ef59109bbc7b70810a6f.tar.gz
anaconda-1def62d877bd7f8efff3ef59109bbc7b70810a6f.tar.xz
anaconda-1def62d877bd7f8efff3ef59109bbc7b70810a6f.zip
fix problem with properly initializing one ethernet device as active by default
Diffstat (limited to 'network.py')
-rw-r--r--network.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/network.py b/network.py
index e6c50e498..a8da860bf 100644
--- a/network.py
+++ b/network.py
@@ -136,6 +136,7 @@ class NetworkDevice(SimpleConfigFile):
class Network:
def __init__(self):
+ self.firstnetdevice = None
self.netdevices = {}
self.gateway = ""
self.primaryNS = ""
@@ -191,9 +192,31 @@ class Network:
elif self.ternaryNS == "":
self.ternaryNS = resolv[1]
+ # now initialize remaining devices
+ # XXX we just throw return away, the method initialize a
+ # object member so we dont need to
+ available_devices = self.available()
+
+ # set first device to start up onboot
+ if len(available_devices) > 0:
+ oneactive = 0
+ for dev in available_devices.keys():
+ try:
+ if available_devices[dev].get("onboot") == "yes":
+ oneactive = 1
+ break
+ except:
+ continue
+
+ if not oneactive:
+ self.netdevices[self.firstnetdevice].set(("onboot", "yes"))
+
def getDevice(self, device):
return self.netdevices[device]
+ def getFirstDeviceName(self):
+ return self.firstnetdevice
+
def available(self):
f = open("/proc/net/dev")
lines = f.readlines()
@@ -203,6 +226,8 @@ class Network:
for line in lines:
dev = string.strip(line[0:6])
if dev != "lo" and not self.netdevices.has_key(dev):
+ if self.firstnetdevice is None:
+ self.firstnetdevice = dev
self.netdevices[dev] = NetworkDevice(dev)
return self.netdevices