Search in sources :

Example 11 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class ComputeSystemHelper method isHostIpInterfacesInUse.

/**
 * Checks if an ipInterface in use by a file export
 *
 * @param ipAddress the interface IP address
 * @return true if the ipInterface in use by a file export
 */
public static boolean isHostIpInterfacesInUse(DbClient dbClient, List<String> endpoints, URI hostId) {
    if (endpoints == null || endpoints.isEmpty()) {
        return false;
    }
    Host host = dbClient.queryObject(Host.class, hostId);
    List<FileShare> fileShares = null;
    if (!NullColumnValueGetter.isNullURI(host.getProject())) {
        fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getProject(), FileShare.class, "project");
    } else if (!NullColumnValueGetter.isNullURI(host.getTenant())) {
        fileShares = CustomQueryUtility.queryActiveResourcesByRelation(dbClient, host.getTenant(), FileShare.class, "tenant");
    }
    if (fileShares == null || fileShares.isEmpty()) {
        return false;
    }
    for (FileShare fileShare : fileShares) {
        if (fileShare != null && fileShare.getFsExports() != null) {
            for (FileExport fileExport : fileShare.getFsExports().values()) {
                if (fileExport != null && fileExport.getClients() != null) {
                    for (String endpoint : endpoints) {
                        if (fileExport.getClients().contains(endpoint)) {
                            return true;
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) Host(com.emc.storageos.db.client.model.Host) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 12 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class ExportVerificationUtility method isFileSystemExported.

private boolean isFileSystemExported() {
    FileObject fileObject = null;
    if (fs != null) {
        fileObject = fs;
    } else {
        fileObject = snapshot;
    }
    String path = fileObject.getPath();
    String subDirectory = param.getSubDir();
    if (subDirectory != null && !subDirectory.equalsIgnoreCase("null") && subDirectory.length() > 0) {
        // Add subdirectory to the path as this is a subdirectory export
        path += "/" + subDirectory;
    }
    FSExportMap exportMap = fileObject.getFsExports();
    if (exportMap != null) {
        Iterator<String> it = fileObject.getFsExports().keySet().iterator();
        while (it.hasNext()) {
            String fsExpKey = it.next();
            FileExport fileExport = fileObject.getFsExports().get(fsExpKey);
            if (fileExport.getPath().equalsIgnoreCase(path)) {
                _log.info("File system path: {} is exported", path);
                return true;
            }
        }
    }
    _log.info("File system path: {} is not exported", path);
    return false;
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) FileObject(com.emc.storageos.db.client.model.FileObject) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Example 13 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method ddModifyExports.

private void ddModifyExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> modifyFileExports) {
    for (FileExport fileExport : modifyFileExports) {
        fileExport.setNativeId(exportMap.get(fileExport.getFileExportKey()).getNativeId());
        List<DDExportClientModify> ddExportClients = ddBuildModifyExportClientList(exportMap, fileExport);
        DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, fileExport.getNativeId());
        if (ddExport.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
            DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExport.getId());
            throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(ddExport.getPath());
        } else {
            DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, fileExport.getNativeId(), ddExportClients);
            FileExport existingExport = exportMap.get(fileExport.getFileExportKey());
            ddSetExistingExportProperties(existingExport, fileExport, ddExportInfo);
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) FileExport(com.emc.storageos.db.client.model.FileExport) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 14 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method isiExport.

/**
 * Create isilon exports
 *
 * @param isi
 *            IsilonApi object
 * @param args
 *            FileDeviceInputOutput object
 * @param exports
 *            new exports to add
 * @throws IsilonException
 */
private void isiExport(IsilonApi isi, FileDeviceInputOutput args, List<FileExport> exports) throws IsilonException {
    // process and export each NFSExport independently.
    for (FileExport fileExport : exports) {
        // create and set IsilonExport instance from NFSExport
        String permissions = fileExport.getPermissions();
        Set<String> orderedSecTypes = new TreeSet<String>();
        for (String securityType : fileExport.getSecurityType().split(",")) {
            securityType = securityType.trim();
            orderedSecTypes.add(securityType);
        }
        Iterator<String> orderedList = orderedSecTypes.iterator();
        String strCSSecurityType = orderedList.next().toString();
        while (orderedList.hasNext()) {
            strCSSecurityType += "," + orderedList.next().toString();
        }
        String root_user = fileExport.getRootUserMapping();
        String storagePortName = fileExport.getStoragePortName();
        String storagePort = fileExport.getStoragePort();
        String protocol = fileExport.getProtocol();
        String path = fileExport.getPath();
        String mountPath = fileExport.getMountPath();
        String comments = fileExport.getComments();
        String subDirectory = fileExport.getSubDirectory();
        List<String> securityTypes = new ArrayList<String>(orderedSecTypes);
        IsilonExport newIsilonExport = setIsilonExport(fileExport, permissions, securityTypes, root_user, mountPath, comments);
        _log.info("IsilonExport:" + fileExport.getClients() + ":" + fileExport.getStoragePortName() + ":" + fileExport.getStoragePort() + ":" + fileExport.getRootUserMapping() + ":" + fileExport.getPermissions() + ":" + fileExport.getProtocol() + ":" + fileExport.getSecurityType() + ":" + fileExport.getMountPoint() + ":" + fileExport.getPath() + ":" + fileExport.getSubDirectory() + ":" + fileExport.getComments());
        // Initialize exports map, if its not already initialized
        if (args.getFileObjExports() == null) {
            args.initFileObjExports();
        }
        String accessZoneName = getZoneName(args.getvNAS());
        // Create/update export in Isilon.
        String exportKey = fileExport.getFileExportKey();
        // If export with the given key does not exist, we create a new
        // export in Isilon and add it to the exports map.
        // In the other case, when export with a given key already exists in
        // Isilon, we need to overwrite endpoints in the current
        // export with endpoints in the
        // new export.
        FileExport fExport = args.getFileObjExports().get(exportKey);
        // check Isilon to verify if export does not exist.
        IsilonExport currentIsilonExport = null;
        if (fExport != null) {
            if (accessZoneName != null) {
                currentIsilonExport = isi.getExport(fExport.getIsilonId(), accessZoneName);
            } else {
                currentIsilonExport = isi.getExport(fExport.getIsilonId());
            }
        }
        if (fExport == null || currentIsilonExport == null) {
            // There is no Isilon export. Create Isilon export and set it
            // the map.
            String id = null;
            if (accessZoneName != null) {
                _log.debug("Export will be created in zone: {}", accessZoneName);
                id = isi.createExport(newIsilonExport, accessZoneName, args.getBypassDnsCheck());
            } else {
                id = isi.createExport(newIsilonExport, args.getBypassDnsCheck());
            }
            // set file export data and add it to the export map
            fExport = new FileExport(newIsilonExport.getClients(), storagePortName, mountPath, strCSSecurityType, permissions, root_user, protocol, storagePort, path, mountPath, subDirectory, comments);
            fExport.setIsilonId(id);
        } else {
            // There is export in Isilon with the given id.
            // Overwrite this export with a new set of clients.
            // We overwrite only clients element in exports. Isilon API does
            // not use read_only_clients, read_write_clients or
            // root_clients.
            List<String> newClients = newIsilonExport.getClients();
            newIsilonExport.setClients(new ArrayList<String>(newClients));
            // modify current export in isilon.
            if (accessZoneName != null) {
                isi.modifyExport(fExport.getIsilonId(), accessZoneName, newIsilonExport, args.getBypassDnsCheck());
            } else {
                isi.modifyExport(fExport.getIsilonId(), newIsilonExport, args.getBypassDnsCheck());
            }
            // update clients
            fExport.setClients(newIsilonExport.getClients());
        }
        args.getFileObjExports().put(exportKey, fExport);
    }
}
Also used : IsilonExport(com.emc.storageos.isilon.restapi.IsilonExport) TreeSet(java.util.TreeSet) FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList)

Example 15 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class IsilonFileStorageDevice method isiUnexport.

/**
 * Delete exports
 *
 * @param isi
 *            IsilonApi object to be used for communicating to the isilon
 *            system
 * @param currentExports
 *            Current exports map
 * @param exports
 *            exports to be deleted
 * @throws ControllerException
 * @throws IsilonException
 */
private void isiUnexport(IsilonApi isi, FileDeviceInputOutput args, List<FileExport> exports) throws ControllerException, IsilonException {
    FSExportMap currentExports = args.getFileObjExports();
    // Do nothing if there are no exports
    if (currentExports == null || exports == null || exports.isEmpty()) {
        return;
    }
    for (FileExport fileExport : exports) {
        // isiExportKey(req);
        String key = fileExport.getFileExportKey();
        String id = null;
        FileExport fExport = currentExports.get(key);
        if (fExport != null) {
            id = fExport.getIsilonId();
        }
        if (id != null) {
            String zoneName = getZoneName(args.getvNAS());
            if (zoneName != null) {
                isi.deleteExport(id, zoneName);
            } else {
                isi.deleteExport(id);
            }
            currentExports.remove(key);
        }
    }
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) FSExportMap(com.emc.storageos.db.client.model.FSExportMap)

Aggregations

FileExport (com.emc.storageos.db.client.model.FileExport)66 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)33 ArrayList (java.util.ArrayList)32 FileShare (com.emc.storageos.db.client.model.FileShare)31 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)29 Snapshot (com.emc.storageos.db.client.model.Snapshot)21 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)20 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)18 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)16 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)14 VNXeException (com.emc.storageos.vnxe.VNXeException)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 URI (java.net.URI)10 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)8 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)8 FileObject (com.emc.storageos.db.client.model.FileObject)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7