<div dir="ltr">Hello! <div><br></div><div>I have a very specific question related to the output of a Vendors API (Palo Alto Networks "pan.xapi" and how I might farm data from this output. I am new to python, doing well in the tutorials, but this is an automation task at work and I know the rest will be much easier once i get past the ability to read this dict.</div><div><br></div><div>The code reaches in to the central Palo Alto firewall manager (Panorama) and executes a simple command to return all of the information for each of the managed firewalls in the field. It captured this output in XML I believe, but has the ability to return it in python dict format too, which looked like probably the best format to use. Here is the test I tried</div><div><br></div><div><snip> </div><div><div>xapi.op(cmd='show devices connected', cmd_xml=True )</div><div>MyDict=xapi.xml_python()</div><div>print (type(MyDict))<br></div></div><div>print (MyDict)</div><div><snip></div><div><br></div><div>and I get: (This displays only 2 firewalls of the 180, so you can see the structure, and that python does say it is a "dict")</div><div><br></div><div><div>bertha bin # ./test.py </div><div><class 'dict'></div><div>{'response': {'result': {'devices': {'entry': [{'av-version': '1391-1863', 'unsupported-version': False, 'ip-address': '1.8.2.8', 'sw-version': '4.1.9', 'vsys': {'entry': [{'name': 'vsys1', 'shared-policy-md5sum': '8a8dcd146e24bd750ae571059bc09210', 'shared-policy-status': None, 'display-name': 'vsys1'}]}, 'uptime': '350 days, 14:29:49', 'threat-version': '460-2394', 'operational-mode': 'normal', 'multi-vsys': False, 'global-protect-client-package-version': '0.0.0', 'app-version': '460-2394', 'model': 'PA-200', 'connected': True, 'name': '001606000002', 'family': '200', 'url-filtering-version': '4390', 'vpn-disable-mode': False, 'logdb-version': '4.1.2', 'serial': '001606000002', 'hostname': 'bob-int-fw'}, {'av-version': '1391-1863', 'unsupported-version': False, 'ip-address': '1.9.8.8', 'sw-version': '4.1.9', 'vsys': {'entry': [{'name': 'vsys1', 'shared-policy-md5sum': '8a8dcd146e24bd750ae571059bc09210', 'shared-policy-status': None, 'display-name': 'vsys1'}]}, 'uptime': '358 days, 0:03:20', 'threat-version': '460-2394', 'operational-mode': 'normal', 'multi-vsys': False, 'global-protect-client-package-version': '0.0.0', 'app-version': '460-2394', 'model': 'PA-200', 'connected': True, 'name': '001606000009', 'family': '200', 'url-filtering-version': '4390', 'vpn-disable-mode': False, 'logdb-version': '4.1.2', 'serial': '001606008639', 'hostname': 'bib-int-fw'}, <****repeats for 180 firewalls****> ]}}, 'status': 'success'}}</div></div><div><br></div><div><br></div><div>What I want is to parse through each firewall grabbing the "ip-address" value so that I can dump it to a list:</div><div><br></div><div><ip></div><div><ip></div><div><ip></div><div><br></div><div>For use in another network management tool so I don't rely on outsourced help to remember to place teh firewalls into the correct tools.<br></div><div><br></div><div>But dang if every dict tutorial seems to deal with slightly simpler looking structures than what this puts out. I would be very appreciative with help stepping out of the 6 line "address book/grocery list" example world for a taste of something useful :-)</div><div><br></div><div>Maybe to a Python coder, it maybe a simple even be able to randomly reference a firewall index number and teh value in this structure so one can easily just pluck any A/V pair at will.. just not for me yet :-D</div><div><br></div><div>Nick</div><div><br></div></div>