Merge "FUP: Catch and reraise routed nets exception"
This commit is contained in:
commit
57913e1230
@ -1195,7 +1195,7 @@ class RequestFilterFailed(NovaException):
|
|||||||
msg_fmt = _("Scheduling failed: %(reason)s")
|
msg_fmt = _("Scheduling failed: %(reason)s")
|
||||||
|
|
||||||
|
|
||||||
class InvalidRoutedNetworkConfiguration(RequestFilterFailed):
|
class InvalidRoutedNetworkConfiguration(NovaException):
|
||||||
msg_fmt = _("Neutron routed networks configuration is invalid: "
|
msg_fmt = _("Neutron routed networks configuration is invalid: "
|
||||||
"%(reason)s.")
|
"%(reason)s.")
|
||||||
|
|
||||||
|
@ -326,8 +326,13 @@ def routed_networks_filter(
|
|||||||
# subnets than only one but given they would be for the same
|
# subnets than only one but given they would be for the same
|
||||||
# port, just looking at the first subnet is needed.
|
# port, just looking at the first subnet is needed.
|
||||||
subnet_id = port['fixed_ips'][0]['subnet_id']
|
subnet_id = port['fixed_ips'][0]['subnet_id']
|
||||||
|
try:
|
||||||
aggregates = utils.get_aggregates_for_routed_subnet(
|
aggregates = utils.get_aggregates_for_routed_subnet(
|
||||||
ctxt, network_api, report_api, subnet_id)
|
ctxt, network_api, report_api, subnet_id)
|
||||||
|
except exception.InvalidRoutedNetworkConfiguration as e:
|
||||||
|
raise exception.RequestFilterFailed(
|
||||||
|
reason=_('Aggregates not found for the subnet %s'
|
||||||
|
) % subnet_id) from e
|
||||||
else:
|
else:
|
||||||
# The port was just created without a subnet.
|
# The port was just created without a subnet.
|
||||||
network_id = port["network_id"]
|
network_id = port["network_id"]
|
||||||
@ -339,8 +344,13 @@ def routed_networks_filter(
|
|||||||
if network_id:
|
if network_id:
|
||||||
# As the user only requested a network or a port unbound to a
|
# As the user only requested a network or a port unbound to a
|
||||||
# segment, we are free to choose any segment from the network.
|
# segment, we are free to choose any segment from the network.
|
||||||
|
try:
|
||||||
aggregates = utils.get_aggregates_for_routed_network(
|
aggregates = utils.get_aggregates_for_routed_network(
|
||||||
ctxt, network_api, report_api, network_id)
|
ctxt, network_api, report_api, network_id)
|
||||||
|
except exception.InvalidRoutedNetworkConfiguration as e:
|
||||||
|
raise exception.RequestFilterFailed(
|
||||||
|
reason=_('Aggregates not found for the network %s'
|
||||||
|
) % network_id) from e
|
||||||
|
|
||||||
if aggregates:
|
if aggregates:
|
||||||
LOG.debug(
|
LOG.debug(
|
||||||
|
@ -518,11 +518,12 @@ class RoutedNetworkTests(integrated_helpers._IntegratedTestBase):
|
|||||||
|
|
||||||
# Make sure we correctly looked up at which aggregates were related to
|
# Make sure we correctly looked up at which aggregates were related to
|
||||||
# the segment ID #2
|
# the segment ID #2
|
||||||
exp_segment_id = self.neutron.segment_id_2['id']
|
expected_subnet_id = self.neutron.subnet_for_segment_id_2['id']
|
||||||
|
expected_segment_id = self.neutron.segment_id_2['id']
|
||||||
mock_get_aggregates.assert_called_once_with(
|
mock_get_aggregates.assert_called_once_with(
|
||||||
mock.ANY, exp_segment_id)
|
mock.ANY, expected_segment_id)
|
||||||
|
|
||||||
self.assertIn('No valid host', server['fault']['message'])
|
self.assertIn('No valid host', server['fault']['message'])
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
'Failed to find aggregate related to segment %s' % exp_segment_id,
|
'Aggregates not found for the subnet %s' % expected_subnet_id,
|
||||||
server['fault']['message'])
|
server['fault']['message'])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user