Search in sources :

Example 91 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class VPlexControllerUtils method getVPlexAPIClient.

/**
 * Get the HTTP client for making requests to the passed VPlex storage system.
 *
 * @param vplexApiFactory A reference to the VPlex API factory.
 * @param vplexSystem The VPlex storage system.
 * @param dbClient A reference to a DB client.
 *
 * @return A reference to the VPlex API HTTP client.
 * @throws URISyntaxException
 */
public static VPlexApiClient getVPlexAPIClient(VPlexApiFactory vplexApiFactory, StorageSystem vplexSystem, DbClient dbClient) throws URISyntaxException {
    // Create the URI to access the VPlex Management Server based
    // on the IP and port for the active provider for the passed
    // VPlex system.
    StorageProvider activeMgmntSvr = null;
    URI activeMgmntSvrURI = vplexSystem.getActiveProviderURI();
    if (!NullColumnValueGetter.isNullURI(activeMgmntSvrURI)) {
        activeMgmntSvr = dbClient.queryObject(StorageProvider.class, activeMgmntSvrURI);
    }
    if (activeMgmntSvr == null) {
        log.error("No active management server for VPLEX system {}", vplexSystem.getId());
        throw VPlexApiException.exceptions.connectionFailure(vplexSystem.getId().toString());
    }
    return getVPlexAPIClient(vplexApiFactory, activeMgmntSvr, dbClient);
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI)

Example 92 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionTest method testDiscovery.

/**
 * Load StorageSystems from DB, and run discovery Provider(s) need to be
 * added outside this class, or run after testScan()
 *
 * @throws Exception
 */
@Test
public void testDiscovery() throws Exception {
    _logger.info("Started Loading Systems from DB for discovery jobs");
    Iterator<URI> systemURIsItr = _dbClient.queryByType(StorageSystem.class, true).iterator();
    while (systemURIsItr.hasNext()) {
        URI systemURI = systemURIsItr.next();
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
        system.setLastDiscoveryRunTime(0L);
        _dbClient.persistObject(system);
        URI providerURI = system.getActiveProviderURI();
        if (providerURI == null || providerURI.equals(NullColumnValueGetter.getNullURI())) {
            _logger.error("Skipping Discovery Job: StorageSystem {} does not have an active provider", systemURI);
            continue;
        }
        StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerURI);
        if (provider == null || provider.getInactive()) {
            _logger.info("Skipping Discovery Job: StorageSystem {} does not have a valid active provider", systemURI);
            continue;
        }
        String taskId = UUID.randomUUID().toString();
        DiscoverTaskCompleter completer = new DiscoverTaskCompleter(StorageSystem.class, systemURI, taskId, ControllerServiceImpl.DISCOVERY);
        DataCollectionJob job = new DataCollectionDiscoverJob(completer, _jobOrigin, Discovery_Namespaces.ALL.name());
        _jobConsumer.consumeItem(job, null);
    }
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Test(org.junit.Test)

Example 93 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionTest method testScan.

/**
 * Load StorageProviders from DB and do scanning Provider(s) need to be
 * added outside this class, or run after createProvider()
 *
 * @throws Exception
 */
@Test
public void testScan() throws Exception {
    _logger.info("Started Loading Storage Providers from DB");
    Iterator<URI> providerURIsIter = _dbClient.queryByType(StorageProvider.class, true).iterator();
    DataCollectionScanJob scanJob = new DataCollectionScanJob(_jobOrigin);
    while (providerURIsIter.hasNext()) {
        URI providerURI = providerURIsIter.next();
        if (isTestNewProvider && !providerURI.equals(_providerURI)) {
            continue;
        }
        StorageProvider provider = _dbClient.queryObject(StorageProvider.class, providerURI);
        provider.setLastScanTime(0L);
        provider.setManufacturer(NullColumnValueGetter.getNullStr());
        _dbClient.persistObject(provider);
        String taskId = UUID.randomUUID().toString();
        scanJob.addCompleter(new ScanTaskCompleter(StorageProvider.class, providerURI, taskId));
    }
    List<URI> providers = scanJob.getProviders();
    if (providers != null && !providers.isEmpty()) {
        _logger.info("Start to process scan job");
        _jobConsumer.consumeItem(scanJob, null);
    } else {
        _logger.error("No scan job to be processed");
    }
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider) URI(java.net.URI) Test(org.junit.Test)

