Trying to get a new RPC running. I add this yang:
module testrpc {
namespace “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