Using Restconf using Confd6.3.1

Hi,

I am using Confd6.3.1 and trying to use restconf on it.
For this i have enabled the restconf in the confd.conf and i am able to fire the below query to identify the root:-

[viprasad@in-mvlb49 ConfdLogs]$ curl -i -u secadmin:Infinera#2 http://10.220.74.53:8008/.well-known/host-meta -H "Accept: application/yang-data+json" -X GET
HTTP/1.1 200 OK
Server: 
Date: Wed, 15 Mar 2017 09:56:00 GMT
Content-Length: 107
Content-Type: application/xrd+xml
Vary: Accept-Encoding

<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
    <Link rel='restconf' href='/restconf'/>
</XRD>
[viprasad@in-mvlb49 ConfdLogs]$ 

After this when i fire the below query,it displays only the statictics info .But not the capabilities,schema info ,etc:-

[viprasad@in-mvlb49 ConfdLogs]$ curl -i -u secadmin:Infinera#2 http://10.220.74.53:8008/restconf/data -H "Accept: application/yang-data+json" -X GET
HTTP/1.1 200 OK
Server: 
Date: Wed, 15 Mar 2017 09:56:33 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Content-Type: application/yang-data+json
Transfer-Encoding: chunked
Pragma: no-cache

{
  "ietf-netconf-monitoring:netconf-state": {
    "statistics": {
      "in-bad-hellos": 0,
      "in-sessions": 0,
      "dropped-sessions": 0,
      "in-rpcs": 0,
      "in-bad-rpcs": 0,
      "out-rpc-errors": 0,
      "out-notifications": 0
    }
  }
}

Can anyone please help me what i might be missing here …

Thanks,
Vivek Prasad

Hi Vivek,

Does your user have access rights to view the data?

Example for reference (admin user - see aaa_init.xml):

$ pwd
/home/tailf/confd-6.3.1/examples.confd/rest/router
$ diff ./confd.conf /home/tailf/confd-6.3.1/examples.confd/rest/router/confd.conf
266,272d265
<  <restconf>
<     <enabled>true</enabled>
<     <!--
<         The RESTCONF root resource is the first part of the RESTCONF API path.
<     -->
<     <rootResource>restconf</rootResource>
<   </restconf>
$ curl -i -u admin:admin http://127.0.0.1:8008/restconf/data/restconf-state -H "Accept: application/yang-data+json" -X GET
HTTP/1.1 200 OK
Server: 
Date: Wed, 15 Mar 2017 18:29:32 GMT
Last-Modified: Fri, 01 Jan 1971 00:00:00 GMT
Cache-Control: private, no-cache, must-revalidate, proxy-revalidate
Etag: 1489-602043-233942
Content-Type: application/yang-data+json
Transfer-Encoding: chunked
Pragma: no-cache

{
  "ietf-restconf-monitoring:restconf-state": {
    "capabilities": {
      "capability": ["urn:ietf:params:restconf:capability:defaults:1.0?basic-mode=explicit", "urn:ietf:params:restconf:capability:depth:1.0", "urn:ietf:params:restconf:capability:fields:1.0", "urn:ietf:params:restconf:capability:with-defaults:1.0", "http://tail-f.com/ns/restconf/collection/1.0", "http://tail-f.com/ns/restconf/query-api/1.0"]
    }
  }
}

Hi,
Got the issue .
Actually there is a defect in Confd6.3.1 if we use candidate database along with running datastore writable which was the case of mine.
I disabled the candidate database .Now its running fine.
Thanks,
Vivek Prasad

Hi,
How to retrieve keyless list element via restconf

 container routes {
            description
              "Current content of the RIB.";
            list route {
              description
                "A RIB route entry. This data node MUST be augmented
                 with information specific for routes of each address
                 family.";
              leaf route-preference {
                type route-preference;
                description
                  "This route attribute, also known as administrative
                   distance, allows for selecting the preferred route
                   among routes with the same destination prefix. A
                   smaller value means a more preferred route.";
              }
              container next-hop {
                description
                  "Route's next-hop attribute.";
                uses next-hop-state-content;
              }
              uses route-metadata;
            }

Tried with below and it produces output below

http://167.254.216.30:33002/restconf/data/ietf-routing:routing-state/routing-instance=default/ribs/rib="ipv4"/routes

<routes xmlns="urn:ietf:params:xml:ns:yang:ietf-routing"  xmlns:rt="urn:ietf:params:xml:ns:yang:ietf-routing">
    <route>
        <route-preference>0</route-preference>
        <next-hop>
            <next-hop-address xmlns="urn:fujitsu:params:xml:ns:yang:ietf-ipv4-unicast-routing-ext">0.0.0.0</next-hop-address>
            <outgoing-interface xmlns="urn:fujitsu:params:xml:ns:yang:ietf-routing-ext">ip-1/0/0/E-SC-E1</outgoing-interface>
        </next-hop>
        <source-protocol>direct</source-protocol>
        <active/>
        <last-updated>2021-11-16T12:06:58-06:00</last-updated>
        <destination-prefix xmlns="urn:ietf:params:xml:ns:yang:ietf-ipv4-unicast-routing">6.6.6.6/32</destination-prefix>
    </route>
</route>
</routes>

wanted to retrieve route[1]… and couldn’t succeed with below format

http://167.254.216.30:33002/restconf/data/ietf-routing:routing-state/routing-instance=default/ribs/rib="ipv4"/routes/route="1"

can someone help?

I don’t know if this works with 6.3 that was released 5 years ago, but with ConfD 7.6 you can use the “limit” and “offset” query parameters.
Example on how to get the second list-entry in a list:

Header: application/vnd.yang.collection+xml
Path: http://localhost:8008/restconf/data/ietf-routing:routing-state/routing-instance=default/ribs/rib="ipv4"/routes/route?offset=2&limit=1

Hi Cohult
Your suggestion worked. How to retreive the specific element which comes under that list entries?

for ex: i wanted to retrieve route-preference of all the list entries.

Just use the RESTCONF standard “fields” parameter. Example:

http://localhost:8008/restconf/data/datamodel:routes/route?offset=0&limit=1&fields=route-preference

More “fields” parameter examples in the RESTCONF RFC RFC 8040 - RESTCONF Protocol