Python Coding Flashcards
Which Python template can you use to retrieve IOS/Avaya/Arista etc files?
Use the ntc-template, which can be retrieved with GIT
Where is netmiko based on?
Netmiko is based on paramiko
What is netmiko using to connect to the device
SSH
Which function can you use to prompt the user a username/password string?
The getpass python library
How does a Python dictionary looks like for a device in a python script during netlike?
cisco_01 = {
“device_type”: “cisco_ios”,
“host”: “10.10.20.17”,
“username”: “cisco”,
“password”: “cisco123”
}
How do you unpack a dictionary?
With **kwargs
When do you use a dictionary to define nodes in your script?
You create more organised code
How do you access the EXEC privilege
connection.enable() # Enable method
Add: “secret”: “cisco123” # Enable password to node dictonary
How do you access config mode?
connection.config_mode()
What is a for loop?
For loop in Python is used to iterate over a sequence such as a Python list. Loop continues until it reaches the last item on the list.
Which library can be used to secure your login credentials?
getpass
Which Netmiko method can you use to send multiple commands to a network node?
send_config_set
Which features are included in the send_config_set method?
Automatically access global configuration mode. After running the script it automatically exit the global configuration mode
How can you create a list of nodes to connect automatically to all?
This is done with a list of dictionaries
In case of multiple nodes with a dictionary and a list, how does it look like?
The list had the dictionary inside. Like a bag with groceries.
What is textfsm
It allows you to take unstructured data and convert it into structured data. It takes a block of text to lists and dictionaries.
What is needed when you want to configure multiple devices with netmiko?q
You must create an empty list. This is Needed to store data. When this list is not present the script can’t save data. The empty list is a kind of container.
Which commands can be used to check devices type information?
connection =netmiko.ConnectHandler(ip=”10.82.1.200”, device_type=”cisco_ios”, username=”alex”, password=”Test123)
connection
dir(connection)
What does tell the whitespace in python?
What is part of a function and what is not.
Which kind of arguments we can provide a functions
- Positional arguments(arguments that can be called by their position in the function
- Keyword arguments(arguments that can be called by their name
- Default arguments(arguments that are given default value)
With which word starts a function?
Def
There are two different kind of functions, which two?
- Built-in functions
- User Defined functions
What are functions in Python?
Print
Str
Len
Etc. Etc