use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.GlobalConfigAugmentation 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.bgp.openconfig.extensions.rev180329.network.instance.protocol.GlobalConfigAugmentation in project bgpcep by opendaylight.
the class OpenConfigMappingUtil method getGlobalClusterIdentifier.
static ClusterIdentifier getGlobalClusterIdentifier(final org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.global.base.Config globalConfig) {
final GlobalConfigAugmentation globalConfigAugmentation = globalConfig.augmentation(GlobalConfigAugmentation.class);
final Ipv4Address addr;
if (globalConfigAugmentation != null && globalConfigAugmentation.getRouteReflectorClusterId() != null) {
addr = globalConfigAugmentation.getRouteReflectorClusterId().getIpv4Address();
} else {
addr = globalConfig.getRouterId();
}
return new ClusterIdentifier(IetfInetUtil.INSTANCE.ipv4AddressNoZoneFor(addr));
}
Aggregations