use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class NeutronFloatingToFixedIpMappingChangeListener method removeRouterPortsOrPortsNode.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeRouterPortsOrPortsNode(String routerName, InstanceIdentifier.InstanceIdentifierBuilder<RouterPorts> routerPortsIdentifierBuilder, List<Ports> portsList, String fixedNeutronPortName, boolean isLockAcquired) {
String lockName = null;
try {
if (portsList.size() == 1) {
// remove entire routerPorts node
lockName = routerName;
isLockAcquired = routerLock.tryLock(lockName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
LOG.debug("removing routerPorts node: {} ", routerName);
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
} else {
// remove entire ports node under this routerPorts node
lockName = fixedNeutronPortName;
isLockAcquired = routerLock.tryLock(lockName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
LOG.debug("removing ports node {} under routerPorts node {}", fixedNeutronPortName, routerName);
InstanceIdentifier.InstanceIdentifierBuilder<Ports> portsIdentifierBuilder = routerPortsIdentifierBuilder.child(Ports.class, new PortsKey(fixedNeutronPortName));
MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, portsIdentifierBuilder.build());
}
} catch (Exception e) {
LOG.error("Failure in deletion of routerPorts node {}", routerName, e);
} finally {
if (isLockAcquired) {
routerLock.unlock(lockName);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project netvirt by opendaylight.
the class GeniusProvider method getEgressVxlanPortForNode.
public Optional<Long> getEgressVxlanPortForNode(BigInteger dpnId) {
List<OvsdbTerminationPointAugmentation> tpList = interfaceMgr.getTunnelPortsOnBridge(dpnId);
if (tpList == null) {
// Most likely the bridge doesnt exist for this dpnId
LOG.warn("getEgressVxlanPortForNode Tunnel Port TerminationPoint list not available for dpnId [{}]", dpnId);
return Optional.empty();
}
for (OvsdbTerminationPointAugmentation tp : tpList) {
if (tp == null) {
// Technically we should never have a list with NULL entries, but
// in a preliminary version of interfaceMgr.getTunnelPortsOnBridge()
// we were getting a list where all termination point entries were
// null. Leaving this check for now for protection.
LOG.error("getEgressVxlanPortForNode received a NULL termination point from tpList on dpnId [{}]", dpnId);
continue;
}
Class<? extends InterfaceTypeBase> ifType = tp.getInterfaceType();
if (ifType.equals(InterfaceTypeVxlan.class)) {
List<Options> tpOptions = tp.getOptions();
for (Options tpOption : tpOptions) {
// From the VXLAN Tunnels, we want the one with the GPE option set
if (tpOption.getKey().getOption().equals(OPTION_KEY_EXTS)) {
if (tpOption.getValue().equals(OPTION_VALUE_EXTS_GPE)) {
return Optional.ofNullable(tp.getOfport());
}
}
}
}
}
LOG.warn("getEgressVxlanPortForNode no Vxgpe tunnel ports available for dpnId [{}]", dpnId);
return Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports 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.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class LLDPSpeakerTest method testLocalNodeConnectorCreation.
/**
* Test that checks if LLDPSpeaker working fine with local ports.
*/
@Test
public void testLocalNodeConnectorCreation() {
// Call nodeConnectorAdded with local port
FlowCapableNodeConnector fcnc = TestUtils.createFlowCapableNodeConnector().setPortNumber(new PortNumberUni("LOCAL")).build();
lldpSpeaker.nodeConnectorAdded(ID, fcnc);
// Verify that nothing happened for local port
verify(packetProcessingService, never()).transmitPacket(any(TransmitPacketInput.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.multipart.reply.multipart.reply.body.multipart.reply.port.desc.Ports in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactory method setPortDesc.
private static MultipartReplyPortDescCase setPortDesc(final ByteBuf input) {
MultipartReplyPortDescCaseBuilder caseBuilder = new MultipartReplyPortDescCaseBuilder();
MultipartReplyPortDescBuilder builder = new MultipartReplyPortDescBuilder();
List<Ports> portsList = new ArrayList<>();
while (input.readableBytes() > 0) {
PortsBuilder portsBuilder = new PortsBuilder();
portsBuilder.setPortNo(input.readUnsignedInt());
input.skipBytes(PADDING_IN_PORT_DESC_HEADER_01);
portsBuilder.setHwAddr(ByteBufUtils.readIetfMacAddress(input));
input.skipBytes(PADDING_IN_PORT_DESC_HEADER_02);
portsBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, EncodeConstants.MAX_PORT_NAME_LENGTH));
portsBuilder.setConfig(createPortConfig(input.readUnsignedInt()));
portsBuilder.setState(createPortState(input.readUnsignedInt()));
portsBuilder.setCurrentFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setAdvertisedFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setSupportedFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setPeerFeatures(createPortFeatures(input.readUnsignedInt()));
portsBuilder.setCurrSpeed(input.readUnsignedInt());
portsBuilder.setMaxSpeed(input.readUnsignedInt());
portsList.add(portsBuilder.build());
}
builder.setPorts(portsList);
caseBuilder.setMultipartReplyPortDesc(builder.build());
return caseBuilder.build();
}
Aggregations