CESNET / netopeer

NETCONF Protocol Toolset
118 stars 65 forks source link

Adding custom Yang modules and TranAPI model #119

Open pradyp11 opened 8 years ago

pradyp11 commented 8 years ago

HI, I'm using lnctool --model ./toaster.yang transapi --aths ./paths_file to generate .c file and editing the file with required tranapi callback functions. and installing it as mentioned in https://rawgit.com/CESNET/libnetconf/master/doc/doxygen/html/d9/d25/transapi.html

I'm using netopeer-manager add --name toaster --model /toaster.yang --datastore /usr/loc to add the yang model to server and i can see .xml file added to /usr/local/etc/netopeer/modules.conf.d

I want to know is this the right way of adding the yang models because im not able to use edit-config on the yang models. It says datastore fails to validate. Please help me in solving it.

rkrejci commented 8 years ago

First, the data models are expected in YIN format, not YANG, see the netopeer-manager help:

  --model MODEL         File holding the main data model (YIN format).

So, please fix the path in XML file in modules.conf.d to YIN. Then try it again and if there will be still the problem with validation, please provide more information about the model, edit-config and the current content of the datastore being edited/validated.

Note: YANG is supported in the new generation of the tools - libyang, libnetconf2 and Netopeer2

pradyp11 commented 8 years ago

Thank you for your reply.I'm using yin format to add the model to server. I have noticed the models are added to modules.conf.d as XMl which is in /etc/netopeer/modules.conf.d . But the path should be /usr/local/etc/netopeer/modules.conf.d . Is there any error in the path.

On Tue, May 31, 2016 at 10:33 AM, Radek Krejčí notifications@github.com wrote:

First, the data models are expected in YIN format, not YANG, see the netopeer-manager help:

--model MODEL File holding the main data model (YIN format).

So, please fix the path in XML file in modules.conf.d to YIN. Then try it again and if there will be still the problem with validation, please provide more information about the model, edit-config and the current content of the datastore being edited/validated.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CESNET/netopeer/issues/119#issuecomment-222707186, or mute the thread https://github.com/notifications/unsubscribe/ASfz6nAwwMqlhhB6wMbqTfKbQSA9C7dBks5qHEaigaJpZM4Iqlc- .

pradyp11 commented 8 years ago

I'm using yin format to add the toaster model to server. but still i have the issue.

<edit-config>:
<?xml version='1.0' encoding='UTF-8'?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <toast:toaster xmlns:toast="http://netconfcentral.org/ns/toaster">
        <toast:toasterManufacturer>Microsoft Toaster</toast:toasterManufacturer>
        <toast:toasterModelNumber>Acrobat Automatic</toast:toasterModelNumber>
        <toast:toasterStatus>up</toast:toasterStatus>
      </toast:toaster>
    </config>
  </edit-config>
</rpc>

reply

 ##### Error Reply or Operation Failed #####
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>access-denied</error-tag>
    <error-severity>error</error-severity>
    <error-message>creating "toaster" data node is not permitted.</error-message>
  </rpc-error>
</rpc-reply>
rkrejci commented 8 years ago

But the error does not say "datastore fails to validate" as you mentioned in the first comment. It says that you are not permitted to make changes - check the NACM settings.

rkrejci commented 8 years ago

or follow the First run configuration section in the netopeer server's README

pradyp11 commented 8 years ago

Sorry for the wrong attachment .

##### Error Reply or Operation Failed #####
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>operation-failed</error-tag>
    <error-severity>error</error-severity>
    <error-message>Datastore fails to validate (Did not expect element toasterManufacturer there)</error-message>
  </rpc-error>
</rpc-reply>

Turing machine example given in netopeer has a folder in /usr/lcoal/etc/netopeer/turing-machine which has datastore.xml,.rng,.xsl files but the toaster module i added into netopeer is not having any datastore.xml file. only toaster.xml file is added into the /usr/local/etc/netopeer/modules.conf.d/ . Does this have anything to do with the error?

rkrejci commented 8 years ago

now I see it - libnotconf and netopeer actually work correctly. The data defined by the toaster module are read-only, so you are not allowed to set them via edit-config. So the validation works correctly, it does not expect read-only data in configuration datastore, so the validation fails.

rkrejci commented 8 years ago

regarding the paths - netopeer-manager stores into the XML config the path to the data model (YIN). The validator files (RNG, XSL) are expected in the same location and with the specific name pattern. But they are not required, so libnetconf is able to work (in a limited way) without validator files.

pradyp11 commented 8 years ago

