cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1758
Views
5
Helpful
6
Replies

NSO - Query via GET Curl

Hi All,

 

I am trying to extract a single variable within a service without success:

 

my curl 

http://10.40.62.20:8080/api/running/services/olt-user-activation/?deep

header Accept application/vnd.yang.collection+json

 

example of reply:

{
  "collection": {
    "olt-user-activation:olt-user-activation": [
      {
        "service-id": "114MColt13",
        "creation-date": "Wed Mar 11 11:10:44 CET 2020",
        "customer": "ING",
        "onu-name": "ONUMultiolt13",
        "olt-name": "RM_00/OLT13",
        "cos-type": "MultiCOS",
        "gpon-slot": 1,
        "gpon-port": 2,
        "onu-number": 5,
        "s-vlan": 112,
        "c-vlan": 60,
        "user-vlan": 835,
        "cos": [
          {
            "cos-class": "0",
            "tcont-profile": "TC_type3_300M_10M",
            "down-traffic-profile": "TP_P100M_C33M"
          },
          {
            "cos-class": "1",
            "tcont-profile": "TC_type3_300M_50M",
            "down-traffic-profile": "TP_P1000M_C67M"
          },
          {
            "cos-class": "5",
            "tcont-profile": "OF_cos05_128K_128K",
            "down-traffic-profile": "TP_P128k_C128k",
            "up-traffic-profile": "TP_P128k_C128k"
          }
        ],
        "operations": {
          "check-sync": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/check-sync",
          "deep-check-sync": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/deep-check-sync",
          "re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/re-deploy",
          "reactive-re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/reactive-re-deploy",
          "touch": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/touch",
          "get-modifications": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/get-modifications",
          "un-deploy": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/un-deploy",
          "self-test": "/api/running/services/olt-user-activation:olt-user-activation/114MColt13/_operations/self-test"
        }
      },
      {
        "service-id": "AAA0052059",
        "creation-date": "Fri Jan 31 17:17:47 CET 2020",
        "customer": "OPT",
        "pop-name": "RM_00",
        "onu-name": "6622851107433438859",
        "olt-name": "RM_00/OLT01",
        "cos-type": "MonoCOS",
        "gpon-slot": 6,
        "gpon-port": 7,
        "onu-number": 2,
        "cos": [
          {
            "cos-class": "0",
            "s-vlan": 647,
            "c-vlan": 6666,
            "user-vlan": 835,
            "tcont-profile": "TC_Type3_300M_20M",
            "down-traffic-profile": "TP_P1000M_C40M"
          },
          {
            "cos-class": "5",
            "s-vlan": 820,
            "c-vlan": 6666,
            "user-vlan": 837,
            "tcont-profile": "TC_Type1_512k",
            "down-traffic-profile": "TP_P512k_C512k",
            "up-traffic-profile": "TP_P512k_C512k"
          }
        ],
        "operations": {
          "check-sync": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/check-sync",
          "deep-check-sync": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/deep-check-sync",
          "re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/re-deploy",
          "reactive-re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/reactive-re-deploy",
          "touch": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/touch",
          "get-modifications": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/get-modifications",
          "un-deploy": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/un-deploy",
          "self-test": "/api/running/services/olt-user-activation:olt-user-activation/AAA0052059/_operations/self-test"
        }
      },
      {
        "service-id": "FIX1",
        "creation-date": "Tue Feb 04 10:39:28 CET 2020",
        "customer": "ING",
        "pop-name": "RM_00",
        "olt-name": "RM_00/OLT01",
        "cos-type": "MonoCOS",
        "gpon-slot": 2,
        "gpon-port": 2,
        "onu-number": 2,
        "onu-type": "ZTE-F601",
        "cos": [
          {
            "cos-class": "0",
            "s-vlan": 2211,
            "c-vlan": 6666,
            "user-vlan": 835,
            "tcont-profile": "TC_type3_100M_10M",
            "down-traffic-profile": "TP_P100M_C10M"
          },
          {
            "cos-class": "5",
            "s-vlan": 2213,
            "c-vlan": 6666,
            "user-vlan": 937,
            "tcont-profile": "TC_type1_512k",
            "down-traffic-profile": "TP_P128k_C128k",
            "up-traffic-profile": "TP_P128k_C128k"
          }
        ],
        "operations": {
          "check-sync": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/check-sync",
          "deep-check-sync": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/deep-check-sync",
          "re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/re-deploy",
          "reactive-re-deploy": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/reactive-re-deploy",
          "touch": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/touch",
          "get-modifications": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/get-modifications",
          "un-deploy": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/un-deploy",
          "self-test": "/api/running/services/olt-user-activation:olt-user-activation/FIX1/_operations/self-test"
        }
      },

 

The request is to extract only a varible for example "customer".

 

Thanks

Matteo

 

1 Accepted Solution

Accepted Solutions

If it is a list that is accessed, the tailf extension for collections is necessary to wrap the list elements in a root element. This functionality is missing from the RFC 8040.

Supply the following arccept header together with the query

Accept: application/vnd.yang.collection+xml

 

View solution in original post

6 Replies 6

lmanor
Cisco Employee
Cisco Employee

Well, to get to the 'customer' tag you'll need to specify the service instance that you want to get that from.

In your example I'm assuming that "service-id = 114Colt13" is the service instance list key. In this case the curl for the get will look something like this to get the customer tag:

http://10.40.62.20:8080/api/running/services/olt-user-activation/114Colt13/customer

 

PSA:  REST interface is deprecated in NSO and will be getting removed, please consider using RESTCONF

 

Note that there are some differences between REST API and RESTCONF:
* Keys are represented a bit differently in URI:s, instead of '/' use '='.
* The module name is required (by default) to prefix first instance in the
datastore when namespace changes.
* RESTCONF uses the unified datastore by default
* RESTCONF queries are "deep" by default, to limit tree depth use the
query parameter "depth".

The corresponding RESTCONF URI would be something like

http://10.40.62.20:8080/restconf/data/tailf-ncs:services/olt-user-activation:olt-user-activation=114Colt13/customer

See the RESTCONF migration guide for further details regarding
differences from REST API.

Thanks for the support, and sorry for the delay of my reply :)

 

I started studying the restconf interface,

when I try to export all the service istances i received this error:

<errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
    <error>
        <error-message>too many instances: 76</error-message>
        <error-tag>invalid-value</error-tag>
        <error-type>application</error-type>
    </error>
</errors>
how can you get the complete list?
thanks

If it is a list that is accessed, the tailf extension for collections is necessary to wrap the list elements in a root element. This functionality is missing from the RFC 8040.

Supply the following arccept header together with the query

Accept: application/vnd.yang.collection+xml

 

Note thate there is no corresponding collectiong header for JSON, since the list elements are always wrapped in a JSON object.

Thanks works correctly!
Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the NSO Developer community: