diff --git a/panos/device.py b/panos/device.py index 85ac899b..d221d723 100644 --- a/panos/device.py +++ b/panos/device.py @@ -1321,11 +1321,7 @@ def _setup(self): ) ) params.append( - VersionedParamPath( - "disabled", - vartype="yesno", - path="disabled", - ), + VersionedParamPath("disabled", vartype="yesno", path="disabled",), ) self._params = tuple(params) @@ -1471,10 +1467,7 @@ def _setup(self): "facility", default="LOG_USER", path="facility", - values=[ - "LOG_USER", - ] - + ["LOG_LOCAL{0}".format(x) for x in range(8)], + values=["LOG_USER",] + ["LOG_LOCAL{0}".format(x) for x in range(8)], ) ) @@ -2282,28 +2275,12 @@ def _setup(self): ) params.append( VersionedParamPath( - "username_field_value", - path="username-field/{username_field}", - ) - ) - params.append( - VersionedParamPath( - "domain", - path="domain", - ) - ) - params.append( - VersionedParamPath( - "use_crl", - path="use-crl", - ) - ) - params.append( - VersionedParamPath( - "use_ocsp", - path="use-ocsp", + "username_field_value", path="username-field/{username_field}", ) ) + params.append(VersionedParamPath("domain", path="domain",)) + params.append(VersionedParamPath("use_crl", path="use-crl",)) + params.append(VersionedParamPath("use_ocsp", path="use-ocsp",)) params.append( VersionedParamPath( "crl_receive_timeout", @@ -2330,50 +2307,27 @@ def _setup(self): ) params.append( VersionedParamPath( - "block_unknown_certificate", - vartype="yesno", - path="block-unknown-cert", + "block_unknown_certificate", vartype="yesno", path="block-unknown-cert", ) ) params.append( VersionedParamPath( - "block_certificate_timeout", - vartype="yesno", - path="block-timeout-cert", + "block_certificate_timeout", vartype="yesno", path="block-timeout-cert", ) ) params.append( - VersionedParamPath( - "block_unauthenticated_certificate", - exclude=True, - ) + VersionedParamPath("block_unauthenticated_certificate", exclude=True,) ) params[-1].add_profile( - "7.1.0", - vartype="yesno", - path="block-unauthenticated-cert", - ) - params.append( - VersionedParamPath( - "block_expired_certificate", - exclude=True, - ) + "7.1.0", vartype="yesno", path="block-unauthenticated-cert", ) + params.append(VersionedParamPath("block_expired_certificate", exclude=True,)) params[-1].add_profile( - "8.1.0", - vartype="yesno", - path="block-expired-cert", - ) - params.append( - VersionedParamPath( - "ocsp_exclude_nonce", - exclude=True, - ) + "8.1.0", vartype="yesno", path="block-expired-cert", ) + params.append(VersionedParamPath("ocsp_exclude_nonce", exclude=True,)) params[-1].add_profile( - "9.0.0", - path="ocsp-exclude-nonce", - vartype="yesno", + "9.0.0", path="ocsp-exclude-nonce", vartype="yesno", ) self._params = tuple(params) @@ -2400,27 +2354,13 @@ def _setup(self): # params params = [] + params.append(VersionedParamPath("default_ocsp_url", path="default-ocsp-url",)) params.append( - VersionedParamPath( - "default_ocsp_url", - path="default-ocsp-url", - ) - ) - params.append( - VersionedParamPath( - "ocsp_verify_certificate", - path="ocsp-verify-cert", - ) - ) - params.append( - VersionedParamPath( - "template_name", - exclude=True, - ) + VersionedParamPath("ocsp_verify_certificate", path="ocsp-verify-cert",) ) + params.append(VersionedParamPath("template_name", exclude=True,)) params[-1].add_profile( - "9.0.0", - path="template-name", + "9.0.0", path="template-name", ) self._params = tuple(params) @@ -2455,8 +2395,7 @@ def _setup(self): params.append( VersionedParamPath( - "forward_trust_certificate_rsa", - path="forward-trust-certificate/rsa", + "forward_trust_certificate_rsa", path="forward-trust-certificate/rsa", ) ) params.append( @@ -2479,17 +2418,13 @@ def _setup(self): ) params.append( VersionedParamPath( - "root_ca_excludes", - vartype="member", - path="root-ca-exclude-list", + "root_ca_excludes", vartype="member", path="root-ca-exclude-list", ) ) # Only option present on Panorama. params.append( VersionedParamPath( - "trusted_root_cas", - vartype="member", - path="trusted-root-CA", + "trusted_root_cas", vartype="member", path="trusted-root-CA", ) ) params.append( @@ -2524,19 +2459,8 @@ def _setup(self): # params params = [] - params.append( - VersionedParamPath( - "description", - path="description", - ) - ) - params.append( - VersionedParamPath( - "exclude", - vartype="yesno", - path="exclude", - ) - ) + params.append(VersionedParamPath("description", path="description",)) + params.append(VersionedParamPath("exclude", vartype="yesno", path="exclude",)) self._params = tuple(params) @@ -2566,19 +2490,9 @@ def _setup(self): params = [] params.append( - VersionedParamPath( - "password_hash", - vartype="encrypted", - path="phash", - ) - ) - params.append( - VersionedParamPath( - "disabled", - vartype="yesno", - path="disabled", - ) + VersionedParamPath("password_hash", vartype="encrypted", path="phash",) ) + params.append(VersionedParamPath("disabled", vartype="yesno", path="disabled",)) self._params = tuple(params) @@ -2619,12 +2533,6 @@ def _setup(self): # params params = [] - params.append( - VersionedParamPath( - "users", - vartype="member", - path="user", - ) - ) + params.append(VersionedParamPath("users", vartype="member", path="user",)) self._params = tuple(params) diff --git a/panos/network.py b/panos/network.py index ef22bc5b..781a412b 100644 --- a/panos/network.py +++ b/panos/network.py @@ -153,48 +153,22 @@ def _setup(self): ) ) params.append( - VersionedParamPath( - "enable_packet_buffer_protection", - exclude=True, - ) + VersionedParamPath("enable_packet_buffer_protection", exclude=True,) ) params[-1].add_profile( - "8.0.0", - path="network/enable-packet-buffer-protection", - vartype="yesno", - ) - params.append( - VersionedParamPath( - "enable_device_identification", - exclude=True, - ) + "8.0.0", path="network/enable-packet-buffer-protection", vartype="yesno", ) + params.append(VersionedParamPath("enable_device_identification", exclude=True,)) params[-1].add_profile( - "10.0.0", - path="enable-device-identification", - vartype="yesno", - ) - params.append( - VersionedParamPath( - "device_include_acl", - exclude=True, - ) + "10.0.0", path="enable-device-identification", vartype="yesno", ) + params.append(VersionedParamPath("device_include_acl", exclude=True,)) params[-1].add_profile( - "10.0.0", - path="device-acl/include-list", - vartype="member", - ) - params.append( - VersionedParamPath( - "device_exclude_acl", - exclude=True, - ) + "10.0.0", path="device-acl/include-list", vartype="member", ) + params.append(VersionedParamPath("device_exclude_acl", exclude=True,)) params[-1].add_profile( - "10.0.0", - path="device-acl/exclude-acl", - vartype="member", + "10.0.0", path="device-acl/exclude-acl", vartype="member", ) self._params = tuple(params) @@ -1403,12 +1377,7 @@ def _setup(self): "mode", path="{mode}", default="layer3", - values=[ - "layer3", - "layer2", - "virtual-wire", - "ha", - ], + values=["layer3", "layer2", "virtual-wire", "ha",], ) ) params.append( @@ -2210,11 +2179,7 @@ def _setup(self): VersionedParamPath("enable", path="enable", default=True, vartype="yesno") ) params.append( - VersionedParamPath( - "reject_default_route", - default=True, - vartype="yesno", - ) + VersionedParamPath("reject_default_route", default=True, vartype="yesno",) ) params.append( VersionedParamPath( @@ -4246,11 +4211,7 @@ def _setup(self): ) params[-1].add_profile( "8.1.0", - values=( - "ip", - "dynamic", - "fqdn", - ), + values=("ip", "dynamic", "fqdn",), path="peer-address/{peer_ip_type}", ) params.append( @@ -4656,14 +4617,7 @@ def _setup(self): params.append( VersionedParamPath( "mk_esp_encryption", - values=( - "des", - "3des", - "aes128", - "aes192", - "aes256", - "null", - ), + values=("des", "3des", "aes128", "aes192", "aes256", "null",), path="{type}/{mk_protocol}/encryption/algorithm", ) ) @@ -5503,9 +5457,7 @@ def _setup(self): params = [] - params.append( - VersionedParamPath("interface", path="interface"), - ) + params.append(VersionedParamPath("interface", path="interface"),) self._params = tuple(params) diff --git a/tests/live/test_network.py b/tests/live/test_network.py index b63852ec..2fdba57d 100644 --- a/tests/live/test_network.py +++ b/tests/live/test_network.py @@ -6,10 +6,7 @@ class TestZoneBasic(testlib.FwFlow): def setup_state_obj(self, fw, state): - state.obj = network.Zone( - testlib.random_name(), - mode="layer3", - ) + state.obj = network.Zone(testlib.random_name(), mode="layer3",) fw.add(state.obj) def update_state_obj(self, fw, state): @@ -68,10 +65,7 @@ def create_dependencies(self, fw, state): state.parent.create() def setup_state_obj(self, fw, state): - state.obj = network.StaticMac( - testlib.random_mac(), - state.eths[0], - ) + state.obj = network.StaticMac(testlib.random_mac(), state.eths[0],) state.parent.add(state.obj) def update_state_obj(self, fw, state): @@ -108,9 +102,7 @@ def create_dependencies(self, fw, state): def setup_state_obj(self, fw, state): state.obj = network.Vlan( - testlib.random_name(), - state.eths[0], - state.vlan_interface.uid, + testlib.random_name(), state.eths[0], state.vlan_interface.uid, ) fw.add(state.obj) @@ -332,9 +324,7 @@ def create_dependencies(self, fw, state): state.eth = testlib.get_available_interfaces(fw)[0] state.parent = network.EthernetInterface( - state.eth, - "layer3", - ip=testlib.random_ip("/24"), + state.eth, "layer3", ip=testlib.random_ip("/24"), ) fw.add(state.parent) state.parent.create() @@ -378,10 +368,7 @@ def create_dependencies(self, fw, state): state.eth = None state.eth = testlib.get_available_interfaces(fw)[0] - state.parent = network.EthernetInterface( - state.eth, - "layer2", - ) + state.parent = network.EthernetInterface(state.eth, "layer2",) fw.add(state.parent) state.parent.create() @@ -389,9 +376,7 @@ def setup_state_obj(self, fw, state): tag = random.randint(1, 4000) name = "{0}.{1}".format(state.eth, tag) state.obj = network.Layer2Subinterface( - name, - tag, - comment="This is my L2 subinterface", + name, tag, comment="This is my L2 subinterface", ) state.parent.add(state.obj) @@ -876,16 +861,14 @@ def create_dependencies(self, fw, state): if self.WITH_BGP_IMPORT_RULE: state.import_rule = network.BgpPolicyImportRule( - name=testlib.random_name(), - enable=True, + name=testlib.random_name(), enable=True, ) state.bgp.add(state.import_rule) state.bgp.apply() if self.WITH_BGP_EXPORT_RULE: state.export_rule = network.BgpPolicyExportRule( - name=testlib.random_name(), - enable=True, + name=testlib.random_name(), enable=True, ) state.bgp.add(state.export_rule) state.bgp.apply() @@ -1426,9 +1409,7 @@ def setup_state_obj(self, fw, state): # 'match_afi': 'ip', # 'match_safi': 'ip', "match_route_table": "unicast", - "match_nexthop": [ - testlib.random_ip("/32"), - ], + "match_nexthop": [testlib.random_ip("/32"),], "match_from_peer": state.peer.name, "match_med": random.randint(0, 4294967295), "match_as_path_regex": "as-path-regex", @@ -1510,8 +1491,7 @@ class MakeBgpPolicyAddressPrefix(MakeVirtualRouter): def setup_state_obj(self, fw, state): state.obj = network.BgpPolicyAddressPrefix( - name=testlib.random_netmask(), - exact=True, + name=testlib.random_netmask(), exact=True, ) if self.WITH_BGP_IMPORT_RULE: state.import_rule.add(state.obj) @@ -1567,9 +1547,7 @@ def setup_state_obj(self, fw, state): ) advert.extend(prefixes) state.obj = network.BgpPolicyConditionalAdvertisement( - name=testlib.random_name(), - enable=True, - used_by=state.pg.name, + name=testlib.random_name(), enable=True, used_by=state.pg.name, ) state.obj.add(non_exist) state.obj.add(advert) @@ -2548,12 +2526,8 @@ class TestIkeCryptoProfile(testlib.FwFlow): def setup_state_obj(self, fw, state): state.obj = network.IkeCryptoProfile( testlib.random_name(), - authentication=[ - "sha256", - ], - dh_group=[ - "group1", - ], + authentication=["sha256",], + dh_group=["group1",], lifetime_minutes=42, ) fw.add(state.obj) @@ -2639,8 +2613,7 @@ def create_dependencies(self, fw, state): raise ValueError("IkeGateway not supported for version < 7.0") state.lbi = network.LoopbackInterface( - "loopback.{0}".format(random.randint(5, 20)), - ipv6_enabled=True, + "loopback.{0}".format(random.randint(5, 20)), ipv6_enabled=True, ) state.lbi.add(network.IPv6Address(testlib.random_ipv6())) state.lbi.add(network.IPv6Address(testlib.random_ipv6())) diff --git a/tests/live/testlib.py b/tests/live/testlib.py index 959f3781..178f4f66 100644 --- a/tests/live/testlib.py +++ b/tests/live/testlib.py @@ -24,9 +24,7 @@ def random_ip(netmask=None): def random_netmask(): return "{0}.{1}.{2}.0/24".format( - random.randint(11, 150), - random.randint(1, 200), - random.randint(1, 200), + random.randint(11, 150), random.randint(1, 200), random.randint(1, 200), )