Skip to content

Commit 6a43534

Browse files
authored
Merge pull request #134 from stackhpc/upstream/2025.1-2026-01-15
Synchronise 2025.1 with upstream
2 parents fc63eb3 + 1067c92 commit 6a43534

File tree

6 files changed

+58
-1
lines changed

6 files changed

+58
-1
lines changed

devstack/plugin.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ function add_generic_switch_to_ml2_config {
183183

184184
if [[ -n "$key_file" ]]; then
185185
populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name key_file=$key_file
186+
populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name use_keys=True
186187
elif [[ -n "$password" ]]; then
187188
populate_ml2_config $GENERIC_SWITCH_INI_FILE $switch_name password=$password
188189
fi

doc/source/configuration.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Switch configuration format::
1414
port = <ssh port>
1515
username = <credential username>
1616
password = <credential password>
17+
use_keys = <set to True when key_file is set>
1718
key_file = <ssh key file>
1819
secret = <enable secret>
1920
ngs_allowed_vlans = <comma-separated list of allowed vlans for switch>

networking_generic_switch/devices/netmiko_devices/__init__.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,31 @@ def __init__(self, device_cfg, *args, **kwargs):
144144
self.config['session_log_record_writes'] = True
145145
self.config['session_log_file_mode'] = 'append'
146146

147+
_NUMERIC_CAST = {
148+
"port": int,
149+
"global_delay_factor": float,
150+
"conn_timeout": float,
151+
"auth_timeout": float,
152+
"banner_timeout": float,
153+
"blocking_timeout": float,
154+
"timeout": float,
155+
"session_timeout": float,
156+
"read_timeout_override": float,
157+
"keepalive": int,
158+
}
159+
160+
for key, expected_type in _NUMERIC_CAST.items():
161+
value = self.config.get(key)
162+
if isinstance(value, str):
163+
try:
164+
self.config[key] = expected_type(value)
165+
except ValueError:
166+
LOG.error(
167+
"Invalid value %s for %s; expected %s",
168+
value, key, expected_type.__name__,
169+
)
170+
raise exc.GenericSwitchNetmikoConfigError()
171+
147172
self.lock_kwargs = {
148173
'locks_pool_size': int(self.ngs_config['ngs_max_connections']),
149174
'locks_prefix': self.config.get(
@@ -435,7 +460,7 @@ def unplug_bond_from_network(self, bond, segmentation_id,
435460
segmentation_id=segmentation_id)
436461
for sub_port in trunk_details.get('sub_ports', []):
437462
cmds += self._format_commands(
438-
self.ADD_NETWORK_TO_BOND_TRUNK, bond=bond,
463+
self.DELETE_NETWORK_ON_BOND_TRUNK, bond=bond,
439464
segmentation_id=sub_port['segmentation_id'])
440465

441466
if ngs_port_default_vlan:

networking_generic_switch/tests/unit/test_devices.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,3 +267,24 @@ def test__get_ssh_disabled_algorithms(self):
267267
"ciphers": ["blowfish-cbc", "3des-cbc"],
268268
}
269269
self.assertEqual(expected, algos)
270+
271+
def test_float_params_cast(self):
272+
config = {
273+
"device_type": 'netmiko_ovs_linux',
274+
"ip": "10.1.2.3",
275+
"username": "u",
276+
"password": "p",
277+
"conn_timeout": "20.0",
278+
"global_delay_factor": "2.5",
279+
"port": "2222",
280+
}
281+
device = devices.device_manager(config)
282+
283+
self.assertIsInstance(device.config["conn_timeout"], float)
284+
self.assertEqual(device.config["conn_timeout"], 20.0)
285+
286+
self.assertIsInstance(device.config["global_delay_factor"], float)
287+
self.assertEqual(device.config["global_delay_factor"], 2.5)
288+
289+
self.assertIsInstance(device.config["port"], int)
290+
self.assertEqual(device.config["port"], 2222)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
fixes:
3+
- |
4+
Fixed incorrect command when unplugging bond subports.
5+
Previously, when a bond was unplugged from a network with trunk subports,
6+
the system would incorrectly try to add subports instead of removing them.
7+
This bug has been fixed, and the system now uses the correct command to remove subports,
8+
ensuring proper bond cleanup.

tox.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ commands =
2929

3030
[testenv:pep8]
3131
deps =
32+
-c{env:TOX_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/2025.1}
3233
hacking~=6.1.0 # Apache-2.0
3334
flake8-import-order~=0.18.0# LGPLv3
3435
bashate~=2.1.0 # Apache-2.0

0 commit comments

Comments
 (0)