Python Coding Flashcards

1
Q

Which Python template can you use to retrieve IOS/Avaya/Arista etc files?

A

Use the ntc-template, which can be retrieved with GIT

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Where is netmiko based on?

A

Netmiko is based on paramiko

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is netmiko using to connect to the device

A

SSH

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which function can you use to prompt the user a username/password string?

A

The getpass python library

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How does a Python dictionary looks like for a device in a python script during netlike?

A

cisco_01 = {
“device_type”: “cisco_ios”,
“host”: “10.10.20.17”,
“username”: “cisco”,
“password”: “cisco123”
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you unpack a dictionary?

A

With **kwargs

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When do you use a dictionary to define nodes in your script?

A

You create more organised code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you access the EXEC privilege

A

connection.enable() # Enable method

Add: “secret”: “cisco123” # Enable password to node dictonary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you access config mode?

A

connection.config_mode()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a for loop?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which library can be used to secure your login credentials?

A

getpass

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which Netmiko method can you use to send multiple commands to a network node?

A

send_config_set

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which features are included in the send_config_set method?

A

Automatically access global configuration mode. After running the script it automatically exit the global configuration mode

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can you create a list of nodes to connect automatically to all?

A

This is done with a list of dictionaries

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

In case of multiple nodes with a dictionary and a list, how does it look like?

A

The list had the dictionary inside. Like a bag with groceries.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is textfsm

A

It allows you to take unstructured data and convert it into structured data. It takes a block of text to lists and dictionaries.

17
Q

What is needed when you want to configure multiple devices with netmiko?q

A

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.

18
Q

Which commands can be used to check devices type information?

A

connection =netmiko.ConnectHandler(ip=”10.82.1.200”, device_type=”cisco_ios”, username=”alex”, password=”Test123)
connection

dir(connection)

19
Q

What does tell the whitespace in python?

A

What is part of a function and what is not.

20
Q

Which kind of arguments we can provide a functions

A
  1. Positional arguments(arguments that can be called by their position in the function
  2. Keyword arguments(arguments that can be called by their name
  3. Default arguments(arguments that are given default value)
21
Q

With which word starts a function?

A

Def

22
Q

There are two different kind of functions, which two?

A
  1. Built-in functions
  2. User Defined functions
23
Q

What are functions in Python?

A

Print
Str
Len

Etc. Etc