FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora Desktop

 
 
LinkBack Thread Tools
 
Old 05-07-2010, 12:49 PM
Radek Vykydal
 
Default Write out ifcfg files only when necessary (#520146)

Writing the files so often is not necessary, and can cause
timing issues (NM itself updates the files after we write
them out) which can result in duplicated connections nm-c-e
list. Write the file only if some value in NetworkDevice
object has been actually changed.
---
gui.py | 7 ++++---
network.py | 48 +++++++++++++++++++++++++++++++++++-------------
2 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/gui.py b/gui.py
index ccd6388..69f6fb7 100755
--- a/gui.py
+++ b/gui.py
@@ -983,11 +983,11 @@ class InstallInterface(InstallInterfaceBase):
self.anaconda.network.updateActiveDevices([install_device])

# we might want to do this only once
- # NOTE: For wireless, we need supplicant to go to ready state,
- # that means to get the wireless device managed by NM
- # - we do it above in setNMControlledDevices.
# TODORV: put into Network objects
if network.hasWirelessDev():
+ # NOTE: For wireless, we need supplicant to go to ready state,
+ # that means to get the wireless device managed by NM
+ self.anaconda.id.network.writeIfcfgFiles()
w = self.anaconda.intf.waitWindow(_("Wireless setup"),
_("Scanning access points for wireless devices"))
# get available wireless APs
@@ -999,6 +999,7 @@ class InstallInterface(InstallInterfaceBase):
dev_ssids = selectSSIDsDialog(dev_all_ssids) or dev_all_ssids
self.anaconda.network.updateIfcfgsSSID(dev_ssids)

+ self.anaconda.id.network.writeIfcfgFiles()
network.logIfcfgFiles(header="========== before nm-c-e run
")
runNMCE(self.anaconda)
network.logIfcfgFiles(header="========== after nm-c-e run
")
diff --git a/network.py b/network.py
index 43d2ae4..fcd8f1c 100644
--- a/network.py
+++ b/network.py
@@ -280,6 +280,7 @@ class NetworkDevice(IfcfgFile):
if iface.startswith('ctc'):
self.info["TYPE"] = "ctc"
self.wepkey = ""
+ self._dirty = False

def clear(self):
IfcfgFile.clear(self)
@@ -312,9 +313,27 @@ class NetworkDevice(IfcfgFile):
def loadIfcfgFile(self):
self.clear()
IfcfgFile.read(self)
-
- def writeIfcfgFile(self, dir=None):
- IfcfgFile.write(self, dir)
+ self.log("NetworkDevice read from %s
" % self.path)
+ self._dirty = False
+
+ def writeIfcfgFile(self):
+ # Write out the file only if there is a key whose
+ # value has been changed since last load of ifcfg file.
+ if self._dirty:
+ IfcfgFile.write(self)
+ self.log("NetworkDevice written to %s
" % self.path)
+ self._dirty = False
+
+ def set(self, *args):
+ # If we are changing value of a key set _dirty flag
+ # informing that ifcfg file needs to be synced.
+ for (key, data) in args:
+ if self.get(key) != data:
+ break
+ else:
+ return
+ IfcfgFile.set(self, *args)
+ self._dirty = True

@property
def keyfilePath(self):
@@ -394,8 +413,12 @@ class Network:
devhash = isys.getDeviceProperties(dev=None)
for iface in devhash.keys():
device = NetworkDevice(netscriptsDir, iface, logfile=ifcfgLogFile)
- device.loadIfcfgFile()
- device.log("===== Network.update
")
+ if os.access(device.path, os.R_OK):
+ device.loadIfcfgFile()
+ else:
+ log.info("Network.update(): %s file not found" %
+ device.path)
+ continue

if device.get('DOMAIN'):
self.domains.append(device.get('DOMAIN'))
@@ -475,6 +498,12 @@ class Network:

return ip

+ # Note that the file is written-out only if there is a value
+ # that has changed.
+ def writeIfcfgFiles(self):
+ for device in self.netdevices.values():
+ device.writeIfcfgFile()
+
# devices == None => set for all
def setNMControlledDevices(self, devices=None):
for devname, device in self.netdevices.items():
@@ -482,8 +511,6 @@ class Network:
device.set(('NM_CONTROLLED', 'no'))
else:
device.set(('NM_CONTROLLED', 'yes'))
- device.writeIfcfgFile()
- device.log_file("device set to be nm controlled
")

# devices == None => set for all
def updateActiveDevices(self, devices=None):
@@ -492,8 +519,6 @@ class Network:
device.set(('ONBOOT', 'no'))
else:
device.set(('ONBOOT', 'yes'))
- device.writeIfcfgFile()
- device.log_file("updateActiveDevices
")

def getOnbootIfaces(self):
ifaces = []
@@ -506,8 +531,6 @@ class Network:
for devname, device in self.netdevices.items():
if devname in devssids.keys():
device.set(('ESSID', devssids[devname][0]))
- device.writeIfcfgFile()
- device.log_file("updateIfcfgSSID
")

def getSSIDs(self):
return getSSIDs(self.netdevices.keys())
@@ -650,8 +673,7 @@ class Network:
dev.set(('NM_CONTROLLED', 'no'))
break

- dev.writeIfcfgFile(netscriptsDir)
- dev.log_file("===== write
")
+ dev.writeIfcfgFile()

if dev.wepkey:
dev.writeWepkeyFile(dir=netscriptsDir, overwrite=False)
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-12-2010, 03:03 PM
Radek Vykydal
 
Default Write out ifcfg files only when necessary (#520146)

Writing the files so often is not necessary, and can cause
timing issues (NM itself updates the files after we write
them out) which can result in duplicated connections nm-c-e
list. Write the file only if some value in NetworkDevice
object has been actually changed.
---
gui.py | 7 ++++---
network.py | 48 +++++++++++++++++++++++++++++++++++-------------
2 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/gui.py b/gui.py
index 29d8810..6f0d6f9 100755
--- a/gui.py
+++ b/gui.py
@@ -982,11 +982,11 @@ class InstallInterface(InstallInterfaceBase):
self.anaconda.id.network.updateActiveDevices([install_device])

# we might want to do this only once
- # NOTE: For wireless, we need supplicant to go to ready state,
- # that means to get the wireless device managed by NM
- # - we do it above in setNMControlledDevices.
# TODORV: put into Network objects
if network.hasWirelessDev():
+ # NOTE: For wireless, we need supplicant to go to ready state,
+ # that means to get the wireless device managed by NM
+ self.anaconda.id.network.writeIfcfgFiles()
w = self.anaconda.intf.waitWindow(_("Wireless setup"),
_("Scanning access points for wireless devices"))
# get available wireless APs
@@ -998,6 +998,7 @@ class InstallInterface(InstallInterfaceBase):
dev_ssids = selectSSIDsDialog(dev_all_ssids) or dev_all_ssids
self.anaconda.id.network.updateIfcfgsSSID(dev_ssid s)

+ self.anaconda.id.network.writeIfcfgFiles()
network.logIfcfgFiles(header="========== before nm-c-e run
")
runNMCE(self.anaconda)
network.logIfcfgFiles(header="========== after nm-c-e run
")
diff --git a/network.py b/network.py
index d3686a8..e2308e8 100644
--- a/network.py
+++ b/network.py
@@ -280,6 +280,7 @@ class NetworkDevice(IfcfgFile):
if iface.startswith('ctc'):
self.info["TYPE"] = "CTC"
self.wepkey = ""
+ self._dirty = False

def clear(self):
IfcfgFile.clear(self)
@@ -310,9 +311,27 @@ class NetworkDevice(IfcfgFile):
def loadIfcfgFile(self):
self.clear()
IfcfgFile.read(self)
-
- def writeIfcfgFile(self, dir=None):
- IfcfgFile.write(self, dir)
+ self.log("NetworkDevice read from %s
" % self.path)
+ self._dirty = False
+
+ def writeIfcfgFile(self):
+ # Write out the file only if there is a key whose
+ # value has been changed since last load of ifcfg file.
+ if self._dirty:
+ IfcfgFile.write(self)
+ self.log("NetworkDevice written to %s
" % self.path)
+ self._dirty = False
+
+ def set(self, *args):
+ # If we are changing value of a key set _dirty flag
+ # informing that ifcfg file needs to be synced.
+ for (key, data) in args:
+ if self.get(key) != data:
+ break
+ else:
+ return
+ IfcfgFile.set(self, *args)
+ self._dirty = True

@property
def keyfilePath(self):
@@ -392,8 +411,12 @@ class Network:
devhash = isys.getDeviceProperties(dev=None)
for iface in devhash.keys():
device = NetworkDevice(netscriptsDir, iface, logfile=ifcfgLogFile)
- device.loadIfcfgFile()
- device.log("===== Network.update
")
+ if os.access(device.path, os.R_OK):
+ device.loadIfcfgFile()
+ else:
+ log.info("Network.update(): %s file not found" %
+ device.path)
+ continue

if device.get('DOMAIN'):
self.domains.append(device.get('DOMAIN'))
@@ -473,6 +496,12 @@ class Network:

return ip

+ # Note that the file is written-out only if there is a value
+ # that has changed.
+ def writeIfcfgFiles(self):
+ for device in self.netdevices.values():
+ device.writeIfcfgFile()
+
# devices == None => set for all
def setNMControlledDevices(self, devices=None):
for devname, device in self.netdevices.items():
@@ -480,8 +509,6 @@ class Network:
device.set(('NM_CONTROLLED', 'no'))
else:
device.set(('NM_CONTROLLED', 'yes'))
- device.writeIfcfgFile()
- device.log_file("device set to be nm controlled
")

# devices == None => set for all
def updateActiveDevices(self, devices=None):
@@ -490,8 +517,6 @@ class Network:
device.set(('ONBOOT', 'no'))
else:
device.set(('ONBOOT', 'yes'))
- device.writeIfcfgFile()
- device.log_file("updateActiveDevices
")

def getOnbootIfaces(self):
ifaces = []
@@ -504,8 +529,6 @@ class Network:
for devname, device in self.netdevices.items():
if devname in devssids.keys():
device.set(('ESSID', devssids[devname][0]))
- device.writeIfcfgFile()
- device.log_file("updateIfcfgSSID
")

def getSSIDs(self):
return getSSIDs(self.netdevices.keys())
@@ -648,8 +671,7 @@ class Network:
dev.set(('NM_CONTROLLED', 'no'))
break

- dev.writeIfcfgFile(netscriptsDir)
- dev.log_file("===== write
")
+ dev.writeIfcfgFile()

if dev.wepkey:
dev.writeWepkeyFile(dir=netscriptsDir, overwrite=False)
--
1.6.0.6

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-12-2010, 03:15 PM
David Cantrell
 
Default Write out ifcfg files only when necessary (#520146)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ack.

On Wed, 12 May 2010, Radek Vykydal wrote:


Writing the files so often is not necessary, and can cause
timing issues (NM itself updates the files after we write
them out) which can result in duplicated connections nm-c-e
list. Write the file only if some value in NetworkDevice
object has been actually changed.
---
gui.py | 7 ++++---
network.py | 48 +++++++++++++++++++++++++++++++++++-------------
2 files changed, 39 insertions(+), 16 deletions(-)

diff --git a/gui.py b/gui.py
index 29d8810..6f0d6f9 100755
--- a/gui.py
+++ b/gui.py
@@ -982,11 +982,11 @@ class InstallInterface(InstallInterfaceBase):
self.anaconda.id.network.updateActiveDevices([install_device])

# we might want to do this only once
- # NOTE: For wireless, we need supplicant to go to ready state,
- # that means to get the wireless device managed by NM
- # - we do it above in setNMControlledDevices.
# TODORV: put into Network objects
if network.hasWirelessDev():
+ # NOTE: For wireless, we need supplicant to go to ready state,
+ # that means to get the wireless device managed by NM
+ self.anaconda.id.network.writeIfcfgFiles()
w = self.anaconda.intf.waitWindow(_("Wireless setup"),
_("Scanning access points for wireless devices"))
# get available wireless APs
@@ -998,6 +998,7 @@ class InstallInterface(InstallInterfaceBase):
dev_ssids = selectSSIDsDialog(dev_all_ssids) or dev_all_ssids
self.anaconda.id.network.updateIfcfgsSSID(dev_ssid s)

+ self.anaconda.id.network.writeIfcfgFiles()
network.logIfcfgFiles(header="========== before nm-c-e run
")
runNMCE(self.anaconda)
network.logIfcfgFiles(header="========== after nm-c-e run
")
diff --git a/network.py b/network.py
index d3686a8..e2308e8 100644
--- a/network.py
+++ b/network.py
@@ -280,6 +280,7 @@ class NetworkDevice(IfcfgFile):
if iface.startswith('ctc'):
self.info["TYPE"] = "CTC"
self.wepkey = ""
+ self._dirty = False

def clear(self):
IfcfgFile.clear(self)
@@ -310,9 +311,27 @@ class NetworkDevice(IfcfgFile):
def loadIfcfgFile(self):
self.clear()
IfcfgFile.read(self)
-
- def writeIfcfgFile(self, dir=None):
- IfcfgFile.write(self, dir)
+ self.log("NetworkDevice read from %s
" % self.path)
+ self._dirty = False
+
+ def writeIfcfgFile(self):
+ # Write out the file only if there is a key whose
+ # value has been changed since last load of ifcfg file.
+ if self._dirty:
+ IfcfgFile.write(self)
+ self.log("NetworkDevice written to %s
" % self.path)
+ self._dirty = False
+
+ def set(self, *args):
+ # If we are changing value of a key set _dirty flag
+ # informing that ifcfg file needs to be synced.
+ for (key, data) in args:
+ if self.get(key) != data:
+ break
+ else:
+ return
+ IfcfgFile.set(self, *args)
+ self._dirty = True

@property
def keyfilePath(self):
@@ -392,8 +411,12 @@ class Network:
devhash = isys.getDeviceProperties(dev=None)
for iface in devhash.keys():
device = NetworkDevice(netscriptsDir, iface, logfile=ifcfgLogFile)
- device.loadIfcfgFile()
- device.log("===== Network.update
")
+ if os.access(device.path, os.R_OK):
+ device.loadIfcfgFile()
+ else:
+ log.info("Network.update(): %s file not found" %
+ device.path)
+ continue

if device.get('DOMAIN'):
self.domains.append(device.get('DOMAIN'))
@@ -473,6 +496,12 @@ class Network:

return ip

+ # Note that the file is written-out only if there is a value
+ # that has changed.
+ def writeIfcfgFiles(self):
+ for device in self.netdevices.values():
+ device.writeIfcfgFile()
+
# devices == None => set for all
def setNMControlledDevices(self, devices=None):
for devname, device in self.netdevices.items():
@@ -480,8 +509,6 @@ class Network:
device.set(('NM_CONTROLLED', 'no'))
else:
device.set(('NM_CONTROLLED', 'yes'))
- device.writeIfcfgFile()
- device.log_file("device set to be nm controlled
")

# devices == None => set for all
def updateActiveDevices(self, devices=None):
@@ -490,8 +517,6 @@ class Network:
device.set(('ONBOOT', 'no'))
else:
device.set(('ONBOOT', 'yes'))
- device.writeIfcfgFile()
- device.log_file("updateActiveDevices
")

def getOnbootIfaces(self):
ifaces = []
@@ -504,8 +529,6 @@ class Network:
for devname, device in self.netdevices.items():
if devname in devssids.keys():
device.set(('ESSID', devssids[devname][0]))
- device.writeIfcfgFile()
- device.log_file("updateIfcfgSSID
")

def getSSIDs(self):
return getSSIDs(self.netdevices.keys())
@@ -648,8 +671,7 @@ class Network:
dev.set(('NM_CONTROLLED', 'no'))
break

- dev.writeIfcfgFile(netscriptsDir)
- dev.log_file("===== write
")
+ dev.writeIfcfgFile()

if dev.wepkey:
dev.writeWepkeyFile(dir=netscriptsDir, overwrite=False)



- --
David Cantrell <dcantrell@redhat.com>

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)

iEYEARECAAYFAkvqxhQACgkQ5hsjjIy1VklAyQCdHUF26pumsE mxqj57K+9B+AJ8
O+8AoI/tWk8uPsnbfFphNrlyeRCMKaJv
=BHnU
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 

Thread Tools




All times are GMT. The time now is 08:45 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org