Configuring Multiple Junos Devices Using Junos PyEZ and Templates

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is James Sandra gir here at juniper Networks education services are you familiar with our learning paths we offer 14 different paths covering the Junos OS and specific juniper technologies each path shows the courses we offer in the relevant certifications in the order we suggest to maximize your learning just visit Deb W juniper dotnet slash learning paths to get started when you click on a track you'll see all the courses in that track and the associated certifications you can click each course or certification to view more details if you follow a learning path you'll get the most from your training with juniper Networks now let's get to your learning pipe welcome to Juniper Networks education services learning bite my name is Mario Fiona's and I'm a lab rocket act with education services within Juniper Networks in this lining bite we'll be talking about configuring multiple general devices using Juno's pi is easy and templates after successfully completing this learning bite you'll be able to configure multiple general devices using the journals PI easy network and configuration templates before you begin you should have basic understanding of Python if you are new to the Python world you should check out the Python our website it's very helpful and a lot of documentation available there that will get you started next you should review the Junos pi is the documentation available on the Juniper Networks tech wiki site ok there are some examples for different functionality of Juno's PI easy so that is very helpful lastly you need to have journals PI easy install on the system while running your scripts ok let's go to the demonstration of the config deployment process okay so for this learning bite I basically consider the scenario that you may find common in many places let's say we have a you know CSV file which is called devices dot CSV that that we'll be using for the deployment so on the CSV file you'll see there are three host definitions and what our goal is basically to configure these three firewalls you know with different configurations okay so we'll be configuring the trust interface the trust IP admin user domain and the DNS and the hostname okay then the last one the management IP we'll be using for our script so the script will be using these IP address to access device through the management network okay and we also have a config template that we'll be using so let me show you that first so this is just a basic config template little beading so we're going to be using you know this template and journals pi is uses the python ginger to I believe so ginger to Python templating you know style so in this style you know when you have your config file you can put you know double curly braces like this and then put a variable instead that that you'll be dynamically changing through different devices you know so your configuration may be same but the values may be different right in this case okay so that that's what the beauty of this templating mechanism okay so as you see here will be you know configuring the hostname the domain the DNS and we're going to be adding a user and then n configure NTP and then defining an interface with the IP address and then we're going to be assigning that interface under the trust zone for this demonstration I'm using Jono's Firefly parameter VMs but he can use similar concept with other generous devices as well okay so let's get started so let me go to the script okay so we're gonna let me clear the screen first so I created a script already and going to go to the script so this script starts with the main function like many Python scripts as you know so it basically going to take the CSV file path then it's going to ask for the Figg template pad and then user name of the device and the password of the devices and then it will process the csv file using this import CSV function which basically extract the information from the csv file and then and then return a list containing those extracted information and then we'll be you know looping through that csv information list and then assigning to a dictionary python dictionary with the key value pairs okay so as you see here you know we are passing you know yeah we're assigning hostname trust interprets and trust IP admin user domain ntp and dns and management IP management IP is only be gonna be used for our skip to basically access the device it's not going to be pass to the configuration load functionality which will be discussing pretty soon and so once we have all those information stored we're going to be calling the deploy config function which i created will be doing the actual work of config deployment committing and then that takes in a dictionary object which out variable you can call it up t of the of this information so this variable will be passing so that we have all this information and then using password in the config template file so in this case our config template file is same right so we have a single template file and all we will be doing is basically changing the variables on the template file so that you know for different devices we you know assign different values okay so let me go to the import CSV file first import CSV function just to take a quick glance and then I'm going to be showing you the deploy config function okay so let me go up a little bit so the the import CSV basically as you see here it uses the CSV library that we import it and then it processed that information it's very simple and then it basically returns the here okay so it's importing and then you know signed the list of all the valleys yeah you know extracted from CSV file and then the deploy config one basically what is doing is basically it's a opening crew initiating a connection with the device through net carve through the open function which is basically device object so we imported this library here this class and we import the device that we're using to initiate the connection of the with the device okay and then once we have that connection initiated with the dev open and we basically set a timeout value of three minutes that you know the divide the RPC connection doesn't timeout you can change that to different timeout settings depending on in use if you're doing a Juno's upgrade you probably want to set it your higher value on your script and then once we have the device open connection is done and time on is done we are basically using the config widget we basically came from here like this you know we imported the config in a widget and then we are passing the device object and then so that we can use it for configuration load okay so that's part of the Cu variable and then that Cu variable is basically as loading the configuration using this load functionality load function that is available on the config class I'll show you how to see the health help of that load function that will give you some more information that can be handy to understand more how and what are the different way you can load can fix with Juno's PI Z so in this case since you're doing template based deployment we need to pass a template path variable which contains the template file path and then the variable template under scrollbars dictionary object which basically going to contain a basic additional variable okay so we're passing those and then that basically goes to the device and then loads the config it is case by default it does a the load function does it load replace according to the documentation so but he can you can have you know different way of loading config an do you know a static configuration file or you can do set set config or XML depending on a need but if you check the help of the log function you'll know more on that on that piece okay then once you're done we're gonna we're going to be running a diff so that we can you know see what we're changing with the load and that is being done by this this line here Cu dot a PD basically you're calling the PD function and then we do a commit check so that we ensure that what we are trying to commit you know it means the requirement there is no error or anything commit check is also a function of the the config widget right so if it's successful it will return true and that's when we're going inside of this function this segment here and where we'll be committing the config using this C you commit this line here and that's committing the config right and then finally we're closing the connection so that we don't have any RPG connection open okay so let me show you the device load documentation little bit and see how we can find out about the documentation of the load function of the config so I'm going to go to Python and then I'm going to do from J NPR Juno's new cheales config import could be okay and then I'm going to do help on config dot load so then I can see all the you know functionality that this function provides so we are using this one the template path it gives us information what it does and as you see here its uses ginger to format I know double curly braces you know thing that you saw that's why ginger - is all about most of it actually and then we're using this one as a parameter and which is as you see is a dictionary type so it's little more information and then you can also see you know config PDF right it gives information but what it does similarly you can do commit check ok you can see some information about commit check functionality it returns true and finally you can do a help on the committee ok you can see some information what it does the commit function this is too successful ok so let's go back I'm just gonna run the script down just to show you how it looks like so that's actually before I before I run the screen I'm going to show you one device what we have there so I'm gonna less attached to one of the devices that we're going to be using so let's login to town or our one device possible one device and I want to show you what we have there ok so I'm going to do a short configuration so as you see here the device doesn't have the host name and the user account is not there that we're trying to add an NTP is not configured G 0 0 1 is not configured right ok so I'm gonna get out and run the script ok so so the first thing we ask this script asking CSV file path so I can give in in a path exact path of the CSV file that we will be using the which I showed at the beginning so it will be scripts or a king I think it's called devices on CSV and then it asks for a template file the config template that I showed which is based calm okay and they user name/password okay and then it's going to start doing this thing okay so now it's going to log into each of these devices and then config as this here this is the first device you know it's a it's adding this configuration it's going to load the config and and then then duck I think the load is successful and then it's performing the idea and scroll down a little bit here so that's the first device see there in the log here it shows the device high P and then it goes to the second device and the hostname is set to the FW 2 and the user account is added same things happening so as you see here the first case it chain it's set the hostname is fw 1 or the second device it said the host name is fw 2 and same thing with the IP addresses and the domain name right so they're different in all of these devices so i can just use one config template and and and deploy them on multiple devices with different variables right so that's the beauty of this you know spy easy template based config deployment so now let me go to one of those devices let me see if I can use that account that I had and log in as that user okay so I'm gonna see NOC admin ok okay okay I'm logged in so that user account is added if I do show configuration I can see all this information added so that's the beauty of Juno spy easy and template based config deployed and you can save a lot of time for you think about a situation what you have to deploy you know you no more than three devices like you know 20 30 devices site together and and then let's say say you have an automated system that does the in a CSV generation it generates CSV file based on the user request and then you basically deploy them automatically with the scripts so you can achieve all that with Janus PI easy if you like thanks for watching I hope this video was successful visit the Juniper education services website to learn more about courses if you are full range of classroom online and e-learning courses learning paths industry segments and technology specific training paths Juniper Networks certification program the ultimate demonstration of your competence and the training community from forums to social media join the discussion
Info
Channel: JuniperNetworks
Views: 9,374
Rating: 4.7692308 out of 5
Keywords: Junos, PyEZ, pythonEZ, configuration, deployment
Id: Gk5KKozJmz8
Channel Id: undefined
Length: 17min 8sec (1028 seconds)
Published: Tue Feb 24 2015
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.