# Defining a new NETCONF RPC

**URL:** <https://dmap-community.ductus.global/t/defining-a-new-netconf-rpc/1499>\
**Category:** NETCONF\
**Created:** [August 29, 2017, 1:23pm UTC](https://dmap-community.ductus.global/t/defining-a-new-netconf-rpc/1499 "2017-08-29T13:23:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/erik/32/181_2.png) [@Erik](https://dmap-community.ductus.global/u/Erik)\
**Post date:** [August 29, 2017, 1:23pm UTC](https://dmap-community.ductus.global/t/defining-a-new-netconf-rpc/1499/1 "2017-08-29T13:23:59Z")

</div>

Trying to get a new RPC running. I add this yang:  
module testrpc {  
namespace “[http://example.com/ns/yang/testrpc](http://example.com/ns/yang/testrpc)”;  
prefix testrpc;

```
  import ietf-inet-types {
    prefix inet;
  }

  import tailf-common {
    prefix tailf;
  }

  organization "Test";

  contact "Test@example.com";

  rpc testrpc {
    tailf:exec "/bin/uname";
    output {
      leaf res {
        type string;
      }
    }
  }
}

```

I compile with `source confd/confdrc; confdc -c testrpc.yang` and copy the fxs into the load path of my confd instance.

I add `<capability>http://example.com/ns/yang/testrpc</capability>` to /confdConfig/netconf/capabilities` and restart confd.

Now I issue `netconf-console --proto=tcp --port=2022 --host=192.168.1.12 -u myuser -p mypassword testrpc.xml` where testrpc.xml is:

```
<?xml version="1.0" encoding="UTF-8"?>
<hello xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <capabilities>
    <capability>urn:ietf:params:netconf:base:1.0</capability>
  </capabilities>
</hello>
]]>]]>
<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <testrpc xmlns="http://example.com/ns/yang/testrpc"/>
</rpc>
]]>]]>
<?xml version="1.0" encoding="UTF-8"?>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <close-session/>
</rpc>
]]>]]>

```

My response in netconf-console is:

```
<?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-path xmlns:testrpc="http://example.com/ns/yang/testrpc" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    /nc:rpc/testrpc:testrpc
  </error-path>
    <error-message xml:lang="en">application protocol error</error-message>
    <error-info>
      <bad-element>testrpc</bad-element>
    </error-info>
  </rpc-error>
</rpc-reply>

```

The logs from the confd instance show:  
`confd Bad result from external command "/bin/uname": "Linux\n"`

Can someone help me out? Is there a requirement on how the output should be formatted to be accepted as an RPC reply, or am I missing something else? The example was chosen to have a short succinct reply string to test creating RPCs that run serverside commands.

TIA&BR /Erik

---

<div class="post-metadata">

**Author:** ![per](https://avatars.discourse-cdn.com/v4/letter/p/9f8e36/32.png) [@per](https://dmap-community.ductus.global/u/per)\
**Post date:** [August 29, 2017, 2:37pm UTC](https://dmap-community.ductus.global/t/defining-a-new-netconf-rpc/1499/2 "2017-08-29T14:37:59Z")

</div>

> [@Erik](#):
>
> Is there a requirement on how the output should be formatted to be accepted as an RPC reply,

Yes, see the section “11.3. Action as an Executable” in the UG. The output should be “tag-value” pairs just like the input. If you change “/bin/uname” to the path of a script that does

```
echo res `/bin/uname`

```

(where ‘res’ is of course the name you have defined for the output parameter) it should work.

---

<div class="post-metadata">

**Author:** ![Erik](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/erik/32/181_2.png) [@Erik](https://dmap-community.ductus.global/u/Erik)\
**Post date:** [August 30, 2017, 6:13am UTC](https://dmap-community.ductus.global/t/defining-a-new-netconf-rpc/1499/3 "2017-08-30T06:13:15Z")

</div>

That was exactly it. I was stuck in 15.5 where I didn’t get that detail. Thank you.
