use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockCreateMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> syncVolumeIter = null;
DbClient dbClient = jobContext.getDbClient();
BlockMirrorCreateCompleter completer = null;
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
completer = (BlockMirrorCreateCompleter) getTaskCompleter();
BlockMirror mirror = dbClient.queryObject(BlockMirror.class, completer.getMirrorURI());
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
CIMConnectionFactory cimConnectionFactory;
WBEMClient client = null;
// from pool's reserved capacity map.
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
cimConnectionFactory = jobContext.getCimConnectionFactory();
client = getWBEMClient(dbClient, cimConnectionFactory);
URI poolURI = mirror.getPool();
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
StoragePool pool = dbClient.queryObject(StoragePool.class, poolURI);
StringMap reservationMap = pool.getReservedCapacityMap();
// remove from reservation map
reservationMap.remove(mirror.getId().toString());
dbClient.persistObject(pool);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Mirror creation success");
cimConnectionFactory = jobContext.getCimConnectionFactory();
client = getWBEMClient(dbClient, cimConnectionFactory);
syncVolumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
if (syncVolumeIter.hasNext()) {
// Get the target mirror volume native device id
CIMObjectPath targetVolumePath = syncVolumeIter.next();
CIMInstance syncVolume = client.getInstance(targetVolumePath, false, false, null);
String syncDeviceID = targetVolumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
String elementName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_ELEMENT_NAME);
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
String alternateName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
CIMInstance syncInstance = getStorageSyncInstanceFromVolume(client, targetVolumePath);
// Lookup the associated source volume based on the volume native device id
mirror.setProvisionedCapacity(getProvisionedCapacityInformation(client, syncVolume));
mirror.setAllocatedCapacity(getAllocatedCapacityInformation(client, syncVolume));
mirror.setWWN(wwn);
mirror.setAlternateName(alternateName);
mirror.setNativeId(syncDeviceID);
mirror.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, mirror));
mirror.setDeviceLabel(elementName);
mirror.setInactive(false);
mirror.setSynchronizedInstance(syncInstance.getObjectPath().toString());
updateSynchronizationAspects(client, mirror);
// mirror.setIsSyncActive(_wantSyncActive);
Volume volume = dbClient.queryObject(Volume.class, mirror.getSource().getURI());
_log.info(String.format("For target mirror volume %1$s, going to set BlockMirror %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", targetVolumePath.toString(), mirror.getId().toString(), syncDeviceID, elementName, volume.getNativeId(), volume.getDeviceLabel()));
dbClient.persistObject(mirror);
}
} else if (isJobInTerminalFailedState()) {
_log.info("Failed to create mirror");
completer.error(dbClient, DeviceControllerException.exceptions.attachVolumeMirrorFailed(getMessage()));
mirror.setInactive(true);
dbClient.persistObject(mirror);
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block create mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateMirrorJob", e);
if (completer != null) {
completer.error(dbClient, DeviceControllerException.errors.jobFailed(e));
}
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory 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);
}
}
Aggregations