[sysrepo-devel] How to use operation data provider in this?

Jimmy Jin jjin62 at yahoo.com
Thu Nov 3 21:43:23 UTC 2016


Milan,Tried latest master and operational data in a sub module (uses statement in yang model) is working!! 
An issue of sysrepod crush is reported in github, issue 512. 
thanks for the help,Jimmy

      From: Milan Lenčo <Milan.Lenco at pantheon.tech>
 To: Jimmy Jin <jjin62 at yahoo.com> 
Cc: Sysrepo-public <sysrepo-devel at sysrepo.org>
 Sent: Wednesday, November 2, 2016 2:30 AM
 Subject: Re: [sysrepo-devel] How to use operation data provider in this?
   
#yiv2294607444 #yiv2294607444 --P{margin-top:0;margin-bottom:0;}#yiv2294607444 --P {margin-top:0;margin-bottom:0;}#yiv2294607444 --P {margin-top:0;margin-bottom:0;}#yiv2294607444 -- --P {margin-top:0;margin-bottom:0;}#yiv2294607444 Hi Jimmy,
Sorry for a late response, but I accidentally missed your email in all the communication that is going on right now. I recommend you to open an issue in github (https://github.com/sysrepo/sysrepo/issues) everytime you have any problem with sysrepo, rather than sending emails directly. There it will certainly not get overlooked by us.
Now regarding your issue:Firstly, from the schema you posted before it doesn't seem that com-oplink-device-common is a submodule, but rather a module on it's own (import used instead of include). I have triedcom-att-device with a made up version of module com-oplink-device-common (I didn't find its schema in our communication), but didn't experience any issues. Very recently, however, there have been some patches committed to master that fix certain cases related to operational data introduced into the module through the USES statement. Could you please pull the latest master and re-try? If the issue still exists, please file an issue report on github and if it is possible also attach the content of com-oplink-device-common and com-att-device, at least the relevant parts if they are too long.
Thanks,Milan
Od: Jimmy Jin <jjin62 at yahoo.com>
Odoslané: 26. októbra 2016 1:41
Komu: Milan Lenčo
Kópia: Sysrepo-public
Predmet: Re: [sysrepo-devel] How to use operation data provider in this? Hi Milan,
Just pull the master and I did more testing seems here is what I saw:1) if a operational data is in a submodule. as in the following case, operational data device-physical is defined in submodule com-oplink-device-common;2) after sr_dp_get_items_subscribe(sess, xpath...) is called ( for ANY xpath);3) sr_get_??? (sess, xpath...) for ANY xpath will fail with the SAME error (it is always on the FIRST occurrence, where a operational data is in a submodule)
[ERR] (rp_dt_xpath_requests_state_data:684) Unable to find schema node for "MODULE:xpath-to-submodulel/SUBMODULE:xpath-in-submodule."
as in the following example[ERR] (rp_dt_xpath_requests_state_data:684) Unable to find schema node for /com-att-device:open-optical-device/physical/com-oplink-device-common:device-physical
If I remove config false from device-physical, then the error will happen in the next place,  where a operational data is in a submodule.
if I don't call sr_dp_get_items_subscribe in 2), then everything works as usual. Please confirm.
thanks,Jimmy

From: Jimmy Jin <jjin62 at yahoo.com>
To: Milan Lenčo <Milan.Lenco at pantheon.tech>
Cc: Sysrepo-public <sysrepo-devel at sysrepo.org>
Sent: Tuesday, October 18, 2016 12:41 PM
Subject: Re: [sysrepo-devel] How to use operation data provider in this?

thanks Milan.
We have a pretty big yang model, so I just use a small subset to test the subscription. You are right the schema is fixed and I re-installed modules:
module com-att-device{
  namespace "http://com/att/device";    import com-oplink-device-common {    prefix com-oplink-device-common;  }  prefix "com-att-device";  container open-optical-device{    container physical{      uses com-oplink-device-common:device-physical;      config false;    }
    list ports{               key "port-id";      leaf port-id {
        type uint32;
      }
      container port {        leaf target-power {        
            type uint32;
        }        leaf current-power { 
           type uint32;           config false;
        }     }   }  }}
