コード例 #1
0
 def test__infer_driver_from_allocation_positive(self):
     cfg.CONF.set_override('mechanism_drivers', ['fake_agent'], group='ml2')
     manager = managers.MechanismManager()
     with mock.patch.object(mech_fake_agent.FakeAgentMechanismDriver,
                            'responsible_for_ports_allocation',
                            return_value=True):
         responsible_driver = manager._infer_driver_from_allocation(
             FakePortContext(
                 None,
                 None,
                 self.segments_to_bind,
                 profile={'allocation': 'fake_resource_provider'}))
         self.assertEqual(responsible_driver.name, 'fake_agent')
コード例 #2
0
 def test__infer_driver_from_allocation_negative(self):
     cfg.CONF.set_override('mechanism_drivers', ['fake_agent'], group='ml2')
     manager = managers.MechanismManager()
     with mock.patch.object(mech_fake_agent.FakeAgentMechanismDriver,
                            'responsible_for_ports_allocation',
                            return_value=False):
         self.assertRaises(
             place_exc.UnknownResourceProvider,
             manager._infer_driver_from_allocation,
             FakePortContext(
                 None,
                 None,
                 self.segments_to_bind,
                 profile={'allocation': 'fake_resource_provider'}))
コード例 #3
0
 def setUp(self):
     super(TestManagers, self).setUp()
     self.segment_id = "11111111-2222-3333-4444-555555555555"
     self.segments_to_bind = [{
         api.ID: self.segment_id,
         'network_type': 'vlan',
         'physical_network': 'public',
         api.SEGMENTATION_ID: 49
     }]
     self.context = FakePortContext(None, None, self.segments_to_bind)
     self.context._binding = mock.Mock()
     self.context._binding_levels = []
     self.context._new_bound_segment = self.segment_id
     self.context._next_segments_to_bind = None
コード例 #4
0
ファイル: test_managers.py プロジェクト: worldzxw/neutron
 def setUp(self):
     super(TestManagers, self).setUp()
     self.segment_id = "11111111-2222-3333-4444-555555555555"
     self.segments_to_bind = [{api.ID: self.segment_id,
                               'network_type': 'vlan',
                               'physical_network': 'public',
                               api.SEGMENTATION_ID: 49}]
     original_port = {'fixed_ips': [{'subnet_id': mock.ANY,
                                     'ip_address': mock.ANY}]}
     self.context = FakePortContext(None, None, self.segments_to_bind,
                                    original=original_port)
     self.context._binding = mock.Mock()
     self.context._binding_levels = []
     self.context._new_bound_segment = self.segment_id
     self.context._next_segments_to_bind = None
コード例 #5
0
ファイル: test_managers.py プロジェクト: stackhpc/neutron
 def test__infer_driver_from_allocation_ambiguous(self):
     cfg.CONF.set_override('mechanism_drivers',
                           ['fake_agent', 'another_fake_agent'],
                           group='ml2')
     manager = managers.MechanismManager()
     with mock.patch.object(mech_fake_agent.FakeAgentMechanismDriver,
                            'responsible_for_ports_allocation',
                            return_value=True), \
         mock.patch.object(mech_fake_agent.AnotherFakeAgentMechanismDriver,
                           'responsible_for_ports_allocation',
                           return_value=True):
         self.assertRaises(
             place_exc.AmbiguousResponsibilityForResourceProvider,
             manager._infer_driver_from_allocation,
             FakePortContext(None,
                             None,
                             self.segments_to_bind,
                             profile={
                                 'allocation': {
                                     'fake_uuid': 'fake_resource_provider'
                                 }
                             }))