Skip to content

Commit 9e85e95

Browse files
committed
Merge branch 'release/0.12.0'
2 parents d35e285 + a5a59c2 commit 9e85e95

File tree

10 files changed

+189
-31
lines changed

10 files changed

+189
-31
lines changed

HISTORY.rst

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

6+
0.12.0
7+
------
8+
9+
Released: 2019-09-24
10+
11+
Status: Alpha
12+
13+
New Classes:
14+
15+
- `panorama.TemplateVariable`
16+
17+
Other updates:
18+
19+
- New params added to ethernet interfaces
20+
- Fixed `show_system_resources()` for PAN-OS 9.0+
21+
- Added `.rename()` to rename objects.
22+
- Documentation fixes
23+
- Various bug fixes
24+
625
0.11.1
726
------
827

docs/conf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
master_doc = 'index'
6969

7070
# General information about the project.
71-
project = u'Palo Alto Networks Device Framework'
72-
copyright = u'2014, Brian Torres-Gil'
71+
project = 'Palo Alto Networks Device Framework'
72+
copyright = '2014, Brian Torres-Gil'
7373

7474
# The version info for the project you're documenting, acts as replacement
7575
# for |version| and |release|, also used in various other places throughout
@@ -226,8 +226,8 @@
226226
# [howto/manual]).
227227
latex_documents = [
228228
('index', 'pandevice.tex',
229-
u'Palo Alto Networks Device Framework Documentation',
230-
u'Brian Torres-Gil', 'manual'),
229+
'Palo Alto Networks Device Framework Documentation',
230+
'Brian Torres-Gil', 'manual'),
231231
]
232232

233233
# The name of an image file (relative to this directory) to place at
@@ -257,8 +257,8 @@
257257
# (source start file, name, description, authors, manual section).
258258
man_pages = [
259259
('index', 'pandevice',
260-
u'Palo Alto Networks Device Framework Documentation',
261-
[u'Brian Torres-Gil'], 1)
260+
'Palo Alto Networks Device Framework Documentation',
261+
['Brian Torres-Gil'], 1)
262262
]
263263

264264
# If true, show URL addresses after external links.
@@ -272,8 +272,8 @@
272272
# dir menu entry, description, category)
273273
texinfo_documents = [
274274
('index', 'pandevice',
275-
u'Palo Alto Networks Device Framework Documentation',
276-
u'Brian Torres-Gil',
275+
'Palo Alto Networks Device Framework Documentation',
276+
'Brian Torres-Gil',
277277
'pandevice',
278278
'One line description of project.',
279279
'Miscellaneous'),

docs/configtree.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@
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',
4444
'policies': 'fillcolor=lightsalmon',
45-
'panorama': 'fillcolor=lightgreen',
45+
'panorama': 'fillcolor=darkseagreen2',
4646
}
4747

4848

@@ -145,7 +145,7 @@ def create_object_diagram(directory=None):
145145
if directory is not None:
146146
mkdir_p(directory)
147147
path = directory + "/"
148-
for module, lines in output.iteritems():
148+
for module, lines in output.items():
149149
if not lines:
150150
continue
151151
moduleout = "".join(lines)

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.11.1'
26+
__version__ = '0.12.0'
2727

2828

2929
import logging

pandevice/base.py

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class PanObject(object):
6969
CHILDTYPES = ()
7070
CHILDMETHODS = ()
7171
HA_SYNC = True
72+
TEMPLATE_NATIVE = False
7273

