Log in to ask questions, share your expertise, or stay connected to content you value. Don’t have a login? Learn how to become a member.
You can accomplish this by following these extra steps:
Next, you'll need to upload the XML data file to the Junos Space server. Unfortunately, you cannot do this by the usual method to import scripts into Space through the GUI. So you’ll have to copy the file manually.
When you import scripts into Junos Space, they are all stored locally on the servers in the following directory:
Place your data file here as well, using SCP to transfer the file. If you prefer using SFTP, then make sure that you just specify the above directory. Be sure to use the admin user account to authenticate:
Now that the data file resides on the server, let’s work on how you are going to use that information in your local/commit script.
First, let’s reference your external data file in your script. This is done by using the document function within SLAX:
I recommend storing this information in a variable so you can easily search against it. You will do this later on.
For your local/commit script to identify how each device gets the correct configuration, you’ll need a key to match against. Use the device’s host-name since it typically will be different for each device.
NOTE: You can pick other parameters to match against, but I recommend using the host-name since typically each device will be unique.
The above lines grab the host-name from the current device’s configuration, and store it in a variable that we reference against.
Now you can grab the information in your XML file and build the configuration that you want to deploy:
Check $info/data/device[name = $host-name] to see if your current device host-name matches up with the name you identified in your data file. If it does, then it pulls the relevant configuration. If not, then we run the script.
Now that your script is built and ready to go, you need to execute it against your devices. You can do using either of these methods:
(I prefer the latter, but it’s all personal preference.)
Here is the fully completed script for your reference: