diff --git a/library/network_connections.py b/library/network_connections.py index e8ee347..f48e87c 100644 --- a/library/network_connections.py +++ b/library/network_connections.py @@ -1032,7 +1032,8 @@ class NMUtil: if connection["ieee802_1x"]["ca_path"]: s_8021x.set_property( - NM.SETTING_802_1X_CA_PATH, connection["ieee802_1x"]["ca_path"], + NM.SETTING_802_1X_CA_PATH, + connection["ieee802_1x"]["ca_path"], ) s_8021x.set_property( @@ -1912,7 +1913,7 @@ class Cmd(object): """ Hook for after all changes where made successfuly """ def rollback_transaction(self, idx, action, error): - """ Hook if configuring a profile results in an error + """Hook if configuring a profile results in an error :param idx: Index of the connection that triggered the error :param action: Action that triggered the error @@ -2019,7 +2020,7 @@ class Cmd_nm(Cmd): self._checkpoint = None def _check_ethtool_setting_support(self, idx, connection): - """ Check if SettingEthtool support is needed and available + """Check if SettingEthtool support is needed and available If any feature is specified, the SettingEthtool setting needs to be available. Also NM needs to know about each specified setting. Do not @@ -2236,7 +2237,7 @@ class Cmd_nm(Cmd): self.log_error(idx, "up connection failed while waiting: %s" % (e)) def _try_reapply(self, idx, con): - """ Try to reapply a connection + """Try to reapply a connection If there is exactly one active connection with the same UUID activated on exactly one device, ask the device to reapply the connection. diff --git a/module_utils/network_lsr/argument_validator.py b/module_utils/network_lsr/argument_validator.py index 239acfe..77cfe20 100644 --- a/module_utils/network_lsr/argument_validator.py +++ b/module_utils/network_lsr/argument_validator.py @@ -612,7 +612,8 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("esp_tx_csum_hw_offload", default_value=None), ArgValidatorDeprecated( - "esp-tx-csum-hw-offload", deprecated_by="esp_tx_csum_hw_offload", + "esp-tx-csum-hw-offload", + deprecated_by="esp_tx_csum_hw_offload", ), ArgValidatorBool("fcoe_mtu", default_value=None), ArgValidatorDeprecated("fcoe-mtu", deprecated_by="fcoe_mtu"), @@ -648,49 +649,59 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("rx_vlan_stag_filter", default_value=None), ArgValidatorDeprecated( - "rx-vlan-stag-filter", deprecated_by="rx_vlan_stag_filter", + "rx-vlan-stag-filter", + deprecated_by="rx_vlan_stag_filter", ), ArgValidatorBool("rx_vlan_stag_hw_parse", default_value=None), ArgValidatorDeprecated( - "rx-vlan-stag-hw-parse", deprecated_by="rx_vlan_stag_hw_parse", + "rx-vlan-stag-hw-parse", + deprecated_by="rx_vlan_stag_hw_parse", ), ArgValidatorBool("sg", default_value=None), ArgValidatorBool("tls_hw_record", default_value=None), ArgValidatorDeprecated("tls-hw-record", deprecated_by="tls_hw_record"), ArgValidatorBool("tls_hw_tx_offload", default_value=None), ArgValidatorDeprecated( - "tls-hw-tx-offload", deprecated_by="tls_hw_tx_offload", + "tls-hw-tx-offload", + deprecated_by="tls_hw_tx_offload", ), ArgValidatorBool("tso", default_value=None), ArgValidatorBool("tx", default_value=None), ArgValidatorBool("txvlan", default_value=None), ArgValidatorBool("tx_checksum_fcoe_crc", default_value=None), ArgValidatorDeprecated( - "tx-checksum-fcoe-crc", deprecated_by="tx_checksum_fcoe_crc", + "tx-checksum-fcoe-crc", + deprecated_by="tx_checksum_fcoe_crc", ), ArgValidatorBool("tx_checksum_ipv4", default_value=None), ArgValidatorDeprecated( - "tx-checksum-ipv4", deprecated_by="tx_checksum_ipv4", + "tx-checksum-ipv4", + deprecated_by="tx_checksum_ipv4", ), ArgValidatorBool("tx_checksum_ipv6", default_value=None), ArgValidatorDeprecated( - "tx-checksum-ipv6", deprecated_by="tx_checksum_ipv6", + "tx-checksum-ipv6", + deprecated_by="tx_checksum_ipv6", ), ArgValidatorBool("tx_checksum_ip_generic", default_value=None), ArgValidatorDeprecated( - "tx-checksum-ip-generic", deprecated_by="tx_checksum_ip_generic", + "tx-checksum-ip-generic", + deprecated_by="tx_checksum_ip_generic", ), ArgValidatorBool("tx_checksum_sctp", default_value=None), ArgValidatorDeprecated( - "tx-checksum-sctp", deprecated_by="tx_checksum_sctp", + "tx-checksum-sctp", + deprecated_by="tx_checksum_sctp", ), ArgValidatorBool("tx_esp_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-esp-segmentation", deprecated_by="tx_esp_segmentation", + "tx-esp-segmentation", + deprecated_by="tx_esp_segmentation", ), ArgValidatorBool("tx_fcoe_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-fcoe-segmentation", deprecated_by="tx_fcoe_segmentation", + "tx-fcoe-segmentation", + deprecated_by="tx_fcoe_segmentation", ), ArgValidatorBool("tx_gre_csum_segmentation", default_value=None), ArgValidatorDeprecated( @@ -699,7 +710,8 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("tx_gre_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-gre-segmentation", deprecated_by="tx_gre_segmentation", + "tx-gre-segmentation", + deprecated_by="tx_gre_segmentation", ), ArgValidatorBool("tx_gso_partial", default_value=None), ArgValidatorDeprecated( @@ -709,19 +721,23 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ArgValidatorDeprecated("tx-gso-robust", deprecated_by="tx_gso_robust"), ArgValidatorBool("tx_ipxip4_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-ipxip4-segmentation", deprecated_by="tx_ipxip4_segmentation", + "tx-ipxip4-segmentation", + deprecated_by="tx_ipxip4_segmentation", ), ArgValidatorBool("tx_ipxip6_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-ipxip6-segmentation", deprecated_by="tx_ipxip6_segmentation", + "tx-ipxip6-segmentation", + deprecated_by="tx_ipxip6_segmentation", ), ArgValidatorBool("tx_nocache_copy", default_value=None), ArgValidatorDeprecated( - "tx-nocache-copy", deprecated_by="tx_nocache_copy", + "tx-nocache-copy", + deprecated_by="tx_nocache_copy", ), ArgValidatorBool("tx_scatter_gather", default_value=None), ArgValidatorDeprecated( - "tx-scatter-gather", deprecated_by="tx_scatter_gather", + "tx-scatter-gather", + deprecated_by="tx_scatter_gather", ), ArgValidatorBool("tx_scatter_gather_fraglist", default_value=None), ArgValidatorDeprecated( @@ -730,15 +746,18 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("tx_sctp_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-sctp-segmentation", deprecated_by="tx_sctp_segmentation", + "tx-sctp-segmentation", + deprecated_by="tx_sctp_segmentation", ), ArgValidatorBool("tx_tcp6_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-tcp6-segmentation", deprecated_by="tx_tcp6_segmentation", + "tx-tcp6-segmentation", + deprecated_by="tx_tcp6_segmentation", ), ArgValidatorBool("tx_tcp_ecn_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-tcp-ecn-segmentation", deprecated_by="tx_tcp_ecn_segmentation", + "tx-tcp-ecn-segmentation", + deprecated_by="tx_tcp_ecn_segmentation", ), ArgValidatorBool("tx_tcp_mangleid_segmentation", default_value=None), ArgValidatorDeprecated( @@ -747,11 +766,13 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("tx_tcp_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-tcp-segmentation", deprecated_by="tx_tcp_segmentation", + "tx-tcp-segmentation", + deprecated_by="tx_tcp_segmentation", ), ArgValidatorBool("tx_udp_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-udp-segmentation", deprecated_by="tx_udp_segmentation", + "tx-udp-segmentation", + deprecated_by="tx_udp_segmentation", ), ArgValidatorBool("tx_udp_tnl_csum_segmentation", default_value=None), ArgValidatorDeprecated( @@ -760,11 +781,13 @@ class ArgValidator_DictEthtoolFeatures(ArgValidatorDict): ), ArgValidatorBool("tx_udp_tnl_segmentation", default_value=None), ArgValidatorDeprecated( - "tx-udp_tnl-segmentation", deprecated_by="tx_udp_tnl_segmentation", + "tx-udp_tnl-segmentation", + deprecated_by="tx_udp_tnl_segmentation", ), ArgValidatorBool("tx_vlan_stag_hw_insert", default_value=None), ArgValidatorDeprecated( - "tx-vlan-stag-hw-insert", deprecated_by="tx_vlan_stag_hw_insert", + "tx-vlan-stag-hw-insert", + deprecated_by="tx_vlan_stag_hw_insert", ), ], ) @@ -881,7 +904,8 @@ class ArgValidatorPath(ArgValidatorStr): if posixpath.isabs(value) is False: raise ValidationError( - name, "value '%s' is not a valid posix absolute path" % (value), + name, + "value '%s' is not a valid posix absolute path" % (value), ) return value @@ -956,12 +980,14 @@ class ArgValidator_DictWireless(ArgValidatorDict): if result["key_mgmt"] == "wpa-psk": if result["password"] is None: raise ValidationError( - name, "must supply a password if using 'wpa-psk' key management", + name, + "must supply a password if using 'wpa-psk' key management", ) else: if result["password"] is not None: raise ValidationError( - name, "password only allowed if using 'wpa-psk' key management", + name, + "password only allowed if using 'wpa-psk' key management", ) return result diff --git a/module_utils/network_lsr/nm_provider.py b/module_utils/network_lsr/nm_provider.py index c59330e..205dc2b 100644 --- a/module_utils/network_lsr/nm_provider.py +++ b/module_utils/network_lsr/nm_provider.py @@ -9,12 +9,12 @@ ETHTOOL_FEATURE_PREFIX = "ETHTOOL_OPTNAME_FEATURE_" def get_nm_ethtool_feature(name): """ - Translate ethtool feature into Network Manager name + Translate ethtool feature into Network Manager name - :param name: Name of the feature - :type name: str - :returns: Name of the feature to be used by `NM.SettingEthtool.set_feature()` - :rtype: str + :param name: Name of the feature + :type name: str + :returns: Name of the feature to be used by `NM.SettingEthtool.set_feature()` + :rtype: str """ name = ETHTOOL_FEATURE_PREFIX + name.upper() diff --git a/scripts/print_all_options.py b/scripts/print_all_options.py index 18f99dc..78bf56f 100755 --- a/scripts/print_all_options.py +++ b/scripts/print_all_options.py @@ -64,11 +64,15 @@ def parse_validator(validator): if isinstance(validator, av.ArgValidatorDict): res = {} for k, v in validator.nested.items(): - if v.name not in ( - "infiniband_transport_mode", - "infiniband_p_key", - "vlan_id", - ) and not isinstance(v, av.ArgValidatorDeprecated): + if ( + v.name + not in ( + "infiniband_transport_mode", + "infiniband_p_key", + "vlan_id", + ) + and not isinstance(v, av.ArgValidatorDeprecated) + ): name = k if not validator.required: pass @@ -165,7 +169,12 @@ def prioritize(key): yaml.add_representer(dict, represent_dict) sorted_data = priority_sorted([parse_validator(av.ArgValidator_DictConnection())]) yaml_example = ( - yaml.dump(sorted_data, explicit_start=True, default_flow_style=False, width=100,) + yaml.dump( + sorted_data, + explicit_start=True, + default_flow_style=False, + width=100, + ) .replace(COMMENT, "#") .replace(EMPTY, "") ) diff --git a/tests/unit/test_network_connections.py b/tests/unit/test_network_connections.py index 08bc090..a71fab0 100755 --- a/tests/unit/test_network_connections.py +++ b/tests/unit/test_network_connections.py @@ -2655,8 +2655,8 @@ class TestValidator(unittest.TestCase): self.assertEqual(connections[0]["interface_name"], "eth0") def test_interface_name_ethernet_invalid_profile(self): - """ Require explicit interface_name when the profile name is not a - valid interface_name """ + """Require explicit interface_name when the profile name is not a + valid interface_name""" network_connections = [{"name": "internal:main", "type": "ethernet"}] self.assertRaises( n.ValidationError, ARGS_CONNECTIONS.validate, network_connections @@ -3037,7 +3037,10 @@ class TestUtils(unittest.TestCase): (["agent-owned"], 1), (["not-saved"], 2), (["agent-owned", "not-saved"], 3), - (["not-required"], 4,), + ( + ["not-required"], + 4, + ), (["agent-owned", "not-required"], 5), (["not-saved", "not-required"], 6), (["agent-owned", "not-saved", "not-required"], 7),