<?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: Junos deactive using Python in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4927558#M8074</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1509430"&gt;@sayeali&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Have you tried the following?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;trans.set_attr(attr=0x00000000,v=_ncs.Value(False),keypath="/devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}")&lt;/LI-CODE&gt;&lt;P&gt;My assumption is that if you change the "_ncs.Value()" to "False", the attribute will be removed.&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2023 03:01:56 GMT</pubDate>
    <dc:creator>fracjackmac</dc:creator>
    <dc:date>2023-09-22T03:01:56Z</dc:date>
    <item>
      <title>Junos deactive using Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/3732042#M2788</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;In a junos device, you can use "deactivate" to disable a given configuration leaf.&lt;/P&gt;
&lt;P&gt;NSO handles "deactivate" by adding the XML attribute "inactive".&amp;nbsp;&amp;nbsp; I can do this in CLI but how can I do it in python?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Roque&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CLI output:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;admin@ncs(config)# deactivate devices device pe-j1 config junos:configuration system host-name
admin@ncs(config)# commit dry-run outformat xml
result-xml {
    local-node {
        data &amp;lt;devices xmlns="http://tail-f.com/ns/ncs"&amp;gt;
               &amp;lt;device&amp;gt;
                 &amp;lt;name&amp;gt;pe-j1&amp;lt;/name&amp;gt;
                 &amp;lt;config&amp;gt;
                   &amp;lt;configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"&amp;gt;
                     &amp;lt;system&amp;gt;
                       &amp;lt;host-name novalue="true"
                                  inactive="inactive"/&amp;gt;
                     &amp;lt;/system&amp;gt;NSO Developer Hub Discussions, Developer
                   &amp;lt;/configuration&amp;gt;
                 &amp;lt;/config&amp;gt;
               &amp;lt;/device&amp;gt;
             &amp;lt;/devices&amp;gt;
    }
}
admin@ncs(config)#&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Mar 2022 07:08:45 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/3732042#M2788</guid>
      <dc:creator>rogaglia</dc:creator>
      <dc:date>2022-03-10T07:08:45Z</dc:date>
    </item>
    <item>
      <title>Re: Junos deactive using Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/3732043#M2789</link>
      <description>&lt;P&gt;Here is the answer to my own question:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;In [22]: trans.set_attr(attr=0x00000000,v=_ncs.Value(True),keypath="/devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}")

In [24]: trans.compare()
Diff set:
kp=/ncs:devices/device{pe-j0}, op=MOP_MODIFIED, oldv=None, newv=None
kp=/ncs:devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}, op=MOP_MODIFIED, oldv=None, newv=None
kp=/ncs:devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}, op=MOP_ATTR_SET, oldv=None, newv=(&amp;lt;_ncs.Value type=C_UINT32(12) value='0'&amp;gt;, &amp;lt;_ncs.Value type=C_BOOL(17) value='true'&amp;gt;)

In [25]: trans.apply()

In [26]:

Confirmation:

admin@ncs(config)# show full-configuration devices device pe-j0 config junos:configuration system ntp | display xml
&amp;lt;config xmlns="http://tail-f.com/ns/config/1.0"&amp;gt;
  &amp;lt;devices xmlns="http://tail-f.com/ns/ncs"&amp;gt;
  &amp;lt;device&amp;gt;
    &amp;lt;name&amp;gt;pe-j0&amp;lt;/name&amp;gt;
      &amp;lt;config&amp;gt;
      &amp;lt;configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm"&amp;gt;
      &amp;lt;system&amp;gt;
      &amp;lt;ntp&amp;gt;
        &amp;lt;server&amp;gt;
          &amp;lt;name&amp;gt;10.20.10.110&amp;lt;/name&amp;gt;
        &amp;lt;/server&amp;gt;
        &amp;lt;server inactive="inactive"&amp;gt;
          &amp;lt;name&amp;gt;10.30.10.120&amp;lt;/name&amp;gt;
        &amp;lt;/server&amp;gt;
      &amp;lt;/ntp&amp;gt;
      &amp;lt;/system&amp;gt;
      &amp;lt;/configuration&amp;gt;
      &amp;lt;/config&amp;gt;
  &amp;lt;/device&amp;gt;
  &amp;lt;/devices&amp;gt;
&amp;lt;/config&amp;gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 24 Oct 2018 20:19:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/3732043#M2789</guid>
      <dc:creator>rogaglia</dc:creator>
      <dc:date>2018-10-24T20:19:29Z</dc:date>
    </item>
    <item>
      <title>Re: Junos deactive using Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4917501#M8031</link>
      <description>&lt;P&gt;Hi Roque,&lt;BR /&gt;&lt;BR /&gt;Could you pls also suggest how we can mark them active in a similar way .&lt;/P&gt;
&lt;P&gt;Thanks in Advance&lt;/P&gt;</description>
      <pubDate>Mon, 04 Sep 2023 19:52:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4917501#M8031</guid>
      <dc:creator>sayeali</dc:creator>
      <dc:date>2023-09-04T19:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Junos deactive using Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4927557#M8073</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/387925"&gt;@rogaglia&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I see your command above:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;trans.set_attr(attr=0x00000000,v=_ncs.Value(True),keypath="/devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I'm not familiar with this command and I don't see an import command.&lt;BR /&gt;Is there a specific package or module that you used?&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 17:04:35 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4927557#M8073</guid>
      <dc:creator>fracjackmac</dc:creator>
      <dc:date>2023-09-22T17:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Junos deactive using Python</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4927558#M8074</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1509430"&gt;@sayeali&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Have you tried the following?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;trans.set_attr(attr=0x00000000,v=_ncs.Value(False),keypath="/devices/device{pe-j0}/config/junos:configuration/system/ntp/server{10.30.10.120}")&lt;/LI-CODE&gt;&lt;P&gt;My assumption is that if you change the "_ncs.Value()" to "False", the attribute will be removed.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 03:01:56 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/junos-deactive-using-python/m-p/4927558#M8074</guid>
      <dc:creator>fracjackmac</dc:creator>
      <dc:date>2023-09-22T03:01:56Z</dc:date>
    </item>
  </channel>
</rss>

