cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
128
Views
0
Helpful
1
Replies

REST with-defaults=trim

khgrant
Cisco Employee
Cisco Employee

Hi,

 

Would like to get the config for a device interface removing all default leafs over REST, the same way you get with the CLI.

 

Is this possible?

 

admin@ncs> show configuration devices device catalyst0 config ios:interface GigabitEthernet 0/1

description "blah";

switchport {

    access {

        vlan 150;

    }

    mode {

        access;

    }

    nonegotiate;

}

spanning-tree {

    bpduguard {

        enable;

    }

    guard root;

    portfast;

}

[ok][2016-01-29 12:57:48]

 

I tried using the trim value for the with-defaults query option but it does not work for me:

 

curl -u admin:admin  http://172.23.203.249:8080/api/running/devices/device/catalyst0/config/ios:interface/GigabitEthernet/0%2F1/?with-defaults=trim

 

<errors xmlns="http://tail-f.com/ns/tailf-rest-error">

  <error>

    <error-tag>malformed-message</error-tag>

    <error-urlpath>/api/running/devices/device/catalyst0/config/ios:interface/GigabitEthernet/0%2F1</error-urlpath>

    <error-message>with-defaults=trim not supported if defaultHandlingMode is explicit</error-message>

  </error>

</errors>

 

The error message points to a default Handling Mode which I can’t find on the documentation how to set.

 

The other thing I’d like to understand, is that the REST documentation mentions:

 

"Normally, leaf nodes that are not set but has a default value are not displayed at a GET request”

 

So why do I get full config (with default values)?

 

See example below:

curl -u admin:admin  http://172.23.203.249:8080/api/running/devices/device/catalyst0/config/ios:interface/GigabitEthernet/0%2F1/

<GigabitEthernet xmlns="urn:ios" xmlns:y="http://tail-f.com/ns/rest"  xmlns:ios="urn:ios"  xmlns:ncs="http://tail-f.com/ns/ncs">
  <name>0/1</name>
  <description>"glch was here!!"</description>
  <encapsulation>
  </encapsulation>
  <snmp>
    <trap>
      <link-status-capas>
        <link-status>
        </link-status>
      </link-status-capas>
    </trap>
  </snmp>
  <bfd>
  </bfd>
  <cdp>
  </cdp>
  <mpls>
    <accounting>
    </accounting>
    <ldp>
    </ldp>
    <traffic-eng>
      <flooding>
      </flooding>
    </traffic-eng>
  </mpls>
  <ip>
    <igmp>
    </igmp>
    <dhcp>
      <relay>
        <information>
        </information>
      </relay>
      <snooping>
      </snooping>
    </dhcp>
  </ip>
  <ipv6>
    <ospf>
    </ospf>
  </ipv6>
  <mls>
  </mls>
  <power>
  </power>
  <service-policy>
    <type>
    </type>
  </service-policy>
  <standby>
  </standby>
  <storm-control>
  </storm-control>
  <wrr-queue>
  </wrr-queue>
  <priority-queue>
  </priority-queue>
  <rep>
    <block>
    </block>
  </rep>
  <peer>
    <default>
      <ip>
      </ip>
    </default>
  </peer>
  <switchport>
    <access>
      <vlan>150</vlan>
    </access>
    <mode>
      <access/>
    </mode>
    <nonegotiate/>
    <trunk>
      <allowed>
      </allowed>
      <pruning>
      </pruning>
    </trunk>
    <voice>
    </voice>
    <priority>
    </priority>
  </switchport>
  <spanning-tree>
    <bpduguard>
      <enable/>
    </bpduguard>
    <guard>root</guard>
    <portfast/>
  </spanning-tree>
  <srr-queue>
    <bandwidth>
    </bandwidth>
  </srr-queue>
</GigabitEthernet>

1 ACCEPTED SOLUTION

Accepted Solutions

khgrant
Cisco Employee
Cisco Employee

Just FYI,

 

defaultHandlingMode is in confd.conf for confd.

 

And the with-defaults=trim works fine for confd if defaultHandlingMode is configured as trim.

 

curl -i -u admin:admin http://127.0.0.1:8009/api/running/system/logging?with-defaults=trim -X GET

<logging xmlns="http://test.com/system" xmlns:y="http://tail-f.com/ns/rest"  xmlns:test="http://test.com/system">

   <disk>

   </disk>

</logging>

curl -i -u admin:admin http://127.0.0.1:8009/api/running/system/logging?with-defaults=report-all -X GET

<logging xmlns="http://test.com/system" xmlns:y="http://tail-f.com/ns/rest"  xmlns:test="http://test.com/system">
   <disk>
     <enable>true</enable>
     <file>
       <size>10</size>
       <rotate>10</rotate>
     </file>
     <priority>information</priority>
   </disk>
</logging>

 

So seems like this is intended for confd.

 

As far as I researched, looks like the option defaultHandlingMode is not configurable in NCS, the documentation is confusing though...

View solution in original post

1 REPLY 1

khgrant
Cisco Employee
Cisco Employee

Just FYI,

 

defaultHandlingMode is in confd.conf for confd.

 

And the with-defaults=trim works fine for confd if defaultHandlingMode is configured as trim.

 

curl -i -u admin:admin http://127.0.0.1:8009/api/running/system/logging?with-defaults=trim -X GET

<logging xmlns="http://test.com/system" xmlns:y="http://tail-f.com/ns/rest"  xmlns:test="http://test.com/system">

   <disk>

   </disk>

</logging>

curl -i -u admin:admin http://127.0.0.1:8009/api/running/system/logging?with-defaults=report-all -X GET

<logging xmlns="http://test.com/system" xmlns:y="http://tail-f.com/ns/rest"  xmlns:test="http://test.com/system">
   <disk>
     <enable>true</enable>
     <file>
       <size>10</size>
       <rotate>10</rotate>
     </file>
     <priority>information</priority>
   </disk>
</logging>

 

So seems like this is intended for confd.

 

As far as I researched, looks like the option defaultHandlingMode is not configurable in NCS, the documentation is confusing though...

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: