Merge "fix errors messaging around network mappings"

This commit is contained in:
Zuul 2024-03-07 16:17:06 +00:00 committed by Gerrit Code Review
commit aa8d9eeb80
3 changed files with 33 additions and 32 deletions

View File

@ -726,7 +726,8 @@ def validate_network(uuid_or_name, net_type=_('network'), context=None):
"""
if not uuid_or_name:
raise exception.MissingParameterValue(
_('UUID or name of %s is not set in configuration') % net_type)
_('UUID or name of %s is not set in configuration or '
'in node driver_info.') % net_type)
client = get_client(context=context)
network = _get_network_by_uuid_or_name(client, uuid_or_name,
@ -981,7 +982,7 @@ class NeutronNetworkInterfaceMixin(object):
or CONF.neutron.cleaning_network
)
return validate_network(
cleaning_network, _('cleaning network'),
cleaning_network, 'cleaning_network',
context=task.context)
def get_provisioning_network_uuid(self, task):
@ -990,7 +991,7 @@ class NeutronNetworkInterfaceMixin(object):
or CONF.neutron.provisioning_network
)
return validate_network(
provisioning_network, _('provisioning network'),
provisioning_network, 'provisioning_network',
context=task.context)
# TODO(stendulker): FlatNetwork should not use this method.
@ -1001,7 +1002,7 @@ class NeutronNetworkInterfaceMixin(object):
or CONF.neutron.rescuing_network
)
return validate_network(
rescuing_network, _('rescuing network'),
rescuing_network, 'rescuing_network',
context=task.context)
def get_inspection_network_uuid(self, task):
@ -1010,7 +1011,7 @@ class NeutronNetworkInterfaceMixin(object):
or CONF.neutron.inspection_network
)
return validate_network(
inspection_network, _('inspection network'),
inspection_network, 'inspection_network',
context=task.context)
def validate_inspection(self, task):

View File

@ -78,7 +78,7 @@ class TestFlatInterface(db_base.DbTestCase):
self.interface.validate(task)
validate_mock.assert_called_once_with(
CONF.neutron.cleaning_network,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
@mock.patch.object(neutron, 'validate_network', autospec=True)
def test_validate_from_node(self, validate_mock):
@ -91,7 +91,7 @@ class TestFlatInterface(db_base.DbTestCase):
self.interface.validate(task)
validate_mock.assert_called_once_with(
cleaning_network_uuid,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
@mock.patch.object(neutron, 'validate_network',
side_effect=lambda n, t, context=None: n, autospec=True)
@ -107,7 +107,7 @@ class TestFlatInterface(db_base.DbTestCase):
add_mock.assert_called_once_with(
task, CONF.neutron.cleaning_network)
validate_mock.assert_called_once_with(
CONF.neutron.cleaning_network, 'cleaning network',
CONF.neutron.cleaning_network, 'cleaning_network',
context=task.context)
self.port.refresh()
self.assertEqual('vif-port-id',
@ -134,7 +134,7 @@ class TestFlatInterface(db_base.DbTestCase):
add_mock.assert_called_with(task, cleaning_network_uuid)
validate_mock.assert_called_with(
cleaning_network_uuid,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertEqual('vif-port-id',
self.port.internal_info['cleaning_vif_port_id'])
@ -149,7 +149,7 @@ class TestFlatInterface(db_base.DbTestCase):
task, CONF.neutron.cleaning_network)
validate_mock.assert_called_once_with(
CONF.neutron.cleaning_network,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertNotIn('cleaning_vif_port_id', self.port.internal_info)
@ -168,7 +168,7 @@ class TestFlatInterface(db_base.DbTestCase):
remove_mock.assert_called_once_with(task, cleaning_network_uuid)
validate_mock.assert_called_once_with(
cleaning_network_uuid,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertNotIn('cleaning_vif_port_id', self.port.internal_info)
@ -291,7 +291,7 @@ class TestFlatInterface(db_base.DbTestCase):
add_mock.assert_called_once_with(
task, CONF.neutron.inspection_network)
validate_mock.assert_called_once_with(
CONF.neutron.inspection_network, 'inspection network',
CONF.neutron.inspection_network, 'inspection_network',
context=task.context)
self.port.refresh()
self.assertEqual('vif-port-id',
@ -319,7 +319,7 @@ class TestFlatInterface(db_base.DbTestCase):
add_mock.assert_called_with(task, inspection_network_uuid)
validate_mock.assert_called_with(
inspection_network_uuid,
'inspection network', context=task.context)
'inspection_network', context=task.context)
self.port.refresh()
self.assertEqual('vif-port-id',
self.port.internal_info['inspection_vif_port_id'])
@ -335,7 +335,7 @@ class TestFlatInterface(db_base.DbTestCase):
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.validate_inspection(task)
validate_mock.assert_called_once_with(
inspection_network_uuid, 'inspection network',
inspection_network_uuid, 'inspection_network',
context=task.context),
def test_validate_inspection_exc(self):

View File

@ -94,10 +94,10 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
# on validity of the name or UUID as well, the validate_network
# method gets called which rasies a validate parsable error.
self.assertEqual([mock.call(CONF.neutron.cleaning_network,
'cleaning network',
'cleaning_network',
context=task.context),
mock.call(CONF.neutron.provisioning_network,
'provisioning network',
'provisioning_network',
context=task.context)],
validate_mock.call_args_list)
@ -119,7 +119,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
security_groups=[])
validate_mock.assert_called_once_with(
CONF.neutron.provisioning_network,
'provisioning network', context=task.context)
'provisioning_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['provisioning_vif_port_id'])
@ -151,7 +151,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
security_groups=[])
validate_mock.assert_called_once_with(
provisioning_network_uuid,
'provisioning network', context=task.context)
'provisioning_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['provisioning_vif_port_id'])
@ -195,7 +195,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
task, CONF.neutron.provisioning_network)
validate_mock.assert_called_once_with(
CONF.neutron.provisioning_network,
'provisioning network', context=task.context)
'provisioning_network', context=task.context)
self.port.refresh()
self.assertNotIn('provisioning_vif_port_id', self.port.internal_info)
@ -218,7 +218,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
task, provisioning_network_uuid)
validate_mock.assert_called_once_with(
provisioning_network_uuid,
'provisioning network', context=task.context)
'provisioning_network', context=task.context)
self.port.refresh()
self.assertNotIn('provisioning_vif_port_id', self.port.internal_info)
@ -236,7 +236,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(res, add_ports_mock.return_value)
validate_mock.assert_called_once_with(
CONF.neutron.cleaning_network,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['cleaning_vif_port_id'])
@ -262,7 +262,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(res, add_ports_mock.return_value)
validate_mock.assert_called_once_with(
cleaning_network_uuid,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['cleaning_vif_port_id'])
@ -303,7 +303,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
task, CONF.neutron.cleaning_network)
validate_mock.assert_called_once_with(
CONF.neutron.cleaning_network,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertNotIn('cleaning_vif_port_id', self.port.internal_info)
@ -326,7 +326,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
task, cleaning_network_uuid)
validate_mock.assert_called_once_with(
cleaning_network_uuid,
'cleaning network', context=task.context)
'cleaning_network', context=task.context)
self.port.refresh()
self.assertNotIn('cleaning_vif_port_id', self.port.internal_info)
@ -341,14 +341,14 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.validate_rescue(task)
validate_mock.assert_called_once_with(
rescuing_network_uuid, 'rescuing network',
rescuing_network_uuid, 'rescuing_network',
context=task.context),
def test_validate_rescue_exc(self):
self.config(rescuing_network="", group='neutron')
with task_manager.acquire(self.context, self.node.id) as task:
self.assertRaisesRegex(exception.MissingParameterValue,
'rescuing network is not set',
'rescuing_network is not set',
self.interface.validate_rescue, task)
@mock.patch.object(neutron_common, 'validate_network',
@ -376,7 +376,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(add_ports_mock.return_value, res)
validate_mock.assert_called_once_with(
CONF.neutron.rescuing_network,
'rescuing network', context=task.context)
'rescuing_network', context=task.context)
other_port.refresh()
self.assertEqual(neutron_other_port['id'],
other_port.internal_info['rescuing_vif_port_id'])
@ -412,7 +412,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(add_ports_mock.return_value, res)
validate_mock.assert_called_once_with(
rescuing_network_uuid,
'rescuing network', context=task.context)
'rescuing_network', context=task.context)
other_port.refresh()
self.assertEqual(neutron_other_port['id'],
other_port.internal_info['rescuing_vif_port_id'])
@ -459,7 +459,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
task, CONF.neutron.rescuing_network)
validate_mock.assert_called_once_with(
CONF.neutron.rescuing_network,
'rescuing network', context=task.context)
'rescuing_network', context=task.context)
other_port.refresh()
self.assertNotIn('rescuing_vif_port_id', self.port.internal_info)
self.assertNotIn('rescuing_vif_port_id', other_port.internal_info)
@ -799,7 +799,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(res, add_ports_mock.return_value)
validate_mock.assert_called_once_with(
CONF.neutron.inspection_network,
'inspection network', context=task.context)
'inspection_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['inspection_vif_port_id'])
@ -826,7 +826,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
self.assertEqual(res, add_ports_mock.return_value)
validate_mock.assert_called_once_with(
inspection_network_uuid,
'inspection network', context=task.context)
'inspection_network', context=task.context)
self.port.refresh()
self.assertEqual(self.neutron_port.id,
self.port.internal_info['inspection_vif_port_id'])
@ -866,7 +866,7 @@ class NeutronInterfaceTestCase(db_base.DbTestCase):
with task_manager.acquire(self.context, self.node.id) as task:
self.interface.validate_inspection(task)
validate_mock.assert_called_once_with(
inspection_network_uuid, 'inspection network',
inspection_network_uuid, 'inspection_network',
context=task.context),
def test_validate_inspection_exc(self):