Skip to content

Commit 71c1fcc

Browse files
authored
Merge pull request #35 from stackhpc/upstream/xena-2022-06-27
Synchronise xena with upstream
2 parents fc202ea + ce67ddb commit 71c1fcc

File tree

4 files changed

+23
-4
lines changed

4 files changed

+23
-4
lines changed

devstack/plugin.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,12 @@ function configure_generic_switch {
145145
if [ -n "$HOST_TOPOLOGY_SUBNODES" ]; then
146146
# NOTE(vsaienko) with multinode topology we need to add switches from all
147147
# the subnodes to the config on primary node
148+
# NOTE(TheJulia) We *also* need to use the local key which will have
149+
# access to the subnode instead of attemping to configure our own,
150+
# as the plugins execute separately.
151+
if [ -f /opt/stack/.ssh/id_rsa ]; then
152+
GENERIC_SWITCH_KEY_FILE="/opt/stack/.ssh/id_rsa"
153+
fi
148154
local cnt=0
149155
local section
150156
for node in $HOST_TOPOLOGY_SUBNODES; do

networking_generic_switch/devices/netmiko_devices/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def __init__(self, device_cfg):
109109
if CONF.ngs_coordination.backend_url:
110110
self.locker = coordination.get_coordinator(
111111
CONF.ngs_coordination.backend_url,
112-
('ngs-' + CONF.host).encode('ascii'))
112+
('ngs-' + device_utils.get_hostname()).encode('ascii'))
113113
self.locker.start()
114114
atexit.register(self.locker.stop)
115115

networking_generic_switch/devices/utils.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
# License for the specific language governing permissions and limitations
1313
# under the License.
1414

15+
from oslo_config import cfg
16+
17+
18+
CONF = cfg.CONF
19+
1520

1621
def get_switch_device(switches, switch_info=None,
1722
ngs_mac_address=None):
@@ -46,3 +51,8 @@ def sanitise_config(config):
4651
key: "******" if key in sanitised_fields else value
4752
for key, value in config.items()
4853
}
54+
55+
56+
def get_hostname():
57+
"""Helper to allow isolation of CONF.host and plugin loading."""
58+
return CONF.host

networking_generic_switch/tests/unit/netmiko/test_netmiko_base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from tooz import coordination
2525

2626
from networking_generic_switch.devices import netmiko_devices
27+
from networking_generic_switch.devices import utils
2728
from networking_generic_switch import exceptions as exc
2829

2930

@@ -342,17 +343,18 @@ def fake_save_config():
342343
connect_mock.send_command.assert_has_calls([mock.call('save'),
343344
mock.call('y')])
344345

346+
@mock.patch.object(utils, 'get_hostname', autospec=True)
345347
@mock.patch.object(netmiko_devices.ngs_lock, 'PoolLock', autospec=True)
346348
@mock.patch.object(netmiko_devices.netmiko, 'ConnectHandler')
347349
@mock.patch.object(coordination, 'get_coordinator', autospec=True)
348350
def test_switch_send_commands_with_coordinator(self, get_coord_mock,
349-
nm_mock, lock_mock):
351+
nm_mock, lock_mock,
352+
mock_hostname):
350353
self.cfg.config(acquire_timeout=120, backend_url='mysql://localhost',
351354
group='ngs_coordination')
352-
self.cfg.config(host='viking')
353355
coord = mock.Mock()
354356
get_coord_mock.return_value = coord
355-
357+
mock_hostname.return_value = 'viking'
356358
switch = self._make_switch_device(
357359
extra_cfg={'ngs_max_connections': 2})
358360
self.assertEqual(coord, switch.locker)
@@ -370,6 +372,7 @@ def test_switch_send_commands_with_coordinator(self, get_coord_mock,
370372
timeout=120)
371373
lock_mock.return_value.__exit__.assert_called_once()
372374
lock_mock.return_value.__enter__.assert_called_once()
375+
mock_hostname.assert_called_once()
373376

374377
def test_check_output(self):
375378
self.switch.check_output('fake output', 'fake op')

0 commit comments

Comments
 (0)