use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class VNXFileCommunicationInterface method getVnxFileSMISConnection.
/**
* Check and add valid SMIS connection for storage system to ConnectionManager.
*
* @param accessProfile
* : AccessProfile for the providers
* @param StorageSystem
* : Storage system
* @return boolean : true if connection can be establish
*/
private boolean getVnxFileSMISConnection(AccessProfile accessProfile, StorageSystem system) {
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
// getConnection method also add the valid connection to connection manager.
CimConnection cxn = connectionFactory.getConnection(system);
if (cxn != null && connectionFactory.checkConnectionliveness(cxn)) {
return true;
}
} catch (final Exception ex) {
_logger.error("Not able to get CIMOM Client instance for provider ip {} due to ", system.getSmisProviderIP(), ex);
}
return false;
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class ConnectionManagerUtils method disallowReaping.
public void disallowReaping(Object profile, Object client) throws BaseCollectionException {
AccessProfile accessProfile = (AccessProfile) profile;
DbClient dbClient = (DbClient) client;
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
connectionFactory.setKeepAliveForConnection(storageSystem);
} catch (final IllegalStateException ex) {
log.error("Not able to get CIMOM Client instance for ip {} due to ", accessProfile.getIpAddress(), ex);
throw new SMIPluginException(SMIPluginException.ERRORCODE_NO_WBEMCLIENT, ex.fillInStackTrace(), ex.getMessage());
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisAbstractCreateVolumeJob method updateStatus.
/**
* Called to update the job status when the volume create job completes.
* <p/>
* This is common update code for volume create operations.
*
* @param jobContext The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> iterator = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
int volumeCount = 0;
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, jobStatus.name()));
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
iterator = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
Calendar now = Calendar.getInstance();
// from pool's reserved capacity map.
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
SmisUtils.updateStoragePoolCapacity(dbClient, client, _storagePool);
StoragePool pool = dbClient.queryObject(StoragePool.class, _storagePool);
StringMap reservationMap = pool.getReservedCapacityMap();
for (URI volumeId : getTaskCompleter().getIds()) {
// remove from reservation map
reservationMap.remove(volumeId.toString());
}
dbClient.persistObject(pool);
}
if (jobStatus == JobStatus.SUCCESS) {
List<URI> volumes = new ArrayList<URI>();
while (iterator.hasNext()) {
CIMObjectPath volumePath = iterator.next();
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
String nativeID = deviceID.getValue();
URI volumeId = getTaskCompleter().getId(volumeCount++);
volumes.add(volumeId);
persistVolumeNativeID(dbClient, volumeId, nativeID, now);
processVolume(jobContext, volumePath, nativeID, volumeId, client, dbClient, logMsgBuilder, now);
}
// Add Volumes to Consistency Group (if needed)
addVolumesToConsistencyGroup(jobContext, volumes);
} else if (jobStatus == JobStatus.FAILED) {
if (iterator.hasNext()) {
while (iterator.hasNext()) {
CIMObjectPath volumePath = iterator.next();
CIMProperty<String> deviceID = (CIMProperty<String>) volumePath.getKey(SmisConstants.CP_DEVICE_ID);
String nativeID = deviceID.getValue();
URI volumeId = getTaskCompleter().getId(volumeCount++);
if ((nativeID != null) && (nativeID.length() != 0)) {
persistVolumeNativeID(dbClient, volumeId, nativeID, now);
processVolume(jobContext, volumePath, nativeID, volumeId, client, dbClient, logMsgBuilder, now);
} else {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, volumeId));
Volume volume = dbClient.queryObject(Volume.class, volumeId);
volume.setInactive(true);
dbClient.persistObject(volume);
}
}
} else {
for (URI id : getTaskCompleter().getIds()) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, id.toString()));
Volume volume = dbClient.queryObject(Volume.class, id);
volume.setInactive(true);
dbClient.persistObject(volume);
}
}
}
_log.info(logMsgBuilder.toString());
} catch (Exception e) {
_log.error("Caught an exception while trying to updateStatus for SmisCreateVolumeJob", e);
setPostProcessingErrorStatus("Encountered an internal error during volume create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
if (iterator != null) {
iterator.close();
}
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockCreateCGMirrorJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMInstance> syncVolumeIter = null;
CloseableIterator<CIMObjectPath> repGroupPathIter = null;
DbClient dbClient = jobContext.getDbClient();
BlockMirrorCreateCompleter completer = (BlockMirrorCreateCompleter) getTaskCompleter();
;
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
updatePools(client, dbClient, mirrors);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Group mirror creation success");
repGroupPathIter = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null);
CIMObjectPath repGroupPath = repGroupPathIter.next();
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
String repGroupID = (String) repGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
repGroupID = SmisUtils.getTargetGroupName(repGroupID, storage.getUsingSmis80());
CIMInstance syncInst = getSynchronizedInstance(client, repGroupPath);
String syncType = CIMPropertyFactory.getPropertyValue(syncInst, SmisConstants.CP_SYNC_TYPE);
syncVolumeIter = client.associatorInstances(repGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
processCGMirrors(syncVolumeIter, client, dbClient, jobContext.getSmisCommandHelper(), storage, mirrors, repGroupID, syncInst.getObjectPath().toString(), syncType);
} else if (isJobInTerminalFailedState()) {
_log.info("Failed to create group mirrors");
completer.error(dbClient, DeviceControllerException.exceptions.attachVolumeMirrorFailed(getMessage()));
for (BlockMirror mirror : mirrors) {
mirror.setInactive(true);
}
dbClient.persistObject(mirrors);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during block create CG mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateCGMirrorJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
if (repGroupPathIter != null) {
repGroupPathIter.close();
}
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockCreateSnapshotJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMObjectPath> syncVolumeIter = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockSnapshotCreateCompleter completer = (BlockSnapshotCreateCompleter) getTaskCompleter();
List<BlockSnapshot> snapshots = dbClient.queryObject(BlockSnapshot.class, completer.getSnapshotURIs());
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
if (jobStatus == JobStatus.SUCCESS) {
_log.info(String.format("Post-processing successful snap creation task:%s. Expected: snapshot.size() = 1; Actual: snapshots.size() = %d", getTaskCompleter().getOpId(), snapshots.size()));
// Get the snapshot device ID and set it against the BlockSnapshot object
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
syncVolumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
if (syncVolumeIter.hasNext()) {
// Get the sync volume native device id
CIMObjectPath syncVolumePath = syncVolumeIter.next();
CIMInstance syncVolume = client.getInstance(syncVolumePath, false, false, null);
String syncDeviceID = syncVolumePath.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);
// Lookup the associated snapshot based on the volume native device id
BlockSnapshot snapshot = snapshots.get(0);
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent().getURI());
snapshot.setNativeId(syncDeviceID);
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
snapshot.setDeviceLabel(elementName);
snapshot.setInactive(false);
snapshot.setIsSyncActive(_wantSyncActive);
snapshot.setCreationTime(Calendar.getInstance());
snapshot.setWWN(wwn.toUpperCase());
snapshot.setAlternateName(alternateName);
commonSnapshotUpdate(snapshot, syncVolume, client, storage, volume.getNativeId(), syncDeviceID, true, dbClient);
_log.info(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", syncVolumePath.toString(), snapshot.getId().toString(), syncDeviceID, elementName, volume.getNativeId(), volume.getDeviceLabel()));
dbClient.persistObject(snapshot);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create snapshot");
BlockSnapshot snapshot = snapshots.get(0);
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during block create snapshot job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateSnapshotJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
Aggregations