Search in sources :

Example 41 with Configuration

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

Example 42 with Configuration

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);
    }
}
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)

Example 43 with Configuration

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

Example 44 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Example 45 with Configuration

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;
}
Also used : Configuration(com.emc.storageos.coordinator.common.Configuration) ConfigurationImpl(com.emc.storageos.coordinator.common.impl.ConfigurationImpl)

Aggregations

Configuration (com.emc.storageos.coordinator.common.Configuration)87 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)16 InterProcessLock (org.apache.curator.framework.recipes.locks.InterProcessLock)11 CoordinatorException (com.emc.storageos.coordinator.exceptions.CoordinatorException)9 IOException (java.io.IOException)9 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)8 RetryableCoordinatorException (com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException)8 Site (com.emc.storageos.coordinator.client.model.Site)7 UnknownHostException (java.net.UnknownHostException)7 KeeperException (org.apache.zookeeper.KeeperException)7 PropertyInfoMapper.decodeFromString (com.emc.storageos.coordinator.mapper.PropertyInfoMapper.decodeFromString)6 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Test (org.junit.Test)6 Matchers.anyString (org.mockito.Matchers.anyString)3 MigrationStatus (com.emc.storageos.coordinator.client.model.MigrationStatus)2 PropertyInfoExt (com.emc.storageos.coordinator.client.model.PropertyInfoExt)2 DrUtil (com.emc.storageos.coordinator.client.service.DrUtil)2 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)2 SiteConfigRestRep (com.emc.storageos.model.dr.SiteConfigRestRep)2