Search in sources :

Example 61 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class FileSystems method deleteFileSystemExport.

@FlashException(referrer = { "fileSystem" })
public static void deleteFileSystemExport(String fileSystemId, String security, String exportPath) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    ExportRule rule = new ExportRule();
    rule.setSecFlavor(security);
    List<ExportRule> list = Lists.newArrayList();
    list.add(rule);
    ExportRules exportRules = new ExportRules();
    exportRules.setExportRules(list);
    FileShareExportUpdateParams params = new FileShareExportUpdateParams();
    params.setExportRulesToDelete(exportRules);
    FileShareRestRep fileSystem = client.fileSystems().get(uri(fileSystemId));
    String subDir = FileUtils.findSubDirectory(fileSystem.getMountPath(), exportPath);
    client.fileSystems().updateExport(uri(fileSystemId), subDir, params);
    flash.put("info", MessagesUtils.get("resources.filesystem.export.deactivate"));
    fileSystem(fileSystemId);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRules(com.emc.storageos.model.file.ExportRules) FileShareExportUpdateParams(com.emc.storageos.model.file.FileShareExportUpdateParams) ExportRule(com.emc.storageos.model.file.ExportRule) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) FlashException(controllers.util.FlashException)

Example 62 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method verifyAddExportRule.

/**
 * Verify each export rule that can be added
 *
 * @param listExportRule
 */
private void verifyAddExportRule(List<ExportRule> listExportRule) throws Exception {
    if (listExportRule == null) {
        return;
    }
    _log.info("Checking if file system is exported before adding export rule");
    if (!isFileSystemExported()) {
        String msg = "File system is not exported. To add export rule, file system must be exported first.";
        _log.error(msg);
        String urn = fs != null ? fs.getId().toString() : snapshot.getId().toString();
        throw APIException.badRequests.fileSystemNotExported(ExportOperationType.ADD.name(), urn);
    }
    _log.info("Number of Export Rule(s) Requested to Add {} - Iterating ..", listExportRule.size());
    for (ExportRule exportRule : listExportRule) {
        exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
        _log.info("Verifying Export Rule {}", exportRule.toString());
        // is same security flavor found in several exports - report the error
        scanForDuplicateSecFlavor(exportRule);
        if (exportRule.getErrorTypeIfNotToProceed() != null && !(exportRule.getErrorTypeIfNotToProceed().name().equals(ExportOperationErrorType.NO_ERROR.name()))) {
            _log.info("Same Security Flavor found across the exports {}", exportRule.toString());
            break;
        }
        // Now validate hosts
        FileExportRule rule = validateHosts(exportRule);
        // If same export already found -- Don't allow to add again.
        if (rule != null) {
            _log.info("Duplicate Export to Add {} Requested : {}", rule, exportRule);
            exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_EXISTS);
            break;
        } else // If not found proceed for further verifications.
        {
            if (exportRule.isToProceed()) {
                _log.info("No Existing Export found in DB {}", exportRule);
                verifyExportAnon(exportRule);
            }
        }
    }
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 63 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method verifyModifyExportRule.

/**
 * Verify each export rule that can be added
 *
 * @param fs
 * @param listExportRule
 */
private void verifyModifyExportRule(List<ExportRule> listExportRule) throws Exception {
    if (listExportRule == null) {
        return;
    }
    _log.info("{} Export Rule(s) Requested to Modify {} - Iterating ..", listExportRule.size());
    for (ExportRule exportRule : listExportRule) {
        exportRule.setIsToProceed(true, ExportOperationErrorType.NO_ERROR);
        _log.info("Verifying Export Rule {}", exportRule.toString());
        // is same security flavor found in several exports - report the error
        scanForDuplicateSecFlavor(exportRule);
        if (!exportRule.isToProceed()) {
            _log.info("Same Security Flavor found across the exports {}", exportRule.toString());
            break;
        }
        FileExportRule rule = validateHosts(exportRule);
        // If found -- allow to modify.
        if (rule != null) {
            verifyExportAnon(exportRule);
        } else // If not, stop proceed further.
        {
            if (exportRule.isToProceed()) {
                _log.info("Export not found to modify");
                exportRule.setIsToProceed(false, ExportOperationErrorType.EXPORT_NOT_FOUND);
            }
        }
    }
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule)

Example 64 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method reportAddErrors.

