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