Search in sources :

Example 86 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _log.info("doUnExport " + args.getOperationType());
    _log.info("Call FileShare UnExport");
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        for (int expCount = 0; expCount < exportList.size(); expCount++) {
            List<String> endPoints = new ArrayList<String>();
            FileExport export = exportList.get(expCount);
            String exportEntryKey = FileExport.exportLookupKey(export.getProtocol(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), export.getPath());
            FileExport fileExport = args.getFileObjExports().get(exportEntryKey);
            if (fileExport != null) {
                endPoints.addAll(fileExport.getClients());
            }
            export.setClients(endPoints);
            _log.info("FileExport:" + export.getClients() + ":" + export.getStoragePortName() + ":" + export.getStoragePort() + ":" + export.getRootUserMapping() + ":" + export.getPermissions() + ":" + export.getProtocol() + ":" + export.getSecurityType() + ":" + export.getMountPoint() + ":" + export.getPath());
        }
        List<VNXFileExport> vnxExps = getVNXFileExports(exportList);
        result = vnxComm.doUnexport(storage, vnxExps.get(0), args, false);
    } 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.unableToUnexportFileSystem(result.getMessage()));
    }
    return cmdResult;
}
Also used : VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) ArrayList(java.util.ArrayList) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) 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) FileExport(com.emc.storageos.db.client.model.FileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) VNXFileExport(com.emc.storageos.vnx.xmlapi.VNXFileExport) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 87 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doDeleteQuotaDirectory.

@Override
public BiosCommandResult doDeleteQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    ApplicationContext context = null;
    XMLApiResult apiResult = null;
    try {
        _log.info("VNXFileStorageDeviceXML doDeleteQuotaDirectory - start");
        String fsName = args.getFsName();
        String quotaTreetreeName = args.getQuotaDirectoryName();
        QuotaDirectory quotaDir = args.getQuotaDirectory();
        if (null == fsName) {
            _log.error("VNXFileStorageDeviceXML::doDeleteQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToDeleteQuotaDir();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == quotaTreetreeName) {
            _log.error("VNXFileStorageDeviceXML::doDeleteQuotaDirectory failed:  Quota Tree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.vnx.unableToDeleteQuotaDir();
            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 delete quota dir requested {}", isMountRequired);
        // Load the context
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // we can't delete quota, if the filsystem is not mount, We should changes quota cmd
        apiResult = vnxComm.deleteQuotaDirectory(storage, args.getFsName(), quotaTreetreeName, true, isMountRequired);
        if (apiResult.isCommandSuccess()) {
            result = BiosCommandResult.createSuccessfulResult();
        }
        _log.info("doDeleteQuotaDirectory call result : {}", apiResult.isCommandSuccess());
    } 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.unableToDeleteQuotaDir());
    }
    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) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 88 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doDeleteSnapshot.

@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // generate checkpoint baseline name
    _log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
    _log.info("FSName: {}", args.getFsName());
    _log.info("SnapShotName: {}", args.getSnapshotName());
    _log.info("SnapShotBaseline: {}", args.getSnapshotCheckPointBaseline());
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        result = vnxComm.doDeleteSnapshot(storage, args.getSnapNativeId(), args.getSnapshotName(), true);
    } 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.unableToDeleteFileSnapshot(result.getMessage()));
    }
    return cmdResult;
}
Also used : 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) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 89 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult 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 90 with BiosCommandResult

use of com.emc.storageos.volumecontroller.impl.BiosCommandResult in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    // generate checkpoint baseline name
    args.setSnaphotCheckPointBaseline(args.getSnapshotName() + "_baseline");
    args.setSnapshotMountPath("/" + args.getSnapshotName());
    _log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
    _log.info("FSName: {}", args.getFsName());
    _log.info("SnapShotName: {}", args.getSnapshotName());
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        FileShare fileShare = args.getFs();
        result = vnxComm.createSnapshot(storage, args.getFsName(), args.getSnapshotName(), fileShare);
        _log.info("createSnapshot call result : {}", result.isCommandSuccess());
        if (result.isCommandSuccess()) {
            VNXSnapshot vnxSnap = (VNXSnapshot) result.getObject();
            args.setSnapNativeId(String.valueOf(vnxSnap.getId()));
            String path = "/" + args.getSnapshotName();
            // Set path & mountpath
            args.setSnapshotMountPath(path);
            args.setSnapshotPath(path);
        }
    } 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.unableToCreateFileSnapshot(result.getMessage()));
    }
    return cmdResult;
}
Also used : 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) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) VNXSnapshot(com.emc.storageos.vnx.xmlapi.VNXSnapshot) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)135 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)76 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)69 ControllerException (com.emc.storageos.volumecontroller.ControllerException)64 NetAppException (com.emc.storageos.netapp.NetAppException)34 ArrayList (java.util.ArrayList)34 NetworkDeviceControllerException (com.emc.storageos.networkcontroller.exceptions.NetworkDeviceControllerException)28 NetAppCException (com.emc.storageos.netappc.NetAppCException)19 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 NetAppApi (com.emc.storageos.netapp.NetAppApi)18 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)18 URI (java.net.URI)16 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)15 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileShare (com.emc.storageos.db.client.model.FileShare)14 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)14 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)11