<?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 Panorama with pan-os-python API in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/panorama-with-pan-os-python-api/m-p/521583#M3262</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three firewalls added to a device group in Panorama. I am accessing Panorama via pan-os-python API and from there I want to fetch some device group "MyDG" and then delete one of the firewalls from panorama based on the hostname of the firewall. I can see the hostnames set/configured in Panorama &amp;gt; Managed Devices &amp;gt; Summary in the GUI but when I try to fetch the information for any of my firewall devices via Panorama object through the API I get this error about hostname. I have tried other methods for this "fw0" object too and it throws the same error. Probably I am missing something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone pls guide what am I doing wrong or is it some bug?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; pano
&amp;lt;Panorama 202.24.62.93 0x10adc3d30&amp;gt;
&amp;gt;&amp;gt;&amp;gt; devices = pano.refresh_devices(include_device_groups=False)
&amp;gt;&amp;gt;&amp;gt; devices
[&amp;lt;Firewall '007955000319973' 'vsys1' at 0x10ad29180&amp;gt;, &amp;lt;Firewall '007955000319994' 'vsys1' at 0x10ad2bca0&amp;gt;, &amp;lt;Firewall '007955000399952' 'vsys1' at 0x10a5af640&amp;gt;]
&amp;gt;&amp;gt;&amp;gt; fw0 = devices[0]
&amp;gt;&amp;gt;&amp;gt; fw0.serial
'007955000319973'
&amp;gt;&amp;gt;&amp;gt; fw0.refresh()
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/panos/firewall.py", line 253, in generate_xapi
    self.panorama()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 1132, in panorama
    raise err.PanDeviceNotSet("No Panorama set for object tree")
panos.errors.PanDeviceNotSet: No Panorama set for object tree

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 901, in refresh
    xml = self._refresh_xml(running_config, exceptions, refresh_children)
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 1053, in _refresh_xml
    api_action = dev.xapi.show if running_config else dev.xapi.get
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4000, in xapi
    self._xapi_private = self.generate_xapi()
  File "/usr/local/lib/python3.10/site-packages/panos/firewall.py", line 255, in generate_xapi
    return super(Firewall, self).generate_xapi()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4072, in generate_xapi
    "api_key": self.api_key,
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 3994, in api_key
    self._api_key = self._retrieve_api_key()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4151, in _retrieve_api_key
    xapi = PanDevice.XapiWrapper(
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 3776, in __init__
    pan.xapi.PanXapi.__init__(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pan/xapi.py", line 178, in __init__
    raise PanXapiError('hostname argument required')
pan.xapi.PanXapiError: hostname argument required
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Nov 2022 22:43:21 GMT</pubDate>
    <dc:creator>mtkh</dc:creator>
    <dc:date>2022-11-17T22:43:21Z</dc:date>
    <item>
      <title>Panorama with pan-os-python API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/panorama-with-pan-os-python-api/m-p/521583#M3262</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three firewalls added to a device group in Panorama. I am accessing Panorama via pan-os-python API and from there I want to fetch some device group "MyDG" and then delete one of the firewalls from panorama based on the hostname of the firewall. I can see the hostnames set/configured in Panorama &amp;gt; Managed Devices &amp;gt; Summary in the GUI but when I try to fetch the information for any of my firewall devices via Panorama object through the API I get this error about hostname. I have tried other methods for this "fw0" object too and it throws the same error. Probably I am missing something.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can someone pls guide what am I doing wrong or is it some bug?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;gt;&amp;gt;&amp;gt; pano
&amp;lt;Panorama 202.24.62.93 0x10adc3d30&amp;gt;
&amp;gt;&amp;gt;&amp;gt; devices = pano.refresh_devices(include_device_groups=False)
&amp;gt;&amp;gt;&amp;gt; devices
[&amp;lt;Firewall '007955000319973' 'vsys1' at 0x10ad29180&amp;gt;, &amp;lt;Firewall '007955000319994' 'vsys1' at 0x10ad2bca0&amp;gt;, &amp;lt;Firewall '007955000399952' 'vsys1' at 0x10a5af640&amp;gt;]
&amp;gt;&amp;gt;&amp;gt; fw0 = devices[0]
&amp;gt;&amp;gt;&amp;gt; fw0.serial
'007955000319973'
&amp;gt;&amp;gt;&amp;gt; fw0.refresh()
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/panos/firewall.py", line 253, in generate_xapi
    self.panorama()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 1132, in panorama
    raise err.PanDeviceNotSet("No Panorama set for object tree")
panos.errors.PanDeviceNotSet: No Panorama set for object tree

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "&amp;lt;stdin&amp;gt;", line 1, in &amp;lt;module&amp;gt;
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 901, in refresh
    xml = self._refresh_xml(running_config, exceptions, refresh_children)
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 1053, in _refresh_xml
    api_action = dev.xapi.show if running_config else dev.xapi.get
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4000, in xapi
    self._xapi_private = self.generate_xapi()
  File "/usr/local/lib/python3.10/site-packages/panos/firewall.py", line 255, in generate_xapi
    return super(Firewall, self).generate_xapi()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4072, in generate_xapi
    "api_key": self.api_key,
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 3994, in api_key
    self._api_key = self._retrieve_api_key()
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 4151, in _retrieve_api_key
    xapi = PanDevice.XapiWrapper(
  File "/usr/local/lib/python3.10/site-packages/panos/base.py", line 3776, in __init__
    pan.xapi.PanXapi.__init__(self, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pan/xapi.py", line 178, in __init__
    raise PanXapiError('hostname argument required')
pan.xapi.PanXapiError: hostname argument required
&amp;gt;&amp;gt;&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Nov 2022 22:43:21 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/panorama-with-pan-os-python-api/m-p/521583#M3262</guid>
      <dc:creator>mtkh</dc:creator>
      <dc:date>2022-11-17T22:43:21Z</dc:date>
    </item>
    <item>
      <title>Re: Panorama with pan-os-python API</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/panorama-with-pan-os-python-api/m-p/522644#M3269</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Have you tried adding the Firewall object to the Panorama object?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Order of operations here:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;create an object to represent our Panorama instance connection&lt;/LI&gt;
&lt;LI&gt;use this Panorama object to retrieve a list of our devices, storing them in a list&lt;/LI&gt;
&lt;LI&gt;select the correct index for your firewall within this list&lt;/LI&gt;
&lt;LI&gt;add the Firewall object to the Panorama object as a child&lt;/LI&gt;
&lt;LI&gt;execute your refresh method on the firewall object&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;You had all but the 4th step, as the error message presented:&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-markup"&gt;&lt;CODE&gt;panos.errors.PanDeviceNotSet: No Panorama set for object tree
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="example" style="width: 999px;"&gt;&lt;img src="https://live.paloaltonetworks.com/t5/image/serverpage/image-id/45721i1B52FA21BEC14A85/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999" role="button" title="2022-11-28_13-50-52.png" alt="example" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;example&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Let me know if you're still running into an issue,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calvin&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Nov 2022 19:55:42 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/panorama-with-pan-os-python-api/m-p/522644#M3269</guid>
      <dc:creator>cremsburg</dc:creator>
      <dc:date>2022-11-28T19:55:42Z</dc:date>
    </item>
  </channel>
</rss>

