use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisVnxCreateCGCloneJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
CloseableIterator<CIMInstance> syncVolumeIter = null;
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
CloneCreateCompleter completer = (CloneCreateCompleter) getTaskCompleter();
List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
if (jobStatus == JobStatus.SUCCESS) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
// generate a UUID for the set of clones
String setId = UUID.randomUUID().toString();
syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
processCGClones(syncVolumeIter, client, dbClient, clones, setId, isSyncActive);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create clone");
for (Volume clone : clones) {
clone.setInactive(true);
}
dbClient.persistObject(clones);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during create CG clone job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisVnxCreateCGCloneJob", 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 SmisWaitForGroupSynchronizedJob method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
JobPollResult pollResult = new JobPollResult();
DbClient dbClient = jobContext.getDbClient();
CIMConnectionFactory factory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, factory);
TaskCompleter completer = getTaskCompleter();
List<Volume> clones = dbClient.queryObject(Volume.class, completer.getIds());
try {
pollResult.setJobName(getJobName());
pollResult.setJobId(SmisConstants.CP_PERCENT_SYNCED);
pollResult.setJobStatus(JobStatus.IN_PROGRESS);
CIMObjectPath path = getGroupSyncPath();
// no corresponding sync obj, set to complete
if (SmisConstants.NULL_IBM_CIM_OBJECT_PATH.equals(path)) {
log.info("Sync complete");
pollResult.setJobPercentComplete(100);
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
return pollResult;
}
String[] propertyKeys = { SmisConstants.CP_SYNC_STATE, SmisConstants.CP_SYNC_TYPE, SmisConstants.CP_PERCENT_SYNCED, SmisConstants.CP_PROGRESS_STATUS };
CIMInstance syncInstance = client.getInstance(path, false, false, propertyKeys);
if (syncInstance != null) {
String state = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_STATE);
String type = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_TYPE);
String percent = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PERCENT_SYNCED);
String status = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PROGRESS_STATUS);
String msg = String.format("Target=%s, State=%s, Type=%s, Percent=%s, Status=%s", clones.get(0).getId(), state, type, percent, status);
log.info(msg);
pollResult.setJobPercentComplete(Integer.parseInt(percent));
if (COMPLETE.equals(percent)) {
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
}
} else {
pollResult.setJobStatus(JobStatus.FAILED);
}
} catch (Exception e) {
log.error("Failed to update synchronization", e);
pollResult.setJobStatus(JobStatus.FAILED);
completer.error(dbClient, DeviceControllerException.errors.jobFailed(e));
}
return pollResult;
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisWaitForSynchronizedJob method poll.
@Override
public JobPollResult poll(JobContext jobContext, long trackingPeriodInMillis) {
JobPollResult pollResult = new JobPollResult();
DbClient dbClient = jobContext.getDbClient();
CIMConnectionFactory factory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, factory);
TaskCompleter completer = getTaskCompleter();
BlockObject target = dbClient.queryObject(clazz, completer.getId());
CloseableIterator<CIMInstance> references = null;
try {
pollResult.setJobName(getJobName());
pollResult.setJobId(SmisConstants.CP_PERCENT_SYNCED);
pollResult.setJobStatus(JobStatus.IN_PROGRESS);
CIMObjectPath path = getTargetPath();
// no corresponding sync obj, set to complete
if (SmisConstants.NULL_IBM_CIM_OBJECT_PATH.equals(path)) {
log.info("Sync complete");
pollResult.setJobPercentComplete(100);
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
return pollResult;
}
references = client.referenceInstances(getTargetPath(), SmisConstants.CIM_STORAGE_SYNCHRONIZED, null, false, null);
if (references.hasNext()) {
CIMInstance syncInstance = references.next();
String state = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_STATE);
String type = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_SYNC_TYPE);
String percent = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PERCENT_SYNCED);
String status = CIMPropertyFactory.getPropertyValue(syncInstance, SmisConstants.CP_PROGRESS_STATUS);
String msg = String.format("Target=%s, State=%s, Type=%s, Percent=%s, Status=%s", target.getId(), state, type, percent, status);
log.info(msg);
pollResult.setJobPercentComplete(Integer.parseInt(percent));
if (COMPLETE.equals(percent)) {
pollResult.setJobStatus(JobStatus.SUCCESS);
completer.ready(dbClient);
}
} else {
pollResult.setJobStatus(JobStatus.FAILED);
}
} catch (Exception e) {
log.error("Failed to update synchronization", e);
pollResult.setJobStatus(JobStatus.FAILED);
completer.error(dbClient, DeviceControllerException.errors.jobFailed(e));
} finally {
if (references != null) {
references.close();
}
}
return pollResult;
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SMICommunicationInterface method getCIMClient.
/**
* Creates a new WEBClient for a given IP, based on AccessProfile
*
* @param accessProfile
* : AccessProfile for the providers
* @throws WBEMException
* : if WBEMException while creating the WBEMClient
* @throws SMIPluginException
* @return WBEMClient : initialized instance of WBEMClientCIMXML
*/
private static WBEMClient getCIMClient(AccessProfile accessProfile) throws SMIPluginException {
WBEMClient cimClient = null;
try {
final CIMConnectionFactory connectionFactory = (CIMConnectionFactory) accessProfile.getCimConnectionFactory();
CimConnection cxn = connectionFactory.getConnection(accessProfile.getIpAddress(), accessProfile.getProviderPort());
if (cxn == null) {
throw new SMIPluginException(String.format("Not able to get CimConnection to SMISProvider %s on port %s", accessProfile.getIpAddress(), accessProfile.getProviderPort()), SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
}
cimClient = cxn.getCimClient();
if (null == cimClient) {
throw new SMIPluginException("Not able to get CIMOM client", SMIPluginException.ERRORCODE_NO_WBEMCLIENT);
}
} catch (final IllegalStateException ex) {
_logger.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());
}
return cimClient;
}
use of com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory in project coprhd-controller by CoprHD.
the class SmisBlockCreateCGSnapshotJob 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) {
// Create mapping of volume.nativeDeviceId to BlockSnapshot object
Map<String, BlockSnapshot> volumeToSnapMap = new HashMap<String, BlockSnapshot>();
for (BlockSnapshot snapshot : snapshots) {
Volume volume = dbClient.queryObject(Volume.class, snapshot.getParent());
volumeToSnapMap.put(volume.getNativeId(), snapshot);
}
// Iterate through the snapshot elements that were created by the
// Job and try to match them up with the appropriate BlockSnapshot
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
CIMObjectPath replicationGroupPath = client.associatorNames(getCimJob(), null, SmisConstants.SE_REPLICATION_GROUP, null, null).next();
String replicationGroupInstance = (String) replicationGroupPath.getKey(SmisConstants.CP_INSTANCE_ID).getValue();
replicationGroupInstance = SmisUtils.getTargetGroupName(replicationGroupInstance, storage.getUsingSmis80());
String relationshipName = getRelationShipName(client, replicationGroupPath, replicationGroupInstance);
syncVolumeIter = client.associatorNames(replicationGroupPath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
Calendar now = Calendar.getInstance();
while (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);
// Get the associated volume for this sync volume
CIMObjectPath volumePath = null;
CloseableIterator<CIMObjectPath> volumeIter = client.associatorNames(syncVolumePath, null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
volumePath = volumeIter.next();
volumeIter.close();
String volumeDeviceID = volumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
String wwn = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_WWN_NAME);
String alternativeName = CIMPropertyFactory.getPropertyValue(syncVolume, SmisConstants.CP_NAME);
// Lookup the associated snapshot based on the volume native device id
BlockSnapshot snapshot = volumeToSnapMap.get(volumeDeviceID);
// we need to perform this null check to avoid a NPE.
if (snapshot != null) {
snapshot.setNativeId(syncDeviceID);
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(storage, snapshot));
snapshot.setReplicationGroupInstance(replicationGroupInstance);
snapshot.setDeviceLabel(elementName);
snapshot.setInactive(false);
snapshot.setIsSyncActive(_wantSyncActive);
snapshot.setCreationTime(now);
snapshot.setWWN(wwn.toUpperCase());
snapshot.setAlternateName(alternativeName);
commonSnapshotUpdate(snapshot, syncVolume, client, storage, _sourceGroupId, relationshipName, true, dbClient);
_log.info(String.format("For sync volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). " + "Replication Group instance is %5$s. Associated volume is %6$s", syncVolumePath.toString(), snapshot.getId().toString(), syncDeviceID, elementName, replicationGroupInstance, volumePath.toString()));
dbClient.updateObject(snapshot);
}
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create snapshot");
for (BlockSnapshot snapshot : snapshots) {
snapshot.setInactive(true);
}
dbClient.updateObject(snapshots);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during create CG snapshot job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockCreateCGSnapshotJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
Aggregations