use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class IpReconfigManager method initIpReconfig.
/**
* Initiate ip reconfig procedure by creating ipreconfig config znode in ZK
* The config znode include:
* ipinfo
* procedure status
* each node's status
* expiration time for the procedure
*
* @param clusterIpInfo The new cluster ip info
* @param postOperation
* @throws Exception
*/
private void initIpReconfig(ClusterIpInfo clusterIpInfo, String postOperation) throws Exception {
ClusterIpInfo ipinfo = new ClusterIpInfo(clusterIpInfo.getIpv4Setting(), clusterIpInfo.getIpv6Setting());
log.info("Initiating ip reconfiguraton procedure {}", ipinfo.toString());
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setKind(IpReconfigConstants.CONFIG_KIND);
cfg.setId(IpReconfigConstants.CONFIG_ID);
cfg.setConfig(IpReconfigConstants.CONFIG_IPINFO_KEY, new String(Base64.encodeBase64(ipinfo.serialize()), UTF_8));
cfg.setConfig(IpReconfigConstants.CONFIG_STATUS_KEY, ClusterNetworkReconfigStatus.Status.STARTED.toString());
for (int i = 1; i <= ipinfo.getIpv4Setting().getNetworkAddrs().size(); i++) {
String nodestatus_key = String.format(IpReconfigConstants.CONFIG_NODESTATUS_KEY, i);
cfg.setConfig(nodestatus_key, IpReconfigConstants.NodeStatus.None.toString());
}
// Set ip reconfiguration timeout to 1 day
// 1. For poweroff case, user might need to change subnet or even migrate VMs,
// thus we should set timeout longer for the procedure to be finished.
// Later we should extend API for user to set desired expiration time
// 2. For directly reboot case, it would be better to set longer timeout as well to cover
// underlying unexpected node bootstrap issue which needs manual recovery etc.
expiration_time = System.currentTimeMillis() + IPRECONFIG_TIMEOUT;
cfg.setConfig(IpReconfigConstants.CONFIG_EXPIRATION_KEY, String.valueOf(expiration_time));
cfg.setConfig(IpReconfigConstants.CONFIG_POST_OPERATION_KEY, postOperation);
config = cfg;
_coordinator.getCoordinatorClient().persistServiceConfiguration(config);
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class SignatureKeyGenerator method getSignatureKey2.
/**
* getSignatureKey2 (keeping the original getSignature() as deprecated because portal uses this method from
* our jar still).
*
* @param relKeyLocation "leaf" node under \getSignatureKeyConfig()\getSignatureKeyId()\
* @param algo algorithm to use for that key
* @return the key
* @throws Exception
*/
protected synchronized SecretKey getSignatureKey2(String relKeyLocation, String algo) throws Exception {
Configuration config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
if (config != null && config.getConfig(relKeyLocation) != null) {
final String encodedKey = config.getConfig(relKeyLocation);
return SignatureHelper.createKey(encodedKey, algo);
} else {
InterProcessLock lock = null;
try {
lock = _coordinator.getLock(getDistributedSignatureKeyLock());
lock.acquire();
config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
ConfigurationImpl cfg = (ConfigurationImpl) config;
if (cfg == null) {
cfg = new ConfigurationImpl();
cfg.setId(getSignatureKeyId());
cfg.setKind(getSignatureKeyConfig());
}
String keyEncoded = SignatureHelper.generateKey(algo);
cfg.setConfig(relKeyLocation, keyEncoded);
_coordinator.persistServiceConfiguration(cfg);
config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
final String encodedKey = config.getConfig(relKeyLocation);
return SignatureHelper.createKey(encodedKey, algo);
} finally {
if (lock != null) {
lock.release();
}
}
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class SignatureKeyGenerator method getSignatureKey.
/**
* TODO: DELETE in phase 2 when UI has switched to LoginSignatureKeyGenerator api.
* Used by the UI to get a key.
*
* @param algo
* @return
* @throws Exception
*/
@Deprecated
public synchronized SecretKey getSignatureKey(String algo) throws Exception {
Configuration config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
if (config != null && config.getConfig(getSignatureKey()) != null) {
final String encodedKey = config.getConfig(getSignatureKey());
return new SignatureHelper().createKey(encodedKey, algo);
} else {
InterProcessLock lock = null;
try {
lock = _coordinator.getLock(getDistributedSignatureKeyLock());
lock.acquire();
config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
if (config == null || config.getConfig(getSignatureKey()) == null) {
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(getSignatureKeyId());
cfg.setKind(getSignatureKeyConfig());
String keyEncoded = SignatureHelper.generateKey(algo);
cfg.setConfig(getSignatureKey(), keyEncoded);
_coordinator.persistServiceConfiguration(cfg);
}
config = _coordinator.queryConfiguration(getSignatureKeyConfig(), getSignatureKeyId());
final String encodedKey = config.getConfig(getSignatureKey());
return SignatureHelper.createKey(encodedKey, algo);
} finally {
if (lock != null) {
lock.release();
}
}
}
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class TokenKeyGenerator method createOrUpdateBundle.
// Coordinator client interraction for persistence
/**
* Creates or updates a TokenKeysBundle in coordinator.
*
* @param bundleIn: bundle to persist
* MUST BE CALLED BY A CODE OWNING INTERPROCESS LOCK
* @throws Exception
*/
private synchronized void createOrUpdateBundle(TokenKeysBundle bundleIn) throws Exception {
Configuration config = _coordinator.queryConfiguration(SIGNATURE_KEY_CONFIG, SIGNATURE_KEY_ID);
ConfigurationImpl configImpl = null;
if (config == null) {
configImpl = new ConfigurationImpl();
configImpl.setId(SIGNATURE_KEY_ID);
configImpl.setKind(SIGNATURE_KEY_CONFIG);
_log.debug("Creating new config");
} else {
configImpl = (ConfigurationImpl) config;
_log.debug("Updating existing config");
}
configImpl.setConfig(SIGNATURE_KEY, SerializerUtils.serializeAsBase64EncodedString(bundleIn));
_coordinator.persistServiceConfiguration(configImpl);
_log.debug("Updated keys bundle successfully");
return;
}
use of com.emc.storageos.coordinator.common.impl.ConfigurationImpl in project coprhd-controller by CoprHD.
the class CatalogConfigUtils method notifyCatalogAclChange.
/**
* update zk node /config/catalog/acl_change, so portalsvc could get notified and clear its cache.
*/
public void notifyCatalogAclChange() {
ConfigurationImpl configImpl = new ConfigurationImpl();
configImpl.setKind(Constants.CATALOG_CONFIG);
configImpl.setId(Constants.CATALOG_ACL_CHANGE);
String time = String.valueOf(System.currentTimeMillis());
configImpl.setConfig(configKey, time);
try {
log.debug("catalog acl change time: " + time);
_coordinator.persistServiceConfiguration(configImpl);
} catch (Exception e) {
log.warn(String.format("updating zk node /config/%s/%s failed, portalsvc cache will not clear immediately, but will reload 10 minutes later", Constants.CATALOG_CONFIG, Constants.CATALOG_ACL_CHANGE));
}
}
Aggregations