200-901 Question 58
Single answerYou are tasked with automating the creation of a VLAN on a Cisco switch using the Cisco pyATS SDK. The SDK documentation states that the 'config' method is used to send configuration commands to a network device. Below is a snippet of the script that you need to complete:
from genie.conf import Genie
testbed = Genie.init('testbed.yaml')
device = testbed.devices['switch1']
device.connect()
# Add your code here to create VLAN 100 with the name 'Test_VLAN'
Which of the following Python code snippets will correctly create VLAN 100 with the name 'Test_VLAN' as per the SDK documentation?
- A
device.config(['vlan 100', 'name Test_VLAN'])
- B
device.configure('vlan 100 name Test_VLAN')
- C
device.config('vlan 100\nname Test_VLAN')
- D
device.execute(['vlan 100', 'name Test_VLAN'])
Show answer and explanation
Correct answer: A
Explanation
To configure a device using the Cisco pyATS SDK, the 'config' method is used, which accepts a list of configuration commands. In this case, the correct syntax is to pass a list with 'vlan 100' and 'name Test_VLAN' as separate items. The other options either use incorrect methods or incorrect argument formats.
- A. Correct.
Correct. The 'config' method accepts a list of configuration commands, and this syntax is consistent with the pyATS SDK documentation.
- B. Incorrect.
Incorrect. The 'configure' method is not part of the pyATS SDK; instead, the 'config' method is used for device configuration.
- C. Incorrect.
Incorrect. The 'config' method requires a list of commands, not a single string with line breaks.
- D. Incorrect.
Incorrect. The 'execute' method is used for sending operational commands, not configuration commands.