<?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: Using pandevice framework to create python structures from xml in Automation/API Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/239865#M1814</link>
    <description>&lt;P&gt;Hi Joe, thanks for reaching out, happy to help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I cannot automatically create a local firewall object with all of it's children.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is by intention.&amp;nbsp; You mentioned you're trying to "perform logical operations and backup services." Device Framework (pandevice) is not intended to perform backups.&amp;nbsp; This was a design decision early on because the FW and Panorama already have many reliable backup capabilities built in.&amp;nbsp; Thus, Device Framework cannot pull every object type from a device all at once.&amp;nbsp; This would be a huge operation with a lot of XML transfered and converted.&amp;nbsp; Think of accidentally ending up with a config tree containing hundreds of VSYS containing tens of thousands of policy rules each. Then imagine that tree is out of date the first time someone makes a change in the GUI or via another script. One could easily shoot themselves in the foot with that kind of operation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is easy enough to `refreshall` the objects you intend to work on right before working on them. It keeps things well synced and scoped to the work being done, so that is the best way to operate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Device Framework is intended for many use cases such as automation, configuration, and monitoring. But to perform backups, you should use the operational API calls for backups already built into the device. We'll try to clarify this in the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) I cannot create multiple local objects from an xml element without having to specify the names of all sub-elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're probably looking for the `refreshall_from_xml()` method which gets called by `refreshall()`.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pandevice.readthedocs.io/en/latest/module-base.html#pandevice.base.PanObject.refreshall_from_xml" target="_blank"&gt;https://pandevice.readthedocs.io/en/latest/module-base.html#pandevice.base.PanObject.refreshall_from_xml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This method is admitedly not as friendly as `refreshall` because it requires an instance of the class you're trying to refresh with the parent set correctly.&amp;nbsp; The `refreshall` method does this for you, so you can check out the `refreshall` method for an example of how to use `refreshall_from_xml()`:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pandevice.readthedocs.io/en/latest/_modules/pandevice/base.html#PanObject.refreshall" target="_blank"&gt;https://pandevice.readthedocs.io/en/latest/_modules/pandevice/base.html#PanObject.refreshall&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Nov 2018 15:55:22 GMT</pubDate>
    <dc:creator>btorresgil</dc:creator>
    <dc:date>2018-11-14T15:55:22Z</dc:date>
    <item>
      <title>Using pandevice framework to create python structures from xml</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/239834#M1813</link>
      <description>&lt;P&gt;I am trying to achieve two things in Pandevice and am struggling.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) I cannot automatically create a local firewall object with all of it's children.&lt;BR /&gt;I can create a fw object. I can then use it as a parent to manually refreshall the object types that are used as children. I cannot get this to work in a single function though, it looks like refresh() should do it - but it fails with an authorisation error. Has anyone been able to get this working?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) I cannot create multiple local objects from an xml element without having to specify the names of all sub-elements.&lt;BR /&gt;I would like to be able to create all local objects, say all address groups and addresses, from an xml elemtent (an xml copy of a candidate config for example). I have been able to get this working with the fw object&lt;BR /&gt;I've tried using refresh(xml=blah) but this is called on self and requires the object to exist before I can refresh from the xml. I've tried using refresh_from_xml(xml=blah) but again this seems to require reference to self - which is what i'm trying to create.&lt;/P&gt;&lt;P&gt;All of this is just with a view to being able to easily translate objects between xml output and python classes easily to allow me to perform logical operations and backup services.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 14:13:41 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/239834#M1813</guid>
      <dc:creator>joe.shepherd</dc:creator>
      <dc:date>2018-11-14T14:13:41Z</dc:date>
    </item>
    <item>
      <title>Re: Using pandevice framework to create python structures from xml</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/239865#M1814</link>
      <description>&lt;P&gt;Hi Joe, thanks for reaching out, happy to help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1) I cannot automatically create a local firewall object with all of it's children.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is by intention.&amp;nbsp; You mentioned you're trying to "perform logical operations and backup services." Device Framework (pandevice) is not intended to perform backups.&amp;nbsp; This was a design decision early on because the FW and Panorama already have many reliable backup capabilities built in.&amp;nbsp; Thus, Device Framework cannot pull every object type from a device all at once.&amp;nbsp; This would be a huge operation with a lot of XML transfered and converted.&amp;nbsp; Think of accidentally ending up with a config tree containing hundreds of VSYS containing tens of thousands of policy rules each. Then imagine that tree is out of date the first time someone makes a change in the GUI or via another script. One could easily shoot themselves in the foot with that kind of operation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is easy enough to `refreshall` the objects you intend to work on right before working on them. It keeps things well synced and scoped to the work being done, so that is the best way to operate.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Device Framework is intended for many use cases such as automation, configuration, and monitoring. But to perform backups, you should use the operational API calls for backups already built into the device. We'll try to clarify this in the documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2) I cannot create multiple local objects from an xml element without having to specify the names of all sub-elements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You're probably looking for the `refreshall_from_xml()` method which gets called by `refreshall()`.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pandevice.readthedocs.io/en/latest/module-base.html#pandevice.base.PanObject.refreshall_from_xml" target="_blank"&gt;https://pandevice.readthedocs.io/en/latest/module-base.html#pandevice.base.PanObject.refreshall_from_xml&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This method is admitedly not as friendly as `refreshall` because it requires an instance of the class you're trying to refresh with the parent set correctly.&amp;nbsp; The `refreshall` method does this for you, so you can check out the `refreshall` method for an example of how to use `refreshall_from_xml()`:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pandevice.readthedocs.io/en/latest/_modules/pandevice/base.html#PanObject.refreshall" target="_blank"&gt;https://pandevice.readthedocs.io/en/latest/_modules/pandevice/base.html#PanObject.refreshall&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 15:55:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/239865#M1814</guid>
      <dc:creator>btorresgil</dc:creator>
      <dc:date>2018-11-14T15:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Using pandevice framework to create python structures from xml</title>
      <link>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/240111#M1815</link>
      <description>&lt;P&gt;Hi btorresgil,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for coming back to me - wasn't sure i'd find anyone to talk to about the framework so this is very helpful. I should also note that the framework has been a real find for me, making my job much easier - so thanks again.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's good to know that not pulling all children was a design decision.&amp;nbsp;I hadn't read that anywhere so assumed I must have missed&amp;nbsp;some way to do this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will experiment&amp;nbsp;more with the refresh_from_xml method. A use case at the moment is to be able to populate, say, address-objects from 'show config' output. I have checked the jupyter notebook github project as well as the&amp;nbsp;online docs, but examples for this method seem thin on the ground.&amp;nbsp;Sounds like it should be easily possible with the right xpath params so&amp;nbsp;I'll see if I can figure it out - but&amp;nbsp;if you can give me a quick example of how you might call it that'd save me a few days &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Joe&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2018 09:36:21 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/automation-api-discussions/using-pandevice-framework-to-create-python-structures-from-xml/m-p/240111#M1815</guid>
      <dc:creator>joe.shepherd</dc:creator>
      <dc:date>2018-11-16T09:36:21Z</dc:date>
    </item>
  </channel>
</rss>

