Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions devstack/plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Switch configuration format::
port = <ssh port>
username = <credential username>
password = <credential password>
use_keys = <set to True when key_file is set>
key_file = <ssh key file>
secret = <enable secret>
ngs_allowed_vlans = <comma-separated list of allowed vlans for switch>
Expand Down
27 changes: 26 additions & 1 deletion networking_generic_switch/devices/netmiko_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -435,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:
Expand Down
21 changes: 21 additions & 0 deletions networking_generic_switch/tests/unit/test_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
@@ -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.
Loading