cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
425
Views
5
Helpful
2
Replies
ShaunGreen
Beginner

Deleting multiple parts of interface configuration using Rest Conf

Apologies if it's been asked before, but I've search and can't find anything suitable.

 

Also, I'm very new to Rest Conf, so please bear with me

 

I've managed to pull in the switch interface config using the following:

 

GET https://{{host}}:{{port}}/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1%2F0%2F19

 

Resulting in:

 

{
"Cisco-IOS-XE-native:GigabitEthernet": {
"name": "1/0/19",
"description": "something else",
"ip": {
"access-group": {
"in": {
"acl": {
"acl-name": "implicit_deny",
"in": [null]
}
}
},
"Cisco-IOS-XE-nbar:nbar": {
"protocol-discovery": {
}
}
},
"source": {
"template": {
"template-name": [
{
"template-name": "PORT-AUTH-TEMPLATE"
}
]
}
},
"Cisco-IOS-XE-lldp:lldp": {
"receive": false,
"transmit": false
},
"Cisco-IOS-XE-policy:service-policy": {
"input": "WEBUI-MARKING-IN",
"output": "WEBUI-QUEUING-OUT",
"type": {
"control": {
"subscriber": "PORT-AUTH-POLICY"
}
}
},
"Cisco-IOS-XE-spanning-tree:spanning-tree": {
"portfast": {
}
},
"Cisco-IOS-XE-switch:device-tracking": {
"attach-policy": "IPDT_MAX_10"
}
}
}

 

I know I can default the interface from the CLI and do a PUT with the above JSON to re-configure the interface.

 

And I've worked out how to delete the description for instance with:

 

DELETE  https://{{host}}:{{port}}/restconf/data/Cisco-IOS-XE-native:native/interface/GigabitEthernet=1%2F0%2F19/description

 

BUT!!!

What I don't know if it's possible is to delete multiple parts of the config in one go, i.e. Send one DELETE Rest Conf to delete the description and ip access-group commands in one go.

Or, if I can default the interface using REST CONF.

If anyone can share some advice I'd appreciate it.

Thanks in advance,

Simon

2 REPLIES 2
tcragg1
Cisco Employee

I don't think you should need to default the interface first. If you do a PUT it should overwrite whatever is in place with what is in the PUT.

 

As an alternative, you could also look at using the YANG Patch media type for the RESTCONF request. A YANG Patch allows you to perform multiple actions within a single transaction in NSO, and they don't necessarily have to be the same type of action (so for example, you could delete the description and access-group from an interface and add a new BGP peer in a single RESTCONF command). It takes a little more effort to work out the correct data to send, but is a much more flexible way to implement changes.

 

To use a YANG Patch, you should send a PATCH request to /restconf/data with a Content-Type header of application/yang-patch+xml and an Accept header of application/yang-data+xml. Below is an example of a YANG Patch data body:

 

 

<yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
  <patch-id>test-patch</patch-id>
  <edit>
    <edit-id>test1</edit-id>
    <operation>merge</operation>
    <target>/tailf-ncs:devices/device=hs4-inf-p-rr01/config/tailf-ned-cisco-ios:interface/Port-channel=3</target>
    <value>
      <Port-channel xmlns="urn:ios"  xmlns:ios="urn:ios"  xmlns:ncs="http://tail-f.com/ns/ncs">
        <name>3</name>
        <description>Test</description>
      </Port-channel>
    </value>
  </edit>
  <edit>
    <edit-id>test2</edit-id>
    <operation>merge</operation>
    <target>/tailf-ncs:devices/device=hs4-inf-p-rr01/config/tailf-ned-cisco-ios:ip/vrf=patch-vrf</target>
    <value>
      <vrf xmlns="urn:ios"  xmlns:ios="urn:ios"  xmlns:ncs="http://tail-f.com/ns/ncs">
        <name>patch-vrf</name>
        <rd>10.20.30.40:8531</rd>
        <route-target>
          <export>
            <asn-ip>10.20.30.40:8531</asn-ip>
          </export>
          <import>
            <asn-ip>10.20.30.40:8531</asn-ip>
          </import>
        </route-target>
      </vrf>
    </value>
  </edit>
  <edit>
    <edit-id>test3</edit-id>
    <operation>delete</operation>
    <target>/tailf-ncs:devices/device=hs4-inf-p-rr02/config/tailf-ned-cisco-ios:interface/GigabitEthernet=0%2F0%2F4.1236</target>
  </edit>
</yang-patch>

This one request includes 2 merges and a delete to completely different parts of the device configuration, but NSO will treat this as a single transaction.

 

 

You can also find more details on YANG Patch in the relevant RFC, here 

 

Thank you, I shall work through this in a lab and report back how I get on.