Search in sources :

Example 1 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl in project coprhd-controller by CoprHD.

the class PasswordUtils method setCoordinator.

public void setCoordinator(CoordinatorClient coordinator) {
    this.coordinator = coordinator;
    EncryptionProviderImpl encryptionProvider1 = new EncryptionProviderImpl();
    encryptionProvider1.setCoordinator(coordinator);
    encryptionProvider1.start();
    this.encryptionProvider = encryptionProvider1;
}
Also used : EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl)

Example 2 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl in project coprhd-controller by CoprHD.

the class GeoDbSvcStartupTest method getDbClient.

protected static DbClient getDbClient() throws URISyntaxException, IOException {
    if (dbClient == null) {
        dbClient = new DbClientImpl();
        CoordinatorClient coordinator = runner.getCoordinator();
        dbClient.setCoordinatorClient(coordinator);
        DbVersionInfo dbVersionInfo = new DbVersionInfo();
        dbVersionInfo.setSchemaVersion(DbSvcRunner.SVC_VERSION);
        dbClient.setDbVersionInfo(dbVersionInfo);
        dbClient.setBypassMigrationLock(true);
        EncryptionProviderImpl encryptionProvider = new EncryptionProviderImpl();
        encryptionProvider.setCoordinator(coordinator);
        dbClient.setEncryptionProvider(encryptionProvider);
        EncryptionProviderImpl geoEncryptionProvider = new EncryptionProviderImpl();
        geoEncryptionProvider.setCoordinator(coordinator);
        geoEncryptionProvider.setEncryptId("geoid");
        dbClient.setGeoEncryptionProvider(geoEncryptionProvider);
        DbClientContext geoCtx = new DbClientContext();
        geoCtx.setClusterName("GeoStorageOS");
        geoCtx.setKeyspaceName("GeoStorageOS");
        dbClient.setGeoContext(geoCtx);
        dbClient.start();
    }
    return dbClient;
}
Also used : DbClientContext(com.emc.storageos.db.client.impl.DbClientContext) DbClientImpl(com.emc.storageos.db.client.impl.DbClientImpl) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo)

Example 3 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl in project coprhd-controller by CoprHD.

the class ComputeImageMigration method process.

@Override
public void process() throws MigrationCallbackException {
    log.info("Starting Compute Image Migration");
    if (null == encryptionProvider) {
        EncryptionProviderImpl encryptionProviderImpl = new EncryptionProviderImpl();
        encryptionProviderImpl.setCoordinator(coordinatorClient);
        encryptionProviderImpl.start();
        encryptionProvider = encryptionProviderImpl;
    }
    List<URI> computeImageURIList = dbClient.queryByType(ComputeImage.class, true);
    Iterator<ComputeImage> computeImageItr = dbClient.queryIterativeObjects(ComputeImage.class, computeImageURIList, true);
    while (computeImageItr.hasNext()) {
        ComputeImage image = computeImageItr.next();
        String imageUrl = image.getImageUrl();
        String password = extractPasswordFromImageUrl(imageUrl);
        String encryptedPassword = password;
        if (StringUtils.isNotBlank(password)) {
            encryptedPassword = encryptionProvider.getEncryptedString(password);
            imageUrl = StringUtils.replace(imageUrl, ":" + password + "@", ":" + encryptedPassword + "@");
        }
        image.setImageUrl(imageUrl);
        dbClient.updateObject(image);
        log.info("Successfully migrated compute image : {} - {}", image.getLabel(), image.getId());
    }
    log.info("Completed Compute Image Migration");
}
Also used : EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) URI(java.net.URI) ComputeImage(com.emc.storageos.db.client.model.ComputeImage)

Example 4 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl 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 5 with EncryptionProviderImpl

use of com.emc.storageos.db.client.impl.EncryptionProviderImpl in project coprhd-controller by CoprHD.

the class DbServiceTestBase method startDb.

/**
 * Start embedded DB
 */
