Search in sources :

Example 11 with XMLApiResult

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

the class VNXFileStorageDeviceXML method doDeleteFS.

@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("doDeleteFS: fs id = {} Force Delete : {}", args.getFsNativeId(), args.getForceDelete());
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        _log.info("DBClient :" + vnxComm.getDbClient());
        result = vnxComm.deleteFileSystem(storage, args.getFsNativeId(), args.getFsName(), args.getForceDelete(), args.getFs());
    } 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.unableToDeleteFileSystem(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 12 with XMLApiResult

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

the class VNXFileStorageDeviceXML method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    boolean firstExport = false;
    if (args.getFileObjExports() == null || args.getFileObjExports().isEmpty()) {
        args.initFileObjExports();
    }
    // mount the FileSystem
    firstExport = !(args.isFileShareMounted());
    if (firstExport) {
        _log.debug("First export: no existing file exports");
    }
    // Mounting is only necessary for FileSystem and not snapshot for the first time export
    if (!args.getFileOperation()) {
        firstExport = false;
    }
    // Create a list of the new exports.
    FSExportMap newExpList = new FSExportMap();
    FSExportMap curExpList = args.getFileObjExports();
    FileExport curExport = null;
    FileExport newExport = null;
    List<String> newPaths = new ArrayList<String>();
    Iterator<String> it = curExpList.keySet().iterator();
    while (it.hasNext()) {
        curExport = curExpList.get(it.next());
        newExport = new FileExport(curExport.getClients(), curExport.getStoragePortName(), ExportUtils.getFileMountPoint(curExport.getStoragePort(), curExport.getPath()), curExport.getSecurityType(), curExport.getPermissions(), curExport.getRootUserMapping(), curExport.getProtocol(), curExport.getStoragePort(), curExport.getPath(), curExport.getMountPath(), curExport.getSubDirectory(), curExport.getComments());
        _log.info("FileExport key : {} ", newExport.getFileExportKey());
        newExpList.put(newExport.getFileExportKey(), newExport);
    }
    for (FileExport exp : exportList) {
        newExport = new FileExport(exp.getClients(), exp.getStoragePortName(), ExportUtils.getFileMountPoint(exp.getStoragePort(), exp.getPath()), exp.getSecurityType(), exp.getPermissions(), exp.getRootUserMapping(), exp.getProtocol(), exp.getStoragePort(), exp.getPath(), exp.getMountPath(), exp.getSubDirectory(), exp.getComments());
        _log.info("FileExport key : {} ", newExport.getFileExportKey());
        newExpList.put(newExport.getFileExportKey(), newExport);
        if (!newPaths.contains(newExport.getPath())) {
            newPaths.add(newExport.getPath());
        }
    }
    XMLApiResult result = null;
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        // Get DataMover Name and whether it is virtual
        StorageHADomain dm = this.getDataMover(args.getFs());
        if (dm == null) {
            Exception e = new Exception("VNX File Export Failed Data Mover not found");
            throw VNXException.exceptions.createExportFailed("VNX File Export Failed Data Mover not found", e);
        }
        List<VNXFileExport> vnxExports = getVNXFileExports(newExpList);
        if (args.getFileOperation()) {
            // Perform FileSystem export
            result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getFsNativeId(), firstExport);
        } else {
            // perform Snapshot export
            result = vnxComm.doExport(storage, dm, vnxExports, newPaths, args.getFileObj(), args.getSnapNativeId(), firstExport);
        }
        if (result.isCommandSuccess()) {
            curExpList.putAll(newExpList);
        }
    } catch (VNXException e) {
        throw VNXException.exceptions.createExportFailed("VNX File Export Failed", e);
    } finally {
        clearContext(context);
    }
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToExportFileSystem(result.getMessage()));
    }
    return cmdResult;
}
Also used : ArrayList(java.util.ArrayList) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) 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) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain)

Example 13 with XMLApiResult

use of com.emc.storageos.vnx.xmlapi.XMLApiResult 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 14 with XMLApiResult

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

