use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey in project genius by opendaylight.
the class MDSALUtil method getNodeConnRef.
public static NodeConnectorRef getNodeConnRef(String nodeId, String port) {
StringBuilder sb = new StringBuilder();
sb.append(nodeId);
sb.append(SEPARATOR);
sb.append(port);
String nodeConnectorKeyAsString = sb.toString();
NodeConnectorId nodeConnectorId = new NodeConnectorId(nodeConnectorKeyAsString);
NodeConnectorKey nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeKey);
InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder = nodeInstanceIdentifierBuilder.child(NodeConnector.class, nodeConnectorKey);
InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier = nodeConnectorInstanceIdentifierBuilder.toInstance();
NodeConnectorRef nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
return nodeConnectorRef;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey in project openflowplugin by opendaylight.
the class LLDPDiscoveryUtilsTest method testLldpToNodeConnectorRefLLDP.
@Test
public void testLldpToNodeConnectorRefLLDP() throws Exception {
byte[] packetLLDP = { 0x01, 0x23, 0x00, 0x00, 0x00, 0x01, (byte) 0x8a, (byte) 0x8e, (byte) 0xcc, (byte) 0x85, (byte) 0xeb, 0x27, /* ethernet type LLDP 0x88cc */
(byte) 0x88, (byte) 0xcc, 0x02, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x04, 0x02, 0x07, 0x32, 0x06, 0x02, 0x13, 0x37, 0x0a, 0x0a, /* openflow:2 */
0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32, (byte) 0xfe, 0x10, 0x00, 0x26, (byte) 0xe1, 0x00, /* openflow:2:2 */
0x6f, 0x70, 0x65, 0x6e, 0x66, 0x6c, 0x6f, 0x77, 0x3a, 0x32, 0x3a, 0x32, (byte) 0xfe, 0x14, 0x00, 0x26, (byte) 0xe1, 0x01, 0x62, (byte) 0xc8, 0x2b, 0x67, (byte) 0xce, (byte) 0xbe, 0x7c, 0x2b, 0x47, (byte) 0xbe, 0x2b, (byte) 0xe7, (byte) 0xbc, (byte) 0xe9, 0x75, 0x3d, 0x00, 0x00 };
NodeConnectorRef nodeConnectorRef = LLDPDiscoveryUtils.lldpToNodeConnectorRef(packetLLDP, false);
NodeKey nodeKey = nodeConnectorRef.getValue().firstKeyOf(Node.class, NodeKey.class);
NodeConnectorKey nodeConnectorKey = nodeConnectorRef.getValue().firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
assertEquals(nodeKey.getId().getValue(), "openflow:2");
assertEquals(nodeConnectorKey.getId().getValue(), "openflow:2:2");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey in project openflowplugin by opendaylight.
the class NodeConnectorStatNotificationSupplierImpl method createNotification.
@Override
public NodeConnectorStatisticsUpdate createNotification(final FlowCapableNodeConnectorStatistics flowCapableNodeConnectorStatistics, final InstanceIdentifier<FlowCapableNodeConnectorStatistics> path) {
Preconditions.checkArgument(flowCapableNodeConnectorStatistics != null);
Preconditions.checkArgument(path != null);
final NodeConnectorBuilder ncBuilder = new NodeConnectorBuilder();
final NodeConnectorKey ncKey = path.firstKeyOf(NodeConnector.class, NodeConnectorKey.class);
ncBuilder.setId(ncKey.getId());
ncBuilder.setKey(ncKey);
final NodeConnectorStatisticsUpdateBuilder builder = new NodeConnectorStatisticsUpdateBuilder();
builder.setId(getNodeId(path));
builder.setMoreReplies(Boolean.FALSE);
builder.setNodeConnector(Collections.singletonList(ncBuilder.build()));
builder.setNodeConnectorStatisticsAndPortNumberMap(Collections.singletonList(new NodeConnectorStatisticsAndPortNumberMapBuilder(flowCapableNodeConnectorStatistics).build()));
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey in project openflowplugin by opendaylight.
the class PortStatsMultipartWriter method storeStatistics.
@Override
public void storeStatistics(final NodeConnectorStatisticsAndPortNumberMap statistics, final boolean withParents) {
statistics.getNodeConnectorStatisticsAndPortNumberMap().forEach(stat -> {
final OpenflowVersion openflowVersion = OpenflowVersion.get(features.getVersion());
final Long port = InventoryDataServiceUtil.portNumberfromNodeConnectorId(openflowVersion, stat.getNodeConnectorId());
final NodeConnectorId id = InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(features.getDatapathId(), port, OpenflowVersion.get(features.getVersion()));
writeToTransaction(getInstanceIdentifier().child(NodeConnector.class, new NodeConnectorKey(id)).augmentation(FlowCapableNodeConnectorStatisticsData.class).child(FlowCapableNodeConnectorStatistics.class), new FlowCapableNodeConnectorStatisticsBuilder(stat).build(), OFConstants.OFP_VERSION_1_0 == features.getVersion() || withParents);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey in project openflowplugin by opendaylight.
the class DeviceContextImpl method writePortStatusMessage.
private void writePortStatusMessage(final PortStatus portStatusMessage) {
final FlowCapableNodeConnector flowCapableNodeConnector = portStatusTranslator.translate(portStatusMessage, getDeviceInfo(), null);
final KeyedInstanceIdentifier<NodeConnector, NodeConnectorKey> iiToNodeConnector = getDeviceInfo().getNodeInstanceIdentifier().child(NodeConnector.class, new NodeConnectorKey(InventoryDataServiceUtil.nodeConnectorIdfromDatapathPortNo(deviceInfo.getDatapathId(), portStatusMessage.getPortNo(), OpenflowVersion.get(deviceInfo.getVersion()))));
writeToTransaction(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector, new NodeConnectorBuilder().setKey(iiToNodeConnector.getKey()).addAugmentation(FlowCapableNodeConnectorStatisticsData.class, new FlowCapableNodeConnectorStatisticsDataBuilder().build()).addAugmentation(FlowCapableNodeConnector.class, flowCapableNodeConnector).build());
submitTransaction();
if (PortReason.OFPPRDELETE.equals(portStatusMessage.getReason())) {
addDeleteToTxChain(LogicalDatastoreType.OPERATIONAL, iiToNodeConnector);
submitTransaction();
}
}
Aggregations