<?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: How to handle the element provided by operation command in python in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314220#M2207</link>
    <description>&lt;P&gt;Seems like you're using pandevice to do the op() call?&amp;nbsp; If so, this is better since there is an object for address objects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from pandevice.objects import AddressObject

listing = AddressObject.refreshall(fw)

for obj in listing:
  if obj.type != 'ip-netmask':
    continue
  print('Name: {0}) | ip-netmask: {1}'.format(obj.name, obj.value))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really wanted to do "'show config running" to get the answer, your xpath search is wrong.&amp;nbsp; It should be &lt;CODE&gt;./result/config/devices/entry[@name='vsys1']/address/entry&lt;/CODE&gt;.&amp;nbsp; At that location, the name is an attribute, and &lt;CODE&gt;ip-netmask&lt;/CODE&gt; may or may not be there, so using find() is ok.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 03 Mar 2020 17:42:47 GMT</pubDate>
    <dc:creator>gfreeman</dc:creator>
    <dc:date>2020-03-03T17:42:47Z</dc:date>
    <item>
      <title>How to handle the element provided by operation command in python</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314012#M2203</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this little script, the idea is show in the console all address that I have in the running config.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 607px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/24196iE4FA2BFE18940247/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But,&amp;nbsp; when I work with the xml element. the print&amp;nbsp; not show the addresses.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the result or rest api. to operation command "show config running"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 999px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/24197iFE6E0EA19C02DD01/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I need to extract from xml the name object and ip-netmask.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Mar 2020 21:26:34 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314012#M2203</guid>
      <dc:creator>mss.support</dc:creator>
      <dc:date>2020-03-02T21:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the element provided by operation command in python</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314220#M2207</link>
      <description>&lt;P&gt;Seems like you're using pandevice to do the op() call?&amp;nbsp; If so, this is better since there is an object for address objects:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="python"&gt;from pandevice.objects import AddressObject

listing = AddressObject.refreshall(fw)

for obj in listing:
  if obj.type != 'ip-netmask':
    continue
  print('Name: {0}) | ip-netmask: {1}'.format(obj.name, obj.value))
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you really wanted to do "'show config running" to get the answer, your xpath search is wrong.&amp;nbsp; It should be &lt;CODE&gt;./result/config/devices/entry[@name='vsys1']/address/entry&lt;/CODE&gt;.&amp;nbsp; At that location, the name is an attribute, and &lt;CODE&gt;ip-netmask&lt;/CODE&gt; may or may not be there, so using find() is ok.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 17:42:47 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314220#M2207</guid>
      <dc:creator>gfreeman</dc:creator>
      <dc:date>2020-03-03T17:42:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle the element provided by operation command in python</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314260#M2210</link>
      <description>&lt;P&gt;Thank you so much!!!. I'm creating a script to get all object and compare to see the duplicates and take that info to perform a clean up in the firewall.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again thanks a lot!!!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 20:43:17 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/how-to-handle-the-element-provided-by-operation-command-in/m-p/314260#M2210</guid>
      <dc:creator>mss.support</dc:creator>
      <dc:date>2020-03-03T20:43:17Z</dc:date>
    </item>
  </channel>
</rss>

