nerdexam
Cisco

300-435 · Question #106

Which of the following Netmiko code snippets correctly uses the send_command() method and a valid device_type to retrieve interface IP information?

The correct answer is A. from netmiko import ConnectHandler router = { 'device_type': 'cisco_ios', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.send_command('show ip int brief') print(output). The correct Netmiko code snippet uses ConnectHandler with device_type='cisco_ios' and the send_command() method to retrieve the output of the 'show ip int brief' command.

Network Automation Foundation

Question

Which of the following Netmiko code snippets correctly uses the send_command() method and a valid device_type to retrieve interface IP information?

Exhibit

300-435 question #106 exhibit

Options

  • Afrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.send_command('show ip int brief') print(output)
  • Bfrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.command('show ip int brief') print(output)
  • Cfrom netmiko import ConnectHandler router = { 'device_type': 'ios_xe', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.show_command('show ip int brief') print(output)
  • Dfrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios_xe', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.command('show ip int brief') print(output)

How the community answered

(25 responses)
  • A
    80% (20)
  • B
    4% (1)
  • C
    12% (3)
  • D
    4% (1)

Why each option

The correct Netmiko code snippet uses `ConnectHandler` with `device_type='cisco_ios'` and the `send_command()` method to retrieve the output of the 'show ip int brief' command.

Afrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.send_command('show ip int brief') print(output)Correct

This snippet correctly imports `ConnectHandler`, defines the device dictionary with the valid `device_type='cisco_ios'` (which applies to Cisco IOS XE devices), and uses the `send_command()` method, which is the standard and correct way in Netmiko to send a single command to a network device and capture its output.

Bfrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.command('show ip int brief') print(output)

This snippet incorrectly uses `net_connect.command()`. The correct method for sending a command and receiving output is `send_command()`.

Cfrom netmiko import ConnectHandler router = { 'device_type': 'ios_xe', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.show_command('show ip int brief') print(output)

This snippet incorrectly uses `net_connect.show_command()`. The correct method for sending a command and receiving output is `send_command()`.

Dfrom netmiko import ConnectHandler router = { 'device_type': 'cisco_ios_xe', 'host': '10.0.10.1', 'username': 'johndoe', 'password': 'Cisco!23!' } net_connect = ConnectHandler(**router) output = net_connect.command('show ip int brief') print(output)

This snippet incorrectly uses `net_connect.command()`. The correct method for sending a command and receiving output is `send_command()`.

Concept tested: Netmiko send_command and device_type

Source: https://ktbyers.github.io/netmiko/docs/netmiko/index.html

Topics

#Netmiko#Python scripting#Network automation#CLI commands

Community Discussion

No community discussion yet for this question.

Full 300-435 Practice