Skip to content

Commit 38d3d50

Browse files
committed
Merge branch 'release/0.13.0'
2 parents 9e85e95 + 21878c4 commit 38d3d50

File tree

8 files changed

+158
-38
lines changed

8 files changed

+158
-38
lines changed

HISTORY.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
History
44
=======
55

6+
0.13.0
7+
------
8+
9+
Released: 2019-10-29
10+
11+
Status: Alpha
12+
13+
- New flag added to examples/dyn_address_group.py to specify the vsys
14+
- Fixes to `network.AggregateInterface`
15+
- Update to version parsing to handle xfr PAN-OS releases
16+
- Fixes to Panorama commit functions
17+
- Various enhancements to HA support
18+
619
0.12.0
720
------
821

examples/dyn_address_group.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
3737
$ python dyn_address_group.py -u linux 10.0.0.1 admin password 3.3.3.3
3838
39-
Clear all tags from all IP's::
39+
Clear all tags from all IP's in vsys2::
4040
41-
$ python dyn_address_group.py -c 10.0.0.1 admin password notused notused
41+
$ python dyn_address_group_vsys.py -s vsys2 -c 10.0.0.1 admin password notused notused
4242
4343
"""
4444

@@ -64,6 +64,7 @@ def main():
6464
parser.add_argument('-q', '--quiet', action='store_true', help="No output")
6565
parser.add_argument('-r', '--register', help="Tags to register to an IP, for multiple tags use commas eg. linux,apache,server")
6666
parser.add_argument('-u', '--unregister', help="Tags to remove from an an IP, for multiple tags use commas eg. linux,apache,server")
67+
parser.add_argument('-s', '--vsys', help="Specify the vsys target in the form vsysN where N is the vsys number: vsys2, vsys4, etc.")
6768
parser.add_argument('-l', '--list', action='store_true', help="List all tags for an IP")
6869
parser.add_argument('-c', '--clear', action='store_true', help="Clear all tags for all IP")
6970
# Palo Alto Networks related arguments
@@ -105,6 +106,9 @@ def main():
105106
logging.error("Connected to a Panorama, but user-id API is not possible on Panorama. Exiting.")
106107
sys.exit(1)
107108

109+
if args.vsys is not None:
110+
device.vsys = args.vsys
111+
108112
if args.clear:
109113
device.userid.clear_registered_ip()
110114

pandevice/__init__.py

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

2424
__author__ = 'Palo Alto Networks'
2525
__email__ = '[email protected]'
26-
__version__ = '0.12.0'
26+
__version__ = '0.13.0'
2727

2828

2929
import logging

pandevice/base.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3797,8 +3797,10 @@ def _save_system_info(self, system_info):
37973797
def _set_version_and_version_info(self, version):
37983798
"""Sets the version and the specially formatted versioning version."""
37993799
self.version = version
3800-
self._version_info = tuple(int(x) for x in
3801-
self.version.split('-')[0].split('.'))
3800+
# Example PAN-OS versions: 9.0.3-h1, 9.0.3.xfr
3801+
tokens = self.version.split('.')[:3]
3802+
tokens[2] = tokens[2].split('-')[0]
3803+
self._version_info = tuple(int(x) for x in tokens)
38023804

38033805
def refresh_version(self):
38043806
"""Refresh version of PAN-OS

pandevice/firewall.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ def show_system_resources(self):
367367
pan_device=self)
368368

