<?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: NSO add device python API in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838650#M3664</link>
    <description>&lt;P&gt;I have a host with NETCONF server. I created already a NED for it in the NSO.&lt;/P&gt;</description>
    <pubDate>Mon, 15 Apr 2019 11:21:20 GMT</pubDate>
    <dc:creator>mhemmatp</dc:creator>
    <dc:date>2019-04-15T11:21:20Z</dc:date>
    <item>
      <title>NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838494#M3658</link>
      <description>&lt;P&gt;&lt;FONT color="#000000"&gt;Hello all,&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;I am trying to add NETCONF device to NSO through python API as follows:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;import ncs;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;with ncs.maapi.single_write_trans('admin', 'python', groups=['ncsadmin']) as t:&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root = ncs.maagic.get_root(t)&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device.create('test')&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].address = '127.0.0.1'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].port = 22&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.create()&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.ned_id = 'netconf'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.protocol = 'ssh'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].authgroup = 'authtest'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].state.admin_state = 'unlocked'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;But I receive the following error:&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.ned_id = 'netconf'&lt;BR /&gt;File "src/ncs/pyapi/ncs/maagic.py", line 471, in __setattr__&lt;BR /&gt;child.set_value(value)&lt;BR /&gt;File "src/ncs/pyapi/ncs/maagic.py", line 939, in set_value&lt;BR /&gt;value = _python_to_yang(value, self._cs_node)&lt;BR /&gt;File "src/ncs/pyapi/ncs/maagic.py", line 1927, in _python_to_yang&lt;BR /&gt;return _tm.Value.str2val(str(value), cs_node)&lt;BR /&gt;_ncs.error.Error: item has a bad/wrong type (5): Invalid string for type&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;what is the problem of my code?&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;Thanks,&lt;/FONT&gt;&lt;/P&gt;
&lt;P style="margin-bottom: 0in;"&gt;&lt;FONT color="#000000"&gt;Regards,&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 08:23:25 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838494#M3658</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-15T08:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838527#M3659</link>
      <description>&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.ned_id = 'netconf'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#000000"&gt;root.devices.device['test'].device_type.cli.protocol = 'ssh'&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;protocol&lt;/STRONG&gt;&lt;STRONG&gt;&amp;nbsp;will = netconf or ssh&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ned_id should be cisco-ios or nx or xr etc etc&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 08:49:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838527#M3659</guid>
      <dc:creator>yale.prince@leidos.com</dc:creator>
      <dc:date>2019-04-15T08:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838557#M3660</link>
      <description>&lt;P&gt;Still it does not work. My goal is to add a netconf device do you think my syntax is OK:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;root.devices.device['test'].device_type.&lt;STRONG&gt;cli&lt;/STRONG&gt;.ned_id = ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;device_type.cli does not indicate I am adding a cli device?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 09:32:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838557#M3660</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-15T09:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838592#M3661</link>
      <description>&lt;P&gt;what is the actual device ?&lt;/P&gt;&lt;P&gt;and do you have a NED for it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;eg if i wanted to add an IOS router i would use the cisco-ios NED that ned can communicate with the device in several ways eg SSH or Netconf&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 10:07:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838592#M3661</guid>
      <dc:creator>yale.prince@leidos.com</dc:creator>
      <dc:date>2019-04-15T10:07:28Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838623#M3663</link>
      <description>It is worth noting that netconf and ssh are not interchangeable here. Either you want a CLI ned that can communicate over a protocol like ssh or telnet or you want a netconf ned (that can also communicate over ssh). So when it says .cli you are in the cli-ned specific part of the config.&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Apr 2019 10:40:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838623#M3663</guid>
      <dc:creator>vleijon</dc:creator>
      <dc:date>2019-04-15T10:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838650#M3664</link>
      <description>&lt;P&gt;I have a host with NETCONF server. I created already a NED for it in the NSO.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 11:21:20 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838650#M3664</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-15T11:21:20Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838653#M3665</link>
      <description>&lt;P&gt;So, as I understood the cli does not indicate I am adding a cli device it can be used to add a netconf device ad well. Am I right?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 11:24:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838653#M3665</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-15T11:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838664#M3666</link>
      <description>No. CLI definitely indicates that you are adding a CLI device. To add a netconf device, use the netconf sub-tree. That is device_type.netconf instead of device_type.cli.&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Apr 2019 11:40:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838664#M3666</guid>
      <dc:creator>vleijon</dc:creator>
      <dc:date>2019-04-15T11:40:06Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838672#M3667</link>
      <description>&lt;P&gt;Thanks for the reply. I set the netconf.ned_id to 'netconf' and I removed the netconf.protocol. Still I have the following ERR:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;File "src/ncs/pyapi/ncs/maapi.py", line 1005, in apply&lt;BR /&gt;self.maapi.apply_trans_flags(self.th, keep_open, flags)&lt;BR /&gt;File "src/ncs/pyapi/ncs/maapi.py", line 254, in proxy&lt;BR /&gt;return real(self2.msock, *args, **kwargs)&lt;BR /&gt;File "/usr/lib/python2.7/socket.py", line 228, in meth&lt;BR /&gt;return getattr(self._sock,name)(*args)&lt;BR /&gt;File "/usr/lib/python2.7/socket.py", line 174, in _dummy&lt;BR /&gt;raise error(EBADF, 'Bad file descriptor')&lt;BR /&gt;socket.error: [Errno 9] Bad file descriptor&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 11:55:56 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838672#M3667</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-15T11:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838679#M3668</link>
      <description>That is an unrelated error. Might be related to reusing a socket after closing it or overwriting a handle or something.&lt;BR /&gt;</description>
      <pubDate>Mon, 15 Apr 2019 12:02:06 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838679#M3668</guid>
      <dc:creator>vleijon</dc:creator>
      <dc:date>2019-04-15T12:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838897#M3671</link>
      <description>&lt;P&gt;This python code will add a netconf device to the device tree:&lt;/P&gt;
