I came across issue reported by one of CLN users. The issue was about sending XML payload using NETCONF to create Loopback interface.
XML Payload was correct - I confirmed that with YANG Suite, but the following error was returned from device:
`’YANG framework’ detected the ’fatal’ condition ’Operation failed’`
Unfortunately this is NOT descriptive message so I had to dig down what happened.
I went through a few bugs reported on a Bug Tracking Tool that contained that error, but no success.
When I went back to the author’s code, one thing took my attention:
```Python
with connect_ios_xr(ios_xr_device) as m:
# Send NETCONF <edit-config>
netconf_reply = m.edit_config(netconf_payload, target="running")
print(netconf_reply)
```
If we look closer - you’ll see that we tried to push configuration to „running” datastore, which is not possible on IOS-XR-based devices.
Every configuration you enter to device is placed into candidate configuration store first, so you have a comfort to compare it with a running configuration and apply it once you are ready. That way you can minimize a risk of cutting off yourself from device and cause a huge outage. Once you are ready - you need to commit this, so new configuration lands to running configuration store.
This is something I had to reproduce.
In a YANG Suite I changed target to `candidate` datastore and generated a payload with couple of random values like description, etc. Here’s the result:
```XML
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="101">
<edit-config>
<target>
<candidate/>
</target>
<config>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
<interface>
<name>Loopback88</name>
<config>
<name>Loopback88</name>
<type xmlns:ianaift="urn:ietf:params:xml:ns:yang:iana-if-type">ianaift:softwareLoopback</type>
<description>w</description>
</config>
</interface>
</interfaces>
</config>
</edit-config>
</rpc>
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="102">
<commit/>
</rpc>
```
I received `<ok>` response and there we go - config has been applied successfully!
Small adjustment to the codebase and I got author’s script working.
```Python
netconf_reply = m.edit_config(netconf_payload, target="candidate") <<<---- "running" replaced with "candidate"
m.commit() <<<<<------ new line added
```
### See also
1. [[YANG]]
2. [[IOS-XR]]
### Reference
- [Issue on Cisco Learning Network](https://learningnetwork.cisco.com/s/feed/0D56e0000EBun3YCQR)