369369
def commit_device_and_network(self, sync=False, exception=False):
370-
return self._commit(sync=sync, exclude="device-and-network",
370+
return self._commit(sync=sync, exclude="policy-and-objects",
371371
exception=exception)
372372

373373
def commit_policy_and_objects(self, sync=False, exception=False):
374-
return self._commit(sync=sync, exclude="policy-and-objects",
374+
return self._commit(sync=sync, exclude="device-and-network",
375375
exception=exception)
376376

377377
def organize_into_vsys(self, create_vsys_objects=True, refresh_vsys=True):

pandevice/ha.py

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ class HA3(HighAvailabilityInterface):
255255
256256
Args:
257257
port (str): Interface to use for this HA interface (eg. ethernet1/5)
258+
link_speed (str): Link speed
259+
link_duplex (str): Link duplex
258260
259261
"""
260262
XPATH = "/interface/ha3"
@@ -263,6 +265,8 @@ class HA3(HighAvailabilityInterface):
263265
def variables(cls):
264266
return (
265267
Var("port"),
268+
Var("link_speed"),
269+
Var("link_duplex"),
266270
)
267271

268272

@@ -284,6 +288,14 @@ class HighAvailability(VersionedPanObject):
284288
ha2_keepalive (bool): Enable HA2 keepalives
285289
ha2_keepalive_action (str): HA2 keepalive action
286290
ha2_keepalive_threshold (int): HA2 keepalive threshold
291+
peer_ip_backup (str): HA Peer's HA1 backup IP address
292+
device_id (int): HA3 device id (0 or 1)
293+
session_owner_selection (str): active-active session owner mode
294+
session_setup (str): active-active session setup mode
295+
tentative_hold_time (int): active-active tentative hold timer
296+
sync_qos (bool): active-active network sync qos
297+
sync_virtual_router (bool): active-active network sync virtual router
298+
ip_hash_key (str): active-active hash key used by ip-hash algorithm
287299
288300
"""
289301
ROOT = Root.DEVICE
@@ -377,7 +389,74 @@ def _setup(self):
377389
'8.1.0',
378390
vartype='int',
379391
path='group/state-synchronization/ha2-keep-alive/threshold')
380-
392+
params.append(VersionedParamPath(
393+
'peer_ip_backup', path='group/entry group_id/peer-ip-backup'))
394+
params[-1].add_profile(
395+
'8.1.0',
396+
path='group/peer-ip-backup')
397+
params.append(VersionedParamPath(
398+
'device_id', condition={'mode': 'active-active'},
399+
values=(0, 1), vartype='int',
400+
path='group/entry group_id/mode/{mode}/device-id'))
401+
params[-1].add_profile(
402+
'8.1.0',
403+
condition={'mode': 'active-active'},
404+
values=(0, 1), vartype='int',
405+
path='group/mode/{mode}/device-id')
406+
params.append(VersionedParamPath(
407+
'session_owner_selection',
408+
condition={'mode': 'active-active', 'session_owner_selection': 'primary-device'},
409+
values=('primary-device', 'first-packet'),
410+
path='group/entry group_id/mode/{mode}/session-owner-selection/{session_owner_selection}'))
411+
params[-1].add_profile(
412+
'8.1.0',
413+
condition={'mode': 'active-active', 'session_owner_selection': 'primary-device'},
414+
values=('primary-device', 'first-packet'),
415+
path='group/mode/{mode}/session-owner-selection/{session_owner_selection}')
416+
params.append(VersionedParamPath(
417+
'session_setup',
418+
condition={'mode': 'active-active', 'session_owner_selection': 'first-packet'},
419+
values=('first-packet', 'ip-modulo', 'ip-hash', 'primary-device'),
420+
path='group/entry group_id/mode/{mode}/session-owner-selection/first-packet/session-setup/{session_setup}'))
421+
params[-1].add_profile(
422+
'8.1.0',
423+
condition={'mode': 'active-active', 'session_owner_selection': 'first-packet'},
424+
values=('first-packet', 'ip-modulo', 'ip-hash', 'primary-device'),
425+
path='group/mode/{mode}/session-owner-selection/first-packet/session-setup/{session_setup}')
426+
params.append(VersionedParamPath(
427+
'tentative_hold_time',
428+
condition={'mode': 'active-active'}, vartype='int',
429+
path='group/entry group_id/mode/{mode}/tentative-hold-time'))
430+
params[-1].add_profile(
431+
'8.1.0',
432+
condition={'mode': 'active-active'}, vartype='int',
433+
path='group/mode/{mode}/tentative-hold-time')
434+
params.append(VersionedParamPath(
435+
'sync_qos',
436+
condition={'mode': 'active-active'}, vartype='yesno',
437+
path='group/entry group_id/mode/{mode}/network-configuration/sync/qos'))
438+
params[-1].add_profile(
439+
'8.1.0',
440+
condition={'mode': 'active-active'}, vartype='yesno',
441+
path='group/mode/{mode}/network-configuration/sync/qos')
442+
params.append(VersionedParamPath(
443+
'sync_virtual_router',
444+
condition={'mode': 'active-active'}, vartype='yesno',
445+
path='group/entry group_id/mode/{mode}/network-configuration/sync/virtual-router'))
446+
params[-1].add_profile(
447+
'8.1.0',
448+
condition={'mode': 'active-active'}, vartype='yesno',
449+
path='group/mode/{mode}/network-configuration/sync/virtual-router')
450+
params.append(VersionedParamPath(
451+
'ip_hash_key',
452+
condition={'mode': 'active-active', 'session_owner_selection': 'first-packet', 'session_setup': 'ip-hash'},
453+
values=('source', 'source-and-destination'),
454+
path='group/entry group_id/mode/{mode}/session-owner-selection/first-packet/session-setup/{session_setup}/hash-key'))
455+
params[-1].add_profile(
456+
'8.1.0',
457+
condition={'mode': 'active-active', 'session_owner_selection': 'first-packet', 'session_setup': 'ip-hash'},
458+
values=('source', 'source-and-destination'),
459+
path='group/mode/{mode}/session-owner-selection/first-packet/session-setup/{session_setup}/hash-key')
381460
self._params = tuple(params)
382461

383462
# stubs

pandevice/network.py

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,30 +1099,29 @@ class AggregateInterface(PhysicalInterface):
10991099
* layer3
11001100
* layer2
11011101
* virtual-wire
1102-
* tap
11031102
* ha
1104-
* decrypt-mirror
1105-
* aggregate-group
11061103
11071104
Not all modes apply to all interface types (Default: layer3)
11081105
11091106
ip (tuple): Layer3: Interface IPv4 addresses
11101107
ipv6_enabled (bool): Layer3: IPv6 Enabled (requires
11111108
IPv6Address child object)
1112-
management_profile (ManagementProfile): Layer3: Interface Management
1113-
Profile
1109+
management_profile (ManagementProfile): Layer3: Interface Management Profile
11141110
mtu(int): Layer3: MTU for interface
11151111
adjust_tcp_mss (bool): Layer3: Adjust TCP MSS
11161112
netflow_profile (NetflowProfile): Netflow profile
1117-
lldp_enabled (bool): Layer2: Enable LLDP
1118-
lldp_profile (str): Layer2: Reference to an lldp profile
1119-
netflow_profile_l2 (NetflowProfile): Netflow profile
1113+
lldp_enabled (bool): Enable LLDP
1114+
lldp_profile (str): Reference to an lldp profile
11201115
comment (str): The interface's comment
1121-
ipv4_mss_adjust(int): TCP MSS adjustment for ipv4
1122-
ipv6_mss_adjust(int): TCP MSS adjustment for ipv6
1116+
ipv4_mss_adjust(int): Layer3: TCP MSS adjustment for ipv4
1117+
ipv6_mss_adjust(int): Layer3: TCP MSS adjustment for ipv6
11231118
enable_dhcp (bool): Enable DHCP on this interface
1124-
create_dhcp_default_route (bool): Create default route pointing to default gateway provided by server
1125-
dhcp_default_route_metric (int): Metric for the DHCP default route
1119+
create_dhcp_default_route (bool): Layer3: Create default route pointing to default gateway provided by server
1120+
dhcp_default_route_metric (int): Layer3: Metric for the DHCP default route
1121+
lacp_enable (bool): Enables LACP
1122+
lacp_passive_pre_negotiation (bool): Enable LACP passive pre-negotiation, off by default
1123+
lacp_rate (str): Set LACP transmission-rate to 'fast' or 'slow'
1124+
lacp_mode (str): Set LACP mode to 'active' or 'passive'
11261125
11271126
"""
11281127
ALLOW_SET_VLAN = True
@@ -1149,42 +1148,49 @@ def _setup(self):
11491148
params.append(VersionedParamPath(
11501149
'mode', path='{mode}', default='layer3',
11511150
values=[
1152-
'layer3', 'layer2', 'virtual-wire', 'tap',
1153-
'ha', 'decrypt-mirror', 'aggregate-group',
1151+
'layer3', 'layer2', 'virtual-wire', 'ha',
11541152
]))
11551153
params.append(VersionedParamPath(
1156-
'ip', path='ip', vartype='entry'))
1154+
'ip', condition={'mode': 'layer3'},
1155+
path='{mode}/ip', vartype='entry'))
11571156
params.append(VersionedParamPath(
1158-
'ipv6_enabled', path='ipv6/enabled', vartype='yesno'))
1157+
'ipv6_enabled', condition={'mode': 'layer3'},
1158+
path='{mode}/ipv6/enabled', vartype='yesno'))
11591159
params.append(VersionedParamPath(
1160-
'management_profile', path='interface-management-profile'))
1160+
'management_profile', condition={'mode': ['layer3', 'layer2']},
1161+
path='{mode}/interface-management-profile'))
11611162
params.append(VersionedParamPath(
1162-
'mtu', path='mtu', vartype='int'))
1163+
'mtu', condition={'mode': 'layer3'},
1164+
path='{mode}/mtu', vartype='int'))
11631165
params.append(VersionedParamPath(
1164-
'adjust_tcp_mss', path='adjust-tcp-mss', vartype='yesno'))
1166+
'adjust_tcp_mss', condition={'mode': 'layer3'},
1167+
path='{path}/adjust-tcp-mss/enable', vartype='yesno'))
11651168
params[-1].add_profile(
11661169
'7.1.0',
1167-
vartype='yesno', path='adjust-tcp-mss/enable')
1168-
params.append(VersionedParamPath(
1169-
'netflow_profile', path='netflow-profile'))
1170+
condition={'mode': 'layer3'},
1171+
vartype='yesno', path='{mode}/adjust-tcp-mss/enable')
11701172
params.append(VersionedParamPath(
1171-
'lldp_enabled', path='lldp/enable', vartype='yesno'))
1173+
'netflow_profile',
1174+
condition={'mode': ['layer3', 'layer2', 'vwire']},
1175+
path='{mode}/netflow-profile'))
11721176
params.append(VersionedParamPath(
1173-
'lldp_profile', path='lldp/profile'))
1177+
'lldp_enabled', condition={'mode': ['layer3', 'layer2', 'vwire']},
1178+
path='{mode}/lldp/enable', vartype='yesno'))
11741179
params.append(VersionedParamPath(
1175-
'netflow_profile_l2', path='netflow-profile'))
1180+
'lldp_profile', condition={'mode': ['layer3', 'layer2', 'vwire']},
1181+
path='{mode}/lldp/profile'))
11761182
params.append(VersionedParamPath(
11771183
'comment', path='comment'))
11781184
params.append(VersionedParamPath(
11791185
'ipv4_mss_adjust', exclude=True))
11801186
params[-1].add_profile(
1181-
'7.1.0',
1182-
path='adjust-tcp-mss/ipv4-mss-adjustment', vartype='int')
1187+
'7.1.0', condition={'mode': 'layer3'},
1188+
path='{mode}/adjust-tcp-mss/ipv4-mss-adjustment', vartype='int')
11831189
params.append(VersionedParamPath(
11841190
'ipv6_mss_adjust', exclude=True))
11851191
params[-1].add_profile(
1186-
'7.1.0',
1187-
path='adjust-tcp-mss/ipv6-mss-adjustment', vartype='int')
1192+
'7.1.0', condition={'mode': 'layer3'},
1193+
path='{mode}/adjust-tcp-mss/ipv6-mss-adjustment', vartype='int')
11881194
params.append(VersionedParamPath(
11891195
'enable_dhcp', path='{mode}/dhcp-client/enable',
11901196
vartype='yesno', condition={'mode': 'layer3'}))
@@ -1196,6 +1202,22 @@ def _setup(self):
11961202
'dhcp_default_route_metric',
11971203
path='{mode}/dhcp-client/default-route-metric',
11981204
vartype='int', condition={'mode': 'layer3'}))
1205+
params.append(VersionedParamPath(
1206+
'lacp_enable',
1207+
condition={'mode': ['layer3', 'layer2', 'ha']},
1208+
vartype='yesno', path='{mode}/lacp/enable'))
1209+
params.append(VersionedParamPath(
1210+
'lacp_passive_pre_negotiation',
1211+
condition={'mode': ['layer3', 'layer2', 'ha'], 'lacp_enable': True},
1212+
vartype='yesno', path='{mode}/lacp/passive-pre-negotiation'))
1213+
params.append(VersionedParamPath(
1214+
'lacp_mode',
1215+
condition={'mode': ['layer3', 'layer2', 'ha'], 'lacp_enable': True},
1216+
values=['active', 'passive'], path='{mode}/lacp/mode'))
1217+
params.append(VersionedParamPath(
1218+
'lacp_rate',
1219+
condition={'mode': ['layer3', 'layer2', 'ha'], 'lacp_enable': True},
1220+
values=['fast', 'slow'], path='{mode}/lacp/transmission-rate'))
11991221

12001222
self._params = tuple(params)
12011223

setup.py

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

2424
setup_kwargs = dict(
2525
name='pandevice',
26-
version='0.12.0',
26+
version='0.13.0',
2727
description='Framework for interacting with Palo Alto Networks devices via API',
2828
long_description='The Palo Alto Networks Device Framework is a way to interact with Palo Alto Networks devices (including Next-generation Firewalls and Panorama) using the device API that is object oriented and conceptually similar to interaction with the device via the GUI or CLI.',
2929
author='Palo Alto Networks',

0 commit comments

Comments
 (0)