Search in sources :

Example 1 with VNXQuotaTree

use of com.emc.storageos.vnx.xmlapi.VNXQuotaTree in project coprhd-controller by CoprHD.

the class VNXFileCommApi method modifyQuotaDirectory.

public XMLApiResult modifyQuotaDirectory(final StorageSystem system, final String fsName, final String quotaDirName, final String securityStyle, final Long size, final Boolean oplocks, Boolean isMountRequired) throws VNXException {
    _log.info("Modify VNX File System Quota dir: {} on file system {}", quotaDirName, fsName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.QUOTA_DIR_NAME, quotaDirName);
        reqAttributeMap.put(VNXFileConstants.HARD_QUOTA, size);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fsName);
        reqAttributeMap.put(VNXFileConstants.SECURITY_STYLE, securityStyle);
        reqAttributeMap.put(VNXFileConstants.OPLOCKS, oplocks);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (isMountRequired) {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_MODIFY_MOUNT));
        } else {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_MODIFY));
        }
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String quotaDirId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.QUOTA_DIR_ID);
            String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            if (quotaDirId != null) {
                int fsId = Integer.parseInt(fsysId);
                int qdId = Integer.parseInt(quotaDirId);
                VNXQuotaTree vnxQuotaTree = new VNXQuotaTree(quotaDirName, -1, fsId);
                vnxQuotaTree.setId(qdId);
                result.setObject(vnxQuotaTree);
                result.setCommandSuccess();
            } else {
                result.setCommandFailed();
                result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC));
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 2 with VNXQuotaTree

use of com.emc.storageos.vnx.xmlapi.VNXQuotaTree in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doUpdateQuotaDirectory.

