cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
690
Views
0
Helpful
8
Replies

deep-check-sync outformat parameter in REST AP

previousqna
Level 5
Level 5

Hi Experts

We want to use REST API to get the result of below cli command

admin@ncs(config)# l3vpn-svc sites site coke-beijing deep-check-sync outformat cli

the l3vpn-svc is a service located under root.

How can I pass the parameter outformat in URL?

I have tried below url, but it gives an error.

http://{{ip}}:{{nso-port}}/api/config/l3vpn-svc/sites/site/pepsi-b/_operations/deep-check-sync?outformat=cli

Thanks.

8 Replies 8

previousqna
Level 5
Level 5

Try this:

http://{{ip}}:{{nso-port}}/api/running/l3vpn-svc/sites/site/coke-beijing/_operations/deep-check-sync?outformat=cli

I tried your url, but still got the error.

POST http://{{ip}}:{{nso-port}}/api/running/l3vpn-svc/sites/site/coke-beijing/_operations/deep-check-sync?outformat=cli

{
  "errors": {
    "error": [
      {
        "error-message": "invalid query parameter: outformat",
        "error-tag": "malformed-message"
      }
    ]
  }
}

The easiest way is to obtain the path by GET.

 

 

For example, I can get the correct path as following:

 

 

$ curl -u admin:admin http://localhost:8080/api/running/services?deep | grep deep

 

    <deep-check-sync>/api/running/services/bgpmgr:bgpmgr/test/_operations/deep-check-sync</deep-check-sync>

 

 

Just copy and paste the path, then it should work.

 

 

$ curl -u admin:admin http://localhost:8080/api/running/services/bgpmgr:bgpmgr/test/_operations/deep-check-sync -X POST <output xmlns='http://example.com/bgpmgr'>

 

<sync-result>

 

<local-node>

 

<in-sync>true</in-sync>

 

</local-node>

 

</sync-result>

 

</output>

I gave him the correct URL for deep-check-sync, but you added a nice piece to explains how to best get this URL

 

I believe what he is failing on is that he also wants to add “?outformat=cli” to the end of the call..

 

I haven’t seen this work from curl…

 

 

 

On NSO…

 

————————————————————-

 

admin@ncs% request services secPythonTempl1 FOOBAR deep-check-sync outformat

 

Possible completions:

 

  boolean - Returns if the service is in sync or not.

 

  cli     - The CLI config that would have to be applied to the device(s) in order for the service to

 

            become in sync with the network.

 

  xml     - The XML (NETCONF format) that would have to be applied to the device(s) in order for the

 

            service to become in sync with the network.

 

admin@ncs% request services secPythonTempl1 FOOBAR deep-check-sync outformat cli

 

cli {

 

    local-node {

 

        data

 

    }

 

}

 

[ok][2017-02-13 09:07:01]

 

 

[edit]

 

admin@ncs%

 

 

 

On Mac…

 

————————————————————-

 

 

Linux$ curl -X POST -u admin:admin http://localhost:8080/api/running/services/service:secPythonTempl1/FOOBAR/_operations/deep-check-sync

 

<output xmlns='http://example.com/service'>

 

  <sync-result>

 

    <local-node>

 

      <in-sync>true</in-sync>

 

    </local-node>

 

  </sync-result>

 

</output>

 

Linux$ curl -X POST -u admin:admin http://localhost:8080/api/running/services/service:secPythonTempl1/FOOBAR/_operations/deep-check-sync?outformat=cli

 

 

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

 

  <error>

 

    <error-tag>malformed-message</error-tag>

 

    <error-message>invalid query parameter: outformat</error-message>

 

  </error>

 

</errors>

 

Linux$

Its an action, and you need to give it in the payload.

 

 

Check $NCS_DIR/src/ncs/yang/tailf-ncs-services.yang

 

 

$curl ... -d '{"input":{"outformat":"cli"}} -H "Content-type: application/vnd.yang.operation+json"

 

$curl ... -d '{"input":{"outformat":"xml"}} -H "Content-type: application/vnd.yang.operation+json"

 

$curl ... -d '{"input":{"outformat":"boolean"}} -H "Content-type: application/vnd.yang.operation+json"

Sorry [NAME] that I missed that point.

 

Your URL was correct and the problem was "?outformat=cli".

 

 

Thanks [NAME] for additional info.

 

I confirmed it works!

 

 

test@debian:~$ curl -u admin:admin http://127.0.0.1:8080/api/running/services/bgpmgr:bgpmgr/test/_operations/deep-check-sync -X POST -H "Content-type:application/vnd.yang.operation+json" -d '{"input":{"outformat":"boolean"}}'

 

{

 

  "bgpmgr:output": {

 

    "sync-result": {

 

      "local-node": {

 

        "in-sync": false

 

      }

 

    }

 

  }

 

}

 

 

 

test@debian:~$ curl -u admin:admin http://127.0.0.1:8080/api/running/services/bgpmgr:bgpmgr/test/_operations/deep-check-sync -X POST -H "Content-type:application/vnd.yang.operation+json" -d '{"input":{"outformat":"cli"}}'

 

{

 

  "bgpmgr:output": {

 

    "cli": {

 

      "local-node": {

 

        "data": " devices {\n     device R1 {\n         config {\n             ios:router {\n                 bgp 65001 {\n+                    neighbor 10.12.0.2 {\n+                        remote-as 65002;\n+                    }\n                     address-family {\n                         ipv4 unicast {\n+                            neighbor 10.12.0.2 {\n+                                activate;\n+                            }\n                         }\n                     }\n                 }\n             }\n         }\n     }\n }\n"

 

      }

 

    }

 

  }

 

}

 

 

 

test@debian:~$ curl -u admin:admin http://127.0.0.1:8080/api/running/services/bgpmgr:bgpmgr/test/_operations/deep-check-sync -X POST -H "Content-type:application/vnd.yang.operation+json" -d '{"input":{"outformat":"xml"}}'

 

{

 

  "bgpmgr:output": {

 

    "result-xml": {

 

      "local-node": {

 

        "data": "<devices xmlns=\"http://tail-f.com/ns/ncs\">\n  <device>\n    <name>R1</name>\n    <config>\n      <router xmlns=\"urn:ios\">\n        <bgp>\n          <as-no>65001</as-no>\n          <neighbor>\n            <id>10.12.0.2</id>\n            <remote-as>65002</remote-as>\n          </neighbor>\n          <address-family>\n            <ipv4>\n              <af>unicast</af>\n              <neighbor>\n                <id>10.12.0.2</id>\n                <activate/>\n              </neighbor>\n            </ipv4>\n          </address-family>\n        </bgp>\n      </router>\n    </config>\n  </device>\n</devices>\n"

 

      }

 

    }

 

  }

 

}

 

test@debian:~$

Great thanks for all of your help. It works now.

brillant! thanks!

 

perfect!

 

He should have what he needs now