Search in sources :

Example 71 with BiosCommandResult

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

the class VNXUnityFileStorageDevice method doDeleteFS.

/*
     * To get around the KH API delete file system async issues, using sync call for now.
     */
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("deleting file system: ", fileInOut.getFsName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    BiosCommandResult result = null;
    try {
        apiClient.deleteFileSystemSync(fileInOut.getFsNativeId(), fileInOut.getForceDelete());
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Deleted filesystem - Array:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getFsName()));
        _logger.info(logMsgBuilder.toString());
        result = BiosCommandResult.createSuccessfulResult();
    } catch (VNXeException e) {
        _logger.error("Delete file system got the exception", e);
        result = BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
        result = BiosCommandResult.createErrorResult(error);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 72 with BiosCommandResult

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

the class NetAppClusterModeDevice method validateQuotaDirectoryParams.

public BiosCommandResult validateQuotaDirectoryParams(String volName, String qtreeName, String method) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    result = BiosCommandResult.createSuccessfulResult();
    ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
    if (method.equals("doCreateQuotaDirectory")) {
        serviceError = DeviceControllerErrors.netappc.unableToCreateQtree();
    } else if (method.equals("doDeleteQuotaDirectory")) {
        serviceError = DeviceControllerErrors.netappc.unableToDeleteQtree();
    } else {
        serviceError = DeviceControllerErrors.netappc.unableToUpdateQtree();
    }
    if (null == volName) {
        _log.error("NetAppClusterModeDevice:: {} failed:  Filesystem name is either missing or empty", method);
        serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
        result = BiosCommandResult.createErrorResult(serviceError);
        return result;
    }
    if (null == qtreeName) {
        _log.error("NetAppClusterModeDevice::{} failed:  Qtree name is either missing or empty", method);
        serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_MISSING_OR_EMPTY);
        result = BiosCommandResult.createErrorResult(serviceError);
        return result;
    }
    if (method.equals("doCreateQuotaDirectory") && !validQuotaDirectoryPath(volName, qtreeName)) {
        _log.error("NetAppClusterModeDevice::{} failed:  Qtree name or path is too long", method);
        serviceError.setMessage(FileSystemConstants.FS_ERR_QUOTADIR_NAME_PATH_TOO_LONG);
        result = BiosCommandResult.createErrorResult(serviceError);
        return result;
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult)

Example 73 with BiosCommandResult

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

the class NetAppClusterModeDevice method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doDeleteShare - start");
        FileShare fileshare = null;
        if (args.getFileOperation() == true) {
            fileshare = args.getFs();
        } else {
            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
        String portGroup = findSVMName(fileshare);
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        SMBShareMap shares = args.getFileObjShares();
        if (shares == null || shares.isEmpty()) {
            _log.error("NetAppClusterModeDevice::doDeleteShare failed: FileShare(s) is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
            serviceError.setMessage("FileShare(s) is either missing or empty");
            result = BiosCommandResult.createErrorResult(serviceError);
        }
        SMBFileShare fileShare = shares.get(smbFileShare.getName());
        if (fileShare != null) {
            if (!ncApi.deleteShare(smbFileShare.getName())) {
                _log.error("NetAppClusterModeDevice doDeleteShare {} - failed", args.getFileObjId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
                serviceError.setMessage("Deletion of CIFS File Share failed");
                result = BiosCommandResult.createErrorResult(serviceError);
            } else {
                _log.info("NetAppClusterModeDevice doDeleteShare {} - complete", args.getFileObjId());
                args.getFileObjShares().remove(smbFileShare.getName());
                args.getFileObjShares().remove(smbFileShare.getNativeId());
                result = BiosCommandResult.createSuccessfulResult();
            }
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doDeleteShare failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doDeleteShare failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) 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 74 with BiosCommandResult

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

the class NetAppClusterModeDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doCreateFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppClusterModeDevice::doCreateFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getPoolNativeId()) {
            _log.error("NetAppClusterModeDevice::doCreateFS failed:  PoolNativeId either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_POOL_NATIVE_ID_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getFsCapacity()) {
            _log.error("NetAppClusterModeDevice::doCreateFS failed:  Filesystem capacity is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_CAPACITY_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String nativeId = "/" + args.getFsName();
        args.setFsNativeId(nativeId);
        String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storage.getSystemType(), storage.getSerialNumber(), nativeId);
        args.setFsNativeGuid(fsNativeGuid);
        String portGroup = findSVMName(args.getFs());
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        Long fsSize = args.getFsCapacity() / BYTESPERMB;
        String strFsSize = fsSize.toString() + "m";
        if (!ncApi.createFS(args.getFsName(), args.getPoolNativeId(), strFsSize, args.getThinProvision())) {
            _log.error("NetAppClusterModeDevice doCreateFS {} - failed", args.getFsName());
            BiosCommandResult rollbackResult = doDeleteFS(storage, args);
            if (rollbackResult.isCommandSuccess()) {
                _log.info("NetAppClusterModeDevice doCreateFS rollback completed failed for fs, {}", args.getFsName());
            } else {
                _log.error("NetAppClusterModeDevice doCreateFS rollback failed for fs, {} with {}.", args.getFsName(), rollbackResult.getMessage());
            }
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppClusterModeDevice doCreateFS {} - complete", args.getFsName());
            // Set FS path and Mount Path information
            args.setFsPath(nativeId);
            args.setFsMountPath(nativeId);
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doCreateFS failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doCreateFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToCreateFileSystem();
        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 75 with BiosCommandResult

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

the class NetAppClusterModeDevice method doRestoreFS.

@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doRestoreFS - start");
        if (null == args.getFsName()) {
            _log.error("NetAppClusterModeDevice::doRestoreFS failed:  Filesystem name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_FS_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        if (null == args.getSnapshotName()) {
            _log.error("NetAppClusterModeDevice::doRestoreFS failed:  Snapshot name is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
            serviceError.setMessage(FileSystemConstants.FS_ERR_SNAPSHOT_NAME_MISSING_OR_EMPTY);
            result = BiosCommandResult.createErrorResult(serviceError);
            return result;
        }
        String portGroup = findSVMName(args.getFs());
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        if (!ncApi.restoreSnapshot(args.getFsName(), args.getSnapshotName())) {
            _log.error("NetAppClusterModeDevice doRestoreFS {} - failed", args.getFsName());
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("doRestoreFS - restore of snapshot, {}  was successfully for filesystem, {} ", args.getSnapshotName(), args.getFsName());
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doRestoreFS failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doRestoreFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToRestoreFileSystem();
        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)

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