Hi ,
I want to use curl command to some operations using (GET,PUT,CREATE,DELETE) to my service but is it possible to do commit dry-run before commit the changes.
At the moment it will directly do the commit to the service but i want to see the commit dry-run results.Appreciate quick action.
As per northbound 4.4.2.1 document,it says
curl -i -u admin:admin http://localhost:8080/api/running/vpn -X POST -H "Content-Type: application/vnd.yang.data+xml" -T volvo-vpn.xml
If the resource is created, the server might respond as follows:
HTTP/1.1 201 Created
Server: NCS/3.4
Location: http://localhost:8080/api/running/vpn/l3vpn/volvo
$ curl -i -u admin:admin
http://localhost:8080/api/running/vpn/l3vpn/volvo/_operations/check-sync -X POST -H "Content-Type: application/vnd.yang.data+xml"
The server might respond as follows:
HTTP/1.1 200 OK
Server: NCS/3.4
Date: Tue, 03 Feb 2015 14:26:16 GMT
Cache-Control: private,
Content-Type: application/vnd.yang.operation+xml
Vary: Accept-Encoding
Pragma: no-cache
<output xmlns='http://com/example/l3vpn'>
<in-sync>true</in-sync>
</output>
Similar ,i want to do the dry-run to my service but i could see only the limited operation
$ curl -i -u admin:admin http://localhost:8080/api/running/vpn/l3vpninfracfs/S2000123R -X GET -H "Content-Type: application/vnd.yang.data+xml"
//Output
<l3vpninfracfs xmlns="http://com/xxx/l3vpninfracfs" xmlns:y="http://tail-f.com/ns/rest" xmlns:l3vpninfracfs="http://com/xxx/l3vpninfracfs" xmlns:Telstra="http://com/telstra/xxxx">
<service-cfs-name>S2000123R</service-cfs-name>
<end-point>
<end-point-name>END_POINT_123</end-point-name>
</end-point>
<end-point>
<end-point-name>END_POINT_211</end-point-name>
</end-point>
<y:operations>
<check-sync>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/check-sync</check-sync>
<deep-check-sync>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/deep-check-sync</deep-check-sync>
<re-deploy>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/re-deploy</re-deploy>
<reactive-re-deploy>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/reactive-re-deploy</reactive-re-deploy>
<touch>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/touch</touch>
<get-modifications>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/get-modifications</get-modifications>
<un-deploy>/api/running/network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs/S2000123R/_operations/un-deploy</un-deploy>
</y:operations>
</l3vpninfracfs>
I dont see commit dry-run operations here.please help
I've edited my post since I incorrectly stated you could'nt use dry-run with REST. Below is an example a colleague provided me:
curl -i -u admin:admin -X POST -T srvcExm1.xml http://127.0.0.1:8080/api/running/services?dryrun=native
Perhaps you can dry the ?dryrun option and let us know if it works for you?
Thanks,
-Dan
No ...It doesn't worked for me ..It says the below error.
{
"errors": {
"error": [
{
"error-message": "invalid query parameter: dry-run",
"error-tag": "malformed-message"
}
]
}
}
However i tried to to get applicable operations in the same path,it gives me the below output,
<services xmlns="http://tail-f.com/ns/ncs" xmlns:y="http://tail-f.com/ns/rest" xmlns:ncs="http://tail-f.com/ns/ncs">
<logging>
<logger>
<name>default</name>
</logger>
</logging>
<y:operations>
<check-sync>/api/running/services/_operations/check-sync</check-sync>
<commit-dry-run>/api/running/services/_operations/commit-dry-run</commit-dry-run>
</y:operations>
</services>
So i have tried with commit-dry-run options but it is throwing someother error,I'm not sure what mistake i have done.
$ curl -i -u admin:admin http://localhost:8080/api/running/services/_operations/commit-dry-run -X POST -T sample.xml -H "Content-Type: application/vnd.yang.data+xml"
{
"errors": {
"error": [
{
"error-message": "0: container l3vpninfracfs not allowed here",
"error-urlpath": "/api/running/services/commit-dry-run",
"error-tag": "malformed-message"
}
]
}
}
Hello Rajarajan,
It looks you have specified option as "?dry-run=native" with hyphen.
The correct option is "?dryrun=native" without hyphen as Dan wrote.
Please double check.
Best regards,
Hiro
Yes,That was my mistake.
It is giving below output,if execute this command
$ curl -i -u admin:admin http://localhost:8080/api/running/services/dryrun=native -X GET -H "Content-Type: application/vnd.yang.data+xml"
<services xmlns="http://tail-f.com/ns/ncs" xmlns:y="http://tail-f.com/ns/rest" xmlns:ncs="http://tail-f.com/ns/ncs">
<logging>
<logger>
<name>default</name>
</logger>
</logging>
<y:operations>
<check-sync>/api/running/services/_operations/check-sync</check-sync>
<commit-dry-run>/api/running/services/_operations/commit-dry-run</commit-dry-run>
</y:operations>
</services>
I'm trying to execute below command but I couldn't locate the myservice with that path,it will say always unknown element from input.
$ curl -i -u admin:admin http://localhost:8080/api/running/services?dryrun=native -X POST -T sample.xml -H "Content-Type: application/vnd.yang.data+xml"
//output
{
"errors": {
"error": [
{
"error-message": "unknown element: /XXXX:network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs in /ncs:services/ncs:/XXXX:network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs",
"error-urlpath": "/api/running/services",
"error-tag": "malformed-message"
}
]
}
}
please see my input below,
{
"/XXXX:network/edge-service/vpn/l3vpninfracfs:l3vpninfracfs": [
{
"service-cfs-name": "S2000936R",
"end-point": [
{
"end-point-name": "END_POINT_001",
"device-name": "s3cw-e-501",
"sub-interfaces": [
{
"interface-id": "5157",
"vlan-id": "3232",
"connected-node-name": "rcbhy9123",
"ipv4-address": "10.32.128.50",
"ipv6-address": "2001:8004:ff00:4000:0:7:e1c1:a8c9",
"connected-node-role": "DCGW",
"bgp-neighbor-attributes": [
{
"neighbor-address": "10.32.128.95",
"remote-as-number": "65377",
"ip-version": "IPv4",
"connected-node-name": "RCBHY70029"
},
{
"neighbor-address": "2001:8004:ff00:4000:0:7:e1c1:a8d3",
"remote-as-number": "65380",
"ip-version": "IPv6",
"connected-node-name": "ombdb65"
}
]
}
],
"enable-multicast-ipv4": "False",
"enable-multicast-ipv6": "True"
}
]
}
]
}
It is throwing error,I couldn't have much exposure on this.Please help,what would be the exact command to execute
Hello Rajarajan,
I suspect the reason of error was because you are posting json body, though the header type is XML.
If you use json, the header have to be "Content-Type: application/vnd.yang.data+json" (ends with +json, not +xml).
Following is an example in my lab.
cisco@debian:~$ cat body.xml
<bgpmgr>
<name>R1R3</name>
<dev1>R1</dev1>
<dev1-loop>1.1.1.1</dev1-loop>
<dev1-as>65001</dev1-as>
<dev1-addr>10.13.0.1</dev1-addr>
<dev2>R3</dev2>
<dev2-loop>3.3.3.3</dev2-loop>
<dev2-as>65003</dev2-as>
<dev2-addr>10.13.0.3</dev2-addr>
</bgpmgr>
cisco@debian:~$ curl -u admin:admin http://127.0.0.1:8080/api/running/services?dryrun=native -T body.xml -X POST -H "Content-Type:application/vnd.yang.data+xml"
<dryrun-result xmlns='http://tail-f.com/ns/rest/dryrun'>
<native>
<device>
<name>R1</name>
<data>
! Generated offline
router bgp 65001
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 10.13.0.3 remote-as 65003
address-family ipv4 unicast
network 1.1.1.1 mask 255.255.255.255
neighbor 10.13.0.3 activate
exit-address-family
!
!
</data>
</device>
<device>
<name>R3</name>
<data>
! Generated offline
router bgp 65003
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 10.13.0.1 remote-as 65001
address-family ipv4 unicast
network 3.3.3.3 mask 255.255.255.255
neighbor 10.13.0.1 activate
exit-address-family
!
!
</data>
</device>
</native>
</dryrun-result>cisco@debian:~$
Hope this helps.
Best regards,
Hiro
Sorry that was typo error in the command,i used json correctly before getting that error.
Even i tried with xml also it does not worked.
<errors xmlns="http://tail-f.com/ns/tailf-rest-error">
<error>
<error-tag>malformed-message</error-tag>
<error-urlpath>/api/running/services</error-urlpath>
<error-message>unknown element: end-point in /ncs:services/l3vpninfracfs:end-point</error-message>
</error>
</errors>
//input
<end-point xmlns="http://com/xxxx/l3vpninfracfs" xmlns:y="http://tail-f.com/ns/rest" xmlns:l3vpninfracfs="http://com/xxxx/l3vpninfracfs" xmlns:Telstra="http://com/xxxx/XXXX">
<end-point-name>END_POINT_547</end-point-name>
<device-name>s3cw-e-502</device-name>
<sub-interfaces>
<interface-id>5004</interface-id>
<vlan-id>794</vlan-id>
<connected-node-name>rcbhy036</connected-node-name>
<ipv4-address>10.128.65.51</ipv4-address>
<ipv6-address>2001:8004:ff00:4000:0:7:e1c1:a5c9</ipv6-address>
<connected-node-role>DCGW</connected-node-role>
<bgp-neighbor-attributes>
<neighbor-address>10.25.64.83</neighbor-address>
<remote-as-number>60247</remote-as-number>
<ip-version>IPv4</ip-version>
<connected-node-name>omdh1</connected-node-name>
</bgp-neighbor-attributes>
<bgp-neighbor-attributes>
<neighbor-address>2001:8004:ff00:4000:0:7:e1c1:a5d5</neighbor-address>
<remote-as-number>63571</remote-as-number>
<ip-version>IPv6</ip-version>
<connected-node-name>rihns35</connected-node-name>
</bgp-neighbor-attributes>
</sub-interfaces>
<enable-multicast-ipv4>False</enable-multicast-ipv4>
<enable-multicast-ipv6>False</enable-multicast-ipv6>
</end-point>
How did you get XML payload?
The easiest way is to commit a service instance once via CLI and copy & paste the output.
Following is an example.
First, commit an instance via CLI and display it in XML as follows.
admin@ncs# show running-config services bgpmgr | display xml
<config xmlns="http://tail-f.com/ns/config/1.0">
<services xmlns="http://tail-f.com/ns/ncs">
<bgpmgr xmlns="http://example.com/bgpmgr">
<name>R1R2</name>
<dev1>R1</dev1>
<dev1-loop>1.1.1.1</dev1-loop>
<dev1-as>65001</dev1-as>
<dev1-addr>10.12.0.1</dev1-addr>
<dev2>R2</dev2>
<dev2-loop>2.2.2.2</dev2-loop>
<dev2-as>65002</dev2-as>
<dev2-addr>10.12.0.2</dev2-addr>
</bgpmgr>
</services>
</config>
admin@ncs#
In this service model, body would be as follows (just copy and paste highlighted lines above).
cisco@debian:~$ cat body.xml
<bgpmgr xmlns="http://example.com/bgpmgr">
<name>R1R2</name>
<dev1>R1</dev1>
<dev1-loop>1.1.1.1</dev1-loop>
<dev1-as>65001</dev1-as>
<dev1-addr>10.12.0.1</dev1-addr>
<dev2>R2</dev2>
<dev2-loop>2.2.2.2</dev2-loop>
<dev2-as>65002</dev2-as>
<dev2-addr>10.12.0.2</dev2-addr>
</bgpmgr>
cisco@debian:~$
Pleas try that with your service model.
Best regards,
Hiro
Yea ,i was wrong in entering service model path.I changed it to the correct path.It is working now.Many thanks
Glad to know it works!