use of com.emc.storageos.svcs.errorhandling.resources.ServiceUnavailableException in project coprhd-controller by CoprHD.
the class SecretsInit method rotateIPsecKey.
private boolean rotateIPsecKey() {
InterProcessLock lock = null;
try {
if (drUtil.isMultivdc()) {
log.info("Skip ipsec key initial rotation for multi-vdc configuration");
return true;
}
if (drUtil.isMultisite()) {
log.info("Skip ipsec key initial rotation for multi-site DR configuration");
return true;
}
String preSharedKey = ipsecConfig.getPreSharedKeyFromZK();
if (!StringUtils.isBlank(preSharedKey)) {
log.info("IPsec key has been initialized");
return true;
}
lock = coordinator.getCoordinatorClient().getSiteLocalLock(ipsecLock);
lock.acquire();
log.info("Acquired the lock {}", ipsecLock);
preSharedKey = ipsecConfig.getPreSharedKeyFromZK();
if (!StringUtils.isBlank(preSharedKey)) {
log.info("IPsec key has been initialized. No need to regenerate it");
return true;
}
if (drUtil.isAllSitesStable()) {
log.info("No pre shared key in zk, generate a new key");
ipsecMgr.rotateKey(true);
return true;
}
return false;
} catch (ServiceUnavailableException suex) {
log.warn("cluster is not stable currently.");
return false;
} catch (Exception ex) {
log.warn("error when run ipsec initial rotation: ", ex);
return false;
} finally {
try {
if (lock != null) {
lock.release();
log.info("Released the lock {}", ipsecLock);
}
} catch (Exception ex) {
log.warn("error in releasing the lock {}", ipsecLock);
}
}
}
Aggregations