use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class HwvtepPhysicalSwitchListener method updated.
/**
* Upon update checks if the tunnels Ip was null earlier and it got newly added.
* In that case simply call add.
* If not then check if Tunnel Ip has been updated from an old value to new value.
* If yes. delete old ITM tunnels of odl Tunnel Ipand add new ITM tunnels with new Tunnel
* IP then call added ().
*
* @param identifier iid
* @param phySwitchBefore ps Node before update
* @param phySwitchAfter ps Node after update
*/
@Override
protected void updated(InstanceIdentifier<PhysicalSwitchAugmentation> identifier, PhysicalSwitchAugmentation phySwitchBefore, PhysicalSwitchAugmentation phySwitchAfter) {
NodeId nodeId = getNodeId(identifier);
LOG.trace("Received PhysicalSwitch Update Event for node {}: PhysicalSwitch Before: {}, " + "PhysicalSwitch After: {}", nodeId.getValue(), phySwitchBefore, phySwitchAfter);
String psName = getPsName(identifier);
if (psName == null) {
LOG.error("PhysicalSwitchListener Could not find the physical switch name for node {}", nodeId.getValue());
return;
}
L2GatewayDevice existingDevice = l2GatewayCache.get(psName);
if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps())) {
LOG.info("PhysicalSwitchListener Received physical switch update for {} before teps {} after teps {}", nodeId.getValue(), phySwitchBefore.getTunnelIps(), phySwitchAfter.getTunnelIps());
}
InstanceIdentifier<Node> globalNodeIid = getManagedByNodeIid(identifier);
if (DEVICE_NOT_CACHED_OR_PARENT_CONNECTED.test(existingDevice, globalNodeIid)) {
if (TUNNEL_IP_AVAILABLE.test(phySwitchAfter)) {
added(identifier, phySwitchAfter);
}
} else {
if (!Objects.equals(phySwitchAfter.getTunnelIps(), phySwitchBefore.getTunnelIps()) && TUNNEL_IP_CHANGED.test(phySwitchAfter, existingDevice)) {
final String hwvtepId = existingDevice.getHwvtepNodeId();
elanClusterUtils.runOnlyInOwnerNode(existingDevice.getDeviceName(), "handling Physical Switch add create itm tunnels ", () -> {
LOG.info("PhysicalSwitchListener Deleting itm tunnels for {}", existingDevice.getDeviceName());
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, existingDevice.getDeviceName(), existingDevice.getTunnelIp());
// TODO remove these sleeps
Thread.sleep(10000L);
LOG.info("Creating itm tunnels for device {}", existingDevice.getDeviceName());
ElanL2GatewayUtils.createItmTunnels(dataBroker, itmRpcService, hwvtepId, psName, phySwitchAfter.getTunnelIps().get(0).getTunnelIpsKey());
return Collections.emptyList();
});
try {
// TODO remove the sleep by using better itm api to detect finish of prev op
Thread.sleep(20000L);
} catch (InterruptedException e) {
LOG.error("Interrupted ");
}
existingDevice.setTunnelIps(new HashSet<>());
added(identifier, phySwitchAfter);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class HAOpNodeListener method onGlobalNodeAdd.
@Override
public void onGlobalNodeAdd(InstanceIdentifier<Node> childGlobalPath, Node childNode, TypedReadWriteTransaction<Operational> tx) {
// copy child global node to ha global node
// create ha global config node if not present
// copy ha global config node to child global config node
LOG.info("HAOpNodeListener Node connected {} - Checking if Ha or Non-Ha enabled {}", childNode.getNodeId().getValue(), getManagers(childNode));
haOpClusteredListener.onGlobalNodeAdd(childGlobalPath, childNode, tx);
txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, configTx -> {
if (IS_NOT_HA_CHILD.test(childGlobalPath)) {
LOG.info("HAOpNodeListener The connected node is not a HA child {}", childNode.getNodeId().getValue());
if (hwvtepHACache.isHAParentNode(childGlobalPath)) {
LOG.info("HAOpNodeListener this is Parent Node {}", childNode.getNodeId().getValue());
HwvtepGlobalAugmentation globalAugmentation = childNode.augmentation(HwvtepGlobalAugmentation.class);
String operDbVersion = globalAugmentation.getDbVersion();
try {
Optional<Node> globalConfigNodeOptional = configTx.read(childGlobalPath).get();
if (globalConfigNodeOptional.isPresent()) {
HwvtepGlobalAugmentation globalConfigAugmentation = globalConfigNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
String configDbVersion = globalConfigAugmentation.getDbVersion();
if (operDbVersion != null && !operDbVersion.equals(configDbVersion)) {
LOG.info("Change in Db version from {} to {} for Node {}", configDbVersion, operDbVersion, childGlobalPath);
HwvtepGlobalAugmentationBuilder haBuilder = new HwvtepGlobalAugmentationBuilder(globalConfigAugmentation);
haBuilder.setDbVersion(operDbVersion);
NodeBuilder nodeBuilder = new NodeBuilder(childNode);
nodeBuilder.addAugmentation(haBuilder.build());
configTx.merge(childGlobalPath, nodeBuilder.build());
} else {
LOG.debug("No Change in Db version from {} to {} for Node {}", configDbVersion, operDbVersion, childGlobalPath);
}
}
} catch (ExecutionException | InterruptedException ex) {
LOG.error("HAOpNodeListener Failed to read node {} from Config DS", childGlobalPath);
}
}
return;
}
InstanceIdentifier<Node> haNodePath = hwvtepHACache.getParent(childGlobalPath);
LOG.info("HAOpNodeListener Ha enabled child node connected {} create parent oper node", childNode.getNodeId().getValue());
try {
nodeCopier.copyGlobalNode(Optional.ofNullable(childNode), childGlobalPath, haNodePath, OPERATIONAL, tx);
Optional<Node> existingDstGlobalNodeOptional = tx.read(haNodePath).get();
List<Managers> managers = HwvtepHAUtil.buildManagersForHANode(Optional.ofNullable(childNode).get(), existingDstGlobalNodeOptional);
Optional<Node> globalNodeOptional = configTx.read(haNodePath).get();
if (globalNodeOptional.isPresent()) {
// Also update the manager section in config which helps in cluster reboot scenarios
managers.stream().forEach(manager -> {
InstanceIdentifier<Managers> managerIid = haNodePath.augmentation(HwvtepGlobalAugmentation.class).child(Managers.class, manager.key());
configTx.put(managerIid, manager);
});
nodeCopier.copyGlobalNode(globalNodeOptional, haNodePath, childGlobalPath, CONFIGURATION, tx);
} else {
NodeBuilder nodeBuilder = new NodeBuilder().setNodeId(haNodePath.firstKeyOf(Node.class).getNodeId());
HwvtepGlobalAugmentationBuilder augBuilder = new HwvtepGlobalAugmentationBuilder();
augBuilder.setManagers(managers);
if (existingDstGlobalNodeOptional.isPresent()) {
HwvtepGlobalAugmentation srcGlobalAugmentation = existingDstGlobalNodeOptional.get().augmentation(HwvtepGlobalAugmentation.class);
if (srcGlobalAugmentation != null) {
augBuilder.setDbVersion(srcGlobalAugmentation.getDbVersion());
}
}
nodeBuilder.addAugmentation(augBuilder.build());
configTx.put(haNodePath, nodeBuilder.build());
}
} catch (ExecutionException | InterruptedException e) {
LOG.error("HAOpNodeListener Failed to read nodes {} , {} ", childGlobalPath, haNodePath);
}
});
readAndCopyChildPsOpToParent(childNode, tx);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnForSubnet.
@Nullable
private Subnetmap updateVpnForSubnet(Uuid oldVpnId, Uuid newVpnId, Uuid subnet, boolean isBeingAssociated) {
LOG.debug("Moving subnet {} from oldVpn {} to newVpn {} ", subnet.getValue(), oldVpnId.getValue(), newVpnId.getValue());
Uuid networkUuid = neutronvpnUtils.getSubnetmap(subnet).getNetworkId();
Network network = neutronvpnUtils.getNeutronNetwork(networkUuid);
boolean netIsExternal = NeutronvpnUtils.getIsExternal(network);
Uuid vpnExtUuid = netIsExternal ? neutronvpnUtils.getInternetvpnUuidBoundToSubnetRouter(subnet) : null;
Subnetmap sn = updateSubnetNode(subnet, null, newVpnId, vpnExtUuid);
if (sn == null) {
LOG.error("Updating subnet {} with newVpn {} failed", subnet.getValue(), newVpnId.getValue());
return sn;
}
/* vpnExtUuid will contain the value only on if the subnet is V6 and it is already been
* associated with internet BGP-VPN.
*/
if (vpnExtUuid != null) {
/* Update V6 Internet default route match with new VPN metadata.
* isBeingAssociated = true means oldVpnId is same as routerId
* isBeingAssociated = false means newVpnId is same as routerId
*/
if (isBeingAssociated) {
neutronvpnUtils.updateVpnInstanceWithFallback(oldVpnId, vpnExtUuid, true);
} else {
neutronvpnUtils.updateVpnInstanceWithFallback(newVpnId, vpnExtUuid, true);
}
}
// Update Router Interface first synchronously.
// CAUTION: Please DONOT make the router interface VPN Movement as an asynchronous commit again !
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(sn.getRouterInterfacePortId()), isBeingAssociated, true, tx, false));
Futures.addCallback(future, new FutureCallback<Object>() {
@Override
public void onSuccess(Object result) {
// Check for ports on this subnet and update association of
// corresponding vpn-interfaces to external vpn
List<Uuid> portList = sn.getPortList();
if (portList != null) {
for (Uuid port : portList) {
LOG.debug("Updating vpn-interface for port {} isBeingAssociated {}", port.getValue(), isBeingAssociated);
jobCoordinator.enqueueJob("PORT-" + port.getValue(), () -> Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> updateVpnInterface(newVpnId, oldVpnId, neutronvpnUtils.getNeutronPort(port), isBeingAssociated, false, tx, false))));
}
}
}
@Override
public void onFailure(Throwable throwable) {
LOG.error("Failed to update router interface {} in subnet {} from oldVpnId {} to newVpnId {}, " + "returning", sn.getRouterInterfacePortId().getValue(), subnet.getValue(), oldVpnId, newVpnId, throwable);
}
}, MoreExecutors.directExecutor());
return sn;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class NeutronvpnNatManager method handleExternalFixedIpsForRouter.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleExternalFixedIpsForRouter(Router update) {
Uuid routerId = update.getUuid();
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
try {
Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
LOG.trace("Updating External Fixed IPs Routers node {}", routerId.getValue());
if (optionalRouters.isPresent()) {
RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
List<ExternalIps> externalIps = new ArrayList<>();
for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().nonnullExternalFixedIps().values()) {
addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
}
builder.setExternalIps(externalIps);
updateExternalSubnetsForRouter(routerId, update.getExternalGatewayInfo().getExternalNetworkId(), new ArrayList<ExternalFixedIps>(update.getExternalGatewayInfo().nonnullExternalFixedIps().values()));
Routers routerss = builder.build();
LOG.trace("Updating external fixed ips for router {} with value {}", routerId.getValue(), routerss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
LOG.trace("Added External Fixed IPs successfully for Routers to CONFIG Datastore");
}
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("Updating extfixedips for {} in extrouters failed", routerId.getValue(), ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.route.monitoring.message.Update in project netvirt by opendaylight.
the class NeutronvpnNatManager method handleSnatSettingChangeForRouter.
private void handleSnatSettingChangeForRouter(Router update) {
Uuid routerId = update.getUuid();
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
try {
Optional<Routers> optionalRouters = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
LOG.trace("Updating Internal subnets for Routers node: {}", routerId.getValue());
RoutersBuilder builder = null;
if (optionalRouters.isPresent()) {
builder = new RoutersBuilder(optionalRouters.get());
} else {
LOG.trace("No Routers element found for router name {}", routerId.getValue());
return;
}
builder.setEnableSnat(update.getExternalGatewayInfo().isEnableSnat());
Routers routerss = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Updating extrouters for snat change {}", routerss);
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
LOG.trace("Updated successfully Routers to CONFIG Datastore");
} catch (TransactionCommitFailedException | ExecutionException | InterruptedException ex) {
LOG.error("Updation of snat for extrouters failed for router {}", routerId.getValue(), ex);
}
}
Aggregations