use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class BackupSchedulerConfigMigration method process.
@Override
public void process() throws MigrationCallbackException {
try {
Configuration config = coordinatorClient.queryConfiguration(BACKUP_SCHEDULER_CONFIG, GLOBAL_ID);
if (config == null) {
log.info("Backup scheduler config doesn't exist, no need to do migration");
return;
}
coordinatorClient.persistServiceConfiguration(coordinatorClient.getSiteId(), config);
coordinatorClient.deletePath(String.format("%s/%s", ZkPath.CONFIG.toString(), BACKUP_SCHEDULER_CONFIG));
log.info("Backup scheduler has been migrated to site specific area");
} catch (Exception e) {
log.error("Fail to migrate backup scheduler config to site specific area", e);
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class ComputeImageServerMigration method process.
@Override
public void process() throws MigrationCallbackException {
try {
// Retrieve data from zk db using coordinator client
Configuration config1 = coordinatorClient.queryConfiguration(PropertyInfoExt.TARGET_PROPERTY, PropertyInfoExt.TARGET_PROPERTY_ID);
log.info("imageServerIP:" + config1.getConfig(IMAGE_SERVER_ADDRESS));
PropertyInfo p = coordinatorClient.getPropertyInfo();
EncryptionProviderImpl encryptionProvider1 = new EncryptionProviderImpl();
encryptionProvider1.setCoordinator(coordinatorClient);
encryptionProvider1.start();
this.encryptionProvider = encryptionProvider1;
if (!StringUtils.isBlank(p.getProperty("image_server_address"))) {
ComputeImageServer imageServer = new ComputeImageServer();
imageServer.setId(URIUtil.createId(ComputeImageServer.class));
imageServer.setImageServerIp(p.getProperty(IMAGE_SERVER_ADDRESS));
imageServer.setLabel(p.getProperty(IMAGE_SERVER_ADDRESS));
imageServer.setImageServerUser(p.getProperty(IMAGE_SERVER_USERNAME));
imageServer.setTftpBootDir(p.getProperty(IMAGE_SERVER_TFTPBOOT_DIR));
imageServer.setImageServerSecondIp(p.getProperty(IMAGE_SERVER_OS_NETWORK_IP));
imageServer.setImageServerHttpPort(p.getProperty(IMAGE_SERVER_HTTP_PORT));
imageServer.setImageDir(p.getProperty(IMAGE_SERVER_IMAGEDIR));
String encryptedPassword = p.getProperty(IMAGE_SERVER_ENC_PWD);
try {
imageServer.setImageServerPassword(encryptionProvider.decrypt(Base64.decodeBase64(encryptedPassword)));
} catch (Exception e) {
log.error("Can't decrypt image server password :" + e.getLocalizedMessage());
log.error("Failed to save image server details into database during migration", e);
throw e;
}
associateComputeImages(imageServer);
dbClient.createObject(imageServer);
log.info("Saved imageServer info into cassandra db");
// Associate all existing Compute Systems to this image server
List<URI> computeSystemURIs = dbClient.queryByType(ComputeSystem.class, true);
Iterator<ComputeSystem> computeSystemListIterator = dbClient.queryIterativeObjects(ComputeSystem.class, computeSystemURIs);
while (computeSystemListIterator.hasNext()) {
ComputeSystem computeSystem = computeSystemListIterator.next();
computeSystem.setComputeImageServer(imageServer.getId());
dbClient.persistObject(computeSystem);
}
// Delete imageserverConf data from ZK db.
Configuration config = coordinatorClient.queryConfiguration(PropertyInfoExt.TARGET_PROPERTY, PropertyInfoExt.TARGET_PROPERTY_ID);
config.removeConfig(IMAGE_SERVER_ADDRESS);
config.removeConfig(IMAGE_SERVER_USERNAME);
config.removeConfig(IMAGE_SERVER_ENC_PWD);
config.removeConfig(IMAGE_SERVER_TFTPBOOT_DIR);
config.removeConfig(IMAGE_SERVER_HTTP_PORT);
config.removeConfig(IMAGE_SERVER_OS_NETWORK_IP);
config.removeConfig(IMAGE_SERVER_IMAGEDIR);
coordinatorClient.persistServiceConfiguration(config);
} else {
log.info("No image server configuration found in Zookeeper db");
}
} catch (Exception e) {
log.error("Exception occured while migrating compute image server information");
log.error(e.getMessage(), e);
}
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class DbRebuildRunnable method dbRebuildComplete.
private boolean dbRebuildComplete(String svcName) {
List<Configuration> configs = coordinator.queryAllConfiguration(coordinator.getSiteId(), coordinator.getVersionedDbConfigPath(svcName, service.getVersion()));
int count = 0;
for (Configuration config : configs) {
if (isLastDataSyncCurrent(config)) {
count++;
}
}
return (count == nodeCount);
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class DbServiceImpl method checkVersionedConfiguration.
// check and initialize versioned configuration
private Configuration checkVersionedConfiguration() {
String serviceVersion = _serviceInfo.getVersion();
String dbSchemaVersion = _dbClient.getSchemaVersion();
if (!serviceVersion.equals(dbSchemaVersion)) {
_log.warn("The db service version {} doesn't equals Db schema version {}, " + "set db service version to Db schema version", serviceVersion, dbSchemaVersion);
_serviceInfo.setVersion(dbSchemaVersion);
}
String kind = _coordinator.getVersionedDbConfigPath(_serviceInfo.getName(), _serviceInfo.getVersion());
Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), kind, _serviceInfo.getId());
if (config == null) {
// check if it is upgraded from previous version to yoda - configuration may be stored in
// znode /config
config = _coordinator.queryConfiguration(kind, _serviceInfo.getId());
if (config != null) {
_log.info("Upgrade from pre-2.5 release, move versioned dbconfig to new location");
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
return config;
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(_serviceInfo.getId());
cfg.setKind(kind);
// persist configuration
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), cfg);
config = cfg;
}
return config;
}
use of com.emc.storageos.coordinator.common.Configuration in project coprhd-controller by CoprHD.
the class DbServiceImpl method checkGlobalConfiguration.
// check and initialize global configuration
private Configuration checkGlobalConfiguration() {
String configKind = _coordinator.getDbConfigPath(_serviceInfo.getName());
Configuration config = _coordinator.queryConfiguration(_coordinator.getSiteId(), configKind, Constants.GLOBAL_ID);
if (config == null) {
// check if it is upgraded from previous version to yoda - configuration may be stored in
// znode /config. Since SeedProvider still need access that, so we remove the config
// from global in migration callback after migration is done.
config = _coordinator.queryConfiguration(configKind, Constants.GLOBAL_ID);
if (config != null) {
_log.info("Upgrade from pre-yoda release, move global config to new location");
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), config);
return config;
}
ConfigurationImpl cfg = new ConfigurationImpl();
cfg.setId(Constants.GLOBAL_ID);
cfg.setKind(configKind);
cfg.setConfig(Constants.SCHEMA_VERSION, this._serviceInfo.getVersion());
// persist configuration
_coordinator.persistServiceConfiguration(_coordinator.getSiteId(), cfg);
config = cfg;
}
return config;
}
Aggregations