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

Jimmy Jin jjin62 at yahoo.com
Mon Oct 17 23:28:02 UTC 2016


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?
  
#yiv7784892132 --P{margin-top:0;margin-bottom:0;}#yiv7784892132 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



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


More information about the sysrepo-devel mailing list