Search in sources :

Example 21 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class PasswordServiceTest method initPasswordHandler.

private void initPasswordHandler(LocalPasswordHandler ph) {
    Properties properties = generateProperties();
    PasswordUtils.setDefaultProperties(properties);
    PasswordUtils passUtils = new PasswordUtils();
    try {
        CoordinatorClient client = getCoordinatorClient();
        passUtils.setCoordinator(client);
    } catch (Exception e) {
        log.error("Failed to set coordinator client e=", e);
        throw new RuntimeException(e);
    }
    passUtils.setEncryptionProvider(provider);
    passUtils.setDbClient(new DummyDbClient());
    ph.setPasswordUtils(passUtils);
    ph.setConfigService(_cfg);
}
Also used : DummyDbClient(com.emc.storageos.util.DummyDbClient) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) PasswordUtils(com.emc.storageos.security.password.PasswordUtils) Properties(java.util.Properties) URISyntaxException(java.net.URISyntaxException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) LocalRepositoryException(com.emc.storageos.systemservices.exceptions.LocalRepositoryException) ForbiddenException(com.emc.storageos.svcs.errorhandling.resources.ForbiddenException) CoordinatorClientException(com.emc.storageos.systemservices.exceptions.CoordinatorClientException)

Example 22 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class VdcManager method updateSiteErrors.

// TODO - let's see if we can move it to VdcOpHandler later
private void updateSiteErrors() {
    CoordinatorClient coordinatorClient = coordinator.getCoordinatorClient();
    if (!drUtil.isActiveSite()) {
        log.info("Step3: current site is a standby, nothing to do");
        return;
    }
    for (Site site : drUtil.listSites()) {
        SiteError error = getSiteError(site);
        if (error != null) {
            log.info("set site {} state to STANDBY_ERROR, set lastState to {}", site.getName(), site.getState());
            coordinatorClient.setTargetInfo(site.getUuid(), error);
            site.setLastState(site.getState());
            site.setState(SiteState.STANDBY_ERROR);
            coordinatorClient.persistServiceConfiguration(site.toConfiguration());
        }
    }
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient)

Example 23 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class TestSysServiceBeacon method testBeacon.

@Test
@Ignore("This references a configuration that doesn't exist (syssvc-config.xml), either fix or delete this test")
public void testBeacon() throws Exception {
    String curVersion = "current_version";
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("/syssvc-config.xml");
    SysSvcImpl sysservice = (SysSvcImpl) ctx.getBean(SERVICE_BEAN);
    sysservice.start();
    ServiceImpl svc = (ServiceImpl) ctx.getBean(SERVICE_INFO);
    CoordinatorClient client = connectClient();
    SysSvcBeaconImpl beacon = (SysSvcBeaconImpl) ctx.getBean(BEACON_BEAN);
    List<Service> found = client.locateAllServices(svc.getName(), svc.getVersion(), (String) null, null);
    Assert.assertNotNull(found);
    Assert.assertEquals(found.size(), 1);
    Service first = found.get(0);
    Assert.assertEquals(first.getId(), svc.getId());
    Assert.assertEquals(first.getEndpoint(), svc.getEndpoint());
    Assert.assertEquals(first.getAttribute(curVersion), null);
    svc.setAttribute(curVersion, "2");
    beacon.publish();
    found = client.locateAllServices(svc.getName(), svc.getVersion(), (String) null, null);
    Assert.assertNotNull(found);
    Assert.assertEquals(found.size(), 1);
    first = found.get(0);
    Assert.assertEquals(first.getId(), svc.getId());
    Assert.assertEquals(first.getEndpoint(), svc.getEndpoint());
    Assert.assertEquals(first.getAttribute(curVersion), "2");
    sysservice.stop();
}
Also used : SysSvcBeaconImpl(com.emc.storageos.systemservices.impl.SysSvcBeaconImpl) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) SysSvcImpl(com.emc.storageos.systemservices.impl.SysSvcImpl) ServiceImpl(com.emc.storageos.coordinator.common.impl.ServiceImpl) CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) Service(com.emc.storageos.coordinator.common.Service) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 24 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient in project coprhd-controller by CoprHD.

the class DbSvcRunner method isStarted.

/**
 * Check if service is started
 *
 * @return
 */
public boolean isStarted() {
    try {
        CoordinatorClient coordinator = getCoordinator();
        List<Service> service = coordinator.locateAllServices(serviceName, SVC_VERSION, null, null);
        if (service.iterator().hasNext()) {
            Service svc = service.iterator().next();
            URI hostUri = svc.getEndpoint();
            log.info("Found " + svc.getName() + "; host = " + hostUri.getHost() + "; port = " + hostUri.getPort());
            return true;
        }
    } catch (RetryableCoordinatorException e) {
        log.warn("no {} instance running. Coordinator exception message: {}", serviceName, e.getMessage());
    } catch (Exception e) {
        log.error("service lookup failure", e);
    }
    return false;
}
Also used : CoordinatorClient(com.emc.storageos.coordinator.client.service.CoordinatorClient) DbService(com.emc.storageos.db.server.DbService) Service(com.emc.storageos.coordinator.common.Service) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) URI(java.net.URI) URISyntaxException(java.net.URISyntaxException) RetryableCoordinatorException(com.emc.storageos.coordinator.exceptions.RetryableCoordinatorException) IOException(java.io.IOException)

Example 25 with CoordinatorClient

use of com.emc.storageos.coordinator.client.service.CoordinatorClient 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)

Aggregations

CoordinatorClient (com.emc.storageos.coordinator.client.service.CoordinatorClient)49 Test (org.junit.Test)11 Base64TokenEncoder (com.emc.storageos.security.authentication.Base64TokenEncoder)8 TokenKeyGenerator (com.emc.storageos.security.authentication.TokenKeyGenerator)8 TokenMaxLifeValuesHolder (com.emc.storageos.security.authentication.TokenMaxLifeValuesHolder)8 Configuration (com.emc.storageos.coordinator.common.Configuration)7 DbClient (com.emc.storageos.db.client.DbClient)7 CassandraTokenManager (com.emc.storageos.auth.impl.CassandraTokenManager)6 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 StorageOSUserDAO (com.emc.storageos.db.client.model.StorageOSUserDAO)6 TokenOnWire (com.emc.storageos.security.authentication.TokenOnWire)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)5 URI (java.net.URI)5 Service (com.emc.storageos.coordinator.common.Service)4 InterVDCTokenCacheHelper (com.emc.storageos.security.geo.InterVDCTokenCacheHelper)4 ArrayList (java.util.ArrayList)4 ConfigurationImpl (com.emc.storageos.coordinator.common.impl.ConfigurationImpl)3 BaseToken (com.emc.storageos.db.client.model.BaseToken)3 ProxyToken (com.emc.storageos.db.client.model.ProxyToken)3 Token (com.emc.storageos.db.client.model.Token)3