use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class VirtualPoolDedupCapableMigration method process.
@Override
public void process() throws MigrationCallbackException {
logger.info("Virtual pool DedupCapable migration START");
DbClient dbClient = getDbClient();
try {
List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
List<VirtualPool> modifiedVpools = new ArrayList<VirtualPool>();
while (virtualPools.hasNext()) {
VirtualPool virtualPool = virtualPools.next();
if (VirtualPool.Type.block.name().equals(virtualPool.getType()) && virtualPool.getDedupCapable() == null) {
virtualPool.setDedupCapable(false);
modifiedVpools.add(virtualPool);
logger.info("Updating VirtualPool (id={}) with DedupCapable set to default value 'false' ", virtualPool.getId().toString());
}
}
if (!modifiedVpools.isEmpty()) {
dbClient.updateObject(modifiedVpools);
}
} catch (Exception ex) {
logger.error("Exception occured while migrating DedupCapable for Virtual pools");
logger.error(ex.getMessage(), ex);
}
logger.info("Virtual pool DedupCapable migration END");
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class VirtualPoolPlacementPolicyMigration method process.
@Override
public void process() throws MigrationCallbackException {
logger.info("Virtual pool placement policy migration START");
DbClient dbClient = getDbClient();
try {
List<URI> virtualPoolURIs = dbClient.queryByType(VirtualPool.class, true);
Iterator<VirtualPool> virtualPools = dbClient.queryIterativeObjects(VirtualPool.class, virtualPoolURIs, true);
List<VirtualPool> modifiedVpools = new ArrayList<VirtualPool>();
while (virtualPools.hasNext()) {
VirtualPool virtualPool = virtualPools.next();
if (VirtualPool.Type.block.name().equals(virtualPool.getType()) && virtualPool.getPlacementPolicy() == null) {
virtualPool.setPlacementPolicy(VirtualPool.ResourcePlacementPolicyType.default_policy.name());
modifiedVpools.add(virtualPool);
logger.info("Updating VirtualPool (id={}) with placement policy set to default policy", virtualPool.getId().toString());
}
}
if (!modifiedVpools.isEmpty()) {
dbClient.updateObject(modifiedVpools);
}
} catch (Exception ex) {
logger.error("Exception occured while migrating placement policy for Virtual pools");
logger.error(ex.getMessage(), ex);
}
logger.info("Virtual pool placement policy migration END");
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException in project coprhd-controller by CoprHD.
the class MockMigrationHandler method run.
@Override
public boolean run() throws DatabaseException {
for (Entry<String, List<BaseCustomMigrationCallback>> entry : this.getCustomMigrationCallbacks().entrySet()) {
log.info("execute migration callback under {}", entry.getKey());
for (BaseCustomMigrationCallback callback : entry.getValue()) {
callback.setName(callback.getClass().getName());
callback.setDbClient(this.getDbClient());
callback.setCoordinatorClient(this.getCoordinator());
log.info("Invoking migration callback: " + callback.getName());
try {
callback.process();
} catch (MigrationCallbackException e) {
log.error("invoke migration callback {} failed:{}", callback.getName(), e);
return false;
}
}
}
return true;
}
use of com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException 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.svcs.errorhandling.resources.MigrationCallbackException 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);
}
}
Aggregations