netopeer2 icon indicating copy to clipboard operation
netopeer2 copied to clipboard

netopeer2 problem with the ncclient in the edit-config

Open alireza11048 opened this issue 3 years ago • 1 comments

Hi, I'm trying to connect to a netopeer2 server with the ncclient python library. the ncclient sends the below RPC message to the server as edit-config rpc and receives an error which is logged in the bellow:

[INF]: NP: Session 1: thread 3 event new RPC.
[DBG]: LN: Session 1: Received message:
<?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:d80cdb55-fecc-4645-880a-4244e9968912"><nc:edit-config><nc:target><nc:running/></nc:target><config><add_string_filter xmlns="urn:sysrepo:secure_egw"><regex>addadd</regex><desc>filtering</desc><target>email_title</target></add_string_filter></config></nc:edit-config></nc:rpc>

[ERR]: LY: Unknown XML prefix "". (Schema location /ietf-netconf:edit-config, data location /ietf-netconf:edit-config, line number 1.)
[DBG]: LN: Session 1: Sending message:

#333


[DBG]: LN: Session 1: Sending message:
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:d80cdb55-fecc-4645-880a-4244e9968912"><rpc-error><error-type>application</error-type><error-tag>operation-failed</error-tag><error-severity>error</error-severity><error-message xml:lang="en">Unknown XML prefix "".</error-message></rpc-error></rpc-reply>

[DBG]: LN: Session 1: Sending message:

Can anyone kindely tell me what is the problem with the above RPC message?

P.S: I've registered the below yang model in the sysrepo:

module secure_egw {
    namespace "urn:sysrepo:secure_egw";
    prefix seg;

    revision 2018-01-19 {
        description "Initial revision.";
    }

    container add_string_filter {
        description "string filters which can be applied to different sections.";

        leaf regex {
            type string;
            //mandatory true;
            description "the regex which will be applied";
        }

        leaf desc {
            type string;
            description "the description about the filter";
        }

        leaf target {
            description "Parameter determining which part of the mail to perform the operation.";
            type enumeration {
                enum email_title {
                    description "apply the filter to the title.";
                }
                enum email_body {
                    description
                        "apply the filter to the body";
                }
            }
            //mandatory true;
        }
    }

    container get_string_filters
    {
        config false;
        
        list string_filter
        {
            key filter-id;

            leaf filter-id {
                type uint32;
                //mandatory true;
                description "key of the tree";
            }

            leaf regex {
                type string;
                //mandatory true;
                description "the regex which will be applied";
            }

            leaf desc {
                type string;
                description "the description about the filter";
            }

            leaf target {
                description "Parameter determining which part of the mail to perform the operation.";
                type enumeration {
                    enum email_title {
                        description "apply the filter to the title.";
                    }
                    enum email_body {
                        description
                            "apply the filter to the body";
                    }
                }
                //mandatory true;
            }
        }
    }
}

and also I want to point out that I can successfully fetch the current configuration with the below rpc's with the ncclient library:

[INF]: NP: Session 1: thread 1 event bad RPC.
[INF]: NP: Session 1: thread 1 event reply error.
[DBG]: LN: Session 1: Received message:
<?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:5b43b339-43e2-4e76-bd64-ab4fc9747548"><nc:get-config><nc:source><nc:running/></nc:source><nc:filter type="subtree"><add_string_filter xmlns="urn:sysrepo:secure_egw"/></nc:filter></nc:get-config></nc:rpc>

[INF]: SR: Published event "rpc" "/ietf-netconf:get-config" with ID 2 priority 0 for 1 subscribers.
[INF]: SR: Processing "/ietf-netconf:get-config" "rpc" event with ID 2 priority 0 (remaining 1 subscribers).
[INF]: SR: Successful processing of "rpc" event with ID 2 priority 0 (remaining 0 subscribers).
[INF]: SR: Event "rpc" with ID 2 priority 0 succeeded.
[DBG]: LN: Session 1: Sending message:

#281


[DBG]: LN: Session 1: Sending message:
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:5b43b339-43e2-4e76-bd64-ab4fc9747548"><data><add_string_filter xmlns="urn:sysrepo:secure_egw"><regex>bsj</regex><desc>filtering</desc><target>email_title</target></add_string_filter></data></rpc-reply>

[DBG]: LN: Session 1: Sending message:

##

Thanks in advance.

alireza11048 avatar Aug 02 '22 12:08 alireza11048

In the request, config element is missing its namespace (the nc: prefix).

michalvasko avatar Aug 02 '22 13:08 michalvasko