03-28-2022 01:02 AM
Hi All,
Let's say that i have to rely on an external inventory to fullfill some variable values in a service template.
How would you proceed to allow your service package to import those values from an external database like Netbox acting as a SOT for example ?
In the example below i would like to fetch the value of the variable "cpe-ip-address" from Netbox.
<device> <name>{/device-cpe}</name> <config> <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"> <interfaces> <interface> <name>{/interfaces/cpe-iface-id}</name> <flexible-vlan-tagging/> <?foreach {/vlans}?> <unit> <name>{cvlan-id}</name> <description>{/interfaces/cpe-unit-desc}</description> <vlan-id>{cvlan-id}</vlan-id> <family> <inet> <address> <name>{ipv4-address/cpe-ip-address}</name> </address> </inet> </family> </unit> <?end?> </interface> </interfaces> </configuration> </config> </device>
Thanks in advance
Jerems
Solved! Go to Solution.
03-28-2022 03:09 AM
Hey,
I would suggest looking up ReactiveFASTMAP concept in developer guide.I wouldn't be surprised if there is an actual example in examples.ncs for this too (NSO install dir).
Basically your service package python code needs to:
-Figure out that the IP is missing
-Fetch IP via some sort of API (probably rest?)
-Store received IP in a config false yang node for persistency
-Redeploy the service (you will need a subscriber monitoring the above yang node)
-Release mechanism so that NSO releases IP on Netbox once service is deleted (you can pair this mechanism with the subscriber as well)
Flow would be like this:
Commit-> Python detects missing IP -> Calls code for fetching IP from IPAM and exiting create method -> Code fetches IP and places it in NSO -> Subscriber code figures that out and redeploys the service
On service delete:
Subscriber detects service being deleted and runs the IPAM IP release code
Something like that.
03-28-2022 03:09 AM
Hey,
I would suggest looking up ReactiveFASTMAP concept in developer guide.I wouldn't be surprised if there is an actual example in examples.ncs for this too (NSO install dir).
Basically your service package python code needs to:
-Figure out that the IP is missing
-Fetch IP via some sort of API (probably rest?)
-Store received IP in a config false yang node for persistency
-Redeploy the service (you will need a subscriber monitoring the above yang node)
-Release mechanism so that NSO releases IP on Netbox once service is deleted (you can pair this mechanism with the subscriber as well)
Flow would be like this:
Commit-> Python detects missing IP -> Calls code for fetching IP from IPAM and exiting create method -> Code fetches IP and places it in NSO -> Subscriber code figures that out and redeploys the service
On service delete:
Subscriber detects service being deleted and runs the IPAM IP release code
Something like that.
03-28-2022 04:00 AM - edited 03-28-2022 04:00 AM
Thanks a lot @u.avsec
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