def _disable_ipv6_on_system(self, root): """Disable ipv6 on target system. :param root: path to the root of the target system :type root: str """ fpath = os.path.normpath(root + self.ANACONDA_SYSCTL_FILE_PATH) try: with open(fpath, "a") as f: f.write("# Anaconda disabling ipv6 (noipv6 option)\n") f.write("net.ipv6.conf.all.disable_ipv6=1\n") f.write("net.ipv6.conf.default.disable_ipv6=1\n") except OSError as e: msg = "Cannot disable ipv6 on the system: {}".format(e.strerror) raise NetworkInstallationError(msg) from e
def _write_config_file(root, path, content, error_msg, overwrite): """Write content into config file on the target system. :param root: path to the root of the target system :type root: str :param path: config file path in target system root :type path: str :param content: content to be written into config file :type content: str :param error_msg: error message in case of failure :type error_msg: str :param overwrite: overwrite existing configuration file :type overwrite: bool """ fpath = os.path.normpath(root + path) if os.path.isfile(fpath) and not overwrite: return try: with open(fpath, "w") as fobj: fobj.write(content) except OSError as e: msg = "{}: {}".format(error_msg, e.strerror) raise NetworkInstallationError(msg) from e