Thank you radek for your time to answer me. but i'm sorry to take more time of yours. i understood about read only data, but rpc request is also giving error. RPC

<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="d7daf740-2774-11e6-b2dd-00059a3c7a00">
  <toast:make-toast xmlns:toast="http://netconfcentral.org/ns/toaster">
    <toast:toasterDoneness>1</toast:toasterDoneness>
    <toast:toasterToastType>wheat-bread</toast:toasterToastType>
  </toast:make-toast>
</rpc>

RPC reply

 ##### Error Reply or Operation Failed #####
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="d7daf740-2774-11e6-b2dd-00059a3c7a00">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>operation-failed</error-tag>
    <error-severity>error</error-severity>
    <error-message>There is no device/data that could be affected.</error-message>
  </rpc-error>
</rpc-reply>
michalvasko commented 8 years ago

Hi, could you please provide the output of netopeer-server when started like netopeer-server -v 2?

Regards, Michal

pradyp11 commented 8 years ago

Result for netopeer-server -v2

root@mtznjv1nets02:/usr/local/bin# netopeer-server -v2 netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-inet-types. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-yang-types. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-netconf-monitoring. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-netconf-notifications. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model nc-notifications. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model notifications. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-netconf-with-defaults. netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-netconf-acm. netopeer-server[10947]: Datastore ietf-netconf-acm initiated with ID 8. netopeer-server[10947]: Checking the default Events stream path //var/lib/libnetconf//streams/. netopeer-server[10947]: Adding augment model "/usr/local/etc/netopeer/cfgnetopeer/ietf-x509-cert-to-name.yin" netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model ietf-x509-cert-to-name. netopeer-server[10947]: Adding static transapi "/usr/local/etc/netopeer/cfgnetopeer/ietf-netconf-server.yin" netopeer-server[10947]: "ssh" features in "ietf-netconf-server" module enabled. netopeer-server[10947]: "inbound-ssh" features in "ietf-netconf-server" module enabled. netopeer-server[10947]: "outbound-ssh" features in "ietf-netconf-server" module enabled. netopeer-server[10947]: Datastore ietf-netconf-server initiated with ID 1804289384. netopeer-server[10947]: Setting the default SSH configuration for the ietf-netconf-server module... netopeer-server[10947]: callback_srv_netconf_srv_listen_srv_port: SSH listening on the port 830 netopeer-server[10947]: Adding static transapi "/usr/local/etc/netopeer/cfgnetopeer/netopeer-cfgnetopeer.yin" netopeer-server[10947]: "dynamic-modules" features in "netopeer-cfgnetopeer" module enabled. netopeer-server[10947]: "ssh" features in "netopeer-cfgnetopeer" module enabled. netopeer-server[10947]: Datastore netopeer-cfgnetopeer initiated with ID 846930887. netopeer-server[10947]: Setting the default configuration for the cfgnetopeer module... netopeer-server[10947]: Setting the default configuration for the cfgnetopeer module SSH... netopeer-server[10947]: Adding transapi "/usr/local/etc/netopeer/ietf-system/ietf-system.yin" netopeer-server[10947]: "timezone-name" features in "ietf-system" module enabled. netopeer-server[10947]: "authentication" features in "ietf-system" module enabled. netopeer-server[10947]: "local-users" features in "ietf-system" module enabled. netopeer-server[10947]: Datastore ietf-system initiated with ID 1681692778. netopeer-server[10947]: Model "ietf-system" transAPI: nothing changed. netopeer-server[10947]: Starting FMON thread for ietf-system data model. netopeer-server[10947]: Adding transapi "/usr/local/etc/netopeer/turing-machine/turing-machine.yin" netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model turing-machine. netopeer-server[10947]: Datastore turing-machine initiated with ID 1714636916. netopeer-server[10947]: Adding base model "/root/Downloads/netopeer-master/transAPI/toaster/toaster.yin" netopeer-server[10947]: ncds_features_parse: no feature definitions found in data model toaster. netopeer-server[10947]: Datastore toaster initiated with ID 1957747794. netopeer-server[10947]: Netopeer server successfully initialized.

On Wed, Jun 1, 2016 at 2:51 AM, michalvasko notifications@github.com wrote:

Hi, could you please provide the output of netopeer-server when started like netopeer-server -v 2?

Regards, Michal

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CESNET/netopeer/issues/119#issuecomment-222908069, or mute the thread https://github.com/notifications/unsubscribe/ASfz6vEm9FBVEWmJ-qhuBJLPOz76oQ07ks5qHSvbgaJpZM4Iqlc- .

michalvasko commented 8 years ago