the class VNXFileStorageDeviceXML method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult biosResult = new BiosCommandResult();
    biosResult.setCommandSuccess(true);
    biosResult.setCommandStatus(Operation.Status.ready.name());
    List<ExportRule> allExports = args.getExistingDBExportRules();
    String subDir = args.getSubDirectory();
    boolean allDirs = args.isAllDir();
    String exportPath;
    String subDirExportPath = "";
    if (!args.getFileOperation()) {
        exportPath = args.getSnapshotPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getSnapshotPath() + "/" + subDir;
        }
    } else {
        exportPath = args.getFs().getPath();
        if (subDir != null && subDir.length() > 0) {
            subDirExportPath = args.getFs().getPath() + "/" + subDir;
        }
    }
    Set<String> allPaths = new HashSet<String>();
    try {
        if (allDirs) {
            // ALL EXPORTS
            _log.info("Deleting all exports specific to filesystem at device and rules from DB including sub dirs rules and exports");
            for (ExportRule rule : allExports) {
                allPaths.add(rule.getExportPath());
            }
        } else if (subDir != null && !subDir.isEmpty()) {
            // Filter for a specific Sub Directory export
            _log.info("Deleting all subdir exports rules at ViPR and sub directory export at device {}", subDir);
            for (ExportRule rule : allExports) {
                if (rule.getExportPath().endsWith("/" + subDir)) {
                    allPaths.add(subDirExportPath);
                    break;
                }
            }
        } else {
            // Filter for No SUBDIR - main export rules with no sub dirs
            _log.info("Deleting all export rules  from DB and export at device not included sub dirs");
            allPaths.add(exportPath);
        }
        _log.info("Number of Exports to Delete : {}", allPaths.size());
        Map<String, Boolean> operationResult = new HashMap<String, Boolean>();
        XMLApiResult result = null;
        ApplicationContext context = null;
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        for (String exportPathToDelete : allPaths) {
            _log.info("Deleting Export Path {}", exportPathToDelete);
            try {
                result = vnxComm.doDeleteExport(storage, exportPathToDelete, args, false);
                if (result.isCommandSuccess()) {
                    _log.info("Export Deleted : {}", exportPathToDelete);
                    operationResult.put(exportPathToDelete, true);
                } else {
                    _log.error("Error deleting Export : {}", exportPathToDelete);
                    operationResult.put(exportPathToDelete, false);
                    biosResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUnexportFileSystem(result.getMessage()));
                }
            } catch (Exception e) {
                _log.error("Error deleting Export : {}", exportPathToDelete);
                operationResult.put(exportPathToDelete, false);
                biosResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToUnexportFileSystem(result.getMessage()));
            }
        }
    } catch (VNXException e) {
        _log.error("Exception:" + e.getMessage());
        throw new DeviceControllerException("Exception while performing export for {0} ", new Object[] { args.getFsId() });
    }
    _log.info("VNXFileStorageDevice deleteExportRules {} - complete", args.getFsId());
    return biosResult;
}
Also used : HashMap(java.util.HashMap) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) XMLApiResult(com.emc.storageos.vnx.xmlapi.XMLApiResult) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) 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) ExportRule(com.emc.storageos.model.file.ExportRule) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) HashSet(java.util.HashSet)

Example 15 with XMLApiResult

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

the class VNXFileStorageDeviceXML method doRestoreFS.

@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("FileShare, Snapshot {} {}", args.getFsUUID(), args.getSnapshotId());
    _log.info("FSName: {}", args.getFsName());
    _log.info("SnapShotName: {}", args.getSnapshotName());
    int snapNativeId = 0;
    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.doRestoreSnapshot(storage, args.getFsNativeId(), args.getFsName(), args.getSnapNativeId(), args.getSnapshotName());
        _log.info("restoreSnapshot call result : {}", result.isCommandSuccess());
    } catch (NumberFormatException ne) {
        // Call failed
        result = new XMLApiResult();
        result.setCommandFailed();
        result.setMessage("Not valid snapshot Id " + args.getSnapNativeId());
    } catch (VNXException e) {
        throw new DeviceControllerException(e);
    } finally {
        clearContext(context);
    }
    _log.info("restoreSnapshot call result : {}", result.isCommandSuccess());
    BiosCommandResult cmdResult = null;
    if (result.isCommandSuccess()) {
        cmdResult = BiosCommandResult.createSuccessfulResult();
    } else {
        cmdResult = BiosCommandResult.createErrorResult(DeviceControllerErrors.vnx.unableToRestoreFileSystem(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) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint)

Aggregations

XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)30 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)29 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)15 VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)15 ApplicationContext (org.springframework.context.ApplicationContext)15 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)15 FileObject (com.emc.storageos.db.client.model.FileObject)14 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)14 URISyntaxException (java.net.URISyntaxException)14 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 ArrayList (java.util.ArrayList)9 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)8 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)8 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)7 VNXFileExport (com.emc.storageos.vnx.xmlapi.VNXFileExport)7 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)7 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)6 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)6 FileShare (com.emc.storageos.db.client.model.FileShare)6 Snapshot (com.emc.storageos.db.client.model.Snapshot)5