Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
474 changes: 474 additions & 0 deletions plugins/yanger_sample_xml_skeleton.erl

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions test/lux/sample-xml-skeleton/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
include ../../support/*_testcases.mk

build:

clean:
rm -rf lux_logs _tmp_*

.PHONY: build clean
5 changes: 5 additions & 0 deletions test/lux/sample-xml-skeleton/population.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{string, "populate type string"}.
{unit8, "16"}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint8 - maybe?

{unit32, "32"}.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uint32 - maybe?
The populate-functionality is really nice.
For instance with typedefs local in the module - you can just add the atom and voila.

{{yang, 'date-and-time'}, "1985-04-12T23:20:50.52Z"}.
{{inet,'ip-address'}, "192.168.1.5"}.
317 changes: 317 additions & 0 deletions test/lux/sample-xml-skeleton/sample_xml_skeleton_annotations.lux
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
# author: lbevemyr@cisco.com
[doc]
Test of the yanger sample xml skeleton plugin with annotations option

The tests include the option --sample-xml-skeleton-annotations which adds
annotations in the output. The option is tested with both config true (config)
and config false (data).
[enddoc]


[macro sample-xml-skeleton_data FILE]
~yanger -f sample-xml-skeleton -p ${DIR} ${DIR}/${FILE}
! --sample-xml-skeleton-doctype data --sample-xml-skeleton-annotations
[endmacro]

[macro sample-xml-skeleton_config FILE]
~yanger -f sample-xml-skeleton -p ${DIR} ${DIR}/${FILE}
! --sample-xml-skeleton-doctype config --sample-xml-skeleton-annotations
[endmacro]

[shell test_yanger_sample-xml-skeleton]
[timeout 10]

[global DIR=../tree]
[invoke sample-xml-skeleton_data small3.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config small3.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<dynamic-profiles xmlns="http://xml.juniper.net/junos/10.0R3/junos">
<!-- # keys: name -->
<!-- # entries: 0.. -->
<name>
<!-- type: string -->
</name>
<variables>
<!-- # keys: mandatory -->
<!-- # entries: 0.. -->
<name>
<!-- type: empty -->
</name>
<default-value>
<!-- type: empty -->
</default-value>
<mandatory>
<!-- type: string -->
</mandatory>
</variables>
</dynamic-profiles>
</config>
"""

[invoke sample-xml-skeleton_data small4.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config small4.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<dynamic-profiles xmlns="http://xml.juniper.net/junos/10.0R3/junos">
<!-- # keys: name -->
<!-- # entries: 0.. -->
<name>
<!-- type: string -->
</name>
<inget>
<!-- # keys: name -->
<!-- # entries: 0.. -->
<name>
<!-- type: string -->
</name>
<variables>
<!-- # keys: mandatory -->
<!-- # entries: 0.. -->
<name>
<!-- type: empty -->
</name>
<default-value>
<!-- type: empty -->
</default-value>
<mandatory>
<!-- type: string -->
</mandatory>
</variables>
</inget>
</dynamic-profiles>
</config>
"""
[invoke sample-xml-skeleton_data small5.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config small5.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<d xmlns="urn:q">
<e/>
</d>
</config>
"""
[invoke sample-xml-skeleton_data a.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<x xmlns="urn:a">
<foo>
<!-- # entries: 0.. -->
<bar>
<!-- type: int32 -->
</bar>
<baz>
<!-- type: int32 -->
</baz>
</foo>
</x>
</data>
"""
[invoke sample-xml-skeleton_config a.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""

# use pyang test modules
[global DIR=./test_good]
[invoke sample-xml-skeleton_data yt5.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config yt5.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<con2 xmlns="urn:ietf:params:xml:ns:yang:yt5">
<con3>
<b>
<bb>
<e>
<f>
<g>
<!-- type: int64 -->
</g>
<h>
<!-- type: con2 -->
</h>
<i>
<!-- type: con2 -->
</i>
</f>
</e>
<d>
<!-- type: int8 -->
</d>
</bb>
</b>
</con3>
</con2>
<foo xmlns="urn:ietf:params:xml:ns:yang:yt5">
<foo>
<!-- type: foo -->
</foo>
</foo>
<foo2 xmlns="urn:ietf:params:xml:ns:yang:yt5">
<foo3>
<foo>
<!-- type: foo -->
</foo>
<foo4>
<!-- type: foobar -->
<!-- # entries: 0.. -->
</foo4>
</foo3>
<foo4>
<foo>
<!-- type: foo -->
</foo>
<foo4>
<!-- type: foobar -->
<!-- # entries: 0.. -->
</foo4>
</foo4>
</foo2>
<foo3 xmlns="urn:ietf:params:xml:ns:yang:yt5">
<!-- # keys: foo -->
<!-- # entries: 0.. -->
<foo>
<!-- type: foo -->
</foo>
<bar>
<!-- type: foo -->
</bar>
<yyy>
<!-- type: binary -->
<!-- # entries: 2..12 -->
</yyy>
<yyy/>
<baz>
<!-- type: int16 -->
</baz>
<goo>
<!-- type: foo -->
</goo>
<zzz>
<zzzz>
<!-- type: uint32 -->
</zzzz>
</zzz>
</foo3>
</config>
"""

[invoke sample-xml-skeleton_data yt6.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<bar xmlns="urn:ietf:params:xml:ns:yang:yt6">
<!-- # keys: bar1 -->
<!-- # entries: 0.. -->
<zz3>
<!-- type: y:date-and-time -->
<!-- # entries: 4..14 -->
</zz3>
<zz3/>
<zz3/>
<zz3/>
</bar>
</data>
"""

[invoke sample-xml-skeleton_config yt6.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<foo xmlns="urn:ietf:params:xml:ns:yang:yt6">
<bar1>
<!-- type: y:counter32 -->
</bar1>
<bar3>
<!-- type: int32 -->
</bar3>
<bar4>
<!-- type: int32 -->
</bar4>
<bar5>
<!-- type: int32 -->
</bar5>
<x>
<!-- type: int32 -->
</x>
<y>
<!-- type: string -->
</y>
<z/>
<xxx>
<!-- type: binary -->
</xxx>
<zzz>
<!-- type: int64 -->
</zzz>
</foo>
</config>
"""

[invoke sample-xml-skeleton_data yt9.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config yt9.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<a1 xmlns="urn:ietf:params:xml:ns:yang:yt9">
<!-- type: int32 -->
</a1>
<con1 xmlns="urn:ietf:params:xml:ns:yang:yt9">
<a2>
<!-- type: string -->
</a2>
</con1>
</config>
"""

[invoke sample-xml-skeleton_data yt10.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
[invoke sample-xml-skeleton_config yt10.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
<test xmlns="urn:ietf:params:xml:ns:yang:yt10">
<X>
<!-- type: int32 -->
</X>
<Y>
<!-- type: uint32 -->
</Y>
</test>
</config>
"""

[invoke sample-xml-skeleton_data w.yang]
"""???
<?xml version='1.0' encoding='UTF-8'?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
"""
Loading