Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tree: ToXML() fix identityrefs now carry prefix #197

Merged
merged 1 commit into from
Nov 6, 2024
Merged
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
6 changes: 3 additions & 3 deletions pkg/tree/importer/xml/xml_tree_importer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestXmlTreeImporter(t *testing.T) {
<subinterface>
<description>Subinterface 0</description>
<index>0</index>
<type>routed</type>
<type>sdcio_model_common:routed</type>
</subinterface>
</interface>
<interface>
Expand All @@ -46,7 +46,7 @@ func TestXmlTreeImporter(t *testing.T) {
<subinterface>
<description>Subinterface 0</description>
<index>0</index>
<type>routed</type>
<type>sdcio_model_common:routed</type>
</subinterface>
</interface>
<leaflist>
Expand All @@ -60,7 +60,7 @@ func TestXmlTreeImporter(t *testing.T) {
<protocol>
<bgp/>
</protocol>
<type>default</type>
<type>sdcio_model_ni:default</type>
</network-instance>
<patterntest>hallo DU</patterntest>
`,
Expand Down
10 changes: 5 additions & 5 deletions pkg/tree/xml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestToXMLTable(t *testing.T) {
<subinterface>
<description>Subinterface 0</description>
<index>0</index>
<type>routed</type>
<type>sdcio_model_common:routed</type>
</subinterface>
</interface>
<leaflist>
Expand All @@ -57,7 +57,7 @@ func TestToXMLTable(t *testing.T) {
<admin-state>disable</admin-state>
<description>Default NI</description>
<name>default</name>
<type>default</type>
<type>sdcio_model_ni:default</type>
</network-instance>
<patterntest>foo</patterntest>
`,
Expand Down Expand Up @@ -93,7 +93,7 @@ func TestToXMLTable(t *testing.T) {
<subinterface>
<description>Subinterface 5</description>
<index>5</index>
<type>routed</type>
<type>sdcio_model_common:routed</type>
</subinterface>
</interface>
<leaflist operation="delete"/>
Expand All @@ -104,7 +104,7 @@ func TestToXMLTable(t *testing.T) {
<admin-state>enable</admin-state>
<description>Other NI</description>
<name>other</name>
<type>ip-vrf</type>
<type>sdcio_model_ni:ip-vrf</type>
</network-instance>
<patterntest>bar</patterntest>
`,
Expand Down Expand Up @@ -162,7 +162,7 @@ func TestToXMLTable(t *testing.T) {
<subinterface>
<description xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="remove"/>
<index>0</index>
<type>bridged</type>
<type>sdcio_model_common:bridged</type>
</subinterface>
</interface>
`,
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/xml.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ func TypedValueToXML(parent *etree.Element, tv *sdcpb.TypedValue, name string, n

case *sdcpb.TypedValue_EmptyVal:
parent.CreateElement(name)

case *sdcpb.TypedValue_IdentityrefVal:
subelem := parent.CreateElement(name)
if namespace != "" {
subelem.CreateAttr("xmlns", namespace)
}
subelem.SetText(tv.GetIdentityrefVal().YangString())
default:
subelem := parent.CreateElement(name)
if namespace != "" {
Expand Down