<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Using pyang trying to first convert yang file into xml and then converting xml to json in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594842#M2240</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are hitting an error when we try to convert yang file to xml&amp;nbsp; in one of NSO setup but works fine in another setup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone share more information about pyang,&amp;nbsp; Is there any packages we need to install for it to work.&lt;/P&gt;&lt;P&gt;We are kind of stuck in this step&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="BubbleStyle_MessagesContainer"&gt;&lt;/P&gt;&lt;DIV class="BubbleStyle_MessageContainer"&gt;&lt;SPAN style="color: #1a1a1a; font-family: 'Segoe UI'; font-size: 13.33px;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/bin/pyang&lt;/SPAN&gt;", line 411, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run()&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/bin/pyang&lt;/SPAN&gt;", line 383, in run&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; emit_obj.emit(ctx, modules, fd)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 118, in emit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.process_children(yam, self.top, None)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 133, in process_children&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.node_handler[ch.keyword](ch, elem, module)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 163, in list&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.process_children(node, nel, newm)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 133, in process_children&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.node_handler[ch.keyword](ch, elem, module)&lt;BR /&gt;KeyError: ('tailf-common', 'action')&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Mar 2019 12:01:07 GMT</pubDate>
    <dc:creator>mitshett</dc:creator>
    <dc:date>2019-03-01T12:01:07Z</dc:date>
    <item>
      <title>Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594842#M2240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We are hitting an error when we try to convert yang file to xml&amp;nbsp; in one of NSO setup but works fine in another setup.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone share more information about pyang,&amp;nbsp; Is there any packages we need to install for it to work.&lt;/P&gt;&lt;P&gt;We are kind of stuck in this step&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="BubbleStyle_MessagesContainer"&gt;&lt;/P&gt;&lt;DIV class="BubbleStyle_MessageContainer"&gt;&lt;SPAN style="color: #1a1a1a; font-family: 'Segoe UI'; font-size: 13.33px;"&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/bin/pyang&lt;/SPAN&gt;", line 411, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; run()&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/bin/pyang&lt;/SPAN&gt;", line 383, in run&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; emit_obj.emit(ctx, modules, fd)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 118, in emit&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.process_children(yam, self.top, None)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 133, in process_children&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.node_handler[ch.keyword](ch, elem, module)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 163, in list&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.process_children(node, nel, newm)&lt;BR /&gt;&amp;nbsp; File "/root/nso-&lt;SPAN style="color: blue;"&gt;4.4.1.3/lib/pyang/pyang/plugins/sample-xml-skeleton.py&lt;/SPAN&gt;", line 133, in process_children&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.node_handler[ch.keyword](ch, elem, module)&lt;BR /&gt;KeyError: ('tailf-common', 'action')&lt;/SPAN&gt;&lt;P&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2019 12:01:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594842#M2240</guid>
      <dc:creator>mitshett</dc:creator>
      <dc:date>2019-03-01T12:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594843#M2241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hard to say exactly what you are doing based on the above. But I can tell you are not using the latest pyang version. First step I'd recommend is to upgrade: &lt;A class="loading" href="https://github.com/mbj4668/pyang" title="https://github.com/mbj4668/pyang"&gt;https://github.com/mbj4668/pyang&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 09:12:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594843#M2241</guid>
      <dc:creator>Jan Lindblad</dc:creator>
      <dc:date>2017-10-11T09:12:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594844#M2242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333px;"&gt;I am running the below command to convert yang to XML file &lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;pyang -f sample-xml-skeleton -o router.xml router.yang&amp;nbsp;&amp;nbsp; (this command should get me router.xml file&amp;nbsp; out of router.yang file)&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Above command should give me XML file of that yang model.&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;Reason, why I am converting yang to XML and to JSON, is to prepare a request body using that JSON to activate service in NSO by&amp;nbsp; making REST call.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 09:32:18 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594844#M2242</guid>
      <dc:creator>mitshett</dc:creator>
      <dc:date>2017-10-11T09:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594845#M2243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you Jan&amp;nbsp; Lindbald, it worked but we are facing one more issue &lt;/P&gt;&lt;P&gt;sample-xml-skeleton plugin needs a valid module&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any information you have about this.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Oct 2017 13:26:42 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594845#M2243</guid>
      <dc:creator>mitshett</dc:creator>
      <dc:date>2017-10-11T13:26:42Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594846#M2244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mithun,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;May I know for which version of pyang, yang to xml conversion is working. I have 1.5, I see issues while using pyang.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Were you able to generate xml out of yang?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please share the information if you are able to convert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Sujani.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 12 Dec 2017 05:49:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594846#M2244</guid>
      <dc:creator>schalaga</dc:creator>
      <dc:date>2017-12-12T05:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594847#M2245</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When you say "generate xml out of yang", what is it that you're trying to accomplish exactly?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2017 08:52:46 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594847#M2245</guid>
      <dc:creator>Jan Lindblad</dc:creator>
      <dc:date>2017-12-13T08:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594848#M2246</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; would like to create service instance xml by traversing through the yang. I do not want to create service instance from cli and then take out format as xml.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2017 09:01:10 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594848#M2246</guid>
      <dc:creator>schalaga</dc:creator>
      <dc:date>2017-12-13T09:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594849#M2247</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Maybe not terribly useful, but if you want to generate something like that, you can use the pyang -f sample-xml-skeleton command:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;pyang -f sample-xml-skeleton --sample-xml-skeleton-doctype=config ~/nso/4.5.1/examples.ncs/getting-started/developing-with-ncs/17-mpls-vpn-python/packages/l3vpn/src/yang/l3vpn.yang&lt;SPAN class="Apple-converted-space"&gt; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2017 09:21:37 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594849#M2247</guid>
      <dc:creator>Jan Lindblad</dc:creator>
      <dc:date>2017-12-13T09:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594850#M2248</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Jan,&lt;/P&gt;&lt;P&gt;Thanks for the response.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was trying with sample-xml-skeleton option with data and config. But its just giving as below. Were you able to generate?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have nso-4.4.2.1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;- pyang -f sample-xml-skeleton --sample-xml-skeleton-doctype=config l3vpn/src/yang/l3vpn.yang&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;?xml version='1.0' encoding='utf-8'?&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" /&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Dec 2017 09:30:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/3594850#M2248</guid>
      <dc:creator>schalaga</dc:creator>
      <dc:date>2017-12-13T09:30:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using pyang trying to first convert yang file into xml and then converting xml to json</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/4272118#M5998</link>
      <description>&lt;P&gt;Was searching for a document on how to convert yang model to xml, came across this document.&lt;/P&gt;
