use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeDeleteVolumesJob method updateStatus.
/**
* Called to update the job status when the volumes delete job completes.
*
* @param jobContext The job context.
*/
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
// Get list of volumes; get set of storage pool ids to which they belong.
List<Volume> volumes = dbClient.queryObject(Volume.class, getTaskCompleter().getIds());
Set<URI> poolURIs = new HashSet<URI>();
for (Volume volume : volumes) {
poolURIs.add(volume.getPool());
}
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
// If terminal state update storage pool capacity
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
for (URI poolURI : poolURIs) {
VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, poolURI, null);
}
}
if (_status == JobStatus.SUCCESS) {
for (Volume volume : volumes) {
volume.setInactive(true);
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
dbClient.updateObject(volume);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Successfully deleted volume %s", volume.getId()));
}
} else if (_status == JobStatus.FAILED) {
for (URI id : getTaskCompleter().getIds()) {
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Failed to delete volume: %s", id));
}
}
_logger.info(logMsgBuilder.toString());
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeDeleteVolumesJob", e);
setErrorStatus("Encountered an internal error during volume delete job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method deleteGroupSnapshots.
@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
List<BlockSnapshot> snapshots = _dbClient.queryObject(BlockSnapshot.class, Arrays.asList(snapshot));
BlockSnapshot snapshotObj = snapshots.get(0);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeLunGroupSnap lunGroupSnap = apiClient.getLunGroupSnapshot(snapshotObj.getReplicationGroupInstance());
if (lunGroupSnap != null) {
VNXeCommandJob job = apiClient.deleteLunGroupSnap(lunGroupSnap.getId());
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockDeleteSnapshotJob(job.getId(), storage.getId(), taskCompleter)));
} else {
// Should not take this path, but treat as an error if we do
// happen to get a null job due to some error in the client.
_log.error("Unexpected null job from VNXe client call to delete group snapshot.");
ServiceCoded sc = DeviceControllerExceptions.vnxe.nullJobForDeleteGroupSnapshot(snapshotObj.forDisplay(), snapshotObj.getReplicationGroupInstance());
taskCompleter.error(_dbClient, sc);
}
} else {
// Treat as in the single volume snapshot case and presume
// the group snapshot has already been deleted.
List<BlockSnapshot> grpSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
for (BlockSnapshot grpSnapshot : grpSnapshots) {
grpSnapshot.setInactive(true);
grpSnapshot.setIsSyncActive(false);
}
_dbClient.updateObject(grpSnapshots);
taskCompleter.ready(_dbClient);
}
} catch (VNXeException e) {
_log.error("Delete group snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Delete group snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeletGroupSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeSnapshotOperation method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume volume = _dbClient.queryObject(Volume.class, snapshotObj.getParent());
TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
String tenantName = tenant.getLabel();
String snapLabelToUse = _nameGenerator.generate(tenantName, snapshotObj.getLabel(), snapshot.toString(), '-', SmisConstants.MAX_SNAPSHOT_NAME_LENGTH);
VNXeApiClient apiClient = getVnxeClient(storage);
VNXeCommandJob job = apiClient.createLunSnap(volume.getNativeId(), snapLabelToUse);
if (job != null) {
ControllerServiceImpl.enqueueJob(new QueueJob(new VNXeBlockSnapshotCreateJob(job.getId(), storage.getId(), !createInactive, taskCompleter)));
}
} catch (VNXeException e) {
_log.error("Create volume snapshot got the exception", e);
taskCompleter.error(_dbClient, e);
} catch (Exception ex) {
_log.error("Create volume snapshot got the exception", ex);
ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateVolumeSnapshot", ex.getMessage());
taskCompleter.error(_dbClient, error);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeCreateShareJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
String event = "";
FileShare fsObj = null;
Snapshot snapObj = null;
URI fsId = getTaskCompleter().getId();
fsObj = dbClient.queryObject(FileShare.class, fsId);
if (_status == JobStatus.SUCCESS) {
if (isFile) {
updateFileSystem(vnxeApiClient, dbClient, fsObj);
event = String.format("Create file system smbShare successfully for URI: %s", getTaskCompleter().getId());
} else {
snapObj = updateSnapshot(vnxeApiClient, dbClient);
event = String.format("Create snapshot smbShare successfully for URI: %s", getTaskCompleter().getId());
}
} else if (_status == JobStatus.FAILED) {
event = String.format("Task %s failed to create file system smbShare: %s", opId, smbShare.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
}
_logger.info(logMsgBuilder.toString());
if (isFile) {
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_SHARE, _isSuccess, event, smbShare.getName(), fsObj, smbShare);
} else {
fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent());
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.CREATE_FILE_SNAPSHOT_SHARE, _isSuccess, event, smbShare.getName(), snapObj, fsObj, smbShare);
}
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemSnapshotJob", e);
setErrorStatus("Encountered an internal error during file system snapshot create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.vnxe.VNXeApiClient in project coprhd-controller by CoprHD.
the class VNXeDeleteShareJob method updateStatus.
@Override
public void updateStatus(JobContext jobContext) throws Exception {
DbClient dbClient = jobContext.getDbClient();
try {
if (_status == JobStatus.IN_PROGRESS) {
return;
}
String opId = getTaskCompleter().getOpId();
StringBuilder logMsgBuilder = new StringBuilder(String.format("Updating status of job %s to %s", opId, _status.name()));
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
URI fsId = getTaskCompleter().getId();
FileShare fsObj = null;
Snapshot snapObj = null;
String event = null;
if (_status == JobStatus.SUCCESS) {
if (isFile) {
fsObj = dbClient.queryObject(FileShare.class, fsId);
updateFileSystem(vnxeApiClient, dbClient, fsObj);
} else {
snapObj = updateSnapshot(vnxeApiClient, dbClient);
fsObj = dbClient.queryObject(FileShare.class, snapObj.getParent());
}
event = String.format("Deleted file system smbShare successfully for URI: %s", getTaskCompleter().getId());
} else if (_status == JobStatus.FAILED) {
event = String.format("Task %s failed to delete file system sbmShare: %s", opId, smbShare.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
}
_logger.info(logMsgBuilder.toString());
if (isFile) {
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_SHARE, _isSuccess, event, smbShare.getName(), fsObj, smbShare);
} else {
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.DELETE_FILE_SNAPSHOT_SHARE, _isSuccess, event, smbShare.getName(), snapObj, fsObj, smbShare);
}
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemSnapshotJob", e);
setErrorStatus("Encountered an internal error during file system snapshot create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
Aggregations