300-435 exam dumps

300-435 practice question 76 of 322

Automating Cisco Enterprise Solutions. Professional level, Cisco. Free question with the correct answer and a full explanation.

300-435 Question 76

Single answer

You are automating a network device configuration using Python and the ncclient library. The goal is to retrieve the current hostname of a device using NETCONF. Which of the following Python script snippets correctly accomplish this task?

  1. A

    from ncclient import manager with manager.connect(host='10.10.10.1', port=830, username='admin', password='admin', hostkey_verify=False) as m: filter = '' result = m.get(filter=filter) print(result.xml)

  2. B

    from ncclient import manager with manager.connect(host='10.10.10.1', port=830, username='admin', password='admin', hostkey_verify=False) as m: filter = '' result = m.get_config(source='running', filter=('subtree', filter)) print(result.xml)

  3. C

    from ncclient import manager with manager.connect(host='10.10.10.1', port=830, username='admin', password='admin', hostkey_verify=False) as m: query = '' result = m.get(filter=query) print(result)

  4. D

    from ncclient import manager with manager.connect(host='10.10.10.1', port=830, username='admin', password='admin', hostkey_verify=False) as m: filter = '' result = m.get_config(source='running', filter=('subtree', filter)) print(result.xml)

Show answer and explanation

Correct answer: A

Explanation

The correct answer uses the ncclient 'get' method with a proper XML filter '' to retrieve the hostname. The 'get' operation is appropriate for accessing operational data like the hostname, while 'get_config' is used for configuration data, making other options incorrect.

  • A. Correct.

    This is the correct option. It uses ncclient's 'get' method with a valid XML filter to retrieve the 'hostname' from the device using NETCONF, and the result is printed in XML format.

  • B. Incorrect.

    This is incorrect because the XML filter '' is not valid, and the script incorrectly uses 'get_config' instead of 'get' for retrieving the hostname.

  • C. Incorrect.

    This is incorrect because the variable 'query' is passed to the 'get' method, but its XML structure '' is invalid for fetching the hostname.

  • D. Incorrect.

    This is incorrect because while the XML filter used is valid, the script uses 'get_config' instead of 'get', which is unnecessary for retrieving non-configuration data such as the hostname.

Timed practice exam

Take a 300-435 practice test under exam conditions

75 questions in 120 minutes, drawn from this bank, with a score report and a per-question review when you finish.

Start timed exam