use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId in project openflowplugin by opendaylight.
the class PacketReceivedTranslatorTest method testTranslate.
@Test
public void testTranslate() throws Exception {
final KeyedInstanceIdentifier<Node, NodeKey> nodePath = KeyedInstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:10")));
final PacketReceivedTranslator packetReceivedTranslator = new PacketReceivedTranslator(convertorManager);
final PacketInMessage packetInMessage = createPacketInMessage(DATA.getBytes(), PORT_NO);
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
final PacketReceived packetReceived = packetReceivedTranslator.translate(packetInMessage, deviceInfo, null);
Assert.assertArrayEquals(packetInMessage.getData(), packetReceived.getPayload());
Assert.assertEquals("org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.SendToController", packetReceived.getPacketInReason().getName());
Assert.assertEquals("openflow:10:" + PORT_NO, packetReceived.getIngress().getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class).getId().getValue());
Assert.assertEquals(0L, packetReceived.getFlowCookie().getValue().longValue());
Assert.assertEquals(42L, packetReceived.getTableId().getValue().longValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId in project openflowplugin by opendaylight.
the class OpenflowpluginTableFeaturesTestServiceProvider method register.
public ObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider> register(final ProviderContext ctx) {
RoutedRpcRegistration<SalTableService> addRoutedRpcImplementation = ctx.<SalTableService>addRoutedRpcImplementation(SalTableService.class, this);
setTableRegistration(addRoutedRpcImplementation);
InstanceIdentifierBuilder<Nodes> builder1 = InstanceIdentifier.<Nodes>builder(Nodes.class);
NodeId nodeId = new NodeId(OpenflowpluginTestActivator.NODE_ID);
NodeKey nodeKey = new NodeKey(nodeId);
InstanceIdentifierBuilder<Node> nodeIndentifier = builder1.<Node, NodeKey>child(Node.class, nodeKey);
InstanceIdentifier<Node> instance = nodeIndentifier.build();
tableRegistration.registerPath(NodeContext.class, instance);
RoutedRpcRegistration<SalTableService> tableRegistration1 = this.getTableRegistration();
return new AbstractObjectRegistration<OpenflowpluginTableFeaturesTestServiceProvider>(this) {
@Override
protected void removeRegistration() {
tableRegistration1.close();
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId in project openflowplugin by opendaylight.
the class AbstractDirectStatisticsServiceTest method init.
@Before
public void init() throws Exception {
nodeConnectorId = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(DATAPATH_ID, PORT_NO, OpenflowVersion.get(OF_VERSION));
nodeInstanceIdentifier = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(new NodeId(NODE_ID)));
convertorManager = ConvertorManagerFactory.createDefaultManager();
when(deviceContext.getDeviceFlowRegistry()).thenReturn(deviceFlowRegistry);
when(deviceContext.getDeviceGroupRegistry()).thenReturn(deviceGroupRegistry);
when(deviceContext.getDeviceMeterRegistry()).thenReturn(deviceMeterRegistry);
when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
when(deviceContext.getMultiMsgCollector(any())).thenReturn(multiMsgCollector);
when(deviceContext.oook()).thenReturn(translatorLibrary);
when(deviceContext.getDeviceState()).thenReturn(deviceState);
when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
when(deviceInfo.getNodeId()).thenReturn(new NodeId(NODE_ID));
when(deviceInfo.getVersion()).thenReturn(OF_VERSION);
when(deviceInfo.getDatapathId()).thenReturn(DATAPATH_ID);
when(getFeaturesOutput.getVersion()).thenReturn(OF_VERSION);
when(getFeaturesOutput.getDatapathId()).thenReturn(DATAPATH_ID);
when(connectionContext.getFeatures()).thenReturn(features);
when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
when(features.getVersion()).thenReturn(OF_VERSION);
when(features.getDatapathId()).thenReturn(DATAPATH_ID);
multipartWriterProvider = MultipartWriterProviderFactory.createDefaultProvider(deviceContext);
setUp();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId in project openflowplugin by opendaylight.
the class InventoryDataServiceUtilTest method testDataPathIdFromNodeId.
/**
* Test method for {@link InventoryDataServiceUtil#dataPathIdFromNodeId(NodeId)}.
*/
@Test
public void testDataPathIdFromNodeId() {
String string = "openflow:";
NodeId[] nodeIds = new NodeId[] { // 0x00000000 000004d2
new NodeId(string + "1234"), // 0x8db2089e 01391a86
new NodeId(string + "10210232779920710278"), // 0xffffffff ffffffff
new NodeId(string + "18446744073709551615") };
long[] expectedDPIDs = new long[] { 1234L, -8236511293788841338L, -1L };
for (int i = 0; i < nodeIds.length; i++) {
BigInteger datapathId = InventoryDataServiceUtil.dataPathIdFromNodeId(nodeIds[i]);
Assert.assertEquals(expectedDPIDs[i], datapathId.longValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId in project openflowplugin by opendaylight.
the class RpcManagerImplTest method setUp.
@Before
public void setUp() {
final NodeKey nodeKey = new NodeKey(nodeId);
rpcManager = new RpcManagerImpl(new OpenflowProviderConfigBuilder().setRpcRequestsQuota(new NonZeroUint16Type(QUOTA_VALUE)).setIsStatisticsRpcEnabled(false).build(), rpcProviderRegistry, extensionConverterProvider, convertorExecutor, notificationPublishService);
FeaturesReply features = new GetFeaturesOutputBuilder().setVersion(OFConstants.OFP_VERSION_1_3).build();
Mockito.when(deviceInfo.getNodeId()).thenReturn(nodeKey.getId());
Mockito.when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodePath);
Mockito.when(connectionContext.getFeatures()).thenReturn(features);
Mockito.when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
Mockito.when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
Mockito.when(rpcProviderRegistry.addRoutedRpcImplementation(Matchers.any(), Matchers.any(RpcService.class))).thenReturn(routedRpcRegistration);
Mockito.when(contexts.remove(deviceInfo)).thenReturn(removedContexts);
}
Aggregations