&lt;P&gt;In [15]: with ncs.maapi.Maapi() as m:&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;with ncs.maapi.Session(m, 'admin', 'python'):&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; with m.start_write_trans() as t:&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; root = ncs.maagic.get_root(t)&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newdev = root.devices.device.create('test-dev')&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newdev.address = '127.0.0.1'&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newdev.port = 830&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newdev.authgroup = 'default'&lt;/P&gt;
&lt;P&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dev_type = newdev.device_type.netconf.create()&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; dev_type.ned_id = 'netconf'&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; print (dev_type)&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; newdev.state.admin_state = 'southbound-locked'&lt;BR /&gt;...:&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; t.apply()&lt;BR /&gt;...:&lt;BR /&gt;netconf&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;admin@ncs% show devices device test-dev&lt;BR /&gt;address 127.0.0.1;&lt;BR /&gt;port 830;&lt;BR /&gt;authgroup default;&lt;BR /&gt;device-type {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; netconf {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;ned-id netconf;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;BR /&gt;state {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; admin-state southbound-locked;&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Mon, 15 Apr 2019 16:55:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3838897#M3671</guid>
      <dc:creator>lmanor</dc:creator>
      <dc:date>2019-04-15T16:55:26Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3839345#M3676</link>
      <description>&lt;P&gt;Thanks. It worked for me!&lt;/P&gt;</description>
      <pubDate>Tue, 16 Apr 2019 10:09:52 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/3839345#M3676</guid>
      <dc:creator>mhemmatp</dc:creator>
      <dc:date>2019-04-16T10:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: NSO add device python API</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/4938122#M8127</link>
      <description>&lt;P&gt;I have multiple neds with me and I need to add a device with multiple&lt;/P&gt;&lt;P&gt;cisco-nx-cli-3.0&lt;/P&gt;&lt;P&gt;snmp&lt;/P&gt;&lt;P&gt;netconf&lt;/P&gt;&lt;P&gt;how do i do that&lt;/P&gt;</description>
      <pubDate>Wed, 11 Oct 2023 13:56:22 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/nso-add-device-python-api/m-p/4938122#M8127</guid>
      <dc:creator>nisheeth</dc:creator>
      <dc:date>2023-10-11T13:56:22Z</dc:date>
    </item>
  </channel>
</rss>