@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    ApplicationContext context = null;
    XMLApiResult apiResult = null;
    try {
        _log.info("VNXFileStorageDeviceXML doUpdateQuotaDirectory - start");
        String fslName = args.getFsName();
        String quotaTreetreeName = args.getQuotaDirectoryName();
        Boolean oplocks = quotaDir.getOpLock();
        String securityStyle = quotaDir.getSecurityStyle();
        Long size = quotaDir.getSize();
        if (null == fslName) {
            _log.error("VNXFileStorageDeviceXML::doUpdateQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToUpdateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == quotaTreetreeName) {
            _log.error("VNXFileStorageDeviceXML::doUpdateQuotaDirectory failed:  Quota Tree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToUpdateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        _log.info("FSName: {}", args.getFsName());
        _log.info("Quota tree name: {}", args.getQuotaDirectoryName());
        boolean isMountRequired = !(args.isFileShareMounted());
        _log.info("Mount required or not, to update quota dir requested {}", isMountRequired);
        // Load the context
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // quota directory create/update takes size in MB as similar to FS create.
        Long sizeMBs = size / BYTESPERMB;
        apiResult = vnxComm.modifyQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, securityStyle, sizeMBs, oplocks, isMountRequired);
        _log.info("doUpdateQuotaDirectory call result : {}", apiResult.isCommandSuccess());
        if (apiResult.isCommandSuccess()) {
            VNXQuotaTree quotaTree = (VNXQuotaTree) apiResult.getObject();
            args.getQuotaDirectory().setNativeId(String.valueOf(quotaTree.getId()));
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUpdateQuotaDir());
    }
    return cmdResult;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 3 with VNXQuotaTree

use of com.emc.storageos.vnx.xmlapi.VNXQuotaTree in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory quotaDir) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    ApplicationContext context = null;
    XMLApiResult apiResult = null;
    try {
        _log.info("VNXFileStorageDeviceXML doCreateQuotaDirectory - start");
        String fsName = args.getFsName();
        String quotaTreetreeName = args.getQuotaDirectoryName();
        Boolean oplocks = quotaDir.getOpLock();
        String securityStyle = quotaDir.getSecurityStyle();
        Long size = quotaDir.getSize();
        if (null == fsName) {
            _log.error("VNXFileStorageDeviceXML::doCreateQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToCreateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == quotaTreetreeName) {
            _log.error("VNXFileStorageDeviceXML::doCreateQuotaDirectory failed:  Quota Tree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToCreateQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        _log.info("FSName: {}", args.getFsName());
        _log.info("Quota tree name: {}", args.getQuotaDirectoryName());
        boolean isMountRequired = !(args.isFileShareMounted());
        _log.info("Mount required or not, to create quota dir requested {}", isMountRequired);
        // Load the context
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // quota directory create/update takes size in MB as similar to FS create.
        Long sizeMBs = size / BYTESPERMB;
        apiResult = vnxComm.createQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, securityStyle, sizeMBs, oplocks, isMountRequired);
        _log.info("createQuotaDirectory call result : {}", apiResult.isCommandSuccess());
        if (apiResult.isCommandSuccess()) {
            VNXQuotaTree quotaTree = (VNXQuotaTree) apiResult.getObject();
            args.getQuotaDirectory().setNativeId(String.valueOf(quotaTree.getId()));
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    _log.info("Status of the result {}", (result != null) ? result.isCommandSuccess() : result);
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToCreateQuotaDir());
    }
    return cmdResult;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 4 with VNXQuotaTree

use of com.emc.storageos.vnx.xmlapi.VNXQuotaTree in project coprhd-controller by CoprHD.

the class VNXFileCommApi method createQuotaDirectory.

public XMLApiResult createQuotaDirectory(final StorageSystem system, final String fsName, final String quotaDirName, final String securityStyle, final Long size, final Boolean oplocks, Boolean isMountRequired) throws VNXException {
    _log.info("Create VNX File System Quota dir: {} on file system {}", quotaDirName, fsName);
    XMLApiResult result = new XMLApiResult();
    Map<String, Object> reqAttributeMap = new ConcurrentHashMap<String, Object>();
    try {
        if (isMountRequired) {
            // means there is no fs export in Vipr and mount is needed.
            // just cross check with array fs have mount.
            isMountRequired = !isMountPresentOnArray(fsName, system);
        }
        updateAttributes(reqAttributeMap, system);
        reqAttributeMap.put(VNXFileConstants.FILESYSTEM_NAME, fsName);
        reqAttributeMap.put(VNXFileConstants.QUOTA_DIR_NAME, quotaDirName);
        reqAttributeMap.put(VNXFileConstants.HARD_QUOTA, size);
        reqAttributeMap.put(VNXFileConstants.SECURITY_STYLE, securityStyle);
        reqAttributeMap.put(VNXFileConstants.OPLOCKS, oplocks);
        reqAttributeMap.put(VNXFileConstants.MOUNT_PATH, "/" + fsName);
        _provExecutor.setKeyMap(reqAttributeMap);
        if (isMountRequired) {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_CREATE_MOUNT));
        } else {
            _provExecutor.execute((Namespace) _provNamespaces.getNsList().get(PROV_FILE_QUOTA_DIR_CREATE));
        }
        String cmdResult = (String) _provExecutor.getKeyMap().get(VNXFileConstants.CMD_RESULT);
        if (cmdResult != null && cmdResult.equals(VNXFileConstants.CMD_SUCCESS)) {
            String quotaDirId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.QUOTA_DIR_ID);
            String fsysId = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FILESYSTEM_ID);
            if (quotaDirId != null) {
                int fsId = Integer.parseInt(fsysId);
                int qdId = Integer.parseInt(quotaDirId);
                VNXQuotaTree vnxQuotaTree = new VNXQuotaTree(quotaDirName, -1, fsId);
                vnxQuotaTree.setId(qdId);
                result.setObject(vnxQuotaTree);
                result.setCommandSuccess();
            } else {
                result.setCommandFailed();
                result.setMessage((String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC));
            }
        } else {
            String errMsg = (String) _provExecutor.getKeyMap().get(VNXFileConstants.FAULT_DESC);
            result.setCommandFailed();
            result.setMessage(errMsg);
        }
    } catch (Exception e) {
        throw new VNXException("Failure", e);
    }
    return result;
}
Also used : VNXException(com.emc.storageos.vnx.xmlapi.VNXException) VNXQuotaTree(com.emc.storageos.vnx.xmlapi.VNXQuotaTree) FileObject(com.emc.storageos.db.client.model.FileObject) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) URISyntaxException(java.net.URISyntaxException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Aggregations

VNXException (com.emc.storageos.vnx.xmlapi.VNXException)4 VNXQuotaTree (com.emc.storageos.vnx.xmlapi.VNXQuotaTree)4 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)4 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)2 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)2 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)2 FileObject (com.emc.storageos.db.client.model.FileObject)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)2 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)2 URISyntaxException (java.net.URISyntaxException)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 ApplicationContext (org.springframework.context.ApplicationContext)2 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)2