def test_bind_port_unsupported_vnic_type(self): network = mock.MagicMock(spec=driver_api.NetworkContext) port_context = mock.MagicMock( spec=ctx.PortContext, current={'id': 'CURRENT_CONTEXT_ID', portbindings.VNIC_TYPE: portbindings.VNIC_DIRECT}, segments_to_bind=[self.valid_segment, self.invalid_segment], network=network) mgr = legacy_port_binding.LegacyPortBindingManager() mgr.bind_port(port_context) port_context.set_binding.assert_not_called()
def test_bind_port_front_end(self): given_front_end = mech_driver.OpenDaylightMechanismDriver() given_port_context = self.given_port_context() given_back_end = mech_driver.OpenDaylightDriver() given_front_end.odl_drv = given_back_end given_back_end.port_binding_controller = \ legacy_port_binding.LegacyPortBindingManager() # when port is bound given_front_end.bind_port(given_port_context) # then context binding is setup with returned vif_type and valid # segment API ID given_port_context.set_binding.assert_called_once_with( self.valid_segment[api.ID], portbindings.VIF_TYPE_OVS, given_back_end.port_binding_controller.vif_details, status=n_constants.PORT_STATUS_ACTIVE)
def test_bind_port(self): network = mock.MagicMock(spec=driver_api.NetworkContext) port_context = mock.MagicMock( spec=ctx.PortContext, current={'id': 'CURRENT_CONTEXT_ID'}, segments_to_bind=[self.valid_segment, self.invalid_segment], network=network) mgr = legacy_port_binding.LegacyPortBindingManager() vif_type = mgr._get_vif_type(port_context) mgr.bind_port(port_context) port_context.set_binding.assert_called_once_with( self.valid_segment[api.ID], vif_type, mgr.vif_details, status=n_constants.PORT_STATUS_ACTIVE)
def test_check_segment(self): """Validate the _check_segment method.""" all_network_types = [n_constants.TYPE_FLAT, n_constants.TYPE_GRE, n_constants.TYPE_LOCAL, n_constants.TYPE_VXLAN, n_constants.TYPE_VLAN, n_constants.TYPE_NONE] mgr = legacy_port_binding.LegacyPortBindingManager() valid_types = { network_type for network_type in all_network_types if mgr._check_segment({api.NETWORK_TYPE: network_type})} self.assertEqual({ n_constants.TYPE_FLAT, n_constants.TYPE_LOCAL, n_constants.TYPE_GRE, n_constants.TYPE_VXLAN, n_constants.TYPE_VLAN}, valid_types)