Search in sources :

Example 16 with MigrationCallbackException

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");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 17 with MigrationCallbackException

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");
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) ArrayList(java.util.ArrayList) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 18 with MigrationCallbackException

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;
}
Also used : BaseCustomMigrationCallback(com.emc.storageos.db.client.upgrade.BaseCustomMigrationCallback) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) List(java.util.List)

Example 19 with MigrationCallbackException

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);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)

Example 20 with MigrationCallbackException

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);
    }
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ComputeImageServer(com.emc.storageos.db.client.model.ComputeImageServer) PropertyInfo(com.emc.storageos.model.property.PropertyInfo) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) URI(java.net.URI) MigrationCallbackException(com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Aggregations

MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)36 URI (java.net.URI)25 DbClient (com.emc.storageos.db.client.DbClient)24 ArrayList (java.util.ArrayList)18 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)9 StringSet (com.emc.storageos.db.client.model.StringSet)6 FileShare (com.emc.storageos.db.client.model.FileShare)4 HashMap (java.util.HashMap)4 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)3 FilePolicy (com.emc.storageos.db.client.model.FilePolicy)3 Volume (com.emc.storageos.db.client.model.Volume)3 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)3 Configuration (com.emc.storageos.coordinator.common.Configuration)2 FatalCoordinatorException (com.emc.storageos.coordinator.exceptions.FatalCoordinatorException)2 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 ExportMask (com.emc.storageos.db.client.model.ExportMask)2 FileReplicationTopology (com.emc.storageos.db.client.model.FileReplicationTopology)2 Initiator (com.emc.storageos.db.client.model.Initiator)2