protected void startDb(String schemaVersion, String extraModelsPkg) throws Exception {
    List<String> packages = new ArrayList<String>();
    packages.add("com.emc.storageos.db.client.model");
    if (extraModelsPkg != null) {
        packages.add(extraModelsPkg);
    }
    String[] pkgsArray = packages.toArray(new String[packages.size()]);
    ServiceImpl service = new ServiceImpl();
    service.setName("dbsvc");
    service.setVersion(schemaVersion);
    service.setEndpoint(URI.create("thrift://localhost:9160"));
    service.setId("db-standalone");
    DataObjectScanner scanner = new DataObjectScanner();
    scanner.setPackages(pkgsArray);
    scanner.init();
    dbVersionInfo = new DbVersionInfo();
    dbVersionInfo.setSchemaVersion(schemaVersion);
    coordinator.setDbVersionInfo(dbVersionInfo);
    DbServiceStatusChecker statusChecker = new DbServiceStatusChecker();
    statusChecker.setCoordinator(coordinator);
    statusChecker.setClusterNodeCount(1);
    statusChecker.setDbVersionInfo(dbVersionInfo);
    statusChecker.setServiceName(service.getName());
    CoordinatorClientInetAddressMap coordinatorMap = new CoordinatorClientInetAddressMap();
    coordinatorMap.setNodeId("localhost");
    coordinatorMap.setDualInetAddress(DualInetAddress.fromAddress("127.0.0.1"));
    Map<String, DualInetAddress> addressLookupMap = new HashMap<String, DualInetAddress>();
    addressLookupMap.put(coordinatorMap.getNodeId(), coordinatorMap.getDualInetAddress());
    coordinatorMap.setControllerNodeIPLookupMap(addressLookupMap);
    coordinatorMap.setCoordinatorClient(coordinator);
    coordinator.setInetAddessLookupMap(coordinatorMap);
    SchemaUtil util = new SchemaUtil();
    util.setKeyspaceName("Test");
    util.setClusterName("Test");
    util.setDataObjectScanner(scanner);
    util.setService(service);
    util.setStatusChecker(statusChecker);
    util.setCoordinator(coordinator);
    util.setVdcShortId("vdc1");
    util.setClientContext(createLocalContext());
    List<String> vdcHosts = new ArrayList();
    vdcHosts.add("127.0.0.1");
    util.setVdcNodeList(vdcHosts);
    util.setDbCommonInfo(new java.util.Properties());
    dbsvc = new InternalDbService();
    dbsvc.setConfig("db-test.yaml");
    dbsvc.setSchemaUtil(util);
    dbsvc.setCoordinator(coordinator);
    dbsvc.setStatusChecker(statusChecker);
    dbsvc.setService(service);
    dbsvc.setDbDir(".");
    JmxServerWrapper jmx = new JmxServerWrapper();
    jmx.setEnabled(false);
    dbsvc.setJmxServerWrapper(jmx);
    dbClient = getDbClientBase();
    dbsvc.setDbClient(dbClient);
    PasswordUtils passwordUtils = new PasswordUtils();
    passwordUtils.setCoordinator(coordinator);
    EncryptionProviderImpl provider = new EncryptionProviderImpl();
    provider.setCoordinator(coordinator);
    provider.start();
    passwordUtils.setEncryptionProvider(provider);
    passwordUtils.setDbClient(dbClient);
    util.setPasswordUtils(passwordUtils);
    StubBeaconImpl beacon = new StubBeaconImpl(service);
    dbsvc.setBeacon(beacon);
    MigrationHandlerImpl handler = new MigrationHandlerImpl();
    handler.setPackages(pkgsArray);
    handler.setService(service);
    handler.setStatusChecker(statusChecker);
    handler.setCoordinator(coordinator);
    handler.setDbClient(dbClient);
    handler.setSchemaUtil(util);
    dbsvc.setMigrationHandler(handler);
    dbsvc.setDisableScheduledDbRepair(true);
    dbsvc.start();
}
Also used : DataObjectScanner(com.emc.storageos.db.common.DataObjectScanner) InternalDbService(com.emc.storageos.db.server.upgrade.util.InternalDbService) HashMap(java.util.HashMap) ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) MigrationHandlerImpl(com.emc.storageos.db.server.impl.MigrationHandlerImpl) ArrayList(java.util.ArrayList) DbServiceStatusChecker(com.emc.storageos.db.common.DbServiceStatusChecker) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) EncryptionProviderImpl(com.emc.storageos.db.client.impl.EncryptionProviderImpl) DbVersionInfo(com.emc.storageos.coordinator.client.model.DbVersionInfo) SchemaUtil(com.emc.storageos.db.server.impl.SchemaUtil) CoordinatorClientInetAddressMap(com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap) StubBeaconImpl(com.emc.storageos.db.server.util.StubBeaconImpl) JmxServerWrapper(com.emc.storageos.services.util.JmxServerWrapper) DualInetAddress(com.emc.storageos.coordinator.client.service.impl.DualInetAddress)

Aggregations

EncryptionProviderImpl (com.emc.storageos.db.client.impl.EncryptionProviderImpl)7 DbVersionInfo (com.emc.storageos.coordinator.client.model.DbVersionInfo)2 EncryptionProvider (com.emc.storageos.db.client.model.EncryptionProvider)2 URI (java.net.URI)2 CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)1 CoordinatorClientInetAddressMap (com.emc.storageos.coordinator.client.service.impl.CoordinatorClientInetAddressMap)1 DualInetAddress (com.emc.storageos.coordinator.client.service.impl.DualInetAddress)1 Configuration (com.emc.storageos.coordinator.common.Configuration)1 ServiceImpl (com.emc.storageos.coordinator.common.impl.ServiceImpl)1 DbClientContext (com.emc.storageos.db.client.impl.DbClientContext)1 DbClientImpl (com.emc.storageos.db.client.impl.DbClientImpl)1 ComputeImage (com.emc.storageos.db.client.model.ComputeImage)1 ComputeImageServer (com.emc.storageos.db.client.model.ComputeImageServer)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1 DataObjectScanner (com.emc.storageos.db.common.DataObjectScanner)1 DbServiceStatusChecker (com.emc.storageos.db.common.DbServiceStatusChecker)1 MigrationHandlerImpl (com.emc.storageos.db.server.impl.MigrationHandlerImpl)1 SchemaUtil (com.emc.storageos.db.server.impl.SchemaUtil)1 InternalDbService (com.emc.storageos.db.server.upgrade.util.InternalDbService)1 StubBeaconImpl (com.emc.storageos.db.server.util.StubBeaconImpl)1