@@ -1911,6 +1911,23 @@ def fulltree(self):
1911
1911
return self .parent .fulltree ()
1912
1912
return self .tree ()
1913
1913
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
1914
1931
1915
1932
1916
1933
class VersioningSupport (object ):
@@ -2257,24 +2274,6 @@ def __dir__(self):
2257
2274
2258
2275
return list (ans )
2259
2276
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
-
2278
2277
def _build_element_info (self ):
2279
2278
panos_version = self .retrieve_panos_version ()
2280
2279
settings = {}
@@ -2322,6 +2321,33 @@ def element(self, with_children=True, comparable=False):
2322
2321
2323
2322
self .xml_merge (ans , itertools .chain (* iterchain ))
2324
2323
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
+
2325
2351
return ans
2326
2352
2327
2353
def equal (self , panobject , force = False , compare_children = True ):
@@ -2553,6 +2579,27 @@ def __repr__(self):
2553
2579
self .default , id (self ))
2554
2580
2555
2581
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
+
2556
2603
class VarPath (object ):
2557
2604
"""Configuration variable within the object
2558
2605
@@ -2713,6 +2760,8 @@ def element(self, elm, settings, comparable=False):
2713
2760
# Check if this should return None instead of an element
2714
2761
if self .exclude :
2715
2762
return None
2763
+ elif self .vartype == 'attrib' :
2764
+ return None
2716
2765
elif value is None and self .vartype != 'stub' :
2717
2766
return None
2718
2767
for condition_key , condition_value in self .condition .items ():
0 commit comments