But still got the same error message:[ERR] (rp_dt_xpath_requests_state_data:684) Unable to find schema node for /com-att-device:open-optical-device/physical/com-oplink-device-common:device-physical
Here is my thoughts:In rp_dt_xpath_requests_state_data(), it failed on rp_dt_validate_node_xpath(rp_ctx->dm_ctx, NULL,                    sub->xpath, NULL, &state_data_node);
where the sub->xpath is  /com-att-device:open-optical-device/physical/com-oplink-device-common:device-physical
seems that rp_dt_validate_node_xpath can not handle the submodule com-oplink-device-common: in the xpath?
best,Jimmy



MilanLenčoSoftware Developer
Sídlo / Mlynské Nivy 56 /821 05 Bratislava/ Slovakia
R&D centrum / Janka Kráľa 9 / 974 01 Banská Bystrica / Slovakia
/Milan.Lenco at pantheon.tech
reception: +421 2 206 65 114/www.pantheon.sk 

From: Milan Lenčo <Milan.Lenco at pantheon.tech>
To: Jimmy Jin <jjin62 at yahoo.com> 
Cc: Sysrepo-public <sysrepo-devel at sysrepo.org>
Sent: Tuesday, October 18, 2016 1:52 AM
Subject: Re: [sysrepo-devel] How to use operation data provider in this?

#yiv2294607444 #yiv2294607444 -- --P {margin-top:0;margin-bottom:0;}#yiv2294607444 --P {margin-top:0;margin-bottom:0;}#yiv2294607444 Hi Jimmy,
Is this the full schema? I see a reference to a modulecom-att-device-common inside auses clause, which I suppose is imported somewhere at the top of com-att-device and it's yang schema is present in the "yang" subdirectory of the repository, otherwise libyang wouldn't parse it.
Also, based on the error, sysrepo expects this path to exists: /com-att-device:open-optical-device/physical/com-oplink-device-common:device-physicalHave you changed the prefixcom-oplink-device-common to com-att-device-common in the schema? Anytime you change a yang schema, in needs to be re-installed (using sysrepoctl, not manual copying) for sysrepo to re-run static analysis to gather some metadata from the module for the purpose of more effective processing in the runtime.
Regards,Milan

Od: Jimmy Jin <jjin62 at yahoo.com>
Odoslané: 18. októbra 2016 1:28
Komu: Milan Lenčo
Kópia: Sysrepo-public
Predmet: Re: [sysrepo-devel] How to use operation data provider in this? Hi Milan,I pulled latest master and still had some issues:
schema:module com-att-device{
  namespace "http://com/att/device";
  prefix "com-att-device";
  container open-optical-device{    container physical{      uses com-att-device-common:device-physical;      config false;    }
    list ports{               key "port-id";      leaf port-id {
        type uint32;
      }
      container port {        leaf target-power {        
            type uint32;
        }        leaf current-power { 
           type uint32;           config false;
        }     }   }  }}
