Skip to content

Commit 452db79

Browse files
committed
Merge branch 'release/0.3.1'
2 parents 177b15f + c8b6905 commit 452db79

File tree

16 files changed

+364
-41
lines changed

16 files changed

+364
-41
lines changed

HISTORY.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,34 @@
33
History
44
=======
55

6+
0.3.1
7+
-----
8+
9+
Released: 2016-04-12
10+
11+
Status: Alpha
12+
13+
New objects:
14+
15+
* policies.SecurityRule
16+
* objects.AddressGroup
17+
18+
API changes:
19+
20+
* Changed refresh_all to refreshall and apply_all to applyall
21+
* Added insert() method to PanObject base class
22+
23+
Fixes:
24+
25+
* Objects can now be added as children of Panorama which will make them 'shared'
26+
* Fixes for tracebacks
27+
* Minor fixes to documentation and docstrings
28+
629
0.3.0
730
-----
831

932
Released: 2016-03-30
33+
1034
Status: Alpha
1135

1236
* First release on pypi
@@ -17,6 +41,7 @@ Status: Alpha
1741
-----
1842

1943
Released: 2014-09-17
44+
2045
Status: Pre-alpha
2146

2247
* First release on github

README.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ Features
2626
- Batch User-ID operations
2727
- Device API exception classification
2828

29+
Status
30+
------
31+
32+
Palo Alto Networks Device Framework is considered **alpha**. It is fully tested
33+
and used in many production environments, but it maintains alpha status because
34+
the API interface could change at any time without notification. Please be
35+
prepared to modify your scripts to work with each subsequent version of this
36+
package because backward compatibility is not guaranteed.
37+
2938
Installation
3039
------------
3140

@@ -61,7 +70,8 @@ A few examples
6170
--------------
6271

6372
For configuration tasks, create a tree structure using the classes in
64-
each module. Nodes hierarchy must follow the :ref:`classtree`.
73+
each module. Nodes hierarchy must follow the model in the
74+
`Configuration Tree`_.
6575

6676
The following examples assume the modules were imported as such::
6777

@@ -88,6 +98,7 @@ Some operational commands have methods to refresh the variables in an object::
8898

8999

90100
.. _pan-python: http://github.com/kevinsteves/pan-python
101+
.. _Configuration Tree: http://pandevice.readthedocs.org/en/latest/configtree.html
91102

92103
.. |pypi| image:: https://img.shields.io/pypi/v/pandevice.svg
93104
:target: https://pypi.python.org/pypi/pandevice

docs/configtree.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@
3434

3535

3636
nodestyle = {
37-
'Firewall': '',
38-
'Panorama': '',
37+
#'Firewall': '',
38+
#'Panorama': '',
3939
'device': 'fillcolor=lightpink',
4040
'firewall': 'fillcolor=lightblue',
4141
'ha': 'fillcolor=lavender',
4242
'network': 'fillcolor=lightcyan',
4343
'objects': 'fillcolor=lemonchiffon',
44+
'policies': 'fillcolor=lightsalmon',
4445
'panorama': 'fillcolor=lightgreen',
4546
}
4647

docs/module-policies.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Module: policies
2+
================
3+
4+
Inheritance diagram
5+
-------------------
6+
7+
.. inheritance-diagram:: pandevice.policies
8+
:parts: 1
9+
10+
Class Reference
11+
---------------
12+
13+
.. automodule:: pandevice.policies

docs/moduleref.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
'base',
3737
'errors',
3838
'objects',
39+
'policies',
3940
'updater',
4041
'userid',
4142
]

docs/reference.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ API Reference
1818
module-network
1919
module-objects
2020
module-panorama
21+
module-policies
2122
module-updater
2223
module-userid
2324

docs/usage.rst

Lines changed: 105 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

2324
Create a PanDevice
2425
------------------
@@ -73,7 +74,7 @@ Build the configuration tree: ``add()``, ``remove()``, ``find()``, and ``findall
7374
Push changed configuration to the live device: ``apply()``, ``create()``,
7475
and ``delete()``
7576

76-
Pull configuration from the live device: ``refresh()``, ``refresh_all_from_device()``
77+
Pull configuration from the live device: ``refresh()``, ``refreshall()``
7778

7879
There are other useful methods besides these. See :class:`pandevice.base.PanObject` for
7980
more 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+
145245
Working with virtual systems
146246
----------------------------
147247

@@ -150,7 +250,7 @@ instance represents a single context firewall, or 'vsys1' on a multi-vsys firewa
150250

151251
When 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

155255
Each 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

171271
Create Vsys instances and add them to a 'shared' PanDevice::
172272

pandevice/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
__author__ = 'Brian Torres-Gil'
2626
__email__ = 'btorres-gil@paloaltonetworks.com'
27-
__version__ = '0.3.0'
27+
__version__ = '0.3.1'
2828

2929

3030
import logging

0 commit comments

Comments
 (0)