@@ -16,9 +16,10 @@ apply for all the examples on this page::
1616 from pandevice import base
1717 from pandevice import firewall
1818 from pandevice import panorama
19+ from pandevice import policies
20+ from pandevice import objects
1921 from pandevice import network
2022 from pandevice import device
21- from pandevice import objects
2223
2324Create a PanDevice
2425------------------
@@ -73,7 +74,7 @@ Build the configuration tree: ``add()``, ``remove()``, ``find()``, and ``findall
7374Push changed configuration to the live device: ``apply() ``, ``create() ``,
7475and ``delete() ``
7576
76- Pull configuration from the live device: ``refresh() ``, ``refresh_all_from_device () ``
77+ Pull configuration from the live device: ``refresh() ``, ``refreshall () ``
7778
7879There are other useful methods besides these. See :class: `pandevice.base.PanObject ` for
7980more information.
@@ -126,7 +127,7 @@ device and add them into the configuration tree::
126127
127128 >>> fw.children
128129 []
129- >>> objects.AddressObject.refresh_all_from_device (fw, add=True)
130+ >>> objects.AddressObject.refreshall (fw, add=True)
130131 >>> fw.children
131132 [<pandevice.objects.AddressObject object at 0x108080e90>,
132133 <pandevice.objects.AddressObject object at 0x108080f50>,
@@ -142,6 +143,105 @@ It's also possible to refresh the variables of an existing object::
142143 >>> adserver.value
143144 "4.4.4.4"
144145
146+ Connecting with Panorama
147+ ------------------------
148+
149+ Making changes to Panorama is always done the same way, with a connection to Panorama.
150+ But, there are a different methods to make local changes to a Firewall.
151+
152+ **Method 1: Connect to the Firewall and Panorama directly **
153+
154+ When making changes to Panorama, connect to Panorama.
155+ When making changes to the Firewall, connect directly to the Firewall.
156+
157+ .. graphviz ::
158+
159+ digraph directconnect {
160+ graph [rankdir=LR, fontsize=10, margin=0.001];
161+ node [shape=box, fontsize=10, height=0.001, margin=0.1, ordering=out];
162+ "python script" -> "Panorama";
163+ "python script" -> "Firewall";
164+ Panorama [style=filled];
165+ Firewall [style=filled];
166+ }
167+
168+ This method is best in the following cases:
169+
170+ - Firewall managment IP is accessible to the script
171+ - The credentials for both devices are known
172+ - The permissions/role for the user are set on both devices
173+ - The serial of the firewall is unknown, but the management IP is known
174+
175+ To use this method:
176+
177+ 1. Create a :class: `pandevice.firewall.Firewall ` instance and a
178+ :class: `pandevice.panorama.Panorama ` instance.
179+ 2. In both instances, set the 'hostname' attribute and either the
180+ 'api_key' or the 'api_username' and 'api_password' attributes.
181+
182+ Example::
183+
184+ # Instantiate a Firewall with hostname and credentials
185+ fw = firewall.Firewall("10.0.0.1", "admin", "mypassword")
186+ # Instantiate a Panorama with hostname and credentials
187+ pano = panorama.Panorama("10.0.0.5", "admin", "mypassword")
188+ # Change to Firewall
189+ fw.add(objects.AddressObject("Server", "2.2.2.2")).create()
190+ # Change to Panorama
191+ pano.add(panorama.DeviceGroup("CustomerA")).create()
192+
193+ In this example, the address object is added to the Firewall directly, without
194+ any connection to Panorama. Then a device-group is created on Panorama directly,
195+ without any connection to the Firewall.
196+
197+ **Method 2: Connect to Firewall via Panorama **
198+
199+ When making changes to the Firewall, connect to Panorama which
200+ will proxy the connection to the Firewall. Meaning all connections
201+ are to Panorama.
202+
203+ .. graphviz ::
204+
205+ digraph directconnect {
206+ graph [rankdir=LR, fontsize=10, margin=0.001];
207+ node [shape=box, fontsize=10, height=0.001, margin=0.1, ordering=out];
208+ "pandevice script" -> "Panorama" -> "Firewall";
209+ Panorama [style=filled];
210+ Firewall [style=filled];
211+ }
212+
213+ This method is best in the following cases:
214+
215+ - The Firewall management IP is unknown or not rechable from the script
216+ - You only store one set of credentials (Panorama)
217+ - The serial of the firewall is known or can be determined from Panorama
218+
219+ To use this method:
220+
221+ 1. Create a :class: `pandevice.firewall.Firewall ` instance and a
222+ :class: `pandevice.panorama.Panorama ` instance.
223+ 2. In the Panorama instance, set the 'hostname' attribute and either the
224+ 'api_key' or the 'api_username' and 'api_password' attributes.
225+ 3. In the Firewall instance, set the 'serial' attribute.
226+ 4. Add the Firewall as a child of Panorama, or as a child of a DeviceGroup under Panorama.
227+
228+ Example::
229+
230+ # Instantiate a Firewall with serial
231+ fw = firewall.Firewall(serial="0002487YR3880")
232+ # Instantiate a Panorama with hostname and credentials
233+ pano = panorama.Panorama("10.0.0.5", "admin", "mypassword")
234+ # Add the Firewall as a child of Panorama
235+ pano.add(fw)
236+ # Change to Firewall via Panorama
237+ fw.add(objects.AddressObject("Server", "2.2.2.2")).create()
238+ # Change to Panorama directly
239+ pano.add(panorama.DeviceGroup("CustomerA")).create()
240+
241+ In this example, both changes are made with connections to Panorama. First, the
242+ address object is added to the Firewall by connecting to Panorama which proxies the
243+ API call to the Firewall. Then a device-group is created on Panorama directly.
244+
145245Working with virtual systems
146246----------------------------
147247
@@ -150,7 +250,7 @@ instance represents a single context firewall, or 'vsys1' on a multi-vsys firewa
150250
151251When working with a firewall with multi-vsys mode enabled, there are two methods to work with vsys:
152252
153- **Method 1 ** : A different Firewall instance for each vsys
253+ **Method 1: A different Firewall instance for each vsys **
154254
155255Each Firewall object has a 'vsys' attribute which is assigned the vsys id. For example::
156256
@@ -166,7 +266,7 @@ To create or delete an entire vsys, use the create_vsys() and delete_vsys() meth
166266 fw_vsys2.create_vsys()
167267 fw_vsys3.delete_vsys()
168268
169- **Method 2 ** : A single Firewall instance with Vsys child instances
269+ **Method 2: A single Firewall instance with Vsys child instances **
170270
171271Create Vsys instances and add them to a 'shared' PanDevice::
172272
0 commit comments