&lt;P&gt;Following is what I have done hope others find it useful.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;To view/convert to a tree format use the following&lt;/LI&gt;
&lt;/UL&gt;
&lt;PRE&gt;pyang -f tree ietf-interfaces.yang&lt;/PRE&gt;
&lt;P&gt;this is documented in `pyang --help`&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  -f FORMAT, --format=FORMAT
                        Convert to FORMAT.  Supported formats are: yang, yin,
                        dsdl, jsonxsl, capability, depend, identifiers, tree,
                        jstree, sample-xml-skeleton, omni, uml, jtox, name&lt;/PRE&gt;
&lt;P&gt;The &lt;FONT color="#003366"&gt;&lt;STRONG&gt;sample-xml-skeleton&lt;/STRONG&gt;&lt;/FONT&gt; require few more options, infact the error log doenst give you what exactly is missing, use the following code to convert to xml&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT face="terminal,monaco" color="#003366"&gt;pyang -f sample-xml-skeleton &lt;STRONG&gt;--sample-xml-skeleton-doctype=config &lt;/STRONG&gt; ietf-interfaces.yang&lt;/FONT&gt;
&amp;lt;?xml version='1.0' encoding='UTF-8'?&amp;gt;
&amp;lt;config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"&amp;gt;
  &amp;lt;interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces"&amp;gt;
    &amp;lt;interface&amp;gt;
      &amp;lt;name/&amp;gt;
      &amp;lt;description/&amp;gt;
      &amp;lt;type/&amp;gt;
      &amp;lt;link-up-down-trap-enable/&amp;gt;
    &amp;lt;/interface&amp;gt;
  &amp;lt;/interfaces&amp;gt;
&amp;lt;/config&amp;gt;&lt;/PRE&gt;
&lt;P&gt;we can also use&amp;nbsp;--sample-xml-skeleton-defaults or&amp;nbsp;--sample-xml-skeleton-annotations arguments, they do what they specifies&lt;/P&gt;
&lt;P&gt;These options are also specified in pyang --help&lt;/P&gt;
&lt;PRE&gt;  Sample-xml-skeleton output specific options:
    --sample-xml-skeleton-doctype=DOCTYPE
                        Type of sample XML document (data or config).
    --sample-xml-skeleton-defaults
                        Insert leafs with defaults values.
    --sample-xml-skeleton-annotations
                        Add annotations as XML comments.
    --sample-xml-skeleton-path=SAMPLE_PATH
                        Subtree to print&lt;/PRE&gt;
&lt;DIV id="mouseposition-extension-element-full-container" style="position: fixed; inset: 0px; pointer-events: none; z-index: 2147483647; font-weight: 400;"&gt;
&lt;DIV id="mouseposition-extension-element-rect-display" style="display: none; position: absolute; background: rgba(255, 255, 255, 0.7); outline: black solid 1px; font-size: 12px; z-index: 2147483647; justify-content: center; align-items: center; user-select: none; cursor: default; color: #000000; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; width: 0px; height: 0px;"&gt;
&lt;PRE style="flex: 1 1 0%; text-align: center; background-color: rgba(255, 255, 255, 0.7); color: #000000; min-width: 42px; min-height: 12px; transition: all 1s ease 0s;"&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;PRE id="mouseposition-extension-element-coordinate-display" style="position: absolute; display: none; background: #ffffff; font-size: 12px; line-height: 14px; border-radius: 3px; border-width: 1px; border-color: #222222 black #333333; border-style: solid; padding: 3px; z-index: 2147483647; color: #222222; user-select: none; cursor: default; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;"&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 14 Jan 2021 06:36:57 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/using-pyang-trying-to-first-convert-yang-file-into-xml-and-then/m-p/4272118#M5998</guid>
      <dc:creator>Amod Augustin</dc:creator>
      <dc:date>2021-01-14T06:36:57Z</dc:date>
    </item>
  </channel>
</rss>

