Courseiva
hardMultiple ChoiceObjective-mapped

350-401 Practice Question: Uses the following Python code to subscribe to…

A network engineer uses the following Python code to subscribe to telemetry data from a Cisco IOS-XE device via NETCONF using the YANG module 'Cisco-IOS-XE-mdt-oper':

```python

from ncclient import manager

m = manager.connect( host='192.168.1.1', port=830,

username='admin',

password='cisco', hostkey_verify=False )

# Create a telemetry subscription

subscription = ''' <config> <mdt-config-data xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-mdt-cfg"> <mdt-subscription> <subscription-id>400</subscription-id> <base> <stream>yang-push</stream> <encoding>encode-kvgpb</encoding> <period>5000</period> <xpath>/interfaces/interface/state/counters</xpath> </base> <mdt-receivers> <address>10.1.1.100</address> <port>50051</port> <protocol>grpc-tcp</protocol> </mdt-receivers> </mdt-subscription> </mdt-config-data> </config> '''

reply = m.edit_config(target='running', config=subscription)

print(reply.xml)

m.close_session() ```

What is the issue with this code?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

The code uses target='running' which may not be writable; it should use target='candidate' and then commit.

The NETCONF edit-config operation with target='running' is used to directly modify the running configuration. However, on many Cisco IOS-XE devices, the running configuration is not directly writable via NETCONF; you must use target='candidate' and then commit. Additionally, the XML namespace for mdt-config-data may be incorrect; the correct namespace is 'http://cisco.com/ns/yang/Cisco-IOS-XE-mdt-cfg' but the module name is 'Cisco-IOS-XE-mdt-cfg'. However, the primary issue is that the code uses target='running' instead of target='candidate' and a separate commit operation.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • The code uses target='running' which may not be writable; it should use target='candidate' and then commit.

    Why this is correct

    IOS-XE NETCONF typically requires candidate configuration and commit.

  • The XML namespace is incorrect; it should be 'http://cisco.com/ns/yang/Cisco-IOS-XE-mdt-oper'.

    Why it's wrong here

    The namespace is for configuration, not operational data.

  • The xpath is invalid; it should be '/interfaces/interface/state/counters'.

    Why it's wrong here

    The xpath is correct for OpenConfig counters.

  • The subscription-id should be a string, not an integer.

    Why it's wrong here

    The YANG model defines subscription-id as an integer.

About these practice questions

Courseiva writes every 350-401 question from scratch — 1,175 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 350-401 practice question is part of Courseiva's free Cisco certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 350-401 exam.