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 VNXeCreateVolumesJob method updateStatus.
/**
* Called to update the job status when the volumes create 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()));
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
// If terminal state update storage pool capacity
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
List<URI> volUris = getTaskCompleter().getIds();
List<String> volsInPool = new ArrayList<String>();
for (URI voluri : volUris) {
volsInPool.add(voluri.toString());
}
VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, storagePool, volsInPool);
}
Calendar now = Calendar.getInstance();
int volumeCount = 0;
if (_status == JobStatus.SUCCESS) {
if (!isConsistencyGroup) {
for (String jobId : getJobIds()) {
VNXeCommandJob vnxeJob = vnxeApiClient.getJob(jobId);
ParametersOut output = vnxeJob.getParametersOut();
String nativeId = null;
URI volumeId = getTaskCompleter().getId(volumeCount);
if (output != null) {
VNXeBase storageResource = output.getStorageResource();
if (storageResource != null) {
nativeId = storageResource.getId();
}
}
processVolume(vnxeApiClient, nativeId, volumeId, dbClient, logMsgBuilder, now);
volumeCount++;
}
} else {
List<URI> volIds = getTaskCompleter().getIds();
processVolumesinConsistencyGroup(vnxeApiClient, volIds, dbClient, logMsgBuilder, now);
}
} else if (_status == JobStatus.FAILED) {
List<URI> volIds = getTaskCompleter().getIds();
for (URI volId : volIds) {
Volume volume = dbClient.queryObject(Volume.class, volId);
volume.setInactive(true);
dbClient.updateObject(volume);
if (logMsgBuilder.length() != 0) {
logMsgBuilder.append("\n");
}
logMsgBuilder.append(String.format("Task %s failed to create volume: %s", opId, volId));
}
}
_logger.info(logMsgBuilder.toString());
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeCreateVolumesJob", e);
setErrorStatus("Encountered an internal error during volume 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);
}
}
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 VNXeExpandFileSystemJob method updateStatus.
/**
* Called to update the job status when the file system create 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()));
VNXeApiClient vnxeApiClient = getVNXeClient(jobContext);
URI fsId = getTaskCompleter().getId();
FileShare fsObj = dbClient.queryObject(FileShare.class, fsId);
// If terminal state update storage pool capacity
if (_status == JobStatus.SUCCESS || _status == JobStatus.FAILED) {
VNXeJob.updateStoragePoolCapacity(dbClient, vnxeApiClient, fsObj.getPool(), null);
}
if (_status == JobStatus.SUCCESS && fsObj != null) {
updateFS(fsObj, dbClient, logMsgBuilder, vnxeApiClient);
} else if (_status == JobStatus.FAILED && fsObj != null) {
logMsgBuilder.append("\n");
logMsgBuilder.append(String.format("Task %s failed to expand file system: %s", opId, fsId.toString()));
} else {
logMsgBuilder.append(String.format("The file system: %s is not found anymore", fsId));
}
_logger.info(logMsgBuilder.toString());
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.EXPAND_FILE_SYSTEM, _isSuccess, logMsgBuilder.toString(), "", fsObj, String.valueOf(fsObj.getCapacity()));
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXeCreateFileSystemJob", e);
setErrorStatus("Encountered an internal error during file system create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
Aggregations