@@ -446,7 +446,6 @@ def element(self, with_children=True, comparable=False):
446
446
nextelement = root
447
447
448
448
for section in path :
449
-
450
449
if section .find ("|" ) != - 1 :
451
450
# This is an element variable, so create an element containing
452
451
# the variables's value
@@ -1648,7 +1647,13 @@ def _set_reference(
1648
1647
if var_type == "list" :
1649
1648
if var is None :
1650
1649
update_needed = True
1651
- setattr (obj , reference_var , [self ,])
1650
+ setattr (
1651
+ obj ,
1652
+ reference_var ,
1653
+ [
1654
+ self ,
1655
+ ],
1656
+ )
1652
1657
if update :
1653
1658
obj .update (reference_var )
1654
1659
elif not isinstance (var , list ):
@@ -1992,7 +1997,9 @@ def delete_similar(self):
1992
1997
for chunk in chunk_instances_for_delete_similar (instances ):
1993
1998
dev .xapi .delete (
1994
1999
"{0}/{1}[{2}]" .format (
1995
- xpath , prefix , " or " .join (joiner .format (x .uid ) for x in chunk ),
2000
+ xpath ,
2001
+ prefix ,
2002
+ " or " .join (joiner .format (x .uid ) for x in chunk ),
1996
2003
),
1997
2004
retry_on_peer = self .HA_SYNC ,
1998
2005
)
@@ -2124,14 +2131,13 @@ def hierarchy_info(self):
2124
2131
dict: Hierarchy information about this object.
2125
2132
"""
2126
2133
from panos .firewall import Firewall
2127
- from panos .panorama import DeviceGroup
2128
- from panos .panorama import Panorama
2129
- from panos .panorama import Template
2130
- from panos .panorama import TemplateStack
2134
+ from panos .panorama import DeviceGroup , Panorama , Template , TemplateStack
2131
2135
2132
2136
classes = panos .object_classes ()
2133
2137
configs = [
2134
- [self .__class__ ,],
2138
+ [
2139
+ self .__class__ ,
2140
+ ],
2135
2141
]
2136
2142
updated_configs = []
2137
2143
@@ -2143,7 +2149,10 @@ def hierarchy_info(self):
2143
2149
configs .pop (num )
2144
2150
for p in parents :
2145
2151
configs .append (
2146
- chain + [p ,]
2152
+ chain
2153
+ + [
2154
+ p ,
2155
+ ]
2147
2156
)
2148
2157
break
2149
2158
else :
@@ -2801,7 +2810,8 @@ def __getattr__(self, name):
2801
2810
2802
2811
raise AttributeError (
2803
2812
"'{0}' object has no attribute '{1}'" .format (
2804
- self .__class__ .__name__ , str (name ),
2813
+ self .__class__ .__name__ ,
2814
+ str (name ),
2805
2815
)
2806
2816
)
2807
2817
@@ -2886,9 +2896,7 @@ def __repr__(self):
2886
2896
2887
2897
2888
2898
class ValueEntry (VersionedPanObject ):
2889
- """Base class for objects that only have a value element.
2890
-
2891
- """
2899
+ """Base class for objects that only have a value element."""
2892
2900
2893
2901
ROOT = Root .VSYS
2894
2902
SUFFIX = ENTRY
@@ -3722,7 +3730,12 @@ def get_device_version(self):
3722
3730
3723
3731
@classmethod
3724
3732
def create_from_device (
3725
- cls , hostname , api_username = None , api_password = None , api_key = None , port = 443 ,
3733
+ cls ,
3734
+ hostname ,
3735
+ api_username = None ,
3736
+ api_password = None ,
3737
+ api_key = None ,
3738
+ port = 443 ,
3726
3739
):
3727
3740
"""Factory method to create a :class:`panos.firewall.Firewall`
3728
3741
or :class:`panos.panorama.Panorama` object from a live device
@@ -3744,18 +3757,33 @@ def create_from_device(
3744
3757
# Create generic PanDevice to connect and get information
3745
3758
from panos import firewall , panorama
3746
3759
3747
- device = PanDevice (hostname , api_username , api_password , api_key , port ,)
3760
+ device = PanDevice (
3761
+ hostname ,
3762
+ api_username ,
3763
+ api_password ,
3764
+ api_key ,
3765
+ port ,
3766
+ )
3748
3767
system_info = device .refresh_system_info ()
3749
3768
version = system_info [0 ]
3750
3769
model = system_info [1 ]
3751
3770
if model == "Panorama" or model .startswith ("M-" ):
3752
3771
instance = panorama .Panorama (
3753
- hostname , api_username , api_password , device .api_key , port ,
3772
+ hostname ,
3773
+ api_username ,
3774
+ api_password ,
3775
+ device .api_key ,
3776
+ port ,
3754
3777
)
3755
3778
else :
3756
3779
serial = system_info [2 ]
3757
3780
instance = firewall .Firewall (
3758
- hostname , api_username , api_password , device .api_key , serial , port ,
3781
+ hostname ,
3782
+ api_username ,
3783
+ api_password ,
3784
+ device .api_key ,
3785
+ serial ,
3786
+ port ,
3759
3787
)
3760
3788
instance ._set_version_and_version_info (version )
3761
3789
return instance
@@ -3903,10 +3931,16 @@ def method(self, *args, **kwargs):
3903
3931
3904
3932
def classify_exception (self , e ):
3905
3933
if str (e ) == "Invalid credentials." :
3906
- return err .PanInvalidCredentials (str (e ), pan_device = self .pan_device ,)
3934
+ return err .PanInvalidCredentials (
3935
+ str (e ),
3936
+ pan_device = self .pan_device ,
3937
+ )
3907
3938
elif str (e ).startswith ("URLError:" ):
3908
3939
if str (e ).endswith ("timed out" ):
3909
- return err .PanConnectionTimeout (str (e ), pan_device = self .pan_device ,)
3940
+ return err .PanConnectionTimeout (
3941
+ str (e ),
3942
+ pan_device = self .pan_device ,
3943
+ )
3910
3944
else :
3911
3945
# This could be that we have an old version of OpenSSL
3912
3946
# that doesn't support TLSv1.1, so check for that and give
@@ -4836,7 +4870,12 @@ def _commit(
4836
4870
logger .debug (
4837
4871
self .id
4838
4872
+ ": commit requested: commit_all:%s sync:%s sync_all:%s cmd:%s"
4839
- % (str (commit_all ), str (sync ), str (sync_all ), cmd ,)
4873
+ % (
4874
+ str (commit_all ),
4875
+ str (sync ),
4876
+ str (sync_all ),
4877
+ cmd ,
4878
+ )
4840
4879
)
4841
4880
if commit_all :
4842
4881
action = "all"
@@ -5603,7 +5642,8 @@ def is_ready(self, minutes=None, seconds=None):
5603
5642
end = None
5604
5643
if minutes is not None or seconds is not None :
5605
5644
end = datetime .datetime .now () + datetime .timedelta (
5606
- minutes = minutes or 0 , seconds = seconds or 0 ,
5645
+ minutes = minutes or 0 ,
5646
+ seconds = seconds or 0 ,
5607
5647
)
5608
5648
5609
5649
while True :
0 commit comments