Skip to content

Commit aca38f1

Browse files
committed
Merge branch 'release/0.9.1'
2 parents 4676eea + 4769595 commit aca38f1

File tree

4 files changed

+43
-5
lines changed

4 files changed

+43
-5
lines changed

HISTORY.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,22 @@
33
History
44
=======
55

6-
0.9.1
6+
0.9.2
77
-----
88

99
Released: Pending
1010

1111
Status: Alpha
1212

13+
0.9.1
14+
-----
15+
16+
Released: 2019-04-24
17+
18+
Status: Alpha
19+
20+
- Added additional handling for authcode activation responses from PAN-OS.
21+
1322
0.9.0
1423
-----
1524

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.9.0'
26+
__version__ = '0.9.1'
2727

2828

2929
import logging

pandevice/base.py

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4653,8 +4653,37 @@ def activate_feature_using_authorization_code(self, code):
46534653
Raises:
46544654
PanActivateFeatureAuthCodeError
46554655
"""
4656-
result = self.op('request license fetch auth-code "{0}"'.format(
4657-
code))
4656+
try:
4657+
result = self.op('request license fetch auth-code "{0}"'.format(code))
4658+
except pan.xapi.PanXapiError as e:
4659+
'''
4660+
pan-python can handle both XML responses & plaintext responses from
4661+
a PAN-OS, and it makes this determination based on headers that are
4662+
sent back from any given action. Raw XML text returned is stored
4663+
in pan.xapi.PanXapi.xml_document, and the raw plain text is stored
4664+
in pan.xapi.PanXapi.text_document.
4665+
4666+
When it comes to licensing, it's been observed that PAN-OS can
4667+
send back a response with Content-Type: application/xml, but the
4668+
content isn't actually XML, it's plain text. When this happens,
4669+
pan-python wraps the xml.etree.ElementTree error and returns
4670+
a PanXapiError instead that mentions the parsing problem.
4671+
4672+
So, check the not-actually-XML response sent back to see if the
4673+
licensing operation was actually successful.
4674+
'''
4675+
err_msg = '{0}'.format(e)
4676+
if err_msg.startswith('ElementTree.fromstring ParseError:'):
4677+
acceptable_errors = (
4678+
'VM Device License installed. Restarting pan services.',
4679+
)
4680+
for msg in acceptable_errors:
4681+
if msg in self.xapi.xml_document:
4682+
return
4683+
raise pan.xapi.PanXapiError('{0} | xml_document={1}'.format(
4684+
err_msg, self.xapi.xml_document))
4685+
else:
4686+
raise
46584687

46594688
if result.attrib.get('status') != 'success':
46604689
raise err.PanActivateFeatureAuthCodeError(

setup.py

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

2424
setup(
2525
name='pandevice',
26-
version='0.9.0',
26+
version='0.9.1',
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)