Search in sources :

Example 46 with BiosCommandResult

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

the class NetAppFileStorageDevice method doModifyFS.

@Override
public BiosCommandResult doModifyFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    result.setCommandSuccess(false);
    result.setCommandStatus(Operation.Status.error.name());
    result.setMessage("Modify FS NOT supported for NetApp.");
    return result;
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Example 47 with BiosCommandResult

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

the class NetAppClusterModeDevice method updateExportRules.

@Override
public BiosCommandResult updateExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    // Requested Export Rules
    List<ExportRule> exportAdd = args.getExportRulesToAdd();
    List<ExportRule> exportDelete = args.getExportRulesToDelete();
    List<ExportRule> exportModify = args.getExportRulesToModify();
    // To be processed export rules
    List<ExportRule> exportsToRemove = new ArrayList<>();
    List<ExportRule> exportsToAdd = new ArrayList<>();
    List<ExportRule> exportsRemove = new ArrayList<>();
    // ALL EXPORTS
    List<ExportRule> exportsToprocess = args.getExistingDBExportRules();
    String fsName = "";
    if (exportsToprocess == null) {
        exportsToprocess = new ArrayList<>();
    }
    _log.info("Number of existng Rules found {}", exportsToprocess.size());
    String exportPath;
    String subDir = args.getSubDirectory();
    BiosCommandResult result = new BiosCommandResult();
    if (!args.getFileOperation()) {
        _log.error("NetAppClusterModeDevice::updateExportRules {} : Snapshot export/unexport is not Supported", args.getSnapshotId());
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToUnexportSnapshot();
        serviceError.setMessage(genDetailedMessage("updateExportRules", args.getSnapshotId().toString(), "Snapshot export/unexport is not Supported"));
        result = BiosCommandResult.createErrorResult(serviceError);
        return result;
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            exportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    // if only delete provided with no existing rules -- How do we handle this?
    _log.info("Number of Export Rules to update after processing found {}", exportsToprocess.size());
    try {
        String portGroup = null;
        if (args.getFileOperation() == true) {
            FileShare fileshare = args.getFs();
            fsName = fileshare.getName();
            portGroup = findSVMName(fileshare);
        }
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        String qtreePath = "";
        String qtreeName = null;
        if (args.getFileOperation()) {
            qtreePath = exportPath;
            if (subDir != null && subDir.length() > 0) {
                if (ncApi.isQtree(args.getFsName(), subDir)) {
                    qtreeName = subDir;
                    qtreePath = constructQtreePath(args.getFsName(), subDir);
                } else {
                    _log.error("NetAppClusterModeDevice::updateExportRules {} : Sub-directory export/unexport is not Supported", args.getFsId());
                    ServiceError serviceError = DeviceControllerErrors.netappc.unableToExportFileSystem();
                    serviceError.setMessage(genDetailedMessage("updateExportRules", args.getFsId().toString(), "Sub-directory export/unexport is not Supported"));
                    result = BiosCommandResult.createErrorResult(serviceError);
                    return result;
                }
            }
        }
        _log.info("exportPath : {}", exportPath);
        args.setExportPath(exportPath);
        // Handle Modified export Rules
        if (!exportsToprocess.isEmpty()) {
            for (ExportRule existingRule : exportsToprocess) {
                if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
                    for (ExportRule modifiedrule : exportModify) {
                        if (modifiedrule.getSecFlavor().equals(existingRule.getSecFlavor())) {
                            _log.info("Modifying Export Rule from {}, To {}", existingRule, modifiedrule);
                            if (!ncApi.modifyNFSShare(fsName, qtreeName, qtreePath, existingRule, modifiedrule)) {
                                _log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
                                result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
                                result.setCommandStatus(Operation.Status.error.name());
                                return result;
                            }
                        }
                    }
                }
            }
            // Handle Add export Rules
            if (exportAdd != null && !exportAdd.isEmpty()) {
                for (ExportRule newExport : exportAdd) {
                    _log.info("Adding Export Rule {}", newExport);
                    if (!ncApi.addNFSShare(fsName, qtreeName, qtreePath, newExport)) {
                        _log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
                        result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
                        result.setCommandStatus(Operation.Status.error.name());
                        return result;
                    }
                }
            }
            // Handle Delete export Rules
            if (exportDelete != null && !exportDelete.isEmpty()) {
                for (ExportRule existingRule : exportsToprocess) {
                    if (existingRule.getExportPath().equalsIgnoreCase(exportPath)) {
                        exportsToRemove.add(existingRule);
                        for (ExportRule oldExport : exportDelete) {
                            if (oldExport.getSecFlavor().equals(existingRule.getSecFlavor())) {
                                _log.info("Deleting Export Rule {}", existingRule);
                                exportsRemove.add(existingRule);
                                if (!ncApi.deleteNFSShare(fsName, qtreeName, existingRule, qtreePath)) {
                                    _log.error("NetAppClusterModeDevice updateFSExportRules {} - failed", args.getFsId());
                                    result.setMessage("NetAppClusterModeDevice updateFSExportRules {} - failed");
                                    result.setCommandStatus(Operation.Status.error.name());
                                    return result;
                                }
                            }
                        }
                    }
                }
            }
            // No of exports found to remove from the list
            _log.info("No of exports found to remove from the existing exports list {}", exportsRemove.size());
            exportsToRemove.removeAll(exportsRemove);
            _log.info("No of exports found to add to the existing exports list {}", exportsToAdd.size());
            // If we delete filesystem without deleting export policy. Export policy will not get cleared on Array.
            if (exportsToRemove.isEmpty() && !exportsRemove.isEmpty()) {
                ncApi.deleteNFSExport(qtreePath);
            }
        }
    } catch (NetAppCException e) {
        _log.info("Exception:" + e.getMessage());
        throw new DeviceControllerException("Exception while performing export for {0} - {1} ", new Object[] { args.getFsId(), e.getMessage() });
    }
    _log.info("NetAppClusterModeDevice updateFSExportRules {} - complete", args.getFsId());
    result.setCommandSuccess(true);
    result.setCommandStatus(Operation.Status.ready.name());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ExportRule(com.emc.storageos.model.file.ExportRule) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 48 with BiosCommandResult

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

