def __init__(self, dir, iface): IfcfgFile.__init__(self, dir, iface) self.description = "" if iface.startswith('ctc'): self.info["TYPE"] = "CTC" self.wepkey = "" 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\n" % self.path) self._dirty = False
def loadIfcfgFile(self): ifcfglog.debug("%s:\n%s" % (self.path, self.fileContent())) ifcfglog.debug("NetworkDevice %s:\n%s" % (self.iface, self.__str__())) ifcfglog.debug("loadIfcfgFile %s from %s" % (self.iface, self.path)) self.clear() IfcfgFile.read(self) self._dirty = False ifcfglog.debug("NetworkDevice %s:\n%s" % (self.iface, self.__str__()))
def writeIfcfgFile(self): # Write out the file only if there is a key whose # value has been changed since last load of ifcfg file. ifcfglog.debug("%s:\n%s" % (self.path, self.fileContent())) ifcfglog.debug("NetworkDevice %s:\n%s" % (self.iface, self.__str__())) ifcfglog.debug("writeIfcfgFile %s to %s%s" % (self.iface, self.path, ("" if self._dirty else " not needed"))) if self._dirty: IfcfgFile.write(self) 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
def set(self, *args): # If we are changing value of a key set _dirty flag # informing that ifcfg file needs to be synced. s = " ".join(["%s=%s" % key_val for key_val in args]) ifcfglog.debug("NetworkDevice %s set: %s" % (self.iface, s)) for (key, data) in args: if self.get(key) != data: break else: return IfcfgFile.set(self, *args) self._dirty = True
def clear(self): IfcfgFile.clear(self) if self.iface.startswith('ctc'): self.info["TYPE"] = "CTC"
def log_values(self, header="\n"): lf = open(self.logfile, 'a') lf.write(header) lf.write("== values for file %s\n" % self.path) lf.write(IfcfgFile.__str__(self)) lf.close()
def loadIfcfgFile(self): self.clear() IfcfgFile.read(self) self.log("NetworkDevice read from %s\n" % self.path) self._dirty = False
def loadIfcfgFile(self): ifcfglog.debug("loadIfcfFile %s" % self.path) self.clear() IfcfgFile.read(self) self._dirty = False