def set_omsagent_configuration(workspace_id, omsagent_incoming_port):
    '''
    Download the omsagent configuration and then change the omsagent incoming port
    if required and change the protocol if required
    :param workspace_id:
    :param omsagent_incoming_port:
    :param tcp:
    :param udp:
    :return:
    '''
    configuration_directory = "/etc/opt/microsoft/omsagent/" + workspace_id + "/conf/omsagent.d/"
    configuration_path = "/etc/opt/microsoft/omsagent/" + workspace_id + "/conf/omsagent.d/security_events.conf"

    print("Creating omsagent configuration to listen to syslog daemon forwarding port - " + omsagent_incoming_port)
    print("Configuration location is - " + configuration_path)
    mkdir_command_tokens = ["sudo", "mkdir", "-p", configuration_directory]
    wget_command_tokens = ["sudo", "wget", "-O", configuration_path, oms_agent_configuration_url]
    print("Download configuration into the correct directory")
    print_notice(" ".join(mkdir_command_tokens))
    print_notice(" ".join(wget_command_tokens))
    time.sleep(3)
    create_omsagent_configuration_directory = subprocess.Popen(mkdir_command_tokens, stdout=subprocess.PIPE)
    set_omsagent_configuration_command = subprocess.Popen(wget_command_tokens, stdout=subprocess.PIPE)
    o, e = create_omsagent_configuration_directory.communicate()
    if e is not None:
        handle_error(e, error_response_str="Error: could not create omsagent configuration directory.")
        return False
    o, e = set_omsagent_configuration_command.communicate()
    if e is not None:
        handle_error(e, error_response_str="Error: could not download omsagent configuration.")
        return False
    # set read permissions to the configuration file after downloaded and created
    set_file_read_permissions(configuration_path)
    print_ok("Configuration for omsagent downloaded successfully.")
    print("Trying to change omsagent configuration")
    if omsagent_incoming_port is not omsagent_default_incoming_port:
        if change_omsagent_configuration_port(omsagent_incoming_port=omsagent_incoming_port, configuration_path=configuration_path):
            print_ok("Incoming port for omsagent was changed to " + omsagent_incoming_port)
        else:
            print_error("Could not change omsagent incoming port")
    if change_omsagent_protocol(configuration_path=configuration_path):
        print_ok("Finished changing omsagent configuration")
        return True
    else:
        print_error("Could not change the omsagent configuration")
        return False

    Download the omsagent configuration and then change the omsagent incoming port
    if required and change the protocol if required
    :param workspace_id:
    :param omsagent_incoming_port:
    :param tcp:
    :param udp:
    :return:
    
DataConnectors/CEF/cef_installer.py