use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef 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.NodeRef in project openflowplugin by opendaylight.
the class NodeNotificationSupplierImpl method createNotification.
@Override
public NodeUpdated createNotification(final FlowCapableNode flowCapableNode, final InstanceIdentifier<FlowCapableNode> ii) {
Preconditions.checkArgument(flowCapableNode != null);
Preconditions.checkArgument(ii != null);
final FlowCapableNodeUpdatedBuilder flowNodeNotifBuilder = new FlowCapableNodeUpdatedBuilder(flowCapableNode);
final NodeUpdatedBuilder notifBuilder = new NodeUpdatedBuilder();
notifBuilder.setId(ii.firstKeyOf(Node.class, NodeKey.class).getId());
notifBuilder.setNodeRef(new NodeRef(getNodeII(ii)));
notifBuilder.addAugmentation(FlowCapableNodeUpdated.class, flowNodeNotifBuilder.build());
return notifBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class DefaultConfigPusher method onDataTreeChanged.
@Override
public void onDataTreeChanged(@Nonnull final Collection<DataTreeModification<FlowCapableNode>> modifications) {
for (DataTreeModification<FlowCapableNode> modification : modifications) {
if (modification.getRootNode().getModificationType() == ModificationType.WRITE) {
SetConfigInputBuilder setConfigInputBuilder = new SetConfigInputBuilder();
setConfigInputBuilder.setFlag(SwitchConfigFlag.FRAGNORMAL.toString());
setConfigInputBuilder.setMissSearchLength(OFConstants.OFPCML_NO_BUFFER);
setConfigInputBuilder.setNode(new NodeRef(modification.getRootPath().getRootIdentifier().firstIdentifierOf(Node.class)));
final Future<RpcResult<SetConfigOutput>> resultFuture = nodeConfigService.setConfig(setConfigInputBuilder.build());
JdkFutures.addErrorLogging(resultFuture, LOG, "addFlow");
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class Test method testFlow.
@Override
public Future<RpcResult<Void>> testFlow(TestFlowInput input) {
AddFlowInputBuilder flow = new AddFlowInputBuilder();
flow.setPriority(2);
flow.setMatch(createMatchBld().build());
flow.setInstructions(createDecNwTtlInstructionsBld().build());
flow.setBarrier(Boolean.FALSE);
BigInteger value = BigInteger.valueOf(10L);
flow.setCookie(new FlowCookie(value));
flow.setCookieMask(new FlowCookie(value));
flow.setHardTimeout(0);
flow.setIdleTimeout(0);
flow.setInstallHw(false);
flow.setStrict(false);
flow.setContainerName(null);
flow.setFlags(new FlowModFlags(false, false, false, false, true));
flow.setTableId((short) 0);
flow.setFlowName("NiciraFLOW");
// Construct the flow instance id
final InstanceIdentifier<Node> flowInstanceId = InstanceIdentifier.builder(// File under nodes
Nodes.class).child(Node.class, new NodeKey(new NodeId("openflow:1"))).build();
flow.setNode(new NodeRef(flowInstanceId));
pushFlowViaRpc(flow.build());
return Futures.immediateFuture(RpcResultBuilder.<Void>status(true).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef in project openflowplugin by opendaylight.
the class SalRoleServiceImplTest method setup.
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
Mockito.when(mockDeviceInfo.getNodeId()).thenReturn(testNodeId);
Mockito.when(mockDeviceInfo.getDatapathId()).thenReturn(BigInteger.TEN);
short testVersion = 4;
Mockito.when(mockFeaturesOutput.getVersion()).thenReturn(testVersion);
Mockito.when(mockDeviceContext.getDeviceState()).thenReturn(mockDeviceState);
Mockito.when(mockDeviceContext.getDeviceInfo()).thenReturn(mockDeviceInfo);
Mockito.when(mockDeviceContext.getPrimaryConnectionContext()).thenReturn(mockConnectionContext);
Mockito.when(mockConnectionContext.getFeatures()).thenReturn(mockFeaturesReply);
Mockito.when(mockConnectionContext.getNodeId()).thenReturn(testNodeId);
Mockito.when(mockFeaturesReply.getVersion()).thenReturn(testVersion);
Mockito.when(mockDeviceContext.getMessageSpy()).thenReturn(mockMessageSpy);
Mockito.when(mockRequestContextStack.<RoleRequestOutput>createRequestContext()).thenReturn(mockRequestContext);
Mockito.when(mockRequestContext.getXid()).thenReturn(new Xid(testXid));
Mockito.when(mockConnectionContext.getOutboundQueueProvider()).thenReturn(mockOutboundQueue);
Mockito.when(mockDeviceContext.getPrimaryConnectionContext().getConnectionState()).thenReturn(ConnectionContext.CONNECTION_STATE.WORKING);
NodeKey key = new NodeKey(testNodeId);
InstanceIdentifier<Node> path = InstanceIdentifier.<Nodes>builder(Nodes.class).<Node, NodeKey>child(Node.class, key).build();
nodeRef = new NodeRef(path);
}
Aggregations