tail-f-systems / JNC

JNC (Java NETCONF Client) is the name of a Java library for communicating with NETCONF agents, and a plugin for pyang (http://code.google.com/p/pyang/) to generate Java classes from YANG models, to be used by the JNC library.
Other
77 stars 87 forks source link

NetConf session create Subscription is not working for filter type=xpath #73

Open mohit-telsiz opened 8 years ago

mohit-telsiz commented 8 years ago

The createSubscription() creates a Malformed rpc request xml if filter argument is present. [Found in JNC1.2 release]

`int encode_createSubscription(Transport out, String stream, String filter, String startTime, String stopTime) { final String prefix = Element.defaultPrefixes .nsToPrefix(Capabilities.NS_NOTIFICATION); final String ncn = mk_prefix_colon(prefix); final String xmlnsAttr = mk_xmlns_attr(prefix, Capabilities.NS_NOTIFICATION);

    final int mid = encode_rpc_begin(out);
    out.println("<" + ncn + "create-subscription " + xmlnsAttr + ">");
    if (stream != null) {
        out.print("<" + ncn + STREAM_GT);
        out.print(stream);
        out.println("</" + ncn + STREAM_GT);
    }
    **if (filter != null) {
        out.print("<" + ncn + FILTER + ncn + "type='xpath'>");
        out.print(filter);
        out.println("</" + ncn + FILTER_GT);
    }**
    if (startTime != null) {
        out.print("<" + ncn + START_TIME_GT);
        out.print(startTime);
        out.println("</" + ncn + START_TIME_GT);
    }
    if (stopTime != null) {
        out.print("<" + ncn + STOP_TIME_GT);
        out.print(stopTime);
        out.println("</" + ncn + STOP_TIME_GT);
    }
    out.println("</" + ncn + "create-subscription>");
    encode_rpc_end(out);
    return mid;
}`

Highlighted code snippet shows that if filter type is xpath then the 'filter' string should be used as value for 'select' attribute within element, which is missing here

klacke commented 8 years ago

Ok, I guess no one has ever done this, it's not the most common thing to do though, I've never done it.

Can you provide a proper patch maybe ??

/klacke

On 26/10/16 01:19, mohit-telsiz wrote:

The createSubscription() creates a Malformed rpc request xml if filter argument is present. `int encode_createSubscription(Transport out, String stream, String filter, String startTime, String stopTime) { final String prefix = Element.defaultPrefixes .nsToPrefix(Capabilities.NS_NOTIFICATION); final String ncn = mk_prefix_colon(prefix); final String xmlnsAttr = mk_xmlns_attr(prefix, Capabilities.NS_NOTIFICATION);

|final int mid = encode_rpc_begin(out); out.println("<" + ncn + "create-subscription " + xmlnsAttr + ">"); if (stream != null) { out.print("<" + ncn + STREAM_GT); out.print(stream); out.println("</" + ncn + STREAM_GT); } **if (filter != null) { out.print("<" + ncn + FILTER

  • ncn + "type='xpath'>"); out.print(filter); out.println("</" + ncn + FILTER_GT); }\ if (startTime != null) { out.print("<" + ncn + START_TIME_GT); out.print(startTime); out.println("</" + ncn + START_TIME_GT); } if (stopTime != null) { out.print("<" + ncn + STOP_TIME_GT); out.print(stopTime); out.println("</" + ncn + STOP_TIME_GT); } out.println("</" + ncn + "create-subscription>"); encode_rpc_end(out); return mid; }` |

Highlighted code snippet shows that if filter type is xpath then the 'filter' string should be used as value for 'select' attribute within element, which is missing here

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tail-f-systems/JNC/issues/73, or mute the thread https://github.com/notifications/unsubscribe-auth/AADYIHVR3gDBuoBsNtR4UFA_6vctnI4Lks5q3o5ygaJpZM4Kgl4s.