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 > Debian > Debian GCC

 
 
LinkBack Thread Tools
 
Old 04-27-2010, 08:49 AM
Radek Vykydal
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

---
network.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ +++------
1 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/network.py b/network.py
index a2ca6bd..0a90800 100644
--- a/network.py
+++ b/network.py
@@ -34,7 +34,7 @@ import os
import time
import dbus
from flags import flags
-from simpleconfig import SimpleConfigFile
+from simpleconfig import IfcfgFile

import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -45,6 +45,7 @@ log = logging.getLogger("anaconda")
sysconfigDir = "/etc/sysconfig"
netscriptsDir = "%s/network-scripts" % (sysconfigDir)
networkConfFile = "%s/network" % (sysconfigDir)
+ifcfgLogFile = "/tmp/ifcfg.log"

class IPError(Exception):
pass
@@ -237,7 +238,19 @@ def getActiveNetDevs():
ret.sort()
return ret

-class NetworkDevice(SimpleConfigFile):
+class NetworkDevice(IfcfgFile):
+
+ def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
+ IfcfgFile.__init__(self, dir, iface)
+ self.logfile = logfile
+ if iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"
+
+ def clear(self):
+ IfcfgFile.clear(self)
+ if self.iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"
+
def __str__(self):
s = ""
s = s + "DEVICE=" + self.info["DEVICE"] + "
"
@@ -263,10 +276,44 @@ class NetworkDevice(SimpleConfigFile):

return s