private void reportAddErrors(FileExportUpdateParams param) throws Exception {
    String opName = ExportOperationType.ADD.name();
    // Report Add Export Errors
    ExportRules listExportRules = param.getExportRulesToAdd();
    if (listExportRules == null || listExportRules.getExportRules().isEmpty()) {
        return;
    }
    List<ExportRule> listExportRule = listExportRules.getExportRules();
    for (ExportRule exportRule : listExportRule) {
        if (!exportRule.isToProceed()) {
            ExportOperationErrorType error = exportRule.getErrorTypeIfNotToProceed();
            switch(error) {
                case SNAPSHOT_EXPORT_SHOULD_BE_READ_ONLY:
                    {
                        throw APIException.badRequests.snapshotExportPermissionReadOnly();
                    }
                case INVALID_SECURITY_TYPE:
                    {
                        if (exportRule.getSecFlavor() != null) {
                            throw APIException.badRequests.invalidSecurityType(exportRule.getSecFlavor());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
                        }
                    }
                case MULTIPLE_EXPORTS_WITH_SAME_SEC_FLAVOR:
                    {
                        if (exportRule.getSecFlavor() != null) {
                            throw APIException.badRequests.sameSecurityFlavorInMultipleExportsFound(exportRule.getSecFlavor(), opName);
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(SEC_TYPE, opName);
                        }
                    }
                case INVALID_ANON:
                    {
                        if (exportRule.getAnon() != null) {
                            throw APIException.badRequests.invalidAnon(exportRule.getAnon());
                        } else {
                            throw APIException.badRequests.missingInputTypeFound(ANON_TYPE, opName);
                        }
                    }
                case NO_HOSTS_FOUND:
                    {
                        throw APIException.badRequests.missingInputTypeFound(NO_HOSTS_FOUND, opName);
                    }
                case EXPORT_EXISTS:
                    {
                        throw APIException.badRequests.exportExists(opName, exportRule.toString());
                    }
                case STORAGE_SYSTEM_NOT_SUPPORT_MUL_SECS:
                    {
                        StorageSystem system = null;
                        String systemName = "";
                        if (fs != null) {
                            system = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
                        } else if (snapshot != null) {
                            FileShare fileSystem = _dbClient.queryObject(FileShare.class, snapshot.getParent());
                            system = _dbClient.queryObject(StorageSystem.class, fileSystem.getStorageDevice());
                        }
                        if (system != null) {
                            systemName = system.getSystemType();
                        }
                        throw APIException.badRequests.storageDoesNotSupportMulSecRule(opName, systemName, exportRule.toString());
                    }
                case EXPORT_NOT_FOUND:
                case NO_ERROR:
                default:
                    break;
            }
        }
    }
}
Also used : ExportRules(com.emc.storageos.model.file.ExportRules) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileShare(com.emc.storageos.db.client.model.FileShare) ExportOperationErrorType(com.emc.storageos.model.file.FileExportUpdateParams.ExportOperationErrorType) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 65 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class FileDeviceController method checkIfMountExistsOnHost.

public void checkIfMountExistsOnHost(URI fsId, String opId) {
    try {
        WorkflowStepCompleter.stepExecuting(opId);
        ContainmentConstraint containmentConstraint = ContainmentConstraint.Factory.getFileMountsConstraint(fsId);
        List<FileMountInfo> fsDBMounts = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, FileMountInfo.class, containmentConstraint);
        FileShare fs = _dbClient.queryObject(FileShare.class, fsId);
        for (FileMountInfo fsMount : fsDBMounts) {
            LinuxMountUtils mountUtils = new LinuxMountUtils(_dbClient.queryObject(Host.class, fsMount.getHostId()));
            ExportRule export = FileOperationUtils.findExport(fs, fsMount.getSubDirectory(), fsMount.getSecurityType(), _dbClient);
            if (mountUtils.verifyMountPoints(export.getMountPoint(), fsMount.getMountPath())) {
                String errMsg = new String("delete file system from ViPR database failed because mounts exist for file system " + fs.getLabel() + " and once deleted the mounts cannot be ingested into ViPR");
                final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.DELETE_FILE_SYSTEM.toString(), errMsg);
                WorkflowStepCompleter.stepFailed(opId, serviceCoded);
            }
        }
        for (FileMountInfo fsMount : fsDBMounts) {
            fsMount.setInactive(true);
        }
        _dbClient.updateObject(fsDBMounts);
        WorkflowStepCompleter.stepSucceded(opId);
    } catch (ControllerException ex) {
        WorkflowStepCompleter.stepFailed(opId, ex);
        _log.error("Couldn't verify dependencies: ", fsId);
        throw ex;
    }
}
Also used : LinuxMountUtils(com.emc.storageos.computesystemcontroller.hostmountadapters.LinuxMountUtils) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ExportRule(com.emc.storageos.model.file.ExportRule) FileMountInfo(com.emc.storageos.db.client.model.FileMountInfo) Host(com.emc.storageos.db.client.model.Host) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Aggregations

ExportRule (com.emc.storageos.model.file.ExportRule)67 ArrayList (java.util.ArrayList)27 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 FileShare (com.emc.storageos.db.client.model.FileShare)16 ExportRules (com.emc.storageos.model.file.ExportRules)13 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 HashSet (java.util.HashSet)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 HashMap (java.util.HashMap)10 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)8 Snapshot (com.emc.storageos.db.client.model.Snapshot)7 FileExport (com.emc.storageos.db.client.model.FileExport)6 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 URI (java.net.URI)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 VNXeException (com.emc.storageos.vnxe.VNXeException)4 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)4