provider:sr_dp_get_items_subscribe(session, "/com-att-device:open-optical-device/ports/port/port-current-power", data_provider_cb, NULL,...
requestor:sr_get_items_iter(session, "/com-att-device:open-optical-device/ports/port/port-current-power", &iter);

when requstor is called, sysrepod had error:[ERR] (rp_dt_xpath_requests_state_data:684) Unable to find schema node for /com-att-device:open-optical-device/physical/com-oplink-device-common:device-physical[ERR] (rp_dt_prepare_data:811) rp_dt_xpath_requests_state_data failed[ERR] (rp_dt_get_values_wrapper_with_opts:966) rp_dt_prepare_data failed[ERR] (rp_dt_get_values_wrapper_with_opts:995) Copying values from nodes failed for xpath '/com-att-device:open-optical-device/ports/port/port-current-power'[ERR] (rp_get_items_req_process:516) Get items failed for '/com-att-device:open-optical-device/ports/port/port-current-power', session id=501286277.
 the error in first line seems very strange. Any idea?
thanks,Jimmy


From: Milan Lenčo <Milan.Lenco at pantheon.tech>
To: Jimmy Jin <jjin62 at yahoo.com> 
Cc: Sysrepo-public <sysrepo-devel at sysrepo.org>
Sent: Friday, October 14, 2016 1:52 PM
Subject: Re: [sysrepo-devel] How to use operation data provider in this?

#yiv2294607444 #yiv2294607444 -- -- --P {margin-top:0;margin-bottom:0;}#yiv2294607444 Hi Jimmy,
it turned out that there is a bug in sysrepo that occurs in a scenario when state data are inside configurable list, just like in your case. So firstly, thanks for helping to discover and navigate this issue. The patch is ready in this pull request: https://github.com/sysrepo/sysrepo/pull/424. Once it is reviewed, it will be merged to master, most likely on Monday. You will then need to update your local copy of the master branch to the latest version (will be 0.4.3).
Now regarding sr_dp_get_items_subscribe: when you are subscribing for state data, always use xpath without predicates, as if to reference the schema node rather then a data node. So in your case, you may directly subscribe the provider to "/com-att-device:ports/port/current-power" or to any predecessor of the current-power schema node. Your attempt to use "/com-att-device:ports" was also correct, just the aforementioned bug caused sysrepo to incorrectly process the data returned by the provider.Your state data provider will be asked to provide values for the predicate-less xpath "/com-att-device:ports/port/current-power", so it is expected to return value for every port in the ports list that there is (or there can be, provider may or may not track the list of all ports currently configured). E.g.:
values[0].xpath =  strdup("/com-att-device:ports[port-id='0']/port/current-power");values[0].data.uint32_val = 10;
values[1].xpath =  strdup("/com-att-device:ports[port-id='1']/port/current-power");values[1].data.uint32_val = 15;
values[2].xpath =  strdup("/com-att-device:ports[port-id='2']/port/current-power");values[2].data.uint32_val = 5;
etc.

The truth is that this topic is under-documented in sysrepo and in the following two weeks we are planing to improve the documentation and focus also on this area in detail.
Regards,Milan

Od: Jimmy Jin <jjin62 at yahoo.com>
Odoslané: 14. októbra 2016 1:42
Komu: sysrepo-devel at sysrepo.org
Predmet: [sysrepo-devel] How to use operation data provider in this? Hi,when operation data and conf data are mixed in a sub tree, I can not make the data provide callback working.
here is the schema example:

module com-att-device{
  namespace "http://com/att/device";
  prefix "com-att-device";    list ports{     
      leaf port-id {
        type uint32;
      }
      container port {        leaf target-power {       
            type uint32;
        }        leaf current-power {
           type uint32;           config false;
        }     }  }}

I like to implement a data provider for current-power, but had no luck so far. I am not sure what xpath I should use in this call:sr_dp_get_items_subscribe(session, xpath.....).seems xpath =" /com-att-device:ports" is not working. Because it is a list, so i can not specify the path all the way to current-power, is wildcard support? like:/com-att-device:ports[port-id='?']/port/current-power.


thanks in advance.Jimmy





MilanLenčo Software Developer
Sídlo / Mlynské Nivy 56 / 821 05 Bratislava/ Slovakia
R&D centrum / Janka Kráľa 9 / 974 01 Banská Bystrica / Slovakia
/Milan.Lenco at pantheon.tech
reception: +421 2 206 65 114/www.pantheon.sk 

   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sysrepo.org/archives/sysrepo-devel/attachments/20161103/bf641ea7/attachment.html>


More information about the sysrepo-devel mailing list