Subject: [netmod] translation to IOS

From: Ladislav Lhotka <[email-masked]>
Date: Mon, 25 Jul 2011 10:46:56 -0400

Hi,

I wrote an XSLT stylesheet that takes an instance document combining (most of) data trees of the 'ietf-system', 'ietf-interfaces' and 'ietf-ip' modules and translates it to a Cisco IOS configuration. An example is shown below.

Apart from practical applications, it could IMO serve as an evidence that NETMOD-developed data models remain closely related to real-world data models and configuration languages.

The stylesheet can be extended to include other modules such as snmp-cfg. Integration of the routing stuff will not be that easy though.

Comments are welcome.

Lada

$ cat test-get-config-reply.xml 
<rpc-reply
    xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"
    message-id="101">
  <data>
    <system xmlns="urn:ietf:params:xml:ns:yang:ietf-system">
      <name>my-router</name>
      <dns>
	<server>192.0.2.254</server>
	<server>2001:CAFE::FE</server>
	<search>cesnet.cz</search>
	<search>ietf.org</search>
      </dns>
      <ntp>
	<ntp-server>
	  <address>tik.cesnet.cz</address>
	</ntp-server>
	<ntp-server>
	  <address>tak.cesnet.cz</address>
	</ntp-server>
      </ntp>
    </system>
    <interfaces
	xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
      <interface>
	<name>GigabitEthernet1/1</name>
	<description>
	  External interface.
	</description>
	<type>ethernetCsmacd</type>
	<location>1/1</location>
	<mtu>8192</mtu>
	<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
	  <address>
	    <ip>192.0.2.1</ip>
	    <prefix-length>24</prefix-length>
	  </address>
	</ipv4>
	<ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
	  <address>
	    <ip>2001:CAFE::1</ip>
	    <prefix-length>64</prefix-length>
	  </address>
	</ipv6>
      </interface>
      <interface>
	<name>GigabitEthernet1/2</name>
	<description>
	  Internal interface.
	</description>
	<type>ethernetCsmacd</type>
	<location>1/2</location>
	<ipv4 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
	  <address>
	    <ip>192.0.3.129</ip>
	    <prefix-length>25</prefix-length>
	  </address>
	</ipv4>
	<ipv6 xmlns="urn:ietf:params:xml:ns:yang:ietf-ip">
	  <address>
	    <ip>2001:F00B::1</ip>
	    <prefix-length>64</prefix-length>
	  </address>
	</ipv6>
      </interface>
    </interfaces>
  </data>
</rpc-reply>

$ xsltproc ../cisco-ios.xsl test-get-config-reply.xml 
!
! Created from NETCONF get-config reply
!
hostname my-router
!
ip name-server 192.0.2.254
ip name-server 2001:CAFE::FE
ip domain-list cesnet.cz ietf.org
!
ntp server tik.cesnet.cz
ntp server tak.cesnet.cz
!
interface GigabitEthernet1/1
 description External interface.
 mtu 8192
 ip address 192.0.2.1 255.255.255.0
 ipv6 address 2001:CAFE::1/64
!
interface GigabitEthernet1/2
 description Internal interface.
 ip address 192.0.3.129 255.255.255.128
 ipv6 address 2001:F00B::1/64
!
end

--
Ladislav Lhotka, CESNET
PGP Key ID: E74E8C0C