10-05-2022 07:08 PM
I have a very simple template to provide a dayZero configuration to a router.
It works via ncs_cli as : dayZero <name> hostName <newhostname> userName <newUserName> secret <NewSecret>
Using Postman, I'm POSTing to http://{{NSO_IP}}:{{NSO_HTTP_PORT}}/restconf/data/tailf-ncs:devices/device=<device>/apply-template
I'm attempting to send this payload with the POST request but it's failing.
I'm sure it's not correct, but I'm unable to figure out how to organize the variables in the XML syntax correctly.
Can anyone please point me in the right direction?
10-06-2022 06:51 AM
Ok - Making some progress based on some feedback.
The URL I'm targeting is now: http://{{NSO_IP}}:{{NSO_HTTP_PORT}}/restconf/data/tailf-ncs:services
My payload is now:
10-07-2022 12:30 AM
Try something like:
http://localhost:8080/restconf/data/tailf-ncs:services/dayZero:dayZero
{
"dayZero": [
{
"device": "dev-csr",
...
}
]
}
Tip: In the more recent NSO versions, there are lots of RESTCONF examples under examples.ncs/development-guide. Run the *-rc examples (make showcase-rc or demo-rc etc.) that use Python requests to run the RESTCONF variant and print what is sent and received in JSON format.
10-07-2022 12:45 AM - edited 10-07-2022 12:50 AM
Hello
Regarding the original question :
To apply a device template this should be the Body
URL
{{PROTOCOL}}://{{NSO_IP}}:{{NSO_HTTP_PORT}}/restconf/data/tailf-ncs:devices/device={{IOS_XR_DEVICE}}/apply-template/
BODY ( add the remaining variables )
<input>
<template-name>dayZero</template-name>
<variable>
<name>HOSTNAME</name>
<value>'Changeme'</value>
</variable>
<variable>
<name>USERNAME</name>
<value>'JoeBob'</value>
</variable>
...
</input>
ncs-make-package --service-skeleton template dayZero
then you need to do a "packages reload" , edit the YANG model creating the variables ( hostname, username, secret , ... ) and edit the XML with the equivalent device config mapping the YANG variables.
10-07-2022 11:39 AM - edited 10-07-2022 11:47 AM
https://gitlab.com/nso-developer/rest-api-explorer should build the POST url and body (in JSON or XML) automatically, by clicking the parameters to be included.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide