CESNET / libnetconf

C NETCONF library
Other
113 stars 83 forks source link

NETCONF/Yang Object type suggestion #225

Closed virajmistry closed 8 years ago

virajmistry commented 8 years ago

Hi,

I am developing my own yang module. For statistic types of YANG object in TransAPI module there is only one function called get_state_data which will be called when request is come of any state yang object. Now i have one object foo used to state data of device. With this object i need to give support for different types of state data based on input given to foo. e.g. foo a --> status of a foo b --> status of b foo c --> status of c

above foo object is define in YANG file as per below,

leaf foo{
    config false;
    type string;
    description 
        "leaf contain the foo related information based on input.";    
}

so my question is, How can i define this kind of object in my YANG file ? Which takes input argument and then give status. As per i know only edit-config allows user to give input argument for config data types but for state data type, Is there any way to give input argument to read status based ?

NOTE: I can accommodate this all objects individually in yang file but any other way is possible ? e.g

leaf foo a{
    config false;
    type string;
    description 
    "leaf contain the foo related information a.";    
}

Please suggest your view.

Regards, Viraj

michalvasko commented 8 years ago

Hi Viraj, I don't think it is possible to do what you described, but I think there are too many YANG features not to be able to model something using them. In your case you can simply use 3 state leaves a, b, and c. You can then retrieve only those you want using with a filter. Or perhaps a list will suit you better, several instances of one data differentiated by a key leaf. You can choose whatever you prefer.

Regards, Michal

virajmistry commented 8 years ago

Hi Michal,

Thank you for prompt reply. Yes we can do like below ,

list foo{               
  key "input";
  config false;             
  leaf input{
    type uint8;                 
    description
      "leaf takes as a input parameter";
  }
  leaf output{
    type string;                    
    description
      "leaf displays the output of list as per the input parameter";
  }
}

and then our get request would be

<get>
  <filter type="subtree">
   <xyz xmlns="urn:ietf:params:xml:ns:yang:xyz-model">
   <foo>
    <input>a</input>
   </foo>
  </filter>
 </get>

But then using TransAPI module , there is only one function called get_state_data which is being called when request of state data will come. So now when i give <input>a</input> in get request then how can this value "a" will come as input argument in function get_state_data or is there any another function called for this ?

Awaiting your reply.

Regards, Viraj

michalvasko commented 8 years ago

Hi Viraj, in this case the function get_state_data() must generate all the current instances of foo and then later libnetconf will filter out all except those with input of value a. But I still think you are trying to do something unnatural for YANG, which there is a better way for. If you really want this kind of separate state data, you can also define your own RPC with input and output parameters.

Regards, Michal

virajmistry commented 8 years ago

Hi Michal,

Thanks for reply. I have done the way you suggest for foo object i.e I have created foo as list object and in that two objects called input and output where input is key and output is status of foo. It works fine for me. But the only problem is whenever there is a request of one object of state data then get_state_data will read all the instances that may create overhead on system as in my yang file there are numbers of state data. Is there any other way ?

If you really want this kind of separate state data, you can also define your own RPC with input and output parameters. It is good way to create RPC for state data ?

Regards, Viraj

rkrejci commented 8 years ago

The way how libnetconf gets status data from TransAPI is very limiting. We know it and it is changed in the new generation of the tools.

With libnetconf, you have the following options:

It does not matter which data are in the RPC output. As RPC output, you are supposed to define anything you believe that is relevant to the RPC request (input). <get> is defined as RPC and it also returns status data.

virajmistry commented 8 years ago

Hi Radek,

Thank you very much for prompt reply. It clears my all doubts regarding state date.

We know it and it is changed in the new generation of the tools. May i know the name of this tool ?

Regards, Viraj

rkrejci commented 8 years ago

libyang, libnetconf2, Netopeer2 and sysrepo - they are not yet finished, but I believe that at the end of this year I could recommend the current users of libnetconf and netopeer to move to the new generation of the tools.

virajmistry commented 8 years ago

Hi Radek,

Thank you for input. As of now i will use stable version of netopeer. Yours input really helps me lot.

Regards, Viraj