<?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: Can we get master key expiration via API? in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/435357#M2786</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/4294"&gt;@JimmyHolland&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Indeed I took your advice, read up on pan-os-python and tested a few scripts out.&amp;nbsp; So far so good.&amp;nbsp; I even read up on&amp;nbsp;ElementTree (if only I knew what I was getting myself into before accepting this task lol).&amp;nbsp; I have one question related to this which I was unable to find searching the community.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can create a bash script to pull the list of devices from Panorama and then loop through that list to pull the master key from each device.&amp;nbsp; However, I will need this all integrated with other scripts eventually so I need to do the same with Python.&amp;nbsp; I was able to get the list of devices in Panorama and loop through them, but in the loop I have to log into each device separately to pass the OP command.&amp;nbsp; I'm sure there's a way to do it directly through Panorama like with the curl command, except I can't seem to figure this out.&amp;nbsp; This is how my code looks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pano = Panorama( {{ip-address}}, {{username}}, {{password}} )
devices = pano.refresh_devices(include_device_groups=False)

for device in devices:
    fw = Firewall( {{ip-address}}, {{username}}, {{password}} )
    system_settings = device.find("", SystemSettings)
    mk = fw.op('show system masterkey-properties')
    print('%s \t %s' %(system_settings.hostname, mk[0].find('expire-at').text))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that both variables 'device' and 'fw' are firewall objects, so I would have thought I could just do mk = device.op('show system masterkey properties') but when I do it spits out the below error.&amp;nbsp; Would anyone have some feedback on this?&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;PanXapiError: hostname argument required&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 21:17:55 GMT</pubDate>
    <dc:creator>Steven_Lowry</dc:creator>
    <dc:date>2021-09-20T21:17:55Z</dc:date>
    <item>
      <title>Can we get master key expiration via API?</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434138#M2781</link>
      <description>&lt;P&gt;Hi, I am just starting to explore pan-python and was wondering if there was a way to pull master key details (like expiration date) via the API, whether from Panorama or on an individual firewall?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:25:52 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434138#M2781</guid>
      <dc:creator>Steven_Lowry</dc:creator>
      <dc:date>2021-09-15T12:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get master key expiration via API?</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434159#M2782</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/179794"&gt;@Steven_Lowry&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;First an FYI, &lt;STRONG&gt;pan-os-python&lt;/STRONG&gt; is the successor to &lt;STRONG&gt;pan-python&lt;/STRONG&gt;, and is your best resource for your Python work:&amp;nbsp;&lt;A href="https://github.com/PaloAltoNetworks/pan-os-python" target="_blank"&gt;https://github.com/PaloAltoNetworks/pan-os-python&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can call the API directly, targeting Panorama or an NGFW, to get that device's master key details:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;https://{{host}}/api/?key={{key}}&amp;amp;type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;system&amp;gt;&amp;lt;masterkey-properties/&amp;gt;&amp;lt;/system&amp;gt;&amp;lt;/show&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-offset-key="dvvnf-4-0"&gt;You can also target Panorama to get a managed NGFW's master key details, if you can't or don't want to target the NGFW directly:&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;https://{{host}}/api/?key={{key}}&amp;amp;type=op&amp;amp;cmd=&amp;lt;show&amp;gt;&amp;lt;system&amp;gt;&amp;lt;masterkey-properties/&amp;gt;&amp;lt;/system&amp;gt;&amp;lt;/show&amp;gt;&amp;amp;target={{ngfw-serial-number}}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Both the API calls above are examples of "op" (operational) commands. Within pan-os-python, op commands can be executed from the base module: &lt;A href="https://pan-os-python.readthedocs.io/en/latest/module-base.html#panos.base.PanDevice.op" target="_blank"&gt;https://pan-os-python.readthedocs.io/en/latest/module-base.html#panos.base.PanDevice.op&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 13:01:43 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434159#M2782</guid>
      <dc:creator>JimmyHolland</dc:creator>
      <dc:date>2021-09-15T13:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get master key expiration via API?</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434173#M2783</link>
      <description>&lt;P&gt;Wow, this is very helpful, thank you so much I will give this a try &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 13:11:14 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/434173#M2783</guid>
      <dc:creator>Steven_Lowry</dc:creator>
      <dc:date>2021-09-15T13:11:14Z</dc:date>
    </item>
    <item>
      <title>Re: Can we get master key expiration via API?</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/435357#M2786</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://live.paloaltonetworks.com/t5/user/viewprofilepage/user-id/4294"&gt;@JimmyHolland&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Indeed I took your advice, read up on pan-os-python and tested a few scripts out.&amp;nbsp; So far so good.&amp;nbsp; I even read up on&amp;nbsp;ElementTree (if only I knew what I was getting myself into before accepting this task lol).&amp;nbsp; I have one question related to this which I was unable to find searching the community.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can create a bash script to pull the list of devices from Panorama and then loop through that list to pull the master key from each device.&amp;nbsp; However, I will need this all integrated with other scripts eventually so I need to do the same with Python.&amp;nbsp; I was able to get the list of devices in Panorama and loop through them, but in the loop I have to log into each device separately to pass the OP command.&amp;nbsp; I'm sure there's a way to do it directly through Panorama like with the curl command, except I can't seem to figure this out.&amp;nbsp; This is how my code looks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;pano = Panorama( {{ip-address}}, {{username}}, {{password}} )
devices = pano.refresh_devices(include_device_groups=False)

for device in devices:
    fw = Firewall( {{ip-address}}, {{username}}, {{password}} )
    system_settings = device.find("", SystemSettings)
    mk = fw.op('show system masterkey-properties')
    print('%s \t %s' %(system_settings.hostname, mk[0].find('expire-at').text))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see that both variables 'device' and 'fw' are firewall objects, so I would have thought I could just do mk = device.op('show system masterkey properties') but when I do it spits out the below error.&amp;nbsp; Would anyone have some feedback on this?&amp;nbsp; Thank you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;PanXapiError: hostname argument required&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 21:17:55 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/can-we-get-master-key-expiration-via-api/m-p/435357#M2786</guid>
      <dc:creator>Steven_Lowry</dc:creator>
      <dc:date>2021-09-20T21:17:55Z</dc:date>
    </item>
  </channel>
</rss>

