use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXUnityDeleteFileSystemQuotaDirectoryJob method updateStatus.
/**
* Called to update the job status when the file system Quota Directory 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()));
URI quotaId = getTaskCompleter().getId();
QuotaDirectory quotaObj = dbClient.queryObject(QuotaDirectory.class, quotaId);
URI fsUri = quotaObj.getParent().getURI();
FileShare fsObj = dbClient.queryObject(FileShare.class, fsUri);
StorageSystem storageObj = dbClient.queryObject(StorageSystem.class, getStorageSystemUri());
String event = null;
if (_status == JobStatus.SUCCESS && quotaObj != null) {
quotaObj.setInactive(true);
dbClient.updateObject(quotaObj);
event = String.format("Deleted file system quota directory %s successfully", quotaObj.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
} else if (_status == JobStatus.FAILED && quotaObj != null) {
event = String.format("Task %s failed to delete file system quota directory: %s", opId, quotaObj.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
} else {
event = "File sytem quota directory has been deleted";
logMsgBuilder.append(String.format("Could not find the quota directory: %s", quotaId));
}
_logger.info(logMsgBuilder.toString());
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.DELETE_FILE_SYSTEM_QUOTA_DIR, _isSuccess, event, "", quotaObj, fsObj, storageObj);
} catch (Exception e) {
_logger.error("Caught an exception while trying to update status for VNXUnityDeleteFileSystemQuotaDirectoryJob", e);
setErrorStatus("Encountered an internal error during file system quota delete job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXUnityUpdateFileSystemQuotaDirectoryJob 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()));
URI quotaId = getTaskCompleter().getId();
QuotaDirectory quotaObj = dbClient.queryObject(QuotaDirectory.class, quotaId);
URI fsUri = quotaObj.getParent().getURI();
FileShare fsObj = dbClient.queryObject(FileShare.class, fsUri);
String event = null;
if (_status == JobStatus.SUCCESS && quotaObj != null) {
event = String.format("update file system quota directory successfully for URI: %s", getTaskCompleter().getId());
} else if (_status == JobStatus.FAILED && quotaObj != null) {
if (!quotaObj.getInactive()) {
quotaObj.setInactive(true);
dbClient.updateObject(quotaObj);
}
event = String.format("Task %s failed to update file system quota directory: %s", opId, quotaObj.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
} else {
logMsgBuilder.append(String.format("Could not find the quota directory:%s", quotaId.toString()));
}
_logger.info(logMsgBuilder.toString());
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.UPDATE_FILE_SYSTEM_QUOTA_DIR, _isSuccess, event, "", quotaObj, fsObj);
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXUnityUpdateFileSystemQuotaDirectoryJob", e);
setErrorStatus("Encountered an internal error during file system quota update job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method checkStorageQuotaDirectoryExistsInDB.
/**
* check QuotaDirectory for given nativeGuid exists in DB
*
* @param nativeGuid
* @return boolean
* @throws java.io.IOException
*/
protected boolean checkStorageQuotaDirectoryExistsInDB(String nativeGuid) throws IOException {
URIQueryResultList result = new URIQueryResultList();
_dbClient.queryByConstraint(AlternateIdConstraint.Factory.getQuotaDirsByNativeGuid(nativeGuid), result);
Iterator<URI> iter = result.iterator();
while (iter.hasNext()) {
URI storageQDURI = iter.next();
QuotaDirectory quotaDirectory = _dbClient.queryObject(QuotaDirectory.class, storageQDURI);
if (quotaDirectory != null && !quotaDirectory.getInactive()) {
return true;
}
}
return false;
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXUnityCreateFileSystemQuotaDirectoryJob method updateStatus.
/**
* Called to update the job status when the file system Quota Directory 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 quotaId = getTaskCompleter().getId();
QuotaDirectory quotaObj = dbClient.queryObject(QuotaDirectory.class, quotaId);
URI fsUri = quotaObj.getParent().getURI();
FileShare fsObj = dbClient.queryObject(FileShare.class, fsUri);
String event = null;
if (_status == JobStatus.SUCCESS && quotaObj != null) {
updateQuota(quotaObj, dbClient, logMsgBuilder, vnxeApiClient);
event = String.format("Create file system quota directory successfully for URI: %s", getTaskCompleter().getId());
} else if (_status == JobStatus.FAILED && quotaObj != null) {
if (!quotaObj.getInactive()) {
quotaObj.setInactive(true);
dbClient.updateObject(quotaObj);
}
event = String.format("Task %s failed to create file system quota directory: %s", opId, quotaObj.getName());
logMsgBuilder.append("\n");
logMsgBuilder.append(event);
} else {
logMsgBuilder.append(String.format("Could not find the quota directory:%s", quotaId.toString()));
}
_logger.info(logMsgBuilder.toString());
FileDeviceController.recordFileDeviceOperation(dbClient, OperationTypeEnum.CREATE_FILE_SYSTEM_QUOTA_DIR, _isSuccess, event, "", quotaObj, fsObj);
} catch (Exception e) {
_logger.error("Caught an exception while trying to updateStatus for VNXUnityCreateFileSystemQuotaDirectoryJob", e);
setErrorStatus("Encountered an internal error during file system quota create job status processing : " + e.getMessage());
} finally {
super.updateStatus(jobContext);
}
}
use of com.emc.storageos.db.client.model.QuotaDirectory in project coprhd-controller by CoprHD.
the class VNXUnityQuotaDirectoryTaskCompleter method complete.
@Override
protected void complete(DbClient dbClient, Operation.Status status, ServiceCoded coded) throws DeviceControllerException {
QuotaDirectory quota = dbClient.queryObject(QuotaDirectory.class, getId());
FileShare fsObj = dbClient.queryObject(FileShare.class, quota.getParent());
switch(status) {
case error:
dbClient.error(QuotaDirectory.class, getId(), getOpId(), coded);
if (fsObj != null) {
dbClient.error(FileShare.class, fsObj.getId(), getOpId(), coded);
}
break;
default:
dbClient.ready(QuotaDirectory.class, getId(), getOpId());
if (fsObj != null) {
dbClient.ready(FileShare.class, fsObj.getId(), getOpId());
}
}
_logger.info("Done Quota operation {}, with Status: {}", getOpId(), status.name());
}
Aggregations