10-01-2017 03:27 AM - edited 03-01-2019 04:00 AM
Hi,
in some cases, the same "logical" configuration is applied differently across several IOS or IOS-XE platforms. For example, on some platform you can create subinterface, on some others you will have to create service instances and BDI or vlan interfaces etc.
The question is - what is the best way for a service (say Python-based) to find out what is the exact platform of the device configured with IOS NED and apply the right template accordingly?
Thanks in advance
10-02-2017 01:16 AM
Hi Djordje,
The best way in my opinion is using python mapping with templates. As you said, the configuration will be logically the same for all platforms - you define the variables which represent your service and push those variables to the template. So you can use the same template (same xml file) for all platforms and it would look something like this:
<config-template xmlns="http://tail-f.com/ns/config/1.0">
<devices xmlns="http://tail-f.com/ns/ncs">
<device>
<name>{$DEVICE}</name>
<config>
<!-- IOS XR -->
<interface xmlns="http://tail-f.com/ned/cisco-ios-xr">
<GigabitEthernet>
<id>{$INTF_NUM}</id>
<description>{$DESCRIPTION}</description>
</GigabitEthernet>
</interface>
<!-- JUNOS -->
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<interfaces>
<interface>
<name>{$INTF_NUM}</name>
<description>{$DESCRIPTION}</description>
</interface>
</interfaces>
</configuration>
</config>
</device>
</devices>
</config-template>
Template engine will know based on the device you push to the template ($DEVICE variable) what kind of platform it is, and then based on the namespace (e.g. http://tail-f.com/ned/cisco-ios-xr ), apply the correct configuration for the right device type.
Simon
10-02-2017 09:56 AM
Hi,
Check the platform status information. It gets filled with the device platform name and os version. You can then use it in your service code.
See example using ALU but the same will work with Cisco.
To check your devices just perform (in basic mode): #show devices device MYDEVICE platform
Roque
<port xmlns="http://tail-f.com/ned/alu-sr" when=
"{starts-with(/../../ncs:devices/ncs:device[ncs:name=/device]/ncs:platform/ncs:model,'7750')}">
<port-id>{/port}</port-id>
<ethernet>
<egress-scheduler-policy>NO_CROZON</egress-scheduler-policy>
<egress-scheduler-override>
<max-rate>{/max-rate}</max-rate>
</egress-scheduler-override>
</ethernet>
<shutdown>false</shutdown>
</port>
<port xmlns="http://tail-f.com/ned/alu-sr" when=
"{starts-with(/../../ncs:devices/ncs:device[ncs:name=/device]/ncs:platform/ncs:model,'7705')}">
<port-id>{/port}</port-id>
<ethernet>
<egress-rate>{/max-rate}</egress-rate>
</ethernet>
<shutdown>false</shutdown>
</port>
<port xmlns="http://tail-f.com/ned/alu-sr" when=
"{starts-with(/../../ncs:devices/ncs:device[ncs:name=/device]/ncs:platform/ncs:model,'NETSIM')}">
<port-id>{/port}</port-id>
<ethernet>
<egress-rate>{/max-rate}</egress-rate>
</ethernet>
<shutdown>true</shutdown>
</port>
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide