use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisBlockDeleteCGMirrorJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
BlockMirrorDeleteCompleter completer = (BlockMirrorDeleteCompleter) getTaskCompleter();
List<BlockMirror> mirrors = dbClient.queryObject(BlockMirror.class, completer.getIds());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
Set<URI> poolURIs = new HashSet<URI>();
for (BlockMirror mirror : mirrors) {
poolURIs.add(mirror.getPool());
}
for (URI poolURI : poolURIs) {
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Group mirror delete success");
dbClient.markForDeletion(mirrors);
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete group mirrors");
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete group mirror job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteCGMirrorJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisBlockDeleteListReplicaJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
List<? extends BlockObject> replicas = BlockObject.fetch(dbClient, getTaskCompleter().getIds());
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
Set<URI> poolURIs = new HashSet<URI>();
for (BlockObject replica : replicas) {
if (replica instanceof Volume)
poolURIs.add(((Volume) replica).getPool());
}
for (URI poolURI : poolURIs) {
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("List replica delete success");
dbClient.markForDeletion(replicas);
} else if (jobStatus == JobStatus.FATAL_ERROR || jobStatus == JobStatus.FAILED) {
String msg = String.format("Failed to delete list replica");
_log.error(msg);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(msg));
}
} catch (Exception e) {
setFatalErrorStatus("Encountered an internal error during block delete replica replica job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteListReplicaJob", e);
getTaskCompleter().error(dbClient, DeviceControllerErrors.smis.jobFailed(e.getMessage()));
} finally {
super.updateStatus(jobContext);
}
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisBlockDeleteSnapshotJob method updateStatus.
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
JobStatus jobStatus = getJobStatus();
try {
BlockSnapshotDeleteCompleter completer = (BlockSnapshotDeleteCompleter) getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, completer.getId());
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
// If terminal state update storage pool capacity
if (jobStatus == JobStatus.SUCCESS || jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
NamedURI volumeURI = snapshot.getParent();
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
URI poolURI = volume.getPool();
// Update capacity of storage pools.
SmisUtils.updateStoragePoolCapacity(dbClient, client, poolURI);
}
if (jobStatus == JobStatus.SUCCESS) {
_log.info("Deleting snapshot job was successful.");
snapshot.setInactive(true);
dbClient.persistObject(snapshot);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to delete snapshot: {}", getTaskCompleter().getId());
}
} catch (Exception e) {
setFatalErrorStatus(e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisBlockDeleteSnapshotJob", e);
Operation updateOp = new Operation();
updateOp.setStatus("Encountered an internal error during block delete snapshot job status processing: " + e.getMessage());
dbClient.updateTaskOpStatus(BlockSnapshot.class, getTaskCompleter().getId(), getTaskCompleter().getOpId(), updateOp);
} finally {
super.updateStatus(jobContext);
}
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisBlockSnapshotSessionLinkTargetJob method updateStatus.
/**
* {@inheritDoc}
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
JobStatus jobStatus = getJobStatus();
CloseableIterator<CIMObjectPath> volumeIter = null;
try {
DbClient dbClient = jobContext.getDbClient();
TaskCompleter completer = getTaskCompleter();
BlockSnapshot snapshot = dbClient.queryObject(BlockSnapshot.class, _snapshotURI);
if (jobStatus == JobStatus.IN_PROGRESS) {
return;
}
if (jobStatus == JobStatus.SUCCESS) {
s_logger.info("Post-processing successful link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
// Get the snapshot session to which the target is being linked.
BlockSnapshotSession snapSession = dbClient.queryObject(BlockSnapshotSession.class, completer.getId());
// Get the snapshot device ID and set it against the BlockSnapshot object.
BlockObject sourceObj = BlockObject.fetch(dbClient, snapshot.getParent().getURI());
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
volumeIter = client.associatorNames(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
while (volumeIter.hasNext()) {
// Get the sync volume native device id
CIMObjectPath volumePath = volumeIter.next();
s_logger.info("volumePath: {}", volumePath.toString());
CIMInstance volume = client.getInstance(volumePath, false, false, null);
String volumeDeviceId = volumePath.getKey(SmisConstants.CP_DEVICE_ID).getValue().toString();
s_logger.info("volumeDeviceId: {}", volumeDeviceId);
if (volumeDeviceId.equals(sourceObj.getNativeId())) {
// Don't want the source, we want the linked target.
continue;
}
String volumeElementName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_ELEMENT_NAME);
s_logger.info("volumeElementName: {}", volumeElementName);
String volumeWWN = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_WWN_NAME);
s_logger.info("volumeWWN: {}", volumeWWN);
String volumeAltName = CIMPropertyFactory.getPropertyValue(volume, SmisConstants.CP_NAME);
s_logger.info("volumeAltName: {}", volumeAltName);
StorageSystem system = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
snapshot.setNativeId(volumeDeviceId);
snapshot.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(system, snapshot));
snapshot.setDeviceLabel(volumeElementName);
snapshot.setInactive(false);
snapshot.setIsSyncActive(Boolean.TRUE);
snapshot.setCreationTime(Calendar.getInstance());
snapshot.setWWN(volumeWWN.toUpperCase());
snapshot.setAlternateName(volumeAltName);
snapshot.setSettingsInstance(snapSession.getSessionInstance());
commonSnapshotUpdate(snapshot, volume, client, system, sourceObj.getNativeId(), volumeDeviceId, false, dbClient);
s_logger.info(String.format("For target volume path %1$s, going to set blocksnapshot %2$s nativeId to %3$s (%4$s). Associated volume is %5$s (%6$s)", volumePath.toString(), snapshot.getId().toString(), volumeDeviceId, volumeElementName, sourceObj.getNativeId(), sourceObj.getDeviceLabel()));
dbClient.updateObject(snapshot);
}
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
s_logger.info("Failed to link snapshot session target {} for task {}", snapshot.getId(), completer.getOpId());
snapshot.setInactive(true);
dbClient.updateObject(snapshot);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error in link snapshot session target job status processing: " + e.getMessage());
s_logger.error("Encountered an internal error in link snapshot session target job status processing", e);
} finally {
if (volumeIter != null) {
volumeIter.close();
}
super.updateStatus(jobContext);
}
}
use of javax.wbem.client.WBEMClient in project coprhd-controller by CoprHD.
the class SmisCreateListReplicaJob 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;
}
List<? extends BlockObject> replicas = BlockObject.fetch(dbClient, getTaskCompleter().getIds());
if (jobStatus == JobStatus.SUCCESS) {
CIMConnectionFactory cimConnectionFactory = jobContext.getCimConnectionFactory();
WBEMClient client = getWBEMClient(dbClient, cimConnectionFactory);
if (_syncType == SmisConstants.MIRROR_VALUE || _syncType == SmisConstants.CLONE_VALUE) {
updatePools(client, dbClient, (List<? extends Volume>) replicas);
}
syncVolumeIter = client.associatorInstances(getCimJob(), null, SmisConstants.CIM_STORAGE_VOLUME, null, null, false, _volumeProps);
StorageSystem storage = dbClient.queryObject(StorageSystem.class, getStorageSystemURI());
processListReplica(syncVolumeIter, client, dbClient, jobContext.getSmisCommandHelper(), storage, replicas, _syncType, _isSyncActive);
} else if (jobStatus == JobStatus.FAILED || jobStatus == JobStatus.FATAL_ERROR) {
_log.info("Failed to create list relica");
for (BlockObject replica : replicas) {
replica.setInactive(true);
}
dbClient.persistObject(replicas);
}
} catch (Exception e) {
setPostProcessingErrorStatus("Encountered an internal error during create list replica job status processing: " + e.getMessage());
_log.error("Caught an exception while trying to updateStatus for SmisCreateListReplicaJob", e);
} finally {
if (syncVolumeIter != null) {
syncVolumeIter.close();
}
super.updateStatus(jobContext);
}
}
Aggregations