use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class NeutronvpnManager method removeAdjacencyforExtraRoute.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void removeAdjacencyforExtraRoute(Uuid vpnId, List<Routes> routeList) {
for (Routes route : routeList) {
if (route != null && route.getNexthop() != null && route.getDestination() != null) {
boolean isLockAcquired = false;
String nextHop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
String infName = neutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(vpnId.getValue(), nextHop);
if (infName == null) {
LOG.error("Unable to find VPN NextHop interface to remove extra-route destination {} on VPN {} " + "with nexthop {}", destination, vpnId.getValue(), nextHop);
// Proceed to remove the next extra-route
continue;
}
LOG.trace("Removing extra route for destination {} on vpn {} with nexthop {} and infName {}", destination, vpnId.getValue(), nextHop, infName);
InstanceIdentifier<Adjacency> adjacencyIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).augmentation(Adjacencies.class).child(Adjacency.class, new AdjacencyKey(destination)).build();
try {
// Looking for existing prefix in MDSAL database
Optional<Adjacency> adjacency = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
boolean updateNextHops = false;
List<String> nextHopList = new ArrayList<>();
if (adjacency.isPresent()) {
List<String> nhListRead = adjacency.get().getNextHopIpList();
if (nhListRead.size() > 1) {
// ECMP case
for (String nextHopRead : nhListRead) {
if (nextHopRead.equals(nextHop)) {
updateNextHops = true;
} else {
nextHopList.add(nextHopRead);
}
}
}
}
isLockAcquired = interfaceLock.tryLock(infName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
if (updateNextHops) {
// An update must be done, not including the current next hop
InstanceIdentifier<VpnInterface> vpnIfIdentifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
Adjacency newAdj = new AdjacencyBuilder(adjacency.get()).setIpAddress(destination).setNextHopIpList(nextHopList).setKey(new AdjacencyKey(destination)).build();
Adjacencies erAdjs = new AdjacenciesBuilder().setAdjacency(Collections.singletonList(newAdj)).build();
VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(infName)).addAugmentation(Adjacencies.class, erAdjs).build();
SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
} else {
// Remove the whole route
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
LOG.trace("extra route {} deleted successfully", route);
}
} catch (TransactionCommitFailedException | ReadFailedException e) {
LOG.error("exception in deleting extra route with destination {} for interface {}", destination, infName, e);
} finally {
if (isLockAcquired) {
interfaceLock.unlock(infName);
}
}
} else {
LOG.error("Incorrect input received for extra route: {}", route);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnInterfaceWithExtraRouteAdjacency.
protected void updateVpnInterfaceWithExtraRouteAdjacency(Uuid vpnId, List<Routes> routeList) {
checkAlarmExtraRoutes(vpnId, routeList);
for (Routes route : routeList) {
if (route == null || route.getNexthop() == null || route.getDestination() == null) {
LOG.error("Incorrect input received for extra route. {}", route);
} else {
String nextHop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
String infName = neutronvpnUtils.getNeutronPortNameFromVpnPortFixedIp(vpnId.getValue(), nextHop);
if (infName != null) {
LOG.trace("Updating extra route for destination {} onto vpn {} with nexthop {} and infName {}", destination, vpnId.getValue(), nextHop, infName);
boolean isLockAcquired = false;
try {
InstanceIdentifier<VpnInterface> identifier = InstanceIdentifier.builder(VpnInterfaces.class).child(VpnInterface.class, new VpnInterfaceKey(infName)).build();
InstanceIdentifier<Adjacency> path = identifier.augmentation(Adjacencies.class).child(Adjacency.class, new AdjacencyKey(destination));
Optional<Adjacency> existingAdjacency = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, path);
if (existingAdjacency.isPresent() && existingAdjacency.get().getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
LOG.error("The route with destination {} nextHop {} is already present as" + " a primary adjacency for interface {}. Skipping adjacency addition.", destination, nextHop, infName);
continue;
}
Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setNextHopIpList(Collections.singletonList(nextHop)).setKey(new AdjacencyKey(destination)).setAdjacencyType(AdjacencyType.ExtraRoute).build();
isLockAcquired = interfaceLock.tryLock(infName, LOCK_WAIT_TIME, TimeUnit.SECONDS);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, erAdj);
} catch (TransactionCommitFailedException e) {
LOG.error("exception in adding extra route with destination: {}, next hop: {}", destination, nextHop, e);
} catch (ReadFailedException e) {
LOG.error("Exception on reading data-store ", e);
} finally {
if (isLockAcquired) {
interfaceLock.unlock(infName);
}
}
} else {
LOG.error("Unable to find VPN NextHop interface to apply extra-route destination {} on VPN {} " + "with nexthop {}", destination, vpnId.getValue(), nextHop);
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class NeutronvpnManager method getAdjacencyforExtraRoute.
@Nonnull
protected List<Adjacency> getAdjacencyforExtraRoute(List<Routes> routeList, String fixedIp) {
List<Adjacency> adjList = new ArrayList<>();
Map<String, List<String>> adjMap = new HashMap<>();
for (Routes route : routeList) {
if (route == null || route.getNexthop() == null || route.getDestination() == null) {
LOG.error("Incorrect input received for extra route. {}", route);
} else {
String nextHop = String.valueOf(route.getNexthop().getValue());
String destination = String.valueOf(route.getDestination().getValue());
if (!nextHop.equals(fixedIp)) {
LOG.trace("FixedIP {} is not extra route nexthop for destination {}", fixedIp, destination);
continue;
}
LOG.trace("Adding extra route for destination {} with nexthop {} ", destination, nextHop);
List<String> hops = adjMap.computeIfAbsent(destination, k -> new ArrayList<>());
if (!hops.contains(nextHop)) {
hops.add(nextHop);
}
}
}
for (Entry<String, List<String>> entry : adjMap.entrySet()) {
final String destination = entry.getKey();
final List<String> ipList = entry.getValue();
Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination).setAdjacencyType(AdjacencyType.ExtraRoute).setNextHopIpList(ipList).setKey(new AdjacencyKey(destination)).build();
adjList.add(erAdj);
}
return adjList;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class NeutronPortChangeListener method update.
@Override
protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) {
// in order to validate the supported vnic types from the hostconfig
if (isPortTypeSwitchdev(original) && !isPortBound(original) && isPortBound(update)) {
handleNeutronPortCreated(update);
}
final String portName = update.getUuid().getValue();
Network network = neutronvpnUtils.getNeutronNetwork(update.getNetworkId());
LOG.info("Update port {} from network {}", portName, update.getNetworkId().toString());
if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) {
LOG.error("neutron vpn received a port update() for a network without a provider extension augmentation " + "or with an unsupported network type for the port {} which is part of network {}", portName, network);
return;
}
neutronvpnUtils.addToPortCache(update);
if ((Strings.isNullOrEmpty(original.getDeviceOwner()) || Strings.isNullOrEmpty(original.getDeviceId()) || NeutronConstants.FLOATING_IP_DEVICE_ID_PENDING.equalsIgnoreCase(original.getDeviceId())) && !Strings.isNullOrEmpty(update.getDeviceOwner()) && !Strings.isNullOrEmpty(update.getDeviceId())) {
if (update.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) {
handleRouterInterfaceAdded(update);
return;
}
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) {
handleRouterGatewayUpdated(update);
} else if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(update.getDeviceOwner())) {
handleFloatingIpPortUpdated(original, update);
}
} else {
Set<FixedIps> oldIPs = getFixedIpSet(original.getFixedIps());
Set<FixedIps> newIPs = getFixedIpSet(update.getFixedIps());
if (!oldIPs.equals(newIPs)) {
handleNeutronPortUpdated(original, update);
}
}
// check if port security enabled/disabled as part of port update
boolean origSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(original);
boolean updatedSecurityEnabled = NeutronvpnUtils.getPortSecurityEnabled(update);
if (origSecurityEnabled || updatedSecurityEnabled) {
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
try {
Optional<Interface> optionalInf = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, interfaceIdentifier);
if (optionalInf.isPresent()) {
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(optionalInf.get());
InterfaceAcl infAcl = handlePortSecurityUpdated(original, update, origSecurityEnabled, updatedSecurityEnabled, interfaceBuilder).build();
interfaceBuilder.addAugmentation(InterfaceAcl.class, infAcl);
LOG.info("update: Of-port-interface updation for port {}", portName);
// Update OFPort interface for this neutron port
wrtConfigTxn.put(LogicalDatastoreType.CONFIGURATION, interfaceIdentifier, interfaceBuilder.build());
} else {
LOG.warn("update: Interface {} is not present", portName);
}
} catch (ReadFailedException e) {
LOG.error("update: Failed to update interface {}", portName, e);
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(wrtConfigTxn.submit());
return futures;
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180321.network.instances.network.instance.protocols.protocol.bgp.neighbors.neighbor.state.messages.Received in project netvirt by opendaylight.
the class QosInterfaceStateChangeListener method remove.
@Override
protected void remove(InstanceIdentifier<Interface> identifier, Interface intrf) {
if (L2vlan.class.equals(intrf.getType())) {
final String interfaceName = intrf.getName();
// Guava Optional asSet().forEach() emulates Java 8 Optional ifPresent()
getNeutronPortForRemove(intrf).asSet().forEach(port -> {
LOG.trace("Qos Service : Received interface {} PORT DOWN event ", interfaceName);
String lowerLayerIf = intrf.getLowerLayerIf().get(0);
LOG.trace("lowerLayerIf {}", lowerLayerIf);
qosAlertManager.removeFromQosAlertCache(new NodeConnectorId(lowerLayerIf));
QosPortExtension removeQos = port.getAugmentation(QosPortExtension.class);
if (removeQos != null) {
qosNeutronUtils.handleNeutronPortRemove(port, removeQos.getQosPolicyId(), intrf);
qosNeutronUtils.removeFromQosPortsCache(removeQos.getQosPolicyId(), port);
} else {
Network network = neutronVpnManager.getNeutronNetwork(port.getNetworkId());
if (network != null && network.getAugmentation(QosNetworkExtension.class) != null) {
Uuid networkQosUuid = network.getAugmentation(QosNetworkExtension.class).getQosPolicyId();
if (networkQosUuid != null) {
qosNeutronUtils.handleNeutronPortRemove(port, networkQosUuid, intrf);
}
}
}
});
}
}
Aggregations