Skip to content

Commit cdb6787

Browse files
committed
Merge branch 'release/0.11.0'
2 parents d2a925e + 96a2a2f commit cdb6787

File tree

11 files changed

+1410
-45
lines changed

11 files changed

+1410
-45
lines changed

HISTORY.rst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,19 @@ History
66
0.11.0
77
-----
88

9-
Released: Pending
9+
Released: 2019-06-06
1010

1111
Status: Alpha
1212

13+
- Added `network.GreTunnel`
14+
- Added `uuid` params for security and NAT rules
15+
- Fixed User-ID's `get_registered_ip()`
16+
- Added `objects.LogForwardingProfile` and related sub-objects
17+
- Added `device.SnmpServerProfile` and related sub-objects
18+
- Added `device.EmailServerProfile` and related sub-objects
19+
- Added `device.SyslogServerProfile` and related sub-objects
20+
- Added `device.HttpServerProfile` and related sub-objects
21+
1322
0.10.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.10.0'
26+
__version__ = '0.11.0'
2727

2828

2929
import logging

pandevice/base.py

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,6 +1911,23 @@ def fulltree(self):
19111911
return self.parent.fulltree()
19121912
return self.tree()
19131913

1914+
def retrieve_panos_version(self):
1915+
"""Gets the panos_version of the closest PanDevice.
1916+
1917+
If this object is not attached to a PanDevice, then a very large
1918+
number is returned to ensure that the newest version of the
1919+
object and xpath is presented to the user.
1920+
1921+
Returns:
1922+
tuple: The version as (x, y, z)
1923+
"""
1924+
try:
1925+
device = self.nearest_pandevice()
1926+
panos_version = device.get_device_version()
1927+
except (err.PanDeviceNotSet, err.PanApiKeyNotSet):
1928+
panos_version = self._UNKNOWN_PANOS_VERSION
1929+
1930+
return panos_version
19141931

19151932

19161933
class VersioningSupport(object):
@@ -2257,24 +2274,6 @@ def __dir__(self):
22572274

22582275
return list(ans)
22592276

2260-
def retrieve_panos_version(self):
2261-
"""Gets the panos_version of the closest PanDevice.
2262-
2263-
If this object is not attached to a PanDevice, then a very large
2264-
number is returned to ensure that the newest version of the
2265-
object and xpath is presented to the user.
2266-
2267-
Returns:
2268-
tuple: The version as (x, y, z)
2269-
"""
2270-
try:
2271-
device = self.nearest_pandevice()
2272-
panos_version = device.get_device_version()
2273-
except (err.PanDeviceNotSet, err.PanApiKeyNotSet):
2274-
panos_version = self._UNKNOWN_PANOS_VERSION
2275-
2276-
return panos_version
2277-
22782277
def _build_element_info(self):
22792278
panos_version = self.retrieve_panos_version()
22802279
settings = {}
@@ -2322,6 +2321,33 @@ def element(self, with_children=True, comparable=False):
23222321

23232322
self.xml_merge(ans, itertools.chain(*iterchain))
23242323

2324+
# Now that the whole element is built, mixin an attrib vartypes.
2325+
for p in paths:
2326+
if p.vartype != 'attrib':
2327+
continue
2328+
attrib_path = p.path.split('/')
2329+
attrib_name = attrib_path.pop()
2330+
attrib_value = settings[p.param]
2331+
if attrib_value is None or p.exclude:
2332+
continue
2333+
e = ans
2334+
find_path = ['.', ]
2335+
for ap in attrib_path:
2336+
if not ap:
2337+
continue
2338+
if ap.startswith('entry '):
2339+
junk, var_to_use = ap.split()
2340+
sol_value = pandevice.string_or_list(settings[var_to_use])[0]
2341+
find_path.append("entry[@name='{0}']".format(sol_val))
2342+
elif ap == "entry[@name='localhost.localdomain']":
2343+
find_path.append(ap)
2344+
else:
2345+
find_path.append(ap.format(**settings))
2346+
if len(find_path) > 1:
2347+
e = e.find('/'.join(find_path))
2348+
if e is not None:
2349+
e.attrib[attrib_name] = attrib_value
2350+
23252351
return ans
23262352

23272353
def equal(self, panobject, force=False, compare_children=True):
@@ -2553,6 +2579,27 @@ def __repr__(self):
25532579
self.default, id(self))
25542580

25552581

2582+
class ValueEntry(VersionedPanObject):
2583+
"""Base class for objects that only have a value element.
2584+
2585+
"""
2586+
ROOT = Root.VSYS
2587+
SUFFIX = ENTRY
2588+
LOCATION = None
2589+
2590+
def _setup(self):
2591+
if self.LOCATION is None:
2592+
raise Exception('{0}.LOCATION is unset'.format(self.__class__))
2593+
2594+
# xpath
2595+
self._xpaths.add_profile(value=self.LOCATION)
2596+
2597+
# params
2598+
self._params = (
2599+
VersionedParamPath('value', path='value'),
2600+
)
2601+
2602+
25562603
class VarPath(object):
25572604
"""Configuration variable within the object
25582605
@@ -2713,6 +2760,8 @@ def element(self, elm, settings, comparable=False):
27132760
# Check if this should return None instead of an element
27142761
if self.exclude:
27152762
return None
2763+
elif self.vartype == 'attrib':
2764+
return None
27162765
elif value is None and self.vartype != 'stub':
27172766
return None
27182767
for condition_key, condition_value in self.condition.items():

0 commit comments

Comments
 (0)