200-901 Question 167
Single answerYou are reviewing a YANG model for a network device and encounter the following snippet:
module example-interface {
namespace "http://example.com/interfaces";
prefix intf;
container interfaces {
list interface {
key "name";
leaf name {
type string;
}
leaf enabled {
type boolean;
}
}
}
}
What does the key statement in the interface list represent?
- A
The primary attribute used to uniquely identify each entry in the list
- B
The namespace used to reference the module's elements
- C
The parent container that groups all interfaces together
- D
A mandatory leaf that specifies the operational status of the interface
Show answer and explanation
Correct answer: A
Explanation
In YANG models, the key statement within a list specifies the unique identifier for each list entry. In this case, the name leaf is used as the key, meaning each interface in the interface list must have a unique name. This ensures that the list can be properly indexed and managed.
- A. Correct.
Correct. The
keystatement specifies the primary attribute (name) that uniquely identifies each entry in theinterfacelist. - B. Incorrect.
Incorrect. The namespace is defined by the
namespacestatement at the module level, not thekeystatement. - C. Incorrect.
Incorrect. The parent container is defined as
interfaces, but this is unrelated to thekeystatement. - D. Incorrect.
Incorrect. The
enabledleaf represents the operational status of the interface, but it is not related to thekeystatement.