Search in sources :

Example 6 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method loadVNXFileCommunicationAPIs.

/**
 * Loading context every time for each operation doesn't look right.
 *
 * TODO As of v1, adding this code, this definitely had to be changed.
 *
 * @return
 */
private VNXFileCommApi loadVNXFileCommunicationAPIs(ApplicationContext context) {
    VNXFileCommApi vnxComm = null;
    try {
        vnxComm = (VNXFileCommApi) context.getBean(VNXCOMM_API);
        vnxComm.setDbClient(_dbClient);
    } catch (Exception e) {
        throw new DeviceControllerException("VNXFile Provisioning context didn't get loaded properly.Terminating File System Provisioning operations.");
    }
    return vnxComm;
}
Also used : VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 7 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method extraExportRuleFromArray.

/**
 * Get the export rule which are present in array but not in CoprHD Database.
 *
 * @param storage
 * @param args
 * @return map with security flavor and export rule
 */
private Map<String, ExportRule> extraExportRuleFromArray(StorageSystem storage, FileDeviceInputOutput args) {
    // map to store the export rule grouped by sec flavor
    Map<String, ExportRule> exportRuleMap = new HashMap<>();
    Set<String> arrayReadOnlyHost = new HashSet<>();
    Set<String> arrayReadWriteHost = new HashSet<>();
    Set<String> arrayRootHost = new HashSet<>();
    Set<String> dbReadOnlyHost = new HashSet<>();
    Set<String> dbReadWriteHost = new HashSet<>();
    Set<String> dbRootHost = new HashSet<>();
    // get all export rule from CoprHD data base
    List<ExportRule> existingDBExportRules = args.getExistingDBExportRules();
    // get the all the export from the storage system.
    ApplicationContext context = null;
    context = loadContext();
    VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
    if (null == vnxComm) {
        throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
    }
    for (ExportRule exportRule : existingDBExportRules) {
        if (exportRule.getReadOnlyHosts() != null) {
            dbReadOnlyHost.addAll(exportRule.getReadOnlyHosts());
        }
        if (exportRule.getReadWriteHosts() != null) {
            dbReadWriteHost.addAll(exportRule.getReadWriteHosts());
        }
        if (exportRule.getRootHosts() != null) {
            dbRootHost.addAll(exportRule.getRootHosts());
        }
        Map<String, String> vnxExportMap = null;
        vnxExportMap = vnxComm.getNFSExport(storage, args);
        String readOnlyList = vnxExportMap.get("ro");
        String readWriteList = vnxExportMap.get("rw");
        String rootList = vnxExportMap.get("root");
        // we get multiple value each separated by :
        if (readOnlyList != null) {
            for (String readOnly : readOnlyList.split(":")) {
                if (!readOnly.equals("null")) {
                    arrayReadOnlyHost.add(readOnly);
                }
            }
        }
        if (readWriteList != null) {
            for (String readWrite : readWriteList.split(":")) {
                if (!readWrite.equals("null")) {
                    arrayReadWriteHost.add(readWrite);
                }
            }
        }
        if (rootList != null) {
            for (String root : rootList.split(":")) {
                if (!root.equals("null")) {
                    arrayRootHost.add(root);
                }
            }
        }
        // find out the change between array and CoprHD database.
        Set<String> arrayExtraReadOnlyHost = Sets.difference(arrayReadOnlyHost, dbReadOnlyHost);
        Set<String> arrayExtraReadWriteHost = Sets.difference(arrayReadWriteHost, dbReadWriteHost);
        Set<String> arrayExtraRootHost = Sets.difference(arrayRootHost, dbRootHost);
        // if change found update the exportRuleMap
        if (!arrayExtraReadOnlyHost.isEmpty() || !arrayExtraReadWriteHost.isEmpty() || !arrayExtraRootHost.isEmpty()) {
            ExportRule extraRuleFromArray = new ExportRule();
            extraRuleFromArray.setDeviceExportId(exportRule.getDeviceExportId());
            extraRuleFromArray.setAnon(exportRule.getAnon());
            extraRuleFromArray.setSecFlavor(exportRule.getSecFlavor());
            extraRuleFromArray.setExportPath(exportRule.getExportPath());
            extraRuleFromArray.setReadOnlyHosts(arrayExtraReadOnlyHost);
            extraRuleFromArray.setReadWriteHosts(arrayExtraReadWriteHost);
            extraRuleFromArray.setRootHosts(arrayExtraRootHost);
            exportRuleMap.put(exportRule.getSecFlavor(), extraRuleFromArray);
        }
    }
    return exportRuleMap;
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) HashMap(java.util.HashMap) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) ExportRule(com.emc.storageos.model.file.ExportRule) HashSet(java.util.HashSet)

