Search in sources :

Example 1 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doDeleteFS.

/**
 * Deleting a file system: - deletes FileSystem and any correponding exports, smb shares
 *
 * @param StorageSystem storage
 * @param args FileDeviceInputOutput
 * @return BiosCommandResult
 * @throws ControllerException
 */
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doDeleteFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppFileStorageDevice::doDeletFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteFileSystem();
            serviceError.setMessage("Filesystem name is either missing or empty");
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        FileShare fileshare = args.getFs();
        // Now get the VFiler from the fileShare
        String portGroup = findVfilerName(fileshare);
        if (null != args.getFsShares() && !args.getFsShares().isEmpty()) {
            if (!netAppDeleteCIFSExports(storage, args.getFsShares(), portGroup)) {
                _log.info("NetAppFileStorageDevice doDeletFS:netAppDeleteCIFSExports {} - failed", args.getFsName());
            } else {
                _log.info("NetAppFileStorageDevice doDeletFS:netAppDeleteCIFSExports {} - succeeded", args.getFsName());
            }
        }
        boolean failedStatus = false;
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        if (!nApi.deleteFS(args.getFsName())) {
            failedStatus = true;
        }
        if (failedStatus == true) {
            _log.error("NetAppFileStorageDevice doDeletFS {} - failed", args.getFsName());
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppFileStorageDevice doDeletFS {} - complete", args.getFsName());
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doDeleteFS failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doDeleteFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 2 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doRestoreFS.

@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doRestoreFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppFileStorageDevice::doRestoreFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToRestoreFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getSnapshotName()) {
            _log.error("NetAppFileStorageDevice::doRestoreFS failed:  Snapshot name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToRestoreFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_SNAPSHOT_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
        if (!nApi.restoreSnapshot(args.getFsName(), args.getSnapshotName())) {
            _log.error("NetAppFileStorageDevice doRestoreFS {} - failed", args.getFsName());
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToRestoreFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("doRestoreFS - restore of snapshot, {}  was successfully for filesystem, {} ", args.getSnapshotName(), args.getFsName());
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doRestoreFS failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToRestoreFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doRestoreFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToRestoreFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 3 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doUpdateQuotaDirectory.

@Override
public BiosCommandResult doUpdateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory qtree) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doUpdateQuotaDirectory - start");
        // Using NetApp terminology here
        String volName = args.getFsName();
        String qtreeName = args.getQuotaDirectoryName();
        Boolean oplocks = qtree.getOpLock();
        String securityStyle = qtree.getSecurityStyle();
        Long size = qtree.getSize();
        if (null == volName) {
            _log.error("NetAppFileStorageDevice::doUpdateQuotaDirectory failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToUpdateQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == qtreeName) {
            _log.error("NetAppFileStorageDevice::doUpdateQuotaDirectory failed:  Qtree name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToUpdateQtree();
            serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String portGroup = findVfilerName(args.getFs());
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        nApi.updateQtree(qtreeName, volName, oplocks, securityStyle, size, portGroup);
        result = BiosCommandResult.createSuccessfulResult();
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doUpdateQuotaDirectory failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doUpdateQuotaDirectory failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToCreateQtree();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 4 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _log.info("NetAppFileStorageDevice doExport - start");
    // Verify inputs.
    validateExportArgs(exportList);
    List<String> rootHosts = new ArrayList<String>();
    List<String> rwHosts = new ArrayList<String>();
    List<String> roHosts = new ArrayList<String>();
    if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
        args.initFileObjExports();
    }
    FSExportMap existingExpMap = args.getFileObjExports();
    List<FileExport> existingExportList = new ArrayList<FileExport>();
    FileExport existingExport = null;
    Iterator<String> it = existingExpMap.keySet().iterator();
    while (it.hasNext()) {
        existingExport = existingExpMap.get(it.next());
        _log.info("Existing export FileExport key : {} ", existingExport.getFileExportKey());
        existingExportList.add(existingExport);
    }
    // If it's a sub-directory no need to take existing hosts.
    boolean isSubDir = checkIfSubDirectory(args.getFsMountPath(), exportList.get(0).getMountPath());
    if (isSubDir) {
        existingExportList = null;
    }
    // TODO: Revisit once new Data Model for Exports is implemented.
    Map<String, List<String>> existingHosts = null;
    if ((null != existingExportList) && !existingExportList.isEmpty()) {
        existingHosts = sortHostsFromCurrentExports(existingExportList);
    }
    if (null != existingHosts) {
        if ((null != existingHosts.get(ROOT_HOSTS)) && !existingHosts.get(ROOT_HOSTS).isEmpty()) {
            addNewHostsOnly(rootHosts, existingHosts.get(ROOT_HOSTS));
        }
        if ((null != existingHosts.get(RW_HOSTS)) && !existingHosts.get(RW_HOSTS).isEmpty()) {
            addNewHostsOnly(rwHosts, existingHosts.get(RW_HOSTS));
        }
        if ((null != existingHosts.get(RO_HOSTS)) && !existingHosts.get(RO_HOSTS).isEmpty()) {
            addNewHostsOnly(roHosts, existingHosts.get(RO_HOSTS));
        }
    }
    BiosCommandResult result = new BiosCommandResult();
    try {
        for (int expCount = 0; expCount < exportList.size(); expCount++) {
            FileExport export = exportList.get(expCount);
            if (!(export.getMountPath().startsWith(VOL_ROOT_NO_SLASH))) {
                export.setMountPath(VOL_ROOT_NO_SLASH + export.getMountPath());
            }
            FileExport fileExport = new FileExport(export.getClients(), export.getStoragePortName(), export.getMountPoint(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), export.getProtocol(), export.getStoragePort(), export.getPath(), export.getMountPath(), export.getSubDirectory(), export.getComments());
            args.getFileObjExports().put(fileExport.getFileExportKey(), fileExport);
            String portGroup = null;
            FileShare fileshare = null;
            if (args.getFileOperation() == true) {
                fileshare = args.getFs();
                portGroup = findVfilerName(fileshare);
            } else {
                // Get the FS from the snapshot
                URI snapShotUID = args.getSnapshotId();
                Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapShotUID);
                fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
                // Now get the VFiler from the fileshare
                portGroup = findVfilerName(fileshare);
            }
            NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
            List<String> endpointsList = export.getClients();
            if (endpointsList == null) {
                _log.error("NetAppFileStorageDevice::doExport {} failed:  No endpoints specified", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
                serviceError.setMessage(FileSystemConstants.FS_ERR_NO_ENDPOINTS_SPECIFIED);
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
            sortNewEndPoints(rootHosts, rwHosts, roHosts, endpointsList, export.getPermissions());
            String root_user = export.getRootUserMapping();
            String mountPath = export.getMountPath();
            String exportPath = export.getPath();
            if (!nApi.exportFS(exportPath, mountPath, rootHosts, rwHosts, roHosts, root_user, export.getSecurityType())) {
                _log.error("NetAppFileStorageDevice::doExport {} failed", args.getFsId());
                ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
                serviceError.setMessage(genDetailedMessage("doExport", args.getFsId().toString()));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            }
            result = BiosCommandResult.createSuccessfulResult();
            if ((args.getFileOperation() == true) && (isSubDir == false)) {
                nApi.setQtreemode(exportPath, UNIX_QTREE_SETTING);
            }
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doExport failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doExport failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToExportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    _log.info("NetAppFileStorageDevice::doExport {} - complete", args.getFsId());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) ArrayList(java.util.ArrayList) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException) Snapshot(com.emc.storageos.db.client.model.Snapshot) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList) List(java.util.List) NetAppApi(com.emc.storageos.netapp.NetAppApi)

Example 5 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doDeleteSnapshot.

@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    if (null == args.getFsName()) {
        throw new DeviceControllerException("Filesystem name is either missing or empty", new Object[] {});
    }
    if (null == args.getSnapshotName()) {
        throw new DeviceControllerException("Snapshot name is either missing or empty for filesystem name {0}", new Object[] { args.getFsName() });
    }
    _log.info("NetAppFileStorageDevice doDeleteSnapshot: {},{} - start", args.getSnapshotId(), args.getSnapshotName());
    BiosCommandResult result = new BiosCommandResult();
    NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
    try {
        if (!nApi.deleteSnapshot(args.getFsName(), args.getSnapshotName())) {
            _log.error("NetAppFileStorageDevice doDeleteSnapshot {} - failed", args.getFsId());
            result.setCommandSuccess(false);
            result.setMessage("NetAppFileStorageDevice doDeleteSnapshot - failed");
            result.setCommandStatus(Operation.Status.error.name());
        } else {
            _log.info("doDeleteSnapshot for snapshot {} on filesystem {} successful", args.getSnapshotName(), args.getFsName());
            result.setCommandSuccess(true);
            result.setCommandStatus(Operation.Status.ready.name());
            result.setMessage("Snapshot," + args.getSnapshotName() + " has been successfully deleted");
        }
    } catch (NetAppException e) {
        throw new DeviceControllerException("Failed to delete snapshot, {0} for filesystem, {1} with: {2}", new Object[] { args.getSnapshotName(), args.getFsName(), e.getMessage() });
    }
    return result;
}
Also used : BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Aggregations

NetAppException (com.emc.storageos.netapp.NetAppException)27 NetAppApi (com.emc.storageos.netapp.NetAppApi)23 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)16 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 URI (java.net.URI)11 ArrayList (java.util.ArrayList)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)9 IOException (java.io.IOException)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)8 NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)8 HashMap (java.util.HashMap)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 FileShare (com.emc.storageos.db.client.model.FileShare)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 VFilerInfo (com.iwave.ext.netapp.VFilerInfo)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 StringMap (com.emc.storageos.db.client.model.StringMap)5