Hi,
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 > Managed Devices > 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.
Can someone pls guide what am I doing wrong or is it some bug?
>>> pano
<Panorama 202.24.62.93 0x10adc3d30>
>>> devices = pano.refresh_devices(include_device_groups=False)
>>> devices
[<Firewall '007955000319973' 'vsys1' at 0x10ad29180>, <Firewall '007955000319994' 'vsys1' at 0x10ad2bca0>, <Firewall '007955000399952' 'vsys1' at 0x10a5af640>]
>>> fw0 = devices[0]
>>> fw0.serial
'007955000319973'
>>> 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 "<stdin>", line 1, in <module>
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
>>>