cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1026
Views
5
Helpful
5
Replies

Delete VLANs through NETCONF

Hi,

I am working on a script that can create and delete VLANs on Catalyst 9000 series switches through NETCONF. Using the cisco-ios-xe-native YANG module, I am able to deploy the VLAN through the VLAN -> VLAN-list -> ID element. 

However, once I try to revert the configuration I get the following error (output is from YANG-Suite, but I've also tried through a script and get the same result):

<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:7fe08623-bed3-4130-8ad6-a416c19b037d"><rpc-error>
<error-type>application</error-type>
<error-tag>data-missing</error-tag>
<error-severity>error</error-severity>
<error-path xmlns:ios-vlan="http://cisco.com/ns/yang/Cisco-IOS-XE-vlan" xmlns:ios="http://cisco.com/ns/yang/Cisco-IOS-XE-native" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0">
    /nc:rpc/nc:edit-config/nc:config/ios:native/ios:vlan/ios-vlan:vlan-list[ios-vlan:id='511']
  </error-path><error-info><bad-element>vlan-list</bad-element>
</error-info>
</rpc-error>
</rpc-reply>

 

The RPC request is structured like this:

<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:7fe08623-bed3-4130-8ad6-a416c19b037d">
  <nc:edit-config>
    <nc:target>
      <nc:running/>
    </nc:target>
    <nc:config>
      <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
        <vlan>
          <vlan-list xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-vlan" nc:operation="delete">
            <id>511</id>
          </vlan-list>
        </vlan>
      </native>
    </nc:config>
  </nc:edit-config>
</nc:rpc>

 

Any clues?

- Johnny

 

5 Replies 5

@Johnny Karms Pedersen this is a guess, what mode of VTP is your switch in (show vtp status)?

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

It’s in mode server. I’m guessing that it fails as VTP server doesn’t contain the VLANs in the running config?

@Johnny Karms Pedersen this is my guess yes, try this with the switch in transparent mode. 

Please mark this as helpful or solution accepted to help others
Connect with me https://bigevilbeard.github.io

yangorelik
Spotlight
Spotlight

You got delete flag on wrong attribute. It should be:

<nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:7fe08623-bed3-4130-8ad6-a416c19b037d">
  <nc:edit-config>
    <nc:target>
      <nc:running/>
    </nc:target>
    <nc:config>
      <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
        <vlan>
          <vlan-list xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-vlan">
            <id nc:operation="delete">511</id>
          </vlan-list>
        </vlan>
      </native>
    </nc:config>
  </nc:edit-config>
</nc:rpc>
Yan Gorelik
YDK Solutions

"vlan-list" is a list node and "id" is the key to the list.  The proper way to delete a list entry is to apply the delete to the list and provide the key.  The rpc looks correct.  Is the "candidate" datastore configured?  Does the 511 vlan exist in the show command after applying to edit-config?  Can you manually delete it from the CLI without errors?  Does a "remove" work?