use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class MatchConvertorV10Test method createMatchBuilderWithDefaults.
private static MatchBuilder createMatchBuilderWithDefaults() {
EthernetMatchBuilder ethernetMatchBuilder = new EthernetMatchBuilder();
EthernetTypeBuilder ethernetTypeBuilder = new EthernetTypeBuilder();
// IEEE802.3
EtherType etherType = new EtherType(ETH_TYPE_802_3);
ethernetTypeBuilder.setType(etherType);
ethernetMatchBuilder.setEthernetType(ethernetTypeBuilder.build());
EthernetDestinationBuilder ethernetDestinationBuilder = new EthernetDestinationBuilder();
ethernetDestinationBuilder.setAddress(ZERO_MAC);
ethernetDestinationBuilder.setMask(ZERO_MAC);
ethernetMatchBuilder.setEthernetDestination(ethernetDestinationBuilder.build());
EthernetSourceBuilder ethernetSourceBuilder = new EthernetSourceBuilder();
ethernetSourceBuilder.setMask(FF_MAC);
ethernetSourceBuilder.setAddress(FF_MAC);
ethernetMatchBuilder.setEthernetSource(ethernetSourceBuilder.build());
MatchBuilder matchBuilder = new MatchBuilder();
matchBuilder.setEthernetMatch(ethernetMatchBuilder.build());
NodeConnectorId nodeConnectorId = NodeConnectorId.getDefaultInstance(NODE_CONNECTOR_ID);
matchBuilder.setInPhyPort(nodeConnectorId);
matchBuilder.setInPort(nodeConnectorId);
IpMatchBuilder ipMatchBuilder = new IpMatchBuilder();
ipMatchBuilder.setIpDscp(Dscp.getDefaultInstance(DSCP));
ipMatchBuilder.setIpEcn(ZERO);
ipMatchBuilder.setIpProto(IpVersion.Ipv4);
ipMatchBuilder.setIpProtocol(IP_PROTOCOL);
matchBuilder.setIpMatch(ipMatchBuilder.build());
Ipv4MatchBuilder ipv4MatchBuilder = new Ipv4MatchBuilder();
ipv4MatchBuilder.setIpv4Destination(IPV4_PREFIX);
ipv4MatchBuilder.setIpv4Source(IPV4_PREFIX);
matchBuilder.setLayer3Match(ipv4MatchBuilder.build());
matchBuilder.setInPort(new NodeConnectorId(NODE_CONNECTOR_ID));
return matchBuilder;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class OpenflowpluginTestCommandProvider method createAppyActionInstruction23.
private static InstructionsBuilder createAppyActionInstruction23(final NodeId nodeId) {
final List<Action> actionList = new ArrayList<>();
final ActionBuilder ab = new ActionBuilder();
final SetFieldBuilder setFieldBuilder = new SetFieldBuilder();
setFieldBuilder.setInPort(new NodeConnectorId(nodeId + ":2"));
ab.setKey(new ActionKey(0));
actionList.add(ab.build());
// Create an Apply Action
final ApplyActionsBuilder aab = new ApplyActionsBuilder();
aab.setAction(actionList);
// Wrap our Apply Action in an Instruction
final InstructionBuilder ib = new InstructionBuilder();
ib.setInstruction(new ApplyActionsCaseBuilder().setApplyActions(aab.build()).build());
// Put our Instruction in a list of Instructions
final InstructionsBuilder isb = new InstructionsBuilder();
final List<Instruction> instructions = new ArrayList<>();
ib.setKey(new InstructionKey(0));
instructions.add(ib.build());
isb.setInstruction(instructions);
return isb;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class LLDPSpeaker method nodeConnectorRemoved.
@Override
public void nodeConnectorRemoved(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId) {
Preconditions.checkNotNull(nodeConnectorInstanceId);
nodeConnectorMap.remove(nodeConnectorInstanceId);
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
LOG.trace("Port removed from node-connector map : {}", nodeConnectorId.getValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId in project openflowplugin by opendaylight.
the class LLDPSpeaker method nodeConnectorAdded.
@Override
public void nodeConnectorAdded(final InstanceIdentifier<NodeConnector> nodeConnectorInstanceId, final FlowCapableNodeConnector flowConnector) {
NodeConnectorId nodeConnectorId = InstanceIdentifier.keyOf(nodeConnectorInstanceId).getId();
// port, so first we check if we actually need to perform any action
if (nodeConnectorMap.containsKey(nodeConnectorInstanceId)) {
LOG.debug("Port {} already in LLDPSpeaker.nodeConnectorMap, no need for additional processing", nodeConnectorId.getValue());
return;
}
// Prepare to build LLDP payload
InstanceIdentifier<Node> nodeInstanceId = nodeConnectorInstanceId.firstIdentifierOf(Node.class);
NodeId nodeId = InstanceIdentifier.keyOf(nodeInstanceId).getId();
MacAddress srcMacAddress = flowConnector.getHardwareAddress();
Long outputPortNo = flowConnector.getPortNumber().getUint32();
// No need to send LLDP frames on local ports
if (outputPortNo == null) {
LOG.debug("Port {} is local, not sending LLDP frames through it", nodeConnectorId.getValue());
return;
}
// Generate packet with destination switch and port
TransmitPacketInput packet;
try {
packet = new TransmitPacketInputBuilder().setEgress(new NodeConnectorRef(nodeConnectorInstanceId)).setNode(new NodeRef(nodeInstanceId)).setPayload(LLDPUtil.buildLldpFrame(nodeId, nodeConnectorId, srcMacAddress, outputPortNo, addressDestionation)).build();
} catch (NoSuchAlgorithmException | PacketException e) {
LOG.error("Error building LLDP frame", e);
return;
}
// Save packet to node connector id -> packet map to transmit it periodically on the configured interval.
nodeConnectorMap.put(nodeConnectorInstanceId, packet);
LOG.debug("Port {} added to LLDPSpeaker.nodeConnectorMap", nodeConnectorId.getValue());
// Transmit packet for first time immediately
final Future<RpcResult<Void>> resultFuture = packetProcessingService.transmitPacket(packet);
JdkFutures.addErrorLogging(resultFuture, LOG, "transmitPacket");
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId 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);
});
}
Aggregations