<?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 Re: Python code to reference yang objects in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445053#M375</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is a list in your Service instance yang, presumably it is there to handle the case of multiple entries of that list type per service instance, you'll need to loop through all those entries to get the service data to provide to the template in variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all you are doing in python is reading the service instance data and providing to template via variables, it is better (more efficient) to pass the service instance data directly to the template without invoking the python create code at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 15 Feb 2018 14:46:30 GMT</pubDate>
    <dc:creator>lmanor</dc:creator>
    <dc:date>2018-02-15T14:46:30Z</dc:date>
    <item>
      <title>Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445045#M367</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;Anyone have an example on how to reference nested yang objects in python ? For example, if my yang model is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;container a&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;&amp;nbsp; container b&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; leaf c&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;container d&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp; list e&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;What would be the the python service or root path ?&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;service.???&lt;/P&gt;&lt;P style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;root.???&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Mar 2019 12:05:59 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445045#M367</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2019-03-01T12:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445046#M368</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Assuming your service model looks something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;module myservice {&lt;/P&gt;&lt;P&gt;&amp;nbsp; prefix mysvc;&lt;/P&gt;&lt;P&gt;&amp;nbsp; container myservices {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; list myservice {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ncs:servicepoint myservice;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key name;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leaf name { type string; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container a {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container b {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leaf c { type string; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container d {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list e {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your python copde would access the leaf c in the particular service instance like this:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;class ServiceCallbacks(ncs.application.Service):&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="Apple-converted-space" style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt;"&gt;@ncs.application.Service.create&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;SPAN class="Apple-converted-space"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;def cb_create(self, tctx, root, service, proplist):&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the_c = service.a.b.c&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # When navigating from the root, we need to specify which service instance&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # we're talking about. Assuming we want to access the current service instance&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # it has key service.name&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; c_from_the_root = root.myservices.myservice[service.name].a.b.c&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;When you cross over from one namespace to another, or if your YANG model uses names that are keywords in Python, you will need to specify the namespace prefix as well. Let's pretend that b is in one of these cases, then you can always add the namespace name and two underscore characters in front of each name, like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1"&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P class="p1" style="font-size: 13.3333px;"&gt;&lt;SPAN class="s1"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; the_c = service.a.&lt;SPAN style="font-size: 13.3333px;"&gt;mysvc__&lt;/SPAN&gt;b.c&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s1"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class="s1"&gt;Hope this helps.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2018 09:19:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445046#M368</guid>
      <dc:creator>Jan Lindblad</dc:creator>
      <dc:date>2018-02-14T09:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445047#M369</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One addition questions. If the container/leaf/list has a hyphen &lt;IMG src="https://community.cisco.com/legacyfs/online/emoticons/minus.png" /&gt; in the yang, it needs to be replaced with an underscore (_) correct ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Feb 2018 19:17:52 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445047#M369</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-14T19:17:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445048#M370</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yup... but that's just because python sees "-" as "minus"....&lt;/P&gt;&lt;P&gt;(if you use underscore in yang it requires no change in Python)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://community.cisco.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cheers&lt;/P&gt;&lt;P&gt;gregg&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 01:32:04 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445048#M370</guid>
      <dc:creator>gschudel</dc:creator>
      <dc:date>2018-02-15T01:32:04Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445049#M371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am having troubles getting past the first list in the yang model. Could you provide the path to get to leaf "routemap-name" ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tried below with no luck:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;root.services.device_template.templates.template_contents.routemap_name&lt;/P&gt;&lt;P&gt;root.device_template.templates.template_contents.routemap_name&lt;/P&gt;&lt;P&gt;services.device_template.templates.template_contents.routemap_name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;root.services.device_template__device_template.device_template__templates.device_template__template_contents.device_template__routemap_name&lt;/P&gt;&lt;P&gt;root.device_template__device_template.device_template__templates.device_template__template_contents.device_template__routemap_name&lt;/P&gt;&lt;P&gt;services.device_template__device_template.device_template__templates.device_template__template_contents.device_template__routemap_name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;YANG:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;list device-template&lt;/P&gt;&lt;P&gt;&amp;nbsp; leaf name&lt;/P&gt;&lt;P&gt;&amp;nbsp; uses ncs:service-data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; ncs:servicepoint device-template-servicepoint;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; leaf-list device&lt;/P&gt;&lt;P&gt;&amp;nbsp; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp; container templates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; container template-contents&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; leaf routemap-name&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 02:38:32 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445049#M371</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T02:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445050#M372</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a device-template list instance called "foo", you access it in python:&lt;/P&gt;&lt;P&gt;root.device_template["foo"].templates.template_content.routermap_name&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 03:49:18 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445050#M372</guid>
      <dc:creator>frjansso</dc:creator>
      <dc:date>2018-02-15T03:49:18Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445051#M373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. I guess I should have mentioned what exactly I was trying to do as it looks like this method wont work, as it requires you to know the list key value. All that I am trying to do is capture the values entered into the yang model, assign them to a variable and the ship them off to the xml template. Is there a better method/function I should be using ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 06:00:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445051#M373</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T06:00:29Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445052#M374</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;aha, so in your service callback, you have two options, I'd prefer the first:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;service.&lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;templates.template_content.routermap_name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;-or-&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;root.device_template[service.name].templates.template_content.routermap_name&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 06:03:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445052#M374</guid>
      <dc:creator>frjansso</dc:creator>
      <dc:date>2018-02-15T06:03:27Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445053#M375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Robert,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If there is a list in your Service instance yang, presumably it is there to handle the case of multiple entries of that list type per service instance, you'll need to loop through all those entries to get the service data to provide to the template in variables.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If all you are doing in python is reading the service instance data and providing to template via variables, it is better (more efficient) to pass the service instance data directly to the template without invoking the python create code at all.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Larry&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 14:46:30 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445053#M375</guid>
      <dc:creator>lmanor</dc:creator>
      <dc:date>2018-02-15T14:46:30Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445054#M376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. Do you know what the difference between these two calls are ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 15:31:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445054#M376</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T15:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445055#M377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The first one is 30% shorter to write.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seriously, you'd start from service if the data you're looking for is inside the service instance being created/edited. If you need to navigate to something else, e.g. into another service instance, then start at the root.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 15:47:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445055#M377</guid>
      <dc:creator>Jan Lindblad</dc:creator>
      <dc:date>2018-02-15T15:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445056#M378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm all for shorter code &lt;IMG src="https://community.cisco.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But what is said is exactly what I was wondering.&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;Jan Lindblad wrote:&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;.......If you need to navigate to something else, e.g. into another service instance, then start at the root.&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Also I tried both ways, but the plain 'services.' way without 'root.' before it doesnt seem to work. I also dont see 'services.' in ipython whereas I do see 'root.' &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Doesnt work] service.&lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;templates.template_content.routermap_name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;[Works] &lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;root.device_template[service.name].templates.template_content.routermap_name&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;==&amp;gt; ncs-python-vm-test.log &amp;lt;==&lt;/P&gt;&lt;P&gt;2018-02-15 15:27:35 - test - DEBUG - TransactionCallback.cb_init()&lt;/P&gt;&lt;P&gt;2018-02-15 15:27:35 - test - INFO - Service create(service=/ncs:services/test:test{1})&lt;/P&gt;&lt;P&gt;2018-02-15 15:27:35 - test - ERROR - global name 'services' is not defined&lt;/P&gt;&lt;P&gt;2018-02-15 15:27:35 - test - ERROR - Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/home/cisco/nso-4.4.4.1/src/ncs/pyapi/ncs/application.py", line 340, in wrapper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl = fn(self, tctx, root, service, proplist)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/home/cisco/nso-4.4.4.1/ncs-run/state/packages-in-use/1/test/python/test/main.py", line 17, in cb_create&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tportchannel1_number = services.test__test[service.name]. \&lt;/P&gt;&lt;P&gt;NameError: global name 'services' is not defined&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:30:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445056#M378</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T20:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445057#M379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Agreed, I am just building from scratch and adding on.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 20:31:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445057#M379</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T20:31:14Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445058#M380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You have a typo there though, "services" =&amp;gt; "service"&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 22:28:45 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445058#M380</guid>
      <dc:creator>frjansso</dc:creator>
      <dc:date>2018-02-15T22:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445059#M381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;with "service."&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;admin@ncs(config-template-contents)# commit dry-run &lt;/P&gt;&lt;P&gt;Aborted: Python cb_create error. 'ListElement' object has no attribute 'test__test'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;==&amp;gt; ncs-python-vm-test.log &amp;lt;==&lt;/P&gt;&lt;P&gt;2018-02-15 18:13:29 - test - ERROR - Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/home/cisco/nso-4.4.4.1/src/ncs/pyapi/ncs/application.py", line 340, in wrapper&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pl = fn(self, tctx, root, service, proplist)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/home/cisco/nso-4.4.4.1/ncs-run/state/packages-in-use/1/test/python/test/main.py", line 17, in cb_create&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; tportchannel1_number = service.test__test[service.name]. \&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "/home/cisco/nso-4.4.4.1/src/ncs/pyapi/ncs/maagic.py", line 438, in __getattr__&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; super(Node, self).__getattribute__(name)&lt;/P&gt;&lt;P&gt;AttributeError: 'ListElement' object has no attribute 'test__test'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="text-decoration: underline;"&gt;ipython&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In [1]: print(root)&lt;/P&gt;&lt;P&gt;(root)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In [2]: print(root.services)&lt;/P&gt;&lt;P&gt;services&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In [3]: print(service)&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;NameError&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Traceback (most recent call last)&lt;/P&gt;&lt;P&gt;&amp;lt;ipython-input-3-eb3457d971bb&amp;gt; in &amp;lt;module&amp;gt;()&lt;/P&gt;&lt;P&gt;----&amp;gt; 1 print(service)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;NameError: name 'service' is not defined&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Feb 2018 23:15:33 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445059#M381</guid>
      <dc:creator>rocrowe</dc:creator>
      <dc:date>2018-02-15T23:15:33Z</dc:date>
    </item>
    <item>
      <title>Re: Python code to reference yang objects</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445060#M382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In you service callback:&lt;/P&gt;&lt;P&gt;def cb_create(self, tctx, root, &lt;STRONG&gt;service&lt;/STRONG&gt;, proplist):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You have a paremeter named &lt;STRONG&gt;service&lt;/STRONG&gt;, that is what we're referring to above with e.g. &lt;SPAN style="color: #3d3d3d; font-family: arial; font-size: 12px;"&gt;&lt;STRONG&gt;service&lt;/STRONG&gt;.&lt;/SPAN&gt;&lt;SPAN style="font-size: 12px; font-family: arial; color: #3d3d3d;"&gt;templates.template_content.routermap_name.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So let's say you create an instance of your service named foo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That means that the "service" parameter in cb_create "points" to /device-template{foo}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So if you do self.log.info(service.name) you can expect to see "foo" in the logs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now, the root object "points" to /.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To get to your service instance, you have to do root.device_template["foo"] (this is basically root.device_template[service.name]).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So self.log.info(&lt;SPAN style="font-size: 13.3333px;"&gt;root.device_template["foo"].name) will also print "foo" to the logs.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 16 Feb 2018 01:36:01 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/python-code-to-reference-yang-objects/m-p/3445060#M382</guid>
      <dc:creator>frjansso</dc:creator>
      <dc:date>2018-02-16T01:36:01Z</dc:date>
    </item>
  </channel>
</rss>