Hi, the output seems fine, which leaves me clueless about why it isn't working. Do you use the standard toaster model (does namespace match the one in the RPC and is the RPC itself defined)? Maybe try properly removing netopeer-server with all its configuration files and reinstalling it. I have no better advice, sorry.

Regards, Michal

pradyp11 commented 8 years ago

Hi Mical, I reinstalled the netopeer-server but it is giving the error as below

Request

<?xml version='1.0' encoding='UTF-8'?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="0">
  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <nacm:nacm xmlns:nacm="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
        <nacm:enable-nacm>true</nacm:enable-nacm>
      </nacm:nacm>
    </config>
  </edit-config>
</rpc>

Reply

 ##### Error Reply or Operation Failed #####
<?xml version='1.0' encoding='UTF-8'?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="0">
  <rpc-error>
    <error-type>application</error-type>
    <error-tag>access-denied</error-tag>
    <error-severity>error</error-severity>
    <error-message>creating "nacm" data node is not permitted.</error-message>
  </rpc-error>
</rpc-reply>

This error is occuring for all the attributes i tried to do edit-config. I tried to change the NACM settings given in https://rawgit.com/CESNET/libnetconf/master/doc/doxygen/html/dd/d59/nacm.html but no use, giving the same error.

rkrejci commented 8 years ago

Please follow the First run configuration section in the netopeer server's README. There are instructions about setting NACM. How did you solve this issue in the previous installation?

pradyp11 commented 8 years ago

Hi Mical, thank you. I solved the issue by using the netopeer-configurator settings. Please give me a best procedure to add the transapi module which can solve the error of " there is no device to get affected" . This will solve everything for me. Please help me to solve this.

On Wed, Jun 1, 2016 at 4:42 PM, Radek Krejčí notifications@github.com wrote:

Please follow the First run configuration section in the netopeer server's README https://github.com/CESNET/netopeer/blob/master/server/README. There are instructions about setting NACM. How did you solve the NACM setting in the previous installation?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CESNET/netopeer/issues/119#issuecomment-223118310, or mute the thread https://github.com/notifications/unsubscribe/ASfz6nW9PykqSIu1CDq6aRDJEaGCNYE0ks5qHe60gaJpZM4Iqlc- .

michalvasko commented 8 years ago

Hi, first, I would suggest you install our example turing-machine module. You can find it in netopeer/transAPI/turing directory, you just run ./configure, make, and # make install and it should get properly added to netopeer. Then you can try to execute of the 2 RPCs there, either initialize with some random string or run, which does not have any parameters. Without proper configuration it will not do much, but you should definitely not get the error of "no device to be affected".

Regards, Michal

pradyp11 commented 8 years ago

Thank you Mical. Turing machine is running successfully. I have noticed couple of differences:

1.when i run ./configure, make and make install turing machine is creating its directory structure with datastore.xml, .rng, .xsl files in /usr/local/etc/netopeer/turing but for the models i'm adding it is just adding .xml file to /usr/local/etc/netopeer/modules.conf.d . Using lnctool i'm creating transapi model also.

  1. Makefile.in install code in turing machine is varying from my model Makefile.in.

Does this two things have anything to do with the error i'm getting.

On Thu, Jun 2, 2016 at 2:52 AM, michalvasko notifications@github.com wrote:

Hi, first, I would suggest you install our example turing-machine module. You can find it in netopeer/transAPI/turing directory, you just run ./configure, make, and # make install and it should get properly added to netopeer. Then you can try to execute of the 2 RPCs there, either initialize with some random string or run, which does not have any parameters. Without proper configuration it will not do much, but you should definitely not get the error of "no device to be affected".

Regards, Michal

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/CESNET/netopeer/issues/119#issuecomment-223210231, or mute the thread https://github.com/notifications/unsubscribe/ASfz6vjWKc4skJ_uLj0KvZVDpNMjYJhpks5qHn3FgaJpZM4Iqlc- .

michalvasko commented 8 years ago

Hi,

  1. datastore.xml will be created automatically, .rng and .xsl are validation files, which are not strictly required. So, you only need to add the module configuration XML file into modules.conf.d. Turing module installation uses netopeer-manager for this and I suggest you do the same, it creates the correct XML file for you and adds the module properly. I just noticed that your netopeer-server -v2 output is actually not correct, it says "Adding base model .../toaster.yin", if you look at other modules, it says "Adding (static) transapi .../...". Indeed, your module configuration is wrong and use netopeer-manager to add modules, then it will work as expected.
  2. I think I answered this in 1.

Regards, Michal