use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class NeutronvpnManager method removeSubnetFromVpn.
protected void removeSubnetFromVpn(final Uuid vpnId, Uuid subnet, Uuid internetVpnId) {
Preconditions.checkArgument(vpnId != null || internetVpnId != null, "removeSubnetFromVpn: at least one VPN must be not null");
LOG.debug("Removing subnet {} from vpn {}/{}", subnet.getValue(), vpnId, internetVpnId);
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnet);
if (sn == null) {
LOG.error("removeSubnetFromVpn: Subnetmap for subnet {} not found", subnet.getValue());
return;
}
VpnMap vpnMap = null;
VpnInstance vpnInstance = null;
if (vpnId != null) {
vpnMap = neutronvpnUtils.getVpnMap(vpnId);
if (vpnMap == null) {
LOG.error("No vpnMap for vpnId {}, cannot remove subnet {} from VPN", vpnId.getValue(), subnet.getValue());
return;
}
vpnInstance = VpnHelper.getVpnInstance(dataBroker, vpnId.getValue());
}
if (internetVpnId == null) {
internetVpnId = sn.getInternetVpnId();
}
if (internetVpnId != null) {
vpnMap = neutronvpnUtils.getVpnMap(internetVpnId);
if (vpnMap == null) {
LOG.error("No vpnMap for vpnId {}, cannot remove subnet {}" + " from Internet VPN", internetVpnId.getValue(), subnet.getValue());
return;
}
}
if (vpnInstance != null && isVpnOfTypeL2(vpnInstance)) {
neutronEvpnUtils.updateElanAndVpn(vpnInstance, sn.getNetworkId().getValue(), NeutronEvpnUtils.Operation.DELETE);
}
boolean subnetVpnAssociation = false;
if (vpnId != null && sn.getVpnId() != null && sn.getVpnId().getValue().equals(vpnId.getValue())) {
subnetVpnAssociation = true;
} else if (internetVpnId != null && sn.getInternetVpnId() != null && sn.getInternetVpnId().getValue().matches(internetVpnId.getValue())) {
subnetVpnAssociation = true;
}
if (subnetVpnAssociation == false) {
LOG.error("Removing subnet : Subnetmap is not in VPN {}/{}, owns {} and {}", vpnId, internetVpnId, sn.getVpnId(), sn.getInternetVpnId());
return;
}
// Check if there are ports on this subnet; remove corresponding vpn-interfaces
List<Uuid> portList = sn.getPortList();
final Uuid internetId = internetVpnId;
if (portList != null) {
for (final Uuid portId : portList) {
LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp(), portId.getValue());
final Port port = neutronvpnUtils.getNeutronPort(portId);
jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
List<ListenableFuture<Void>> futures = new ArrayList<>();
if (port != null) {
withdrawPortIpFromVpnIface(vpnId, internetId, port, sn, wrtConfigTxn);
} else {
LOG.warn("Cannot proceed with withdrawPortIpFromVpnIface for port {} in subnet {} since " + "port is absent in Neutron config DS", portId.getValue(), subnet.getValue());
}
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
// update subnet-vpn association
removeFromSubnetNode(subnet, null, null, vpnId, null);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.Ports in project netvirt by opendaylight.
the class NeutronvpnManager method createSubnetmapNode.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void createSubnetmapNode(Uuid subnetId, String subnetIp, Uuid tenantId, Uuid networkId, NetworkAttributes.NetworkType networkType, long segmentationId) {
try {
InstanceIdentifier<Subnetmap> subnetMapIdentifier = NeutronvpnUtils.buildSubnetMapIdentifier(subnetId);
synchronized (subnetId.getValue().intern()) {
LOG.info("createSubnetmapNode: subnet ID {}", subnetId.toString());
Optional<Subnetmap> sn = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetMapIdentifier);
if (sn.isPresent()) {
LOG.error("createSubnetmapNode: Subnetmap node for subnet ID {} already exists, returning", subnetId.getValue());
return;
}
SubnetmapBuilder subnetmapBuilder = new SubnetmapBuilder().setKey(new SubnetmapKey(subnetId)).setId(subnetId).setSubnetIp(subnetIp).setTenantId(tenantId).setNetworkId(networkId).setNetworkType(networkType).setSegmentationId(segmentationId);
LOG.debug("createSubnetmapNode: Adding a new subnet node in Subnetmaps DS for subnet {}", subnetId.getValue());
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, subnetMapIdentifier, subnetmapBuilder.build());
}
} catch (TransactionCommitFailedException | ReadFailedException e) {
LOG.error("createSubnetmapNode: Creating subnetmap node failed for subnet {}", subnetId.getValue());
}
// check if there are ports to update for already created Subnetmap node
LOG.debug("createSubnetmapNode: Update created Subnetmap for subnet {} with ports", subnetId.getValue());
for (Map.Entry<Uuid, Uuid> entry : unprocessedPortsMap.entrySet()) {
if (entry.getValue().getValue().equals(subnetId.getValue())) {
updateSubnetmapNodeWithPorts(subnetId, entry.getKey(), null);
unprocessedPortsMap.remove(entry.getKey());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.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.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.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.params.xml.ns.yang.bgp.flowspec.rev200120.flowspec.destination.flowspec.flowspec.type.port._case.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");
}
Aggregations