From b849617857123f26b07b729fdff1c1400858b587 Mon Sep 17 00:00:00 2001 From: Steve Baker Date: Mon, 5 May 2025 15:44:31 +1200 Subject: [PATCH 1/4] Correctly set use_keys when key_file is set use_keys needs to be True for netmiko to attempt public key authentication with the specified key_file. Change-Id: Ic0b2c921af91e667dd95fa174a3e47ddaf37f438 (cherry picked from commit dc96c86c444c5e1ff9516251cd7ee5f451bc1bd3) --- devstack/plugin.sh | 1 + doc/source/configuration.rst | 1 + 2 files changed, 2 insertions(+) diff --git a/devstack/plugin.sh b/devstack/plugin.sh index d000a990..477c74ce 100644 --- a/devstack/plugin.sh +++ b/devstack/plugin.sh @@ -183,6 +183,7 @@ function add_generic_switch_to_ml2_config { if [[ -n "$key_file" ]]; then populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name key_file=$key_file + populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name use_keys=True elif [[ -n "$password" ]]; then populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name password=$password fi diff --git a/doc/source/configuration.rst b/doc/source/configuration.rst index fd781e2f..9c07dfbc 100644 --- a/doc/source/configuration.rst +++ b/doc/source/configuration.rst @@ -14,6 +14,7 @@ Switch configuration format:: port = username = password = + use_keys = key_file = secret = ngs_allowed_vlans = From 10c91e32b235b1f2490c40e688747cf37a7d8279 Mon Sep 17 00:00:00 2001 From: Afonne-CID Date: Tue, 3 Jun 2025 23:14:10 +0100 Subject: [PATCH 2/4] Cast numeric Netmiko kwargs to native types. Convert port/timeout options from str to int/float, fixing type errors raised by ConnectHandler. Closes-Bug: #2110111 Change-Id: I9a4a1f857d2ace7c87cfbd6ed56356c1ed227caf Signed-off-by: Afonne-CID (cherry picked from commit d26adb822d2cd006e9fabe89a31359e416ee7bce) --- .../devices/netmiko_devices/__init__.py | 25 +++++++++++++++++++ .../tests/unit/test_devices.py | 21 ++++++++++++++++ 2 files changed, 46 insertions(+) diff --git a/networking_generic_switch/devices/netmiko_devices/__init__.py b/networking_generic_switch/devices/netmiko_devices/__init__.py index 5c372ef8..16a601d1 100644 --- a/networking_generic_switch/devices/netmiko_devices/__init__.py +++ b/networking_generic_switch/devices/netmiko_devices/__init__.py @@ -144,6 +144,31 @@ def __init__(self, device_cfg, *args, **kwargs): self.config['session_log_record_writes'] = True self.config['session_log_file_mode'] = 'append' + _NUMERIC_CAST = { + "port": int, + "global_delay_factor": float, + "conn_timeout": float, + "auth_timeout": float, + "banner_timeout": float, + "blocking_timeout": float, + "timeout": float, + "session_timeout": float, + "read_timeout_override": float, + "keepalive": int, + } + + for key, expected_type in _NUMERIC_CAST.items(): + value = self.config.get(key) + if isinstance(value, str): + try: + self.config[key] = expected_type(value) + except ValueError: + LOG.error( + "Invalid value %s for %s; expected %s", + value, key, expected_type.__name__, + ) + raise exc.GenericSwitchNetmikoConfigError() + self.lock_kwargs = { 'locks_pool_size': int(self.ngs_config['ngs_max_connections']), 'locks_prefix': self.config.get( diff --git a/networking_generic_switch/tests/unit/test_devices.py b/networking_generic_switch/tests/unit/test_devices.py index 4486c364..dc971007 100644 --- a/networking_generic_switch/tests/unit/test_devices.py +++ b/networking_generic_switch/tests/unit/test_devices.py @@ -267,3 +267,24 @@ def test__get_ssh_disabled_algorithms(self): "ciphers": ["blowfish-cbc", "3des-cbc"], } self.assertEqual(expected, algos) + + def test_float_params_cast(self): + config = { + "device_type": 'netmiko_ovs_linux', + "ip": "10.1.2.3", + "username": "u", + "password": "p", + "conn_timeout": "20.0", + "global_delay_factor": "2.5", + "port": "2222", + } + device = devices.device_manager(config) + + self.assertIsInstance(device.config["conn_timeout"], float) + self.assertEqual(device.config["conn_timeout"], 20.0) + + self.assertIsInstance(device.config["global_delay_factor"], float) + self.assertEqual(device.config["global_delay_factor"], 2.5) + + self.assertIsInstance(device.config["port"], int) + self.assertEqual(device.config["port"], 2222) From 2481e27dbeb8e62f796678b96396269f7c93007b Mon Sep 17 00:00:00 2001 From: Grzegorz Koper Date: Thu, 4 Sep 2025 11:44:20 +0200 Subject: [PATCH 3/4] Fix incorrect command when unplugging bond subports When unplugging a bond from a network with trunk subports, the code was incorrectly using ADD_NETWORK_TO_BOND_TRUNK instead of DELETE_NETWORK_ON_BOND_TRUNK for removing subports from the bond trunk. This caused subports to be added instead of removed during bond cleanup. Fixes the logic to use the correct command for removing subports from bond trunks during network unplug operations. Closes-Bug: #2122025 Change-Id: Ieb01a5b8910b7d3e24ccf2561524f36bbd24b2c5 Signed-off-by: Grzegorz Koper (cherry picked from commit 26160cdb60a0ca27cbb9583182dd58cda1ea3ed9) --- .../devices/netmiko_devices/__init__.py | 2 +- .../fix-unplugging-trunk-subports-66d8496b43c55130.yaml | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 releasenotes/notes/fix-unplugging-trunk-subports-66d8496b43c55130.yaml diff --git a/networking_generic_switch/devices/netmiko_devices/__init__.py b/networking_generic_switch/devices/netmiko_devices/__init__.py index 16a601d1..ca76fb37 100644 --- a/networking_generic_switch/devices/netmiko_devices/__init__.py +++ b/networking_generic_switch/devices/netmiko_devices/__init__.py @@ -460,7 +460,7 @@ def unplug_bond_from_network(self, bond, segmentation_id, segmentation_id=segmentation_id) for sub_port in trunk_details.get('sub_ports', []): cmds += self._format_commands( - self.ADD_NETWORK_TO_BOND_TRUNK, bond=bond, + self.DELETE_NETWORK_ON_BOND_TRUNK, bond=bond, segmentation_id=sub_port['segmentation_id']) if ngs_port_default_vlan: diff --git a/releasenotes/notes/fix-unplugging-trunk-subports-66d8496b43c55130.yaml b/releasenotes/notes/fix-unplugging-trunk-subports-66d8496b43c55130.yaml new file mode 100644 index 00000000..c7915aad --- /dev/null +++ b/releasenotes/notes/fix-unplugging-trunk-subports-66d8496b43c55130.yaml @@ -0,0 +1,8 @@ +--- +fixes: + - | + Fixed incorrect command when unplugging bond subports. + Previously, when a bond was unplugged from a network with trunk subports, + the system would incorrectly try to add subports instead of removing them. + This bug has been fixed, and the system now uses the correct command to remove subports, + ensuring proper bond cleanup. From 1067c920cae0a6730719c941d18f654a601adb1d Mon Sep 17 00:00:00 2001 From: Pavlo Shchelokovskyy Date: Thu, 18 Dec 2025 16:00:02 +0200 Subject: [PATCH 4/4] Use upper constraints in pep8 job use the same dependencies in both unit and lint tests, newer versions of dependencies may bring things like new flake8 extensions (example - neutron-lib). Change-Id: I324a74aa35620bb3a3549c0ee77b02c22c74dbcf Signed-off-by: Pavlo Shchelokovskyy (cherry picked from commit 58ee56cb948b63251213b6975fbd383b28c724d5) --- tox.ini | 1 + 1 file changed, 1 insertion(+) diff --git a/tox.ini b/tox.ini index 4c5f6e30..6f7683d5 100644 --- a/tox.ini +++ b/tox.ini @@ -29,6 +29,7 @@ commands = [testenv:pep8] deps = + -c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1} hacking~=6.1.0 # Apache-2.0 flake8-import-order~=0.18.0# LGPLv3 bashate~=2.1.0 # Apache-2.0