- def __init__(self, dev):
- self.info = { "DEVICE" : dev }
- if dev.startswith('ctc'):
- self.info["TYPE"] = "CTC"
+ def loadIfcfgFile(self):
+ self.clear()
+ IfcfgFile.read(self)
+
+ def writeIfcfgFile(self, dir=None):
+ IfcfgFile.write(self, dir)
+
+ def log(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.close()
+ self.log_file()
+ self.log_write_file()
+ self.log_values()
+
+ def log_values(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== values for file %s
" % self.path)
+ lf.write(IfcfgFile.__str__(self))
+ lf.close()
+
+ def log_write_file(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== file to be written for %s
" % self.path)
+ lf.write(self.__str__())
+ lf.close()
+
+ def log_file(self, header="
"):
+ f = open(self.path, 'r')
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== file %s
" % self.path)
+ lf.write(f.read())
+ lf.close()
+ f.close()
+

class Network:
def __init__(self):
--
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-04-2010, 02:38 AM
David Cantrell
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

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

Comments below.

On Tue, 27 Apr 2010, Radek Vykydal wrote:


---
network.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ +++------
1 files changed, 53 insertions(+), 6 deletions(-)

diff --git a/network.py b/network.py
index a2ca6bd..0a90800 100644
--- a/network.py
+++ b/network.py
@@ -34,7 +34,7 @@ import os
import time
import dbus
from flags import flags
-from simpleconfig import SimpleConfigFile
+from simpleconfig import IfcfgFile

import gettext
_ = lambda x: gettext.ldgettext("anaconda", x)
@@ -45,6 +45,7 @@ log = logging.getLogger("anaconda")
sysconfigDir = "/etc/sysconfig"
netscriptsDir = "%s/network-scripts" % (sysconfigDir)
networkConfFile = "%s/network" % (sysconfigDir)
+ifcfgLogFile = "/tmp/ifcfg.log"

class IPError(Exception):
pass
@@ -237,7 +238,19 @@ def getActiveNetDevs():
ret.sort()
return ret

-class NetworkDevice(SimpleConfigFile):
+class NetworkDevice(IfcfgFile):
+
+ def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
+ IfcfgFile.__init__(self, dir, iface)
+ self.logfile = logfile
+ if iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"


Why 'CTC' over 'ctc'? Other system tools expect the NETTYPE variable in the
ifcfg file on s390x to contain 'ctc' or 'lcs' or 'qeth' (possibly other
values), so we should probably keep it lowercase.


+
+ def clear(self):
+ IfcfgFile.clear(self)
+ if self.iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"
+
def __str__(self):
s = ""
s = s + "DEVICE=" + self.info["DEVICE"] + "
"
@@ -263,10 +276,44 @@ class NetworkDevice(SimpleConfigFile):

return s

- def __init__(self, dev):
- self.info = { "DEVICE" : dev }
- if dev.startswith('ctc'):
- self.info["TYPE"] = "CTC"
+ def loadIfcfgFile(self):
+ self.clear()
+ IfcfgFile.read(self)
+
+ def writeIfcfgFile(self, dir=None):
+ IfcfgFile.write(self, dir)
+
+ def log(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.close()
+ self.log_file()
+ self.log_write_file()
+ self.log_values()
+
+ def log_values(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== values for file %s
" % self.path)
+ lf.write(IfcfgFile.__str__(self))
+ lf.close()
+
+ def log_write_file(self, header="
"):
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== file to be written for %s
" % self.path)
+ lf.write(self.__str__())
+ lf.close()
+
+ def log_file(self, header="
"):
+ f = open(self.path, 'r')
+ lf = open(self.logfile, 'a')
+ lf.write(header)
+ lf.write("== file %s
" % self.path)
+ lf.write(f.read())
+ lf.close()
+ f.close()
+

class Network:
def __init__(self):



Ack for the rest.

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

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvfiLgACgkQ5hsjjIy1Vkl8vgCfcmyC+PJGcC S3G3fFAwzupIfB
5EAAoM+BYhTukDyGz08ekCyzxErLWoic
=z1ge
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-04-2010, 02:18 PM
Radek Vykydal
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

David Cantrell wrote:



On Tue, 27 Apr 2010, Radek Vykydal wrote:



-class NetworkDevice(SimpleConfigFile):
+class NetworkDevice(IfcfgFile):
+
+ def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
+ IfcfgFile.__init__(self, dir, iface)
+ self.logfile = logfile
+ if iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"


Why 'CTC' over 'ctc'? Other system tools expect the NETTYPE variable
in the

ifcfg file on s390x to contain 'ctc' or 'lcs' or 'qeth' (possibly other
values), so we should probably keep it lowercase.


I just keep doing what we used to do. I can commit the change
to lowercase as separate patch (assuming it acked by you).

Radek




- def __init__(self, dev):
- self.info = { "DEVICE" : dev }
- if dev.startswith('ctc'):
- self.info["TYPE"] = "CTC"


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-06-2010, 02:59 PM
David Cantrell
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

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

On Tue, 4 May 2010, Radek Vykydal wrote:


David Cantrell wrote:



On Tue, 27 Apr 2010, Radek Vykydal wrote:



-class NetworkDevice(SimpleConfigFile):
+class NetworkDevice(IfcfgFile):
+
+ def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
+ IfcfgFile.__init__(self, dir, iface)
+ self.logfile = logfile
+ if iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"


Why 'CTC' over 'ctc'? Other system tools expect the NETTYPE variable in
the

ifcfg file on s390x to contain 'ctc' or 'lcs' or 'qeth' (possibly other
values), so we should probably keep it lowercase.


I just keep doing what we used to do. I can commit the change
to lowercase as separate patch (assuming it acked by you).


We were writing CTC to the NETTYPE variable? That does not seem right. A
separate patch to make sure the NETTYPE is lowercase would be a good thing, I
think.



Radek




- def __init__(self, dev):
- self.info = { "DEVICE" : dev }
- if dev.startswith('ctc'):
- self.info["TYPE"] = "CTC"




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

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvi2WcACgkQ5hsjjIy1VkkbnwCgyNtW+nHTeX 3Uq7CWSS6YDAPd
+6MAoOAcL9fapd95CCjMe2UJIQtfLSFq
=sLkz
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-06-2010, 04:28 PM
Steffen Maier
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

On 05/06/2010 04:59 PM, David Cantrell wrote:
> On Tue, 4 May 2010, Radek Vykydal wrote:
>>> On Tue, 27 Apr 2010, Radek Vykydal wrote:
>>>>
>>>> -class NetworkDevice(SimpleConfigFile):
>>>> +class NetworkDevice(IfcfgFile):
>>>> +
>>>> + def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
>>>> + IfcfgFile.__init__(self, dir, iface)
>>>> + self.logfile = logfile
>>>> + if iface.startswith('ctc'):
>>>> + self.info["TYPE"] = "CTC"
>>>
>>> Why 'CTC' over 'ctc'? Other system tools expect the NETTYPE variable
>>> in the
>>> ifcfg file on s390x to contain 'ctc' or 'lcs' or 'qeth' (possibly other
>>> values), so we should probably keep it lowercase.
>>
>> I just keep doing what we used to do. I can commit the change
>> to lowercase as separate patch (assuming it acked by you).
>
> We were writing CTC to the NETTYPE variable? That does not seem right. A
> separate patch to make sure the NETTYPE is lowercase would be a good
> thing, I think.

>>>> - def __init__(self, dev):
>>>> - self.info = { "DEVICE" : dev }
>>>> - if dev.startswith('ctc'):
>>>> - self.info["TYPE"] = "CTC"

Last time, I checked, there are no consumers of what this code fragment
initializes. Linuxrc.s390 sets NETTYPE in the ifcfg file (previously it
used to be loader) and anaconda just copies it over to /mnt/sysimage.
Here it says just TYPE and I have no idea what this was used for.
Looking at the scripts in /etc/sysconfig/network-scripts/ it looks like
there is only "Bridge" or "Tap" for TYPE. s390x network devices use only
NETTYPE (and optionally DEVICETYPE, but that can be derived from NETTYPE
[https://bugzilla.redhat.com/show_bug.cgi?id=507214#c7]).
I guess we can just leave it as is, in order not to risk breaking some
old stuff.

My 2 ct,
Steffen

Linux on System z Development

IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@redhat.com
https://www.redhat.com/mailman/listinfo/anaconda-devel-list
 
Old 05-06-2010, 09:00 PM
David Cantrell
 
Default Use IfcfgFile class to back NetworkDevice objects (#520146)

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

On Thu, 6 May 2010, Steffen Maier wrote:


On 05/06/2010 04:59 PM, David Cantrell wrote:

On Tue, 4 May 2010, Radek Vykydal wrote:

On Tue, 27 Apr 2010, Radek Vykydal wrote:


-class NetworkDevice(SimpleConfigFile):
+class NetworkDevice(IfcfgFile):
+
+ def __init__(self, dir, iface, logfile='/tmp/ifcfg.log'):
+ IfcfgFile.__init__(self, dir, iface)
+ self.logfile = logfile
+ if iface.startswith('ctc'):
+ self.info["TYPE"] = "CTC"


Why 'CTC' over 'ctc'? Other system tools expect the NETTYPE variable
in the
ifcfg file on s390x to contain 'ctc' or 'lcs' or 'qeth' (possibly other
values), so we should probably keep it lowercase.


I just keep doing what we used to do. I can commit the change
to lowercase as separate patch (assuming it acked by you).


We were writing CTC to the NETTYPE variable? That does not seem right. A
separate patch to make sure the NETTYPE is lowercase would be a good
thing, I think.



- def __init__(self, dev):
- self.info = { "DEVICE" : dev }
- if dev.startswith('ctc'):
- self.info["TYPE"] = "CTC"


Last time, I checked, there are no consumers of what this code fragment
initializes. Linuxrc.s390 sets NETTYPE in the ifcfg file (previously it
used to be loader) and anaconda just copies it over to /mnt/sysimage.
Here it says just TYPE and I have no idea what this was used for.
Looking at the scripts in /etc/sysconfig/network-scripts/ it looks like
there is only "Bridge" or "Tap" for TYPE. s390x network devices use only
NETTYPE (and optionally DEVICETYPE, but that can be derived from NETTYPE
[https://bugzilla.redhat.com/show_bug.cgi?id=507214#c7]).
I guess we can just leave it as is, in order not to risk breaking some
old stuff.


That's probably fine then. I was still thinking something lurking in
/etc/sysconfig/network-scripts might still use NETTYPE.

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

Red Hat / Honolulu, HI

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEARECAAYFAkvjLfUACgkQ5hsjjIy1VkkfXACcCQLf3g2ruW nMvtdZmVgmS+4g
v1oAn0aB1vrsxvkarwyEy8dkBAelEiPp
=Fpj2
-----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 07:22 AM.

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