def _set_mtu(self, mtu=1500): # SET RIGHT NOW sudo("ifconfig eth0 mtu "+unicode(mtu)) # DESPITE THE FILE CHANGE, THE MTU VALUE DOES NOT STICK local_file = File("./results/temp/ifcfg-eth0") local_file.delete() get("/etc/sysconfig/network-scripts/ifcfg-eth0", "./results/temp/ifcfg-eth0", use_sudo=True) lines = local_file.read() if lines.find("MTU=1500") == -1: lines += "\nMTU=1500" local_file.write(lines) put("./results/temp/ifcfg-eth0", "/etc/sysconfig/network-scripts/ifcfg-eth0", use_sudo=True)
def _set_mtu(self, mtu=1500): # SET RIGHT NOW sudo("ifconfig eth0 mtu " + unicode(mtu)) # DESPITE THE FILE CHANGE, THE MTU VALUE DOES NOT STICK local_file = File("./results/temp/ifcfg-eth0") local_file.delete() get("/etc/sysconfig/network-scripts/ifcfg-eth0", "./results/temp/ifcfg-eth0", use_sudo=True) lines = local_file.read() if lines.find("MTU=1500") == -1: lines += "\nMTU=1500" local_file.write(lines) put("./results/temp/ifcfg-eth0", "/etc/sysconfig/network-scripts/ifcfg-eth0", use_sudo=True)
class StructuredLogger_usingFile(StructuredLogger): def __init__(self, file): assert file from mo_files import File self.file = File(file) if self.file.exists: self.file.backup() self.file.delete() self.file_lock = allocate_lock() def write(self, template, params): try: with self.file_lock: self.file.append(expand_template(template, params)) except Exception as e: Log.warning("Problem writing to file {{file}}, waiting...", file=file.name, cause=e) time.sleep(5)
class StructuredLogger_usingFile(StructuredLogger): def __init__(self, file): assert file from mo_files import File self.file = File(file) if self.file.exists: self.file.backup() self.file.delete() self.file_lock = allocate_lock() def write(self, template, params): try: with self.file_lock: self.file.append(expand_template(template, params)) except Exception as e: Log.warning("Problem writing to file {{file}}, waiting...", file=self.file.name, cause=e) time.sleep(5)