Search in sources :

Example 6 with VNXeNfsShare

use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.

the class VNXeApiClient method getNfsShareById.

/**
 * Find nfsShare using share Id
 *
 * @param shareId
 *            NFS Share Id
 * @return nfsShare
 */
public VNXeNfsShare getNfsShareById(String shareId) {
    _logger.info("finding nfsShare id: {} ", shareId);
    NfsShareRequests req = new NfsShareRequests(_khClient);
    VNXeNfsShare share = req.getShareById(shareId);
    if (share != null) {
        _logger.info("Got the nfsShare: {}", share.getId());
    } else {
        _logger.info("Could not find nfsShare by Id: {}", shareId);
    }
    return share;
}
Also used : NfsShareRequests(com.emc.storageos.vnxe.requests.NfsShareRequests) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare)

Example 7 with VNXeNfsShare

use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.

the class VNXeApiClient method findNfsShare.

/**
 * Find nfsShare using file system Id and vipr exportKey
 *
 * @param fsId
 *            file system Id
 * @param exportKey
 *            vipr exportKey
 * @return nfsShare Id
 */
public VNXeNfsShare findNfsShare(String fsId, String shareName) {
    _logger.info("finding nfsShare id for file system id: {}, and nameKey: {} ", fsId, shareName);
    NfsShareRequests req = new NfsShareRequests(_khClient);
    VNXeNfsShare share = req.findNfsShare(fsId, shareName, getBasicSystemInfo().getSoftwareVersion());
    return share;
}
Also used : NfsShareRequests(com.emc.storageos.vnxe.requests.NfsShareRequests) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare)

Example 8 with VNXeNfsShare

use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.

the class NfsShareRequests method findNfsShare.

/**
 * find nfsShare using fileSystem id and share name
 *
 * @param fsId fileSystem Id
 * @param shareName
 * @return
 */
public VNXeNfsShare findNfsShare(String fsId, String shareName, String softwareVersion) {
    VNXeNfsShare result = null;
    StringBuilder queryFilter = new StringBuilder(VNXeConstants.NAME_FILTER);
    if (!VNXeUtils.isHigherVersion(softwareVersion, VNXeConstants.VNXE_BASE_SOFT_VER)) {
        queryFilter.append(shareName);
        queryFilter.append(VNXeConstants.AND);
        queryFilter.append(VNXeConstants.FILE_SYSTEM_FILTER);
        queryFilter.append(fsId);
    } else {
        queryFilter.append("\"" + shareName + "\"");
        queryFilter.append(VNXeConstants.AND);
        queryFilter.append(VNXeConstants.FILE_SYSTEM_FILTER_V31);
        queryFilter.append("\"" + fsId + "\"");
    }
    setFilter(queryFilter.toString());
    List<VNXeNfsShare> shareList = getDataForObjects(VNXeNfsShare.class);
    if (shareList != null && !shareList.isEmpty()) {
        result = shareList.get(0);
        _logger.info("File system : {} NFS share named : {} found", fsId, shareName);
    } else {
        _logger.info("No file system share found using the fs id: {}, nfsShare name: {} ", fsId, shareName);
    }
    return result;
}
Also used : VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare)

Example 9 with VNXeNfsShare

use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.

the class NfsShareRequests method findSnapNfsShare.

/**
 * find Snapshot nfsShare using snapshot id and share name
 *
 * @param snapId
 * @param shareName
 * @return VNXeNfsShare
 */
public VNXeNfsShare findSnapNfsShare(String snapId, String shareName, String softwareVersion) {
    StringBuilder queryFilter = new StringBuilder(VNXeConstants.NAME_FILTER);
    if (!VNXeUtils.isHigherVersion(softwareVersion, VNXeConstants.VNXE_BASE_SOFT_VER)) {
        queryFilter.append(shareName);
        queryFilter.append(VNXeConstants.AND);
        queryFilter.append(VNXeConstants.SNAP_FILTER);
        queryFilter.append(snapId);
    } else {
        queryFilter.append("\"" + shareName + "\"");
        queryFilter.append(VNXeConstants.AND);
        queryFilter.append(VNXeConstants.SNAP_FILTER_V31);
        queryFilter.append("\"" + snapId + "\"");
    }
    setFilter(queryFilter.toString());
    VNXeNfsShare result = null;
    // it should just return 1
    List<VNXeNfsShare> shareList = getDataForObjects(VNXeNfsShare.class);
    if (shareList != null && !shareList.isEmpty()) {
        result = shareList.get(0);
        _logger.info("Snapshot : {} NFS share named : {} found", snapId, shareName);
    } else {
        _logger.info("No snapshot share found using the snapId : {}, nfsShare name: {} ", snapId, shareName);
    }
    return result;
}
Also used : VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare)

Example 10 with VNXeNfsShare

use of com.emc.storageos.vnxe.models.VNXeNfsShare in project coprhd-controller by CoprHD.

the class VNXUnityUnManagedObjectDiscoverer method discoverAllExportRules.