Example 8 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi 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)

Example 9 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doCheckFSDependencies.

@Override
public BiosCommandResult doCheckFSDependencies(StorageSystem storage, FileDeviceInputOutput args) {
    _log.info("Checking file system {} has dependencies in storage array: {}", args.getFsName(), storage.getLabel());
    boolean hasDependency = true;
    FileShare fs = args.getFs();
    ApplicationContext context = null;
    try {
        context = loadContext();
        VNXFileCommApi vnxComm = loadVNXFileCommunicationAPIs(context);
        if (null == vnxComm) {
            throw VNXException.exceptions.communicationFailed(VNXCOMM_ERR_MSG);
        }
        String fsMountPath = args.getFsMountPath();
        Map<String, String> nfsShares = vnxComm.getNFSExport(storage, args);
        hasDependency = (nfsShares != null && !nfsShares.isEmpty());
        if (!hasDependency) {
            Map<String, String> cifsShares = vnxComm.getCIFSExport(storage, args);
            hasDependency = (cifsShares != null && !cifsShares.isEmpty());
        }
        if (!hasDependency) {
            List<Checkpoint> snapshots = vnxComm.getCheckpointsOfFilesystem(storage, fs.getNativeId());
            hasDependency = (snapshots != null && !snapshots.isEmpty());
        }
        if (hasDependency) {
            _log.error("File system has dependencies on array: {}", args.getFsName());
            DeviceControllerException e = DeviceControllerException.exceptions.fileSystemHasDependencies(fsMountPath);
            return BiosCommandResult.createErrorResult(e);
        }
        _log.info("File system has no dependencies on array: {}", args.getFsName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (Exception ex) {
        _log.error("Checking FS dependencies failed.", ex);
        throw ex;
    } finally {
        clearContext(context);
    }
}
Also used : ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) ApplicationContext(org.springframework.context.ApplicationContext) Checkpoint(com.emc.nas.vnxfile.xmlapi.Checkpoint) VNXFileCommApi(com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException)

Example 10 with VNXFileCommApi

use of com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi in project coprhd-controller by CoprHD.

the class VNXFileStorageDeviceXML method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("Call FileSystem Expand");
    // For the request to succeed to expand, the system must be mounted.
    // Below snippet helps to verify whether FS Mounted or not.
    // Note : Since, Every Export will mount the FileSystem at first, we
    // should do cross check as below whether file system is already mounted or not
    // using FSExportMap and SMBShareMap
    // If FileShare mounted then Mount is not required
    boolean isMountRequired = !(args.isFileShareMounted());
    _log.info("Mount required or not, to expand requested FileSystem {}", isMountRequired);
    Long newFsExpandSize = args.getNewFSCapacity();
    if (args.getNewFSCapacity() % BYTESPERMB == 0) {
        newFsExpandSize = newFsExpandSize / BYTESPERMB;
    } else {
        newFsExpandSize = newFsExpandSize / BYTESPERMB + 1;
    }
    _log.info("FileSystem new size translation : {} : {}", args.getNewFSCapacity(), args.getFsCapacity());
    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.expandFS(storage, args.getFs(), newFsExpandSize, isMountRequired, args.getThinProvision());
    } 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.unableToExpandFileSystem(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)

Aggregations

VNXFileCommApi (com.emc.storageos.volumecontroller.impl.plugins.provisioning.VNXFileCommApi)19 VNXException (com.emc.storageos.vnx.xmlapi.VNXException)18 ApplicationContext (org.springframework.context.ApplicationContext)18 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)18 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 XMLApiResult (com.emc.storageos.vnx.xmlapi.XMLApiResult)15 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)15 ControllerException (com.emc.storageos.volumecontroller.ControllerException)7 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)4 VNXFileExport (com.emc.storageos.vnx.xmlapi.VNXFileExport)4 ArrayList (java.util.ArrayList)4 Checkpoint (com.emc.nas.vnxfile.xmlapi.Checkpoint)3 FileShare (com.emc.storageos.db.client.model.FileShare)3 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 ExportRule (com.emc.storageos.model.file.ExportRule)3 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)3 FileExport (com.emc.storageos.db.client.model.FileExport)2 VNXQuotaTree (com.emc.storageos.vnx.xmlapi.VNXQuotaTree)2 VNXSnapshot (com.emc.storageos.vnx.xmlapi.VNXSnapshot)2 HashMap (java.util.HashMap)2