Example 94 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class DataCollectionTest method setup.

@Before
public void setup() {
    try {
        for (Lock lock : Lock.values()) {
            Method method = lock.getClass().getDeclaredMethod("setLock", InterProcessLock.class);
            method.setAccessible(true);
            Object[] parameters = new Object[1];
            parameters[0] = _coordinator.getLock(lock.name());
            method.invoke(lock, parameters);
        }
        _dbClient.start();
        if (_provider != null) {
            String providerKey = _provider.getIPAddress() + "-" + _provider.getPortNumber();
            List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByProviderId(_dbClient, providerKey);
            if (providers != null && !providers.isEmpty()) {
                _providerURI = providers.get(0).getId();
                _logger.warn("Provider has already been in db.");
            } else if (isTestNewProvider) {
                _providerURI = URIUtil.createId(StorageProvider.class);
                _provider.setId(_providerURI);
                _dbClient.createObject(_provider);
            }
        }
        CIMConnectionFactory cimConnectionFactory = new CIMConnectionFactory();
        cimConnectionFactory.setDbClient(_dbClient);
        cimConnectionFactory.setConnectionManager(_connectionManager);
        DataCollectionJobScheduler scheduler = new DataCollectionJobScheduler();
        scheduler.setConfigInfo(_configInfo);
        scheduler.setConnectionFactory(cimConnectionFactory);
        scheduler.setCoordinator(_coordinator);
        scheduler.setDbClient(_dbClient);
        _jobUtil = new DataCollectionJobUtil();
        _jobUtil.setDbClient(_dbClient);
        _jobUtil.setConfigInfo(_configInfo);
        _jobConsumer = new TestDataCollectionJobConsumer();
        _jobConsumer.setConfigInfo(_configInfo);
        _jobConsumer.setConnectionFactory(cimConnectionFactory);
        _jobConsumer.setCoordinator(_coordinator);
        _jobConsumer.setDbClient(_dbClient);
        _jobConsumer.setUtil(_jobUtil);
        _jobConsumer.setJobScheduler(scheduler);
        VersionChecker versionChecker = new VersionChecker();
        versionChecker.setCoordinator(_coordinator);
    } catch (Exception e) {
        _logger.error("Failed to run setup. Exception - " + e.getMessage());
        _logger.error(e.getMessage(), e);
    }
}
Also used : Method(java.lang.reflect.Method) StorageProvider(com.emc.storageos.db.client.model.StorageProvider) Lock(com.emc.storageos.volumecontroller.impl.ControllerServiceImpl.Lock) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) VersionChecker(com.emc.storageos.util.VersionChecker) CIMConnectionFactory(com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory) DataObject(com.emc.storageos.db.client.model.DataObject) Before(org.junit.Before)

Example 95 with StorageProvider

use of com.emc.storageos.db.client.model.StorageProvider in project coprhd-controller by CoprHD.

the class BlockDeviceController method updateActiveProvider.

private void updateActiveProvider(StorageSystem storage) throws DatabaseException {
    if (storage.getActiveProviderURI() == null) {
        return;
    }
    StorageProvider mainProvider = _dbClient.queryObject(StorageProvider.class, storage.getActiveProviderURI());
    if (mainProvider != null) {
        storage.setSmisPassword(mainProvider.getPassword());
        storage.setSmisUserName(mainProvider.getUserName());
        storage.setSmisPortNumber(mainProvider.getPortNumber());
        storage.setSmisProviderIP(mainProvider.getIPAddress());
        storage.setSmisUseSSL(mainProvider.getUseSSL());
        _dbClient.updateObject(storage);
    }
}
Also used : StorageProvider(com.emc.storageos.db.client.model.StorageProvider)

Aggregations

StorageProvider (com.emc.storageos.db.client.model.StorageProvider)97 URI (java.net.URI)44 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)26 ArrayList (java.util.ArrayList)24 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)23 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 Produces (javax.ws.rs.Produces)19 IOException (java.io.IOException)18 StringSet (com.emc.storageos.db.client.model.StringSet)17 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)15 Path (javax.ws.rs.Path)15 Consumes (javax.ws.rs.Consumes)11 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)10 MapStorageProvider (com.emc.storageos.api.mapper.functions.MapStorageProvider)8 StorageSystemViewObject (com.emc.storageos.plugins.StorageSystemViewObject)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)7 BlockController (com.emc.storageos.volumecontroller.BlockController)7