the class NetAppClusterModeDevice method doDeleteFS.

@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doDeleteFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppClusterModeDevice::doDeletFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
            serviceError.setMessage("Filesystem name is either missing or empty");
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        // Now get the SVM from the fileShare
        String portGroup = findSVMName(args.getFs());
        if (null != args.getFsShares() && !args.getFsShares().isEmpty()) {
            if (!netAppDeleteCIFSExports(storage, args.getFsShares(), portGroup)) {
                _log.info("NetAppClusterModeDevice doDeletFS:netAppDeleteCIFSExports {} - failed", args.getFsName());
            } else {
                _log.info("NetAppClusterModeDevice doDeletFS:netAppDeleteCIFSExports {} - succeeded", args.getFsName());
            }
        }
        boolean failedStatus = false;
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        if (!ncApi.deleteFS(args.getFsName())) {
            failedStatus = true;
        }
        if (failedStatus == true) {
            _log.error("NetAppClusterModeDevice doDeletFS {} - failed", args.getFsName());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppClusterModeDevice doDeletFS {} - complete", args.getFsName());
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doDeleteFS failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doDeleteFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 49 with BiosCommandResult

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

the class NetAppClusterModeDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doExpandFS - start");
        long newFsExpandSize = args.getNewFSCapacity();
        String volumeName = args.getFsName();
        if (args.getNewFSCapacity() % BYTESPERMB == 0) {
            newFsExpandSize = newFsExpandSize / BYTESPERMB;
        } else {
            newFsExpandSize = newFsExpandSize / BYTESPERMB + 1;
        }
        _log.info("FileSystem new size translation : {} : {}", args.getNewFSCapacity(), newFsExpandSize);
        String strNewFsSize = String.valueOf(newFsExpandSize) + "m";
        String portGroup = findSVMName(args.getFs());
        NetAppClusterApi nApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        if (!nApi.setVolumeSize(volumeName, strNewFsSize)) {
            _log.error("NetAppClusterModeDevice doExpandFS - failed");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppClusterModeDevice doExpandFS - complete");
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doExpandFS failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doExpandFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToExpandFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 50 with BiosCommandResult

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

the class NetAppClusterModeDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    // To be in-sync with isilon implementation, currently forceGroup is
    // set to null which will set the group name as "everyone" by default.
    String forceGroup = null;
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doShare - start");
        SMBShareMap smbShareMap = args.getFileObjShares();
        SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
        Boolean modOrCreateShareSuccess = false;
        if (existingShare != null) {
            modOrCreateShareSuccess = modifyNtpShare(storage, args, smbFileShare, forceGroup, existingShare);
        } else if (existingShare == null) {
            modOrCreateShareSuccess = createNtpShare(storage, args, smbFileShare, forceGroup);
        }
        if (modOrCreateShareSuccess.booleanValue() == true) {
            _log.info("NetAppClusterModeDevice doShare {} - complete", smbFileShare.getName());
            // Update the collection.
            if (args.getFileObjShares() == null) {
                args.initFileObjShares();
            }
            // set Mount Point
            smbFileShare.setMountPoint(smbFileShare.getNetBIOSName(), smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
            args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
            result = BiosCommandResult.createSuccessfulResult();
        } else {
            _log.error("NetAppClusterModeDevice doShare {} - failed", smbFileShare.getName());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
            result = BiosCommandResult.createErrorResult(serviceError);
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doShare failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doShare failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

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