def set_rsyslog_new_configuration():
    """
    Sets the Rsyslog configuration to listen on port 514 for incoming requests- For new config format
    """
    with open(rsyslog_conf_path, "rt") as fin:
        with open(temp_file_path, "wt") as fout:
            for line in fin:
                if "imudp" in line or "imtcp" in line:
                    # Load configuration line requires 1 replacement
                    if "load" in line:
                        fout.write(line.lstrip("#"))
                    # Port configuration line requires 2 replacements
                    elif "port" in line:
                        fout.write(line.replace("#", "", 2))
                    else:
                        fout.write(line)
                else:
                    fout.write(line)
    command_tokens = ["sudo", "cp", temp_file_path, rsyslog_conf_path]
    write_new_content = subprocess.Popen(command_tokens, stdout=subprocess.PIPE)
    time.sleep(3)
    o, e = write_new_content.communicate()
    if e is not None:
        handle_error(e,
                     error_response_str="Error: could not change Rsyslog.conf configuration  in -" + rsyslog_conf_path)
        return False
    print_ok("Rsyslog.conf configuration was changed to fit required protocol - " + rsyslog_conf_path)
    return True

    Sets the Rsyslog configuration to listen on port 514 for incoming requests- For new config format
    
DataConnectors/Syslog/Forwarder_AMA_installer.py