Esempio n. 1
0
    def test_get_vif_type(self):
        normal_port_cxt = base.FakePortContext(None, None, None)
        result = self.driver.get_vif_type(normal_port_cxt, self.AGENT, None)
        self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)

        result = self.driver.get_vif_type(normal_port_cxt,
                                          self.AGENT_SERVER, None)
        self.assertEqual(portbindings.VIF_TYPE_VHOST_USER, result)

        result = self.driver.get_vif_type(normal_port_cxt,
                                          self.AGENT_SYSTEM, None)
        self.assertEqual(portbindings.VIF_TYPE_OVS, result)

        direct_port_cxt = base.FakePortContext(
            None, None, None, vnic_type=portbindings.VNIC_DIRECT)
        result = self.driver.get_vif_type(direct_port_cxt,
                                          self.AGENT, None)
        self.assertEqual(portbindings.VIF_TYPE_OVS, result)
Esempio n. 2
0
 def _test_try_to_bind_segment_for_agent_migration(self, expected,
                                                   original):
     context = base.FakePortContext(self.AGENT_TYPE,
                                    self.AGENTS,
                                    self.MIGRATION_SEGMENTS,
                                    vnic_type=self.VNIC_TYPE,
                                    original=original)
     result = self.driver.try_to_bind_segment_for_agent(
         context, self.MIGRATION_SEGMENT, self.AGENT)
     self.assertEqual(expected, result)
Esempio n. 3
0
 def _make_port_ctx(self, agents):
     segments = [{
         api.ID: 'local_segment_id',
         api.PHYSICAL_NETWORK: 'fake_physical_network',
         api.NETWORK_TYPE: n_const.TYPE_FLAT
     }]
     return base.FakePortContext(self.AGENT_TYPE,
                                 agents,
                                 segments,
                                 vnic_type=self.VNIC_TYPE)
Esempio n. 4
0
    def test_vif_details_contains_physical_net(self):
        VLAN_SEGMENTS = [{api.ID: 'vlan_segment_id',
                          api.NETWORK_TYPE: 'vlan',
                          api.PHYSICAL_NETWORK: 'fake_physical_network',
                          api.SEGMENTATION_ID: 1234}]

        context = base.FakePortContext(self.AGENT_TYPE,
                                       self.AGENTS,
                                       VLAN_SEGMENTS,
                                       portbindings.VNIC_DIRECT)
        segment = VLAN_SEGMENTS[0]
        agent = self.AGENTS[0]
        self.driver.try_to_bind_segment_for_agent(context, segment, agent)
        set({"physical_network": "fake_physical_network"}).issubset(
            set(context._bound_vif_details.items()))
Esempio n. 5
0
    def test_type_vlan_vif_details(self):
        context = base.FakePortContext(self.AGENT_TYPE,
                                       self.AGENTS,
                                       self.VLAN_SEGMENTS,
                                       vnic_type=self.VNIC_TYPE)
        self.driver.bind_port(context)
        vif_details = context._bound_vif_details

        self.assertEqual(1234, vif_details.get(portbindings.VIF_DETAILS_VLAN))
        self.assertEqual(
            "bridge", vif_details.get(portbindings.VIF_DETAILS_MACVTAP_MODE))
        self.assertEqual(
            "fake_if",
            vif_details.get(portbindings.VIF_DETAILS_PHYSICAL_INTERFACE))
        self.assertEqual(
            "fake_if.1234",
            vif_details.get(portbindings.VIF_DETAILS_MACVTAP_SOURCE))
    def test_driver_responsible_for_ports_allocation(self):
        agents = [
            {'agent_type': 'Open vSwitch agent',
             'configurations': {'resource_provider_bandwidths': {'eth0': {}}},
             'id': '1',
             'host': 'host'}
        ]
        segments = []
        # uuid -v5 87ee7d5c-73bb-11e8-9008-c4d987b2a692 host:eth0
        profile = {'allocation': '13cc0ed9-e802-5eaa-b4c7-3441855e31f2'}

        port_ctx = base.FakePortContext(
            self.AGENT_TYPE,
            agents,
            segments,
            vnic_type=portbindings.VNIC_NORMAL,
            profile=profile)
        with mock.patch.object(self.driver, '_possible_agents_for_port',
                               return_value=agents):
            self.assertTrue(
                self.driver.responsible_for_ports_allocation(port_ctx))
Esempio n. 7
0
    def test_driver_responsible_for_ports_allocation(self):
        agents = [
            {'agent_type': constants.AGENT_TYPE_NIC_SWITCH,
             'configurations': {'resource_provider_bandwidths': {'eth0': {}}},
             'host': 'host',
             'id': '1'}
        ]
        segments = []
        # uuid -v5 87f1895c-73bb-11e8-9008-c4d987b2a692 host:eth0
        profile = {'allocation': '5762cf50-781b-5f01-8ebc-0cce8c9e74cd'}

        port_ctx = base.FakePortContext(
            self.AGENT_TYPE,
            agents,
            segments,
            vnic_type=portbindings.VNIC_DIRECT,
            profile=profile)
        with mock.patch.object(self.driver, '_possible_agents_for_port',
                               return_value=agents):
            self.assertTrue(
                self.driver.responsible_for_ports_allocation(port_ctx))
Esempio n. 8
0
 def _make_port_ctx(self, agents):
     segments = [{api.ID: 'local_segment_id', api.NETWORK_TYPE: 'local'}]
     return base.FakePortContext(self.AGENT_TYPE,
                                 agents,
                                 segments,
                                 vnic_type=self.VNIC_TYPE)
 def test_type_vxlan_bad(self):
     context = base.FakePortContext(self.AGENT_TYPE, self.AGENTS_BAD,
                                    self.VXLAN_SEGMENTS)
     self.driver.bind_port(context)
     self._check_unbound(context)
 def test_type_vxlan(self):
     context = base.FakePortContext(self.AGENT_TYPE, self.AGENTS,
                                    self.VXLAN_SEGMENTS)
     self.driver.bind_port(context)
     self._check_bound(context, self.VXLAN_SEGMENTS[1])
Esempio n. 11
0
 def _make_port_ctx(self, agents, profile=None):
     segments = [{api.ID: 'local_segment_id', api.NETWORK_TYPE: 'local'}]
     return base.FakePortContext(self.AGENT_TYPE, agents, segments,
                                 vnic_type=portbindings.VNIC_DIRECT,
                                 profile=profile)
Esempio n. 12
0
 def _check_vif_type_for_vnic_type(self, vnic_type, expected_vif_type):
     context = base.FakePortContext(self.AGENT_TYPE, self.AGENTS,
                                    self.VLAN_SEGMENTS, vnic_type)
     self.driver.bind_port(context)
     self.assertEqual(expected_vif_type, context._bound_vif_type)