Exemple #1
0
    def test_get_aggregates_for_routed_subnet(self, mock_get_segment_ids):
        mock_get_segment_ids.return_value = uuids.segment1
        report_client = report.SchedulerReportClient()
        network_api = neutron.API()
        agg_info = report.AggInfo(aggregates=[uuids.agg1], generation=1)

        with mock.patch.object(report_client, '_get_provider_aggregates',
                return_value=agg_info) as mock_get_aggs:
            res = scheduler_utils.get_aggregates_for_routed_subnet(
                self.context, network_api, report_client,
                uuids.subnet1)
        self.assertEqual([uuids.agg1], res)
        mock_get_segment_ids.assert_called_once_with(
            self.context, uuids.subnet1)
        mock_get_aggs.assert_called_once_with(self.context, uuids.segment1)
Exemple #2
0
    def test_get_aggregates_for_routed_subnet_fails(self,
                                                    mock_get_segment_ids):
        mock_get_segment_ids.return_value = uuids.segment1
        report_client = report.SchedulerReportClient()
        network_api = neutron.API()

        # We could fail on some placement issue...
        with mock.patch.object(report_client, '_get_provider_aggregates',
                return_value=None):
            self.assertRaises(
                exception.InvalidRoutedNetworkConfiguration,
                scheduler_utils.get_aggregates_for_routed_subnet,
                self.context, network_api, report_client, uuids.subnet1)

        # ... but we also want to fail if we can't find the related aggregate
        agg_info = report.AggInfo(aggregates=set(), generation=1)
        with mock.patch.object(report_client, '_get_provider_aggregates',
                return_value=agg_info):
            self.assertRaises(
                exception.InvalidRoutedNetworkConfiguration,
                scheduler_utils.get_aggregates_for_routed_subnet,
                self.context, network_api, report_client, uuids.subnet1)
Exemple #3
0
 def fake_get_provider_aggregates(context, segment_id):
     agg = uuids.agg1 if segment_id == uuids.segment1 else uuids.agg2
     agg_info = report.AggInfo(aggregates=[agg], generation=1)
     return agg_info