7374
def __init__(self, *args, **kwargs):
7475
# Set the 'name' variable
@@ -315,12 +316,13 @@ def xpath(self, root=None):
315316
label = p.VSYS_LABEL
316317
vsys = p.vsys
317318
elif p.__class__.__name__ in ('Template', 'TemplateStack'):
318-
# Hit a template, make sure that the appropriate /config/...
319-
# xpath has been saved.
320-
if not path[0].startswith('/config/'):
321-
path.insert(0, self.xpath_root(root, vsys, label))
322-
vsys = p.vsys
323-
root = p.ROOT
319+
if not self.TEMPLATE_NATIVE:
320+
# Hit a template, make sure that the appropriate /config/...
321+
# xpath has been saved.
322+
if not path[0].startswith('/config/'):
323+
path.insert(0, self.xpath_root(root, vsys, label))
324+
vsys = p.vsys
325+
root = p.ROOT
324326

325327
return ''.join(path)
326328

@@ -630,6 +632,26 @@ def update(self, variable):
630632
device.xapi.edit(xpath, ET.tostring(element, encoding='utf-8'),
631633
retry_on_peer=self.HA_SYNC)
632634

635+
def rename(self, new_name):
636+
"""Change the name of this object.
637+
638+
**Modifies the live device**
639+
640+
NOTE: This does not change any references that may exist in your
641+
pandevice object hierarchy, but it does update the name of the
642+
object itself.
643+
644+
Args:
645+
new_name (str): The new UID for this object.
646+
647+
"""
648+
dev = self.nearest_pandevice()
649+
logger.debug('{0}: rename called on {1} object "{2}"'.format(
650+
dev.id, type(self), self.uid))
651+
dev.set_config_changed()
652+
dev.xapi.rename(self.xpath(), new_name)
653+
setattr(self, self.NAME, new_name)
654+
633655
def move(self, location, ref=None, update=True):
634656
"""Moves the current object.
635657
@@ -4204,29 +4226,34 @@ def config_synced(self):
42044226

42054227
# Commit methods
42064228

4207-
def commit(self, sync=False, exception=False, cmd=None):
4229+
def commit(self, sync=False, exception=False, cmd=None, admins=None):
42084230
"""Trigger a commit
42094231
42104232
Args:
42114233
sync (bool): Block until the commit is finished (Default: False)
42124234
exception (bool): Create an exception on commit errors (Default: False)
42134235
cmd (str): Commit options in XML format
4236+
admins (str/list): name or list of admins whose changes need to be committed
42144237
42154238
Returns:
42164239
dict: Commit results
42174240
42184241
"""
42194242
self._logger.debug("Commit initiated on device: %s" % (self.id,))
4220-
return self._commit(sync=sync, exception=exception, cmd=cmd)
4243+
return self._commit(sync=sync, exception=exception, cmd=cmd, admins=admins)
42214244

42224245
def _commit(self, cmd=None, exclude=None, commit_all=False,
4223-
sync=False, sync_all=False, exception=False):
4246+
sync=False, sync_all=False, exception=False, admins=None):
42244247
"""Internal use commit helper method.
42254248
42264249
:param exclude:
42274250
Can be:
42284251
device-and-network
42294252
policy-and-objects
4253+
4254+
:param admins:
4255+
string or list containing specific admin user(s) whose changes need to be committed
4256+
42304257
:param sync:
42314258
Synchronous commit, ie. wait for job to finish
42324259
:return:
@@ -4247,10 +4274,18 @@ def _commit(self, cmd=None, exclude=None, commit_all=False,
42474274
pass
42484275
else:
42494276
cmd = ET.Element("commit")
4250-
if exclude is not None:
4251-
excluded = ET.SubElement(cmd, "partial")
4252-
excluded = ET.SubElement(excluded, exclude)
4277+
if exclude is not None or admins is not None:
4278+
partial = ET.SubElement(cmd,"partial")
4279+
if admins is not None:
4280+
partial_admin = ET.SubElement(partial, "admin")
4281+
admins = pandevice.string_or_list(admins)
4282+
for admin in admins:
4283+
admin_xml = ET.SubElement(partial_admin, "member")
4284+
admin_xml.text = admin
4285+
if exclude is not None:
4286+
excluded = ET.SubElement(partial, exclude)
42534287
cmd = ET.tostring(cmd, encoding='utf-8')
4288+
42544289
logger.debug(self.id + ": commit requested: commit_all:%s sync:%s sync_all:%s cmd:%s" % (str(commit_all),
42554290
str(sync),
42564291
str(sync_all),
@@ -4268,6 +4303,7 @@ def _commit(self, cmd=None, exclude=None, commit_all=False,
42684303
timeout=self.timeout,
42694304
retry_on_peer=True,
42704305
)
4306+
42714307
# Set locks off
42724308
self.config_changed = []
42734309
self.config_locked = False

pandevice/firewall.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,10 @@ def refreshall_from_xml(self, xml, refresh_children=False, variables=None):
347347
def show_system_resources(self):
348348
self.xapi.op(cmd="show system resources", cmd_xml=True)
349349
result = self.xapi.xml_root()
350-
regex = re.compile(r"load average: ([\d.]+).* ([\d.]+)%id.*Mem:.*?([\d.]+)k total.*?([\d]+)k free", re.DOTALL)
350+
if self._version_info >= (9, 0, 0):
351+
regex = re.compile(r'load average: ([\d\.]+).*? ([\d\.]+) id,.*KiB Mem : (\d+) total,.*? (\d+) free', re.DOTALL)
352+
else:
353+
regex = re.compile(r"load average: ([\d.]+).* ([\d.]+)%id.*Mem:.*?([\d.]+)k total.*?([\d]+)k free", re.DOTALL)
351354
match = regex.search(result)
352355
if match:
353356
"""

pandevice/network.py

Lines changed: 58 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,10 @@ def set_virtual_router(self, virtual_router_name, refresh=False,
352352
Zone: The zone for this interface after the operation completes
353353
354354
"""
355+
# Don't add HA or aggregate-group interfaces to virtual router.
356+
if getattr(self, 'mode', '') in ('ha', 'aggregate-group'):
357+
return False
358+
355359
return self._set_reference(
356360
virtual_router_name, VirtualRouter, "interface", 'list',
357361
True, refresh, update, running_config, return_type, False)
@@ -739,6 +743,7 @@ class Layer3Subinterface(Subinterface):
739743
enable_dhcp (bool): Enable DHCP on this interface
740744
create_dhcp_default_route (bool): Create default route pointing to default gateway provided by server
741745
dhcp_default_route_metric (int): Metric for the DHCP default route
746+
decrypt_forward (bool): (PAN-OS 8.1+) Decrypt forward.
742747
743748
"""
744749
DEFAULT_MODE = 'layer3'
@@ -805,6 +810,11 @@ def _setup(self):
805810
params.append(VersionedParamPath(
806811
'dhcp_default_route_metric',
807812
path='dhcp-client/default-route-metric', vartype='int'))
813+
params.append(VersionedParamPath(
814+
'decrypt_forward', vartype='yesno', exclude=True))
815+
params[-1].add_profile(
816+
'8.1.0',
817+
vartype='yesno', path='decrypt-forward')
808818

809819
self._params = tuple(params)
810820

@@ -933,11 +943,19 @@ class EthernetInterface(PhysicalInterface):
933943
link_state (str): Link state: eg. auto, up, down
934944
aggregate_group (str): Aggregate interface (eg. ae1)
935945
comment (str): The interface's comment
936-
ipv4_mss_adjust(int): TCP MSS adjustment for ipv4
937-
ipv6_mss_adjust(int): TCP MSS adjustment for ipv6
946+
ipv4_mss_adjust(int): (PAN-OS 7.1+) TCP MSS adjustment for ipv4
947+
ipv6_mss_adjust(int): (PAN-OS 7.1+) TCP MSS adjustment for ipv6
938948
enable_dhcp (bool): Enable DHCP on this interface
939949
create_dhcp_default_route (bool): Create default route pointing to default gateway provided by server
940950
dhcp_default_route_metric (int): Metric for the DHCP default route
951+
enable_untagged_subinterface (bool): (PAN-OS 7.1+) Enable untagged
952+
subinterface
953+
decrypt_forward (bool): (PAN-OS 8.1+) Decrypt forward.
954+
rx_policing_rate (int): (PAN-OS 8.1+) Receive policing rate
955+
tx_policing_rate (int): (PAN-OS 8.1+) Transmit policing rate
956+
dhcp_send_hostname_enable (bool): Enable send firewall or custom hostname
957+
to DHCP server
958+
dhcp_send_hostname_value (string): Set interface hostname
941959
942960
"""
943961
ALLOW_SET_VLAN = True
@@ -991,10 +1009,10 @@ def _setup(self):
9911009
condition={'mode': 'layer3'}))
9921010
params.append(VersionedParamPath(
9931011
'lldp_enabled', path='{mode}/lldp/enable', vartype='yesno',
994-
condition={'mode': 'layer2'}))
1012+
condition={'mode': ['layer2', 'layer3', 'virtual-wire']}))
9951013
params.append(VersionedParamPath(
9961014
'lldp_profile', path='{mode}/lldp/profile',
997-
condition={'mode': 'layer2'}))
1015+
condition={'mode': ['layer2', 'layer3', 'virtual-wire']}))
9981016
params.append(VersionedParamPath(
9991017
'netflow_profile_l2', path='{mode}/netflow-profile',
10001018
condition={'mode': 'layer2'}))
@@ -1032,6 +1050,42 @@ def _setup(self):
10321050
'dhcp_default_route_metric',
10331051
path='{mode}/dhcp-client/default-route-metric',
10341052
vartype='int', condition={'mode': 'layer3'}))
1053+
params.append(VersionedParamPath(
1054+
'enable_untagged_subinterface', exclude=True))
1055+
params[-1].add_profile(
1056+
'7.1.0',
1057+
vartype='yesno', condition={'mode': 'layer3'},
1058+
path='{mode}/untagged-sub-interface')
1059+
params.append(VersionedParamPath(
1060+
'decrypt_forward', exclude=True))
1061+
params[-1].add_profile(
1062+
'8.1.0',
1063+
vartype='yesno', condition={'mode': 'layer3'},
1064+
path='{mode}/decrypt-forward')
1065+
params.append(VersionedParamPath(
1066+
'rx_policing_rate', exclude=True))
1067+
params[-1].add_profile(
1068+
'8.1.0',
1069+
vartype='int', condition={'mode': 'layer3'},
1070+
path='{mode}/policing/rx-rate')
1071+
params.append(VersionedParamPath(
1072+
'tx_policing_rate', exclude=True))
1073+
params[-1].add_profile(
1074+
'8.1.0',
1075+
vartype='int', condition={'mode': 'layer3'},
1076+
path='{mode}/policing/tx-rate')
1077+
params.append(VersionedParamPath(
1078+
'dhcp_send_hostname_enable', exclude=True))
1079+
params[-1].add_profile(
1080+
'9.0.0',
1081+
vartype='yesno', condition={'mode': 'layer3'},
1082+
path='{mode}/dhcp-client/send-hostname/enable')
1083+
params.append(VersionedParamPath(
1084+
'dhcp_send_hostname_value', exclude=True))
1085+
params[-1].add_profile(
1086+
'9.0.0',
1087+
condition={'mode': 'layer3'},
1088+
path='{mode}/dhcp-client/send-hostname/hostname')
10351089

10361090
self._params = tuple(params)
10371091

pandevice/objects.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class AddressGroup(VersionedPanObject):
7575
"""Address Group
7676
7777
Args:
78+
name (str): Name of the address group
7879
static_value (list): Values for a static address group
7980
dynamic_value (str): Registered-ip tags for a dynamic address group
8081
description (str): Description of this object

0 commit comments

Comments
 (0)