public void discoverAllExportRules(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxUnityClient(accessProfile);
    log.info("discoverAllExportRules for storage system {} - start", storageSystem.getId());
    unManagedExportRulesInsert = new ArrayList<UnManagedFileExportRule>();
    unManagedExportRulesUpdate = new ArrayList<UnManagedFileExportRule>();
    unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
    List<VNXeNfsShare> nfsExports = apiClient.getAllNfsShares();
    // Verification Utility
    UnManagedExportVerificationUtility validationUtility = new UnManagedExportVerificationUtility(dbClient);
    for (VNXeNfsShare exp : nfsExports) {
        log.info("Discovered fS export {}", exp.toString());
        VNXeFileSystem fs = null;
        if (exp.getFilesystem() != null) {
            fs = apiClient.getFileSystemByFSId(exp.getFilesystem().getId());
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
            try {
                if (checkStorageFileSystemExistsInDB(fsNativeGuid, dbClient)) {
                    log.info("Skipping file system {} as it is already managed by ViPR", fsNativeGuid);
                    continue;
                }
                // Create UnManaged FS
                String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fs.getId());
                UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(dbClient, fsUnManagedFsNativeGuid);
                StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
                String mountPath = extractValueFromStringSet(SupportedFileSystemInformation.MOUNT_PATH.toString(), unManagedFs.getFileSystemInformation());
                String exportPath = exp.getPath();
                if (!exportPath.equalsIgnoreCase("/")) {
                    mountPath = mountPath + exportPath;
                }
                String mountPoint = storagePort.getPortNetworkId() + ":" + mountPath;
                String nfsShareId = exp.getId();
                String fsUnManagedFileExportRuleNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileExportRule(storageSystem, nfsShareId);
                log.info("Native GUID {}", fsUnManagedFileExportRuleNativeGuid);
                UnManagedFileExportRule unManagedExportRule = checkUnManagedFsExportRuleExistsInDB(dbClient, fsUnManagedFileExportRuleNativeGuid);
                UnManagedFileExportRule unManagedExpRule = null;
                List<UnManagedFileExportRule> unManagedExportRules = new ArrayList<UnManagedFileExportRule>();
                if (unManagedExportRule == null) {
                    unManagedExportRule = new UnManagedFileExportRule();
                    unManagedExportRule.setNativeGuid(fsUnManagedFileExportRuleNativeGuid);
                    unManagedExportRule.setFileSystemId(unManagedFs.getId());
                    unManagedExportRule.setId(URIUtil.createId(UnManagedFileExportRule.class));
                    unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
                    unManagedExportRulesInsert.add(unManagedExpRule);
                } else {
                    unManagedExpRule = createExportRules(unManagedFs.getId(), apiClient, exp, unManagedExportRule, mountPath, mountPoint, nfsShareId, storagePort.getPortName());
                    unManagedExportRulesUpdate.add(unManagedExpRule);
                }
                log.info("Unmanaged File Export Rule : {}", unManagedExportRule);
                // Build all export rules list.
                unManagedExportRules.add(unManagedExpRule);
                // apply as per API SVC Validations.
                if (!unManagedExportRules.isEmpty()) {
                    boolean isAllRulesValid = validationUtility.validateUnManagedExportRules(unManagedExportRules, false);
                    if (isAllRulesValid) {
                        log.info("Validating rules success for export {}", unManagedFs.getPath());
                        unManagedFs.setHasExports(true);
                        unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.TRUE.toString());
                        unManagedFilesystemsUpdate.add(unManagedFs);
                        log.info("File System {} has Exports and their size is {}", unManagedFs.getId(), unManagedExportRules.size());
                    } else {
                        log.warn("Validating rules failed for export {}. Ignroing to import these rules into ViPR DB", unManagedFs);
                        unManagedFs.setInactive(true);
                        unManagedFilesystemsUpdate.add(unManagedFs);
                    }
                }
            } catch (IOException e) {
                log.error("IOException occured in discoverAllExportRules()", e);
            }
        }
    }
    if (!unManagedExportRulesInsert.isEmpty()) {
        // Add UnManage export rules
        partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
    }
    if (!unManagedExportRulesUpdate.isEmpty()) {
        // Update UnManage export rules
        partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
    }
    if (!unManagedFilesystemsUpdate.isEmpty()) {
        // Update UnManagedFilesystem
        partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
    }
}
Also used : UnManagedExportVerificationUtility(com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility) UnManagedFileExportRule(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) IOException(java.io.IOException) VNXeNfsShare(com.emc.storageos.vnxe.models.VNXeNfsShare) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Aggregations

VNXeNfsShare (com.emc.storageos.vnxe.models.VNXeNfsShare)19 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 NfsShareRequests (com.emc.storageos.vnxe.requests.NfsShareRequests)6 ArrayList (java.util.ArrayList)6 VNXeBase (com.emc.storageos.vnxe.models.VNXeBase)4 VNXeFileSystem (com.emc.storageos.vnxe.models.VNXeFileSystem)4 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)3 VNXeFileSystemSnap (com.emc.storageos.vnxe.models.VNXeFileSystemSnap)3 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 Snapshot (com.emc.storageos.db.client.model.Snapshot)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 UnManagedFileExportRule (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileExportRule)2 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)2 ExportRule (com.emc.storageos.model.file.ExportRule)2 NFSShareDefaultAccessEnum (com.emc.storageos.vnxe.models.NfsShareParam.NFSShareDefaultAccessEnum)2 VNXeCifsShare (com.emc.storageos.vnxe.models.VNXeCifsShare)2 VNXeHost (com.emc.storageos.vnxe.models.VNXeHost)2 UnManagedExportVerificationUtility (com.emc.storageos.volumecontroller.impl.utils.UnManagedExportVerificationUtility)2 IOException (java.io.IOException)2