Search in sources :

Example 16 with QuotaDirectory

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 17 with QuotaDirectory

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 18 with QuotaDirectory

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;
}
Also used : QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 19 with QuotaDirectory

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);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) URI(java.net.URI) FileShare(com.emc.storageos.db.client.model.FileShare) IOException(java.io.IOException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException)

Example 20 with QuotaDirectory

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());
}
Also used : QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) FileShare(com.emc.storageos.db.client.model.FileShare)

Aggregations

QuotaDirectory (com.emc.storageos.db.client.model.QuotaDirectory)31 FileShareQuotaDirectory (com.emc.storageos.volumecontroller.FileShareQuotaDirectory)17 FileShare (com.emc.storageos.db.client.model.FileShare)15 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)11 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)10 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)9 URI (java.net.URI)9 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)7 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 MapQuotaDirectory (com.emc.storageos.api.mapper.functions.MapQuotaDirectory)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)6 Path (javax.ws.rs.Path)6 Produces (javax.ws.rs.Produces)6 URISyntaxException (java.net.URISyntaxException)5 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)4 NamedURI (com.emc.storageos.db.client.model.NamedURI)4 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)4