From ce0e21b94eea6178ce8e0e079b45d5ab9e4c3654 Mon Sep 17 00:00:00 2001 From: Sebastian Czech Date: Tue, 6 Feb 2024 09:15:04 +0100 Subject: [PATCH] Format code with poetry and Python 3.8 --- panos/device.py | 149 ++++++++++--- panos/network.py | 436 +++++++++++++++++++++++++++++-------- tests/live/test_network.py | 108 ++++++--- tests/live/testlib.py | 4 +- 4 files changed, 551 insertions(+), 146 deletions(-) diff --git a/panos/device.py b/panos/device.py index d221d723..6b55eaac 100644 --- a/panos/device.py +++ b/panos/device.py @@ -421,7 +421,10 @@ def _setup(self): params.append( VersionedParamPath( - "enable", default=False, vartype="yesno", path="advance-routing", + "enable", + default=False, + vartype="yesno", + path="advance-routing", ) ) @@ -1321,7 +1324,11 @@ def _setup(self): ) ) params.append( - VersionedParamPath("disabled", vartype="yesno", path="disabled",), + VersionedParamPath( + "disabled", + vartype="yesno", + path="disabled", + ), ) self._params = tuple(params) @@ -1467,7 +1474,10 @@ 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)], ) ) @@ -2275,12 +2285,28 @@ def _setup(self): ) params.append( VersionedParamPath( - "username_field_value", path="username-field/{username_field}", + "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("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", @@ -2307,27 +2333,50 @@ 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", + "7.1.0", + vartype="yesno", + path="block-unauthenticated-cert", + ) + params.append( + VersionedParamPath( + "block_expired_certificate", + exclude=True, + ) ) - params.append(VersionedParamPath("block_expired_certificate", exclude=True,)) params[-1].add_profile( - "8.1.0", vartype="yesno", path="block-expired-cert", + "8.1.0", + vartype="yesno", + path="block-expired-cert", + ) + params.append( + VersionedParamPath( + "ocsp_exclude_nonce", + exclude=True, + ) ) - 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) @@ -2354,13 +2403,27 @@ def _setup(self): # params params = [] - params.append(VersionedParamPath("default_ocsp_url", path="default-ocsp-url",)) params.append( - VersionedParamPath("ocsp_verify_certificate", path="ocsp-verify-cert",) + 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, + ) ) - 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) @@ -2395,7 +2458,8 @@ 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( @@ -2418,13 +2482,17 @@ 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( @@ -2459,8 +2527,19 @@ 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) @@ -2490,9 +2569,19 @@ def _setup(self): params = [] params.append( - VersionedParamPath("password_hash", vartype="encrypted", path="phash",) + VersionedParamPath( + "password_hash", + vartype="encrypted", + path="phash", + ) + ) + params.append( + VersionedParamPath( + "disabled", + vartype="yesno", + path="disabled", + ) ) - params.append(VersionedParamPath("disabled", vartype="yesno", path="disabled",)) self._params = tuple(params) @@ -2533,6 +2622,12 @@ 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 781a412b..4a4e1d15 100644 --- a/panos/network.py +++ b/panos/network.py @@ -153,22 +153,48 @@ 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", + "8.0.0", + path="network/enable-packet-buffer-protection", + vartype="yesno", + ) + params.append( + VersionedParamPath( + "enable_device_identification", + exclude=True, + ) ) - params.append(VersionedParamPath("enable_device_identification", exclude=True,)) params[-1].add_profile( - "10.0.0", path="enable-device-identification", vartype="yesno", + "10.0.0", + path="enable-device-identification", + vartype="yesno", + ) + params.append( + VersionedParamPath( + "device_include_acl", + exclude=True, + ) ) - params.append(VersionedParamPath("device_include_acl", exclude=True,)) params[-1].add_profile( - "10.0.0", path="device-acl/include-list", vartype="member", + "10.0.0", + path="device-acl/include-list", + vartype="member", + ) + params.append( + VersionedParamPath( + "device_exclude_acl", + exclude=True, + ) ) - 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) @@ -1377,7 +1403,12 @@ def _setup(self): "mode", path="{mode}", default="layer3", - values=["layer3", "layer2", "virtual-wire", "ha",], + values=[ + "layer3", + "layer2", + "virtual-wire", + "ha", + ], ) ) params.append( @@ -2179,7 +2210,11 @@ 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( @@ -4211,7 +4246,11 @@ 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( @@ -4617,7 +4656,14 @@ 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", ) ) @@ -5457,7 +5503,9 @@ def _setup(self): params = [] - params.append(VersionedParamPath("interface", path="interface"),) + params.append( + VersionedParamPath("interface", path="interface"), + ) self._params = tuple(params) @@ -5781,7 +5829,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "ospf_rfc1583", path="ospf/rfc1583", default=False, vartype="yesno", + "ospf_rfc1583", + path="ospf/rfc1583", + default=False, + vartype="yesno", ) ) params.append( @@ -5839,7 +5890,8 @@ def _setup(self): ) params.append( VersionedParamPath( - "ospfv3_redistribution_profile", path="ospfv3/redistribution-profile", + "ospfv3_redistribution_profile", + path="ospfv3/redistribution-profile", ) ) params.append( @@ -5887,27 +5939,48 @@ def _setup(self): ) params.append( - VersionedParamPath("rib_filter_ipv4_static", path="rib-filter/ipv4/static",) + VersionedParamPath( + "rib_filter_ipv4_static", + path="rib-filter/ipv4/static", + ) ) params.append( - VersionedParamPath("rib_filter_ipv4_bgp", path="rib-filter/ipv4/bgp",) + VersionedParamPath( + "rib_filter_ipv4_bgp", + path="rib-filter/ipv4/bgp", + ) ) params.append( - VersionedParamPath("rib_filter_ipv4_ospf", path="rib-filter/ipv4/ospf",) + VersionedParamPath( + "rib_filter_ipv4_ospf", + path="rib-filter/ipv4/ospf", + ) ) params.append( - VersionedParamPath("rib_filter_ipv6_static", path="rib-filter/ipv6/static",) + VersionedParamPath( + "rib_filter_ipv6_static", + path="rib-filter/ipv6/static", + ) ) params.append( - VersionedParamPath("rib_filter_ipv6_bgp", path="rib-filter/ipv6/bgp",) + VersionedParamPath( + "rib_filter_ipv6_bgp", + path="rib-filter/ipv6/bgp", + ) ) params.append( - VersionedParamPath("rib_filter_ipv6_ospfv3", path="rib-filter/ipv6/ospfv3",) + VersionedParamPath( + "rib_filter_ipv6_ospfv3", + path="rib-filter/ipv6/ospfv3", + ) ) params.append( VersionedParamPath( - "ecmp_enable", default=False, path="ecmp/enable", vartype="yesno", + "ecmp_enable", + default=False, + path="ecmp/enable", + vartype="yesno", ) ) params.append( @@ -5998,7 +6071,10 @@ def _setup(self): params.append( VersionedParamPath( - "mode", default="active", values=["active", "passive"], path="mode", + "mode", + default="active", + values=["active", "passive"], + path="mode", ) ) params.append( @@ -6309,7 +6385,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "advertise", path="advertise", vartype="yesno", default=True, + "advertise", + path="advertise", + vartype="yesno", + default=True, ) ) @@ -6346,12 +6425,18 @@ def _setup(self): ) params.append( VersionedParamPath( - "mtu_ignore", path="mtu-ignore", vartype="yesno", default=False, + "mtu_ignore", + path="mtu-ignore", + vartype="yesno", + default=False, ) ) params.append( VersionedParamPath( - "passive", path="passive", vartype="yesno", default=False, + "passive", + path="passive", + vartype="yesno", + default=False, ) ) params.append( @@ -6527,7 +6612,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "advertise", path="advertise", vartype="yesno", default=True, + "advertise", + path="advertise", + vartype="yesno", + default=True, ) ) @@ -6565,12 +6653,18 @@ def _setup(self): ) params.append( VersionedParamPath( - "mtu_ignore", path="mtu-ignore", vartype="yesno", default=False, + "mtu_ignore", + path="mtu-ignore", + vartype="yesno", + default=False, ) ) params.append( VersionedParamPath( - "passive", path="passive", vartype="yesno", default=False, + "passive", + path="passive", + vartype="yesno", + default=False, ) ) params.append( @@ -6661,7 +6755,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "type", path="type/{type}", values=["ebgp", "ibgp"], default="ebgp", + "type", + path="type/{type}", + values=["ebgp", "ibgp"], + default="ebgp", ) ) params.append( @@ -6679,7 +6776,8 @@ def _setup(self): params.append( VersionedParamPath( - "connection_options_timers", path="connection-options/timers/", + "connection_options_timers", + path="connection-options/timers/", ) ) params.append( @@ -6697,7 +6795,8 @@ def _setup(self): ) params.append( VersionedParamPath( - "connection_options_dampening", path="connection-options/dampening", + "connection_options_dampening", + path="connection-options/dampening", ) ) @@ -6734,7 +6833,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "passive", path="passive", default=False, vartype="yesno", + "passive", + path="passive", + default=False, + vartype="yesno", ) ) params.append(VersionedParamPath("peer_as", path="peer-as", vartype="int")) @@ -6764,7 +6866,8 @@ def _setup(self): ) params.append( VersionedParamPath( - "peer_address_value", path="peer-address/{peer_address_type}/", + "peer_address_value", + path="peer-address/{peer_address_type}/", ) ) @@ -6772,7 +6875,9 @@ def _setup(self): params.append( VersionedParamPath( - "bfd_profile", path="bfd/profile", default="Inherit-lr-global-setting", + "bfd_profile", + path="bfd/profile", + default="Inherit-lr-global-setting", ) ) @@ -6834,7 +6939,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "hold_time", path="hold-time", vartype="int", default=90, + "hold_time", + path="hold-time", + vartype="int", + default=90, ) ) params.append( @@ -6847,7 +6955,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "open_delay_time", path="open-delay-time", vartype="int", default=0, + "open_delay_time", + path="open-delay-time", + vartype="int", + default=0, ) ) params.append( @@ -7011,7 +7122,10 @@ def _setup(self): "unicast_maximum_prefix_action", path="{afi}/unicast/maximum-prefix/action/{unicast_maximum_prefix_action}", default="warning-only", - values=["restart", "warning-only",], + values=[ + "restart", + "warning-only", + ], ) ) params.append( @@ -7163,7 +7277,10 @@ def _setup(self): path="{afi}/multicast/maximum-prefix/action/{multicast_maximum_prefix_action}", condition={"afi": "ipv4"}, default="warning-only", - values=["restart", "warning-only",], + values=[ + "restart", + "warning-only", + ], ) ) params.append( @@ -7240,17 +7357,26 @@ def _setup(self): params.append(VersionedParamPath("description", path="description")) params.append( VersionedParamPath( - "half_life", path="half-life", default=15, vartype="int", + "half_life", + path="half-life", + default=15, + vartype="int", ) ) params.append( VersionedParamPath( - "reuse_limit", path="reuse-limit", default=750, vartype="int", + "reuse_limit", + path="reuse-limit", + default=750, + vartype="int", ) ) params.append( VersionedParamPath( - "suppress_limit", path="suppress-limit", default=2000, vartype="int", + "suppress_limit", + path="suppress-limit", + default=2000, + vartype="int", ) ) params.append( @@ -7440,12 +7566,18 @@ def _setup(self): params.append( VersionedParamPath( - "hello_interval", path="hello-interval", vartype="int", default=10, + "hello_interval", + path="hello-interval", + vartype="int", + default=10, ) ) params.append( VersionedParamPath( - "dead_counts", path="dead-counts", vartype="int", default=4, + "dead_counts", + path="dead-counts", + vartype="int", + default=4, ) ) params.append( @@ -7458,11 +7590,19 @@ def _setup(self): ) params.append( VersionedParamPath( - "transit_delay", path="transit-delay", vartype="int", default=1, + "transit_delay", + path="transit-delay", + vartype="int", + default=1, ) ) params.append( - VersionedParamPath("gr_delay", path="gr-delay", vartype="int", default=10,) + VersionedParamPath( + "gr_delay", + path="gr-delay", + vartype="int", + default=10, + ) ) self._params = tuple(params) @@ -7490,7 +7630,10 @@ def _setup(self): params.append( VersionedParamPath( - "lsa_interval", path="lsa-interval", vartype="int", default=5, + "lsa_interval", + path="lsa-interval", + vartype="int", + default=5, ) ) params.append( @@ -7503,12 +7646,18 @@ def _setup(self): ) params.append( VersionedParamPath( - "initial_hold_time", path="initial-hold-time", vartype="int", default=5, + "initial_hold_time", + path="initial-hold-time", + vartype="int", + default=5, ) ) params.append( VersionedParamPath( - "max_hold_time", path="max-hold-time", vartype="int", default=5, + "max_hold_time", + path="max-hold-time", + vartype="int", + default=5, ) ) @@ -7554,7 +7703,10 @@ def _setup(self): params.append( VersionedParamPath( - "static", path="{static}", values=("static"), default=None, + "static", + path="{static}", + values=("static"), + default=None, ) ) params.append( @@ -7585,7 +7737,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "connected", path="{connected}", values=("connected"), default=None, + "connected", + path="{connected}", + values=("connected"), + default=None, ) ) params.append( @@ -7615,7 +7770,12 @@ def _setup(self): ) ) params.append( - VersionedParamPath("rip", path="{rip}", values=("rip"), default=None,) + VersionedParamPath( + "rip", + path="{rip}", + values=("rip"), + default=None, + ) ) params.append( VersionedParamPath( @@ -7644,7 +7804,12 @@ def _setup(self): ) ) params.append( - VersionedParamPath("bgp", path="{bgp}", values=("bgp"), default=None,) + VersionedParamPath( + "bgp", + path="{bgp}", + values=("bgp"), + default=None, + ) ) params.append( VersionedParamPath( @@ -7744,7 +7909,10 @@ def _setup(self): params.append(VersionedParamPath("spi", path="spi")) params.append( VersionedParamPath( - "protocol", path="{protocol}", values=("esp", "ah"), default="esp", + "protocol", + path="{protocol}", + values=("esp", "ah"), + default="esp", ) ) params.append( @@ -7834,12 +8002,18 @@ def _setup(self): params.append( VersionedParamPath( - "hello_interval", path="hello-interval", vartype="int", default=10, + "hello_interval", + path="hello-interval", + vartype="int", + default=10, ) ) params.append( VersionedParamPath( - "dead_counts", path="dead-counts", vartype="int", default=4, + "dead_counts", + path="dead-counts", + vartype="int", + default=4, ) ) params.append( @@ -7852,11 +8026,19 @@ def _setup(self): ) params.append( VersionedParamPath( - "transit_delay", path="transit-delay", vartype="int", default=1, + "transit_delay", + path="transit-delay", + vartype="int", + default=1, ) ) params.append( - VersionedParamPath("gr_delay", path="gr-delay", vartype="int", default=10,) + VersionedParamPath( + "gr_delay", + path="gr-delay", + vartype="int", + default=10, + ) ) self._params = tuple(params) @@ -7884,7 +8066,10 @@ def _setup(self): params.append( VersionedParamPath( - "lsa_interval", path="lsa-interval", vartype="int", default=5, + "lsa_interval", + path="lsa-interval", + vartype="int", + default=5, ) ) params.append( @@ -7897,12 +8082,18 @@ def _setup(self): ) params.append( VersionedParamPath( - "initial_hold_time", path="initial-hold-time", vartype="int", default=5, + "initial_hold_time", + path="initial-hold-time", + vartype="int", + default=5, ) ) params.append( VersionedParamPath( - "max_hold_time", path="max-hold-time", vartype="int", default=5, + "max_hold_time", + path="max-hold-time", + vartype="int", + default=5, ) ) @@ -7944,7 +8135,10 @@ def _setup(self): params.append( VersionedParamPath( - "static", path="{static}", values=("static"), default=None, + "static", + path="{static}", + values=("static"), + default=None, ) ) params.append( @@ -7975,7 +8169,10 @@ def _setup(self): ) params.append( VersionedParamPath( - "connected", path="{connected}", values=("connected"), default=None, + "connected", + path="{connected}", + values=("connected"), + default=None, ) ) params.append( @@ -8005,7 +8202,12 @@ def _setup(self): ) ) params.append( - VersionedParamPath("bgp", path="{bgp}", values=("bgp"), default=None,) + VersionedParamPath( + "bgp", + path="{bgp}", + values=("bgp"), + default=None, + ) ) params.append( VersionedParamPath( @@ -8104,7 +8306,10 @@ def _setup(self): params.append(VersionedParamPath("description", path="description")) params.append( VersionedParamPath( - "type", path="type/{type}", default="ipv4", values=("ipv4", "ipv6"), + "type", + path="type/{type}", + default="ipv4", + values=("ipv4", "ipv6"), ) ) @@ -8134,7 +8339,10 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( @@ -8203,7 +8411,10 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( @@ -8257,7 +8468,10 @@ def _setup(self): params.append(VersionedParamPath("description", path="description")) params.append( VersionedParamPath( - "type", path="type/{type}", default="ipv4", values=("ipv4", "ipv6"), + "type", + path="type/{type}", + default="ipv4", + values=("ipv4", "ipv6"), ) ) @@ -8285,17 +8499,24 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( VersionedParamPath( - "prefix", path="prefix/network", condition={"prefix": "any"}, + "prefix", + path="prefix/network", + condition={"prefix": "any"}, ) ) params.append( VersionedParamPath( - "network", path="prefix/entry/network", condition={"prefix": "network"}, + "network", + path="prefix/entry/network", + condition={"prefix": "network"}, ) ) params.append( @@ -8337,17 +8558,24 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( VersionedParamPath( - "prefix", path="prefix/network", condition={"prefix": "any"}, + "prefix", + path="prefix/network", + condition={"prefix": "any"}, ) ) params.append( VersionedParamPath( - "network", path="prefix/entry/network", condition={"prefix": "network"}, + "network", + path="prefix/entry/network", + condition={"prefix": "network"}, ) ) params.append( @@ -8410,10 +8638,18 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), + ) + ) + params.append( + VersionedParamPath( + "aspath_regex", + path="aspath-regex", ) ) - params.append(VersionedParamPath("aspath_regex", path="aspath-regex",)) self._params = tuple(params) @@ -8473,7 +8709,10 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( @@ -8517,11 +8756,18 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( - VersionedParamPath("lc_regex", path="lc-regex", vartype="member",) + VersionedParamPath( + "lc_regex", + path="lc-regex", + vartype="member", + ) ) self._params = tuple(params) @@ -8545,11 +8791,18 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append( - VersionedParamPath("ec_regex", path="ec-regex", vartype="member",) + VersionedParamPath( + "ec_regex", + path="ec-regex", + vartype="member", + ) ) self._params = tuple(params) @@ -8640,7 +8893,10 @@ def _setup(self): params.append( VersionedParamPath( - "action", path="action", default="deny", values=("deny", "permit"), + "action", + path="action", + default="deny", + values=("deny", "permit"), ) ) params.append(VersionedParamPath("description", path="description")) @@ -8672,12 +8928,14 @@ def _setup(self): params.append(VersionedParamPath("match_peer", path="match/peer")) params.append( VersionedParamPath( - "match_ipv4_address_access_list", path="match/ipv4/address/access-list", + "match_ipv4_address_access_list", + path="match/ipv4/address/access-list", ) ) params.append( VersionedParamPath( - "match_ipv4_address_prefix_list", path="match/ipv4/address/prefix-list", + "match_ipv4_address_prefix_list", + path="match/ipv4/address/prefix-list", ) ) params.append( @@ -8706,12 +8964,14 @@ def _setup(self): ) params.append( VersionedParamPath( - "match_ipv6_address_access_list", path="match/ipv6/address/access-list", + "match_ipv6_address_access_list", + path="match/ipv6/address/access-list", ) ) params.append( VersionedParamPath( - "match_ipv6_address_prefix_list", path="match/ipv6/address/prefix-list", + "match_ipv6_address_prefix_list", + path="match/ipv6/address/prefix-list", ) ) params.append( @@ -8740,7 +9000,9 @@ def _setup(self): params.append(VersionedParamPath("set_origin", path="set/origin")) params.append( VersionedParamPath( - "set_atomic_aggregate", path="set/atomic-aggregate", vartype="yesno", + "set_atomic_aggregate", + path="set/atomic-aggregate", + vartype="yesno", ) ) params.append(VersionedParamPath("set_metric_action", path="set/metric/action")) diff --git a/tests/live/test_network.py b/tests/live/test_network.py index 2fdba57d..52bab2a1 100644 --- a/tests/live/test_network.py +++ b/tests/live/test_network.py @@ -6,7 +6,10 @@ 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): @@ -65,7 +68,10 @@ 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): @@ -102,7 +108,9 @@ 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) @@ -324,7 +332,9 @@ 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() @@ -368,7 +378,10 @@ 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() @@ -376,7 +389,9 @@ 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) @@ -861,14 +876,16 @@ 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() @@ -1409,7 +1426,9 @@ 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", @@ -1491,7 +1510,8 @@ 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) @@ -1547,7 +1567,9 @@ 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) @@ -1930,7 +1952,8 @@ class TestAreRoutingProfileBgpAuth(MakeLogicalRouter): def setup_state_obj(self, fw, state): state.obj = network.RoutingProfileBgpAuth( - name=testlib.random_name(), secret=testlib.random_name(), + name=testlib.random_name(), + secret=testlib.random_name(), ) fw.add(state.obj) @@ -2333,14 +2356,18 @@ def update_state_obj(self, fw, state): class TestAreRoutingProfileFilterAccessListIpv4(MakeLogicalRouter): def setup_state_obj(self, fw, state): - state.filter_access_list_entry_ipv4 = network.RoutingProfileFilterAccessListEntryIpv4( - 1, - action="permit", - source_address_type="any", - destination_address_type="any", + state.filter_access_list_entry_ipv4 = ( + network.RoutingProfileFilterAccessListEntryIpv4( + 1, + action="permit", + source_address_type="any", + destination_address_type="any", + ) ) state.obj = network.RoutingProfileFilterAccessList( - testlib.random_name(), description="access list IPv4", type="ipv4", + testlib.random_name(), + description="access list IPv4", + type="ipv4", ) state.obj.add(state.filter_access_list_entry_ipv4) fw.add(state.obj) @@ -2351,11 +2378,17 @@ def update_state_obj(self, fw, state): class TestAreRoutingProfileFilterAccessListIpv6(MakeLogicalRouter): def setup_state_obj(self, fw, state): - state.filter_access_list_entry_ipv6 = network.RoutingProfileFilterAccessListEntryIpv6( - 1, action="permit", source_address_type="any", + state.filter_access_list_entry_ipv6 = ( + network.RoutingProfileFilterAccessListEntryIpv6( + 1, + action="permit", + source_address_type="any", + ) ) state.obj = network.RoutingProfileFilterAccessList( - testlib.random_name(), description="access list IPv6", type="ipv6", + testlib.random_name(), + description="access list IPv6", + type="ipv6", ) state.obj.add(state.filter_access_list_entry_ipv6) fw.add(state.obj) @@ -2385,7 +2418,9 @@ def setup_state_obj(self, fw, state): 1, action="deny", prefix="any" ) state.obj = network.RoutingProfileFilterPrefixList( - testlib.random_name(), description="prefix list IPv6", type="ipv6", + testlib.random_name(), + description="prefix list IPv6", + type="ipv6", ) state.obj.add(state.prefix_list_entry_ipv6) fw.add(state.obj) @@ -2409,8 +2444,10 @@ def update_state_obj(self, fw, state): class TestAreRoutingProfileFilterCommunityListEntryRegular(MakeLogicalRouter): def setup_state_obj(self, fw, state): - state.filter_community_regular = network.RoutingProfileFilterCommunityListEntryRegular( - 1, action="permit", community=["accept-own", "no-peer"] + state.filter_community_regular = ( + network.RoutingProfileFilterCommunityListEntryRegular( + 1, action="permit", community=["accept-own", "no-peer"] + ) ) state.obj = network.RoutingProfileFilterCommunityList(testlib.random_name()) state.obj.add(state.filter_community_regular) @@ -2422,8 +2459,10 @@ def update_state_obj(self, fw, state): class TestAreRoutingProfileFilterCommunityListEntryLarge(MakeLogicalRouter): def setup_state_obj(self, fw, state): - state.filter_community_large = network.RoutingProfileFilterCommunityListEntryLarge( - 1, action="permit", lc_regex=["123.*:456.*:987.*", "1.*:2.*:3.*"] + state.filter_community_large = ( + network.RoutingProfileFilterCommunityListEntryLarge( + 1, action="permit", lc_regex=["123.*:456.*:987.*", "1.*:2.*:3.*"] + ) ) state.obj = network.RoutingProfileFilterCommunityList( testlib.random_name(), type="large" @@ -2437,8 +2476,10 @@ def update_state_obj(self, fw, state): class TestAreRoutingProfileFilterCommunityListEntryExtended(MakeLogicalRouter): def setup_state_obj(self, fw, state): - state.filter_community_extended = network.RoutingProfileFilterCommunityListEntryExtended( - 1, action="permit", ec_regex=["123.*:456.*", "1.*:2.*"] + state.filter_community_extended = ( + network.RoutingProfileFilterCommunityListEntryExtended( + 1, action="permit", ec_regex=["123.*:456.*", "1.*:2.*"] + ) ) state.obj = network.RoutingProfileFilterCommunityList( testlib.random_name(), type="extended" @@ -2526,8 +2567,12 @@ 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) @@ -2613,7 +2658,8 @@ 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 178f4f66..959f3781 100644 --- a/tests/live/testlib.py +++ b/tests/live/testlib.py @@ -24,7 +24,9 @@ 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), )