<?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 Unable to delete device configuration from a copied device in Python in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938238#M4402</link>
    <description>&lt;P&gt;In ncs_cli, I can do the following:&lt;/P&gt;&lt;PRE&gt;admin@ncs(config)# copy devices device ios0 ios-copy1&lt;BR /&gt;admin@ncs(config)# no devices device ios-copy1 config&lt;BR /&gt;admin@ncs(config)# commit no-networking&lt;BR /&gt;Commit complete.&lt;/PRE&gt;&lt;P&gt;I want to do the same thing from Python, so I have come up with this:&lt;/P&gt;&lt;PRE&gt;maapi.copy_tree(trans.th, '/devices/device{ios0}', '/devices/device{ios0-copy2}')&lt;BR /&gt;del root.devices.device['ios0-copy2'].config&lt;BR /&gt;trans.apply(flags=maapi.COMMIT_NCS_NO_NETWORKING)&lt;/PRE&gt;&lt;P&gt;Unfortunately, it errors on line 2.&amp;nbsp; I see the following when I attempt this from ipython-superuser:&lt;/P&gt;&lt;PRE&gt;---------------------------------------------------------------------------&lt;BR /&gt;Error Traceback (most recent call last)&lt;BR /&gt;&amp;lt;ipython-input-2-253dba028a5a&amp;gt; in &amp;lt;module&amp;gt;&lt;BR /&gt;----&amp;gt; 1 del root.devices.device['ios0-copy2'].config&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in __delattr__(self, name)&lt;BR /&gt;483 child = children[name]&lt;BR /&gt;484 if hasattr(child, 'delete'):&lt;BR /&gt;--&amp;gt; 485 child.delete()&lt;BR /&gt;486 return&lt;BR /&gt;487 else:&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in delete(self)&lt;BR /&gt;742 "To delete a list item, use del list[key]")&lt;BR /&gt;743 if self._backend:&lt;BR /&gt;--&amp;gt; 744 self._backend._delete(self._path)&lt;BR /&gt;745 self._set_attr('_populated', False)&lt;BR /&gt;746 if '_children' in self.__dict__:&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in _delete(self, path)&lt;BR /&gt;128&lt;BR /&gt;129 def _delete(self, path):&lt;BR /&gt;--&amp;gt; 130 self.delete(path)&lt;BR /&gt;131&lt;BR /&gt;132 def _num_instances(self, path):&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maapi.py in proxy(self2, *args, **kwargs)&lt;BR /&gt;941 else:&lt;BR /&gt;942 real = getattr(_tm.maapi, name)&lt;BR /&gt;--&amp;gt; 943 return real(self2.maapi.msock, self2.th, *args, **kwargs)&lt;BR /&gt;944 setattr(Transaction, name, proxy)&lt;BR /&gt;945 return getattr(self, name)&lt;BR /&gt;&lt;BR /&gt;Error: item does not exist (1):&lt;/PRE&gt;&lt;P&gt;Am I doing something wrong?&amp;nbsp; Could this be a bug?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Allen&lt;/P&gt;</description>
    <pubDate>Wed, 09 Oct 2019 19:38:26 GMT</pubDate>
    <dc:creator>allenc</dc:creator>
    <dc:date>2019-10-09T19:38:26Z</dc:date>
    <item>
      <title>Unable to delete device configuration from a copied device in Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938238#M4402</link>
      <description>&lt;P&gt;In ncs_cli, I can do the following:&lt;/P&gt;&lt;PRE&gt;admin@ncs(config)# copy devices device ios0 ios-copy1&lt;BR /&gt;admin@ncs(config)# no devices device ios-copy1 config&lt;BR /&gt;admin@ncs(config)# commit no-networking&lt;BR /&gt;Commit complete.&lt;/PRE&gt;&lt;P&gt;I want to do the same thing from Python, so I have come up with this:&lt;/P&gt;&lt;PRE&gt;maapi.copy_tree(trans.th, '/devices/device{ios0}', '/devices/device{ios0-copy2}')&lt;BR /&gt;del root.devices.device['ios0-copy2'].config&lt;BR /&gt;trans.apply(flags=maapi.COMMIT_NCS_NO_NETWORKING)&lt;/PRE&gt;&lt;P&gt;Unfortunately, it errors on line 2.&amp;nbsp; I see the following when I attempt this from ipython-superuser:&lt;/P&gt;&lt;PRE&gt;---------------------------------------------------------------------------&lt;BR /&gt;Error Traceback (most recent call last)&lt;BR /&gt;&amp;lt;ipython-input-2-253dba028a5a&amp;gt; in &amp;lt;module&amp;gt;&lt;BR /&gt;----&amp;gt; 1 del root.devices.device['ios0-copy2'].config&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in __delattr__(self, name)&lt;BR /&gt;483 child = children[name]&lt;BR /&gt;484 if hasattr(child, 'delete'):&lt;BR /&gt;--&amp;gt; 485 child.delete()&lt;BR /&gt;486 return&lt;BR /&gt;487 else:&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in delete(self)&lt;BR /&gt;742 "To delete a list item, use del list[key]")&lt;BR /&gt;743 if self._backend:&lt;BR /&gt;--&amp;gt; 744 self._backend._delete(self._path)&lt;BR /&gt;745 self._set_attr('_populated', False)&lt;BR /&gt;746 if '_children' in self.__dict__:&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in _delete(self, path)&lt;BR /&gt;128&lt;BR /&gt;129 def _delete(self, path):&lt;BR /&gt;--&amp;gt; 130 self.delete(path)&lt;BR /&gt;131&lt;BR /&gt;132 def _num_instances(self, path):&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maapi.py in proxy(self2, *args, **kwargs)&lt;BR /&gt;941 else:&lt;BR /&gt;942 real = getattr(_tm.maapi, name)&lt;BR /&gt;--&amp;gt; 943 return real(self2.maapi.msock, self2.th, *args, **kwargs)&lt;BR /&gt;944 setattr(Transaction, name, proxy)&lt;BR /&gt;945 return getattr(self, name)&lt;BR /&gt;&lt;BR /&gt;Error: item does not exist (1):&lt;/PRE&gt;&lt;P&gt;Am I doing something wrong?&amp;nbsp; Could this be a bug?&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;-Allen&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 19:38:26 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938238#M4402</guid>
      <dc:creator>allenc</dc:creator>
      <dc:date>2019-10-09T19:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to delete device configuration from a copied device in Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938242#M4403</link>
      <description>Config is a container,  so you cannot use the del built-in, you can use the delete() method, you probably want to do root.devices.device['ios0-copy2'].config.delete(), though I have not checked this.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 19:44:23 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938242#M4403</guid>
      <dc:creator>vleijon</dc:creator>
      <dc:date>2019-10-09T19:44:23Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to delete device configuration from a copied device in Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938268#M4404</link>
      <description>&lt;P&gt;Hi Viktor,&lt;/P&gt;&lt;P&gt;I just tried the .delete() as you suggested and it results in essentially the same error:&lt;/P&gt;&lt;PRE&gt;In [3]: root.devices.device['ios0-copy2'].config.delete()&lt;BR /&gt;---------------------------------------------------------------------------&lt;BR /&gt;Error Traceback (most recent call last)&lt;BR /&gt;&amp;lt;ipython-input-3-61453441d7f2&amp;gt; in &amp;lt;module&amp;gt;&lt;BR /&gt;----&amp;gt; 1 root.devices.device['ios0-copy2'].config.delete()&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in delete(self)&lt;BR /&gt;742 "To delete a list item, use del list[key]")&lt;BR /&gt;743 if self._backend:&lt;BR /&gt;--&amp;gt; 744 self._backend._delete(self._path)&lt;BR /&gt;745 self._set_attr('_populated', False)&lt;BR /&gt;746 if '_children' in self.__dict__:&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maagic.py in _delete(self, path)&lt;BR /&gt;128&lt;BR /&gt;129 def _delete(self, path):&lt;BR /&gt;--&amp;gt; 130 self.delete(path)&lt;BR /&gt;131&lt;BR /&gt;132 def _num_instances(self, path):&lt;BR /&gt;&lt;BR /&gt;/Users/achen/Documents/sandbox/nso/4.7/src/ncs/pyapi/ncs/maapi.py in proxy(self2, *args, **kwargs)&lt;BR /&gt;941 else:&lt;BR /&gt;942 real = getattr(_tm.maapi, name)&lt;BR /&gt;--&amp;gt; 943 return real(self2.maapi.msock, self2.th, *args, **kwargs)&lt;BR /&gt;944 setattr(Transaction, name, proxy)&lt;BR /&gt;945 return getattr(self, name)&lt;BR /&gt;&lt;BR /&gt;Error: item does not exist (1):&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;I will also note that both `del` and `.delete()` of the device config work if I use them on a &lt;EM&gt;committed&lt;/EM&gt; device (or device copy).&lt;/P&gt;&lt;P&gt;-Allen&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2019 20:24:41 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938268#M4404</guid>
      <dc:creator>allenc</dc:creator>
      <dc:date>2019-10-09T20:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to delete device configuration from a copied device in Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938338#M4406</link>
      <description>That is what I get for guessing too quickly! That does look surprising to me, might be worth raising a ticket with post-sales.&lt;BR /&gt;</description>
      <pubDate>Wed, 09 Oct 2019 23:25:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/unable-to-delete-device-configuration-from-a-copied-device-in/m-p/3938338#M4406</guid>
      <dc:creator>vleijon</dc:creator>
      <dc:date>2019-10-09T23:25:53Z</dc:date>
    </item>
  </channel>
</rss>

