Search in sources :

Example 16 with UnManagedFileSystem

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

the class NetAppFileCommunicationInterface method checkUnManagedFileSystemExistsInDB.

/**
 * check Pre Existing Storage filesystem exists in DB
 *
 * @param nativeGuid
 * @return unManageFileSystem
 * @throws IOException
 */
protected UnManagedFileSystem checkUnManagedFileSystemExistsInDB(String nativeGuid) {
    UnManagedFileSystem filesystemInfo = null;
    URIQueryResultList result = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemInfoNativeGUIdConstraint(nativeGuid), result);
    List<URI> filesystemUris = new ArrayList<URI>();
    Iterator<URI> iter = result.iterator();
    while (iter.hasNext()) {
        URI unFileSystemtURI = iter.next();
        filesystemUris.add(unFileSystemtURI);
    }
    if (!filesystemUris.isEmpty()) {
        filesystemInfo = _dbClient.queryObject(UnManagedFileSystem.class, filesystemUris.get(0));
    }
    return filesystemInfo;
}
Also used : ArrayList(java.util.ArrayList) URI(java.net.URI) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 17 with UnManagedFileSystem

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

the class VNXeUnManagedObjectDiscoverer method discoverAllCifsShares.

public void discoverAllCifsShares(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxeClient(accessProfile);
    log.info("discoverAllCifsShares for storage system {} - start", storageSystem.getId());
    unManagedCifsAclInsert = new ArrayList<UnManagedCifsShareACL>();
    unManagedCifsAclUpdate = new ArrayList<UnManagedCifsShareACL>();
    List<VNXeCifsShare> cifsExports = apiClient.getAllCifsShares();
    for (VNXeCifsShare exp : cifsExports) {
        log.info("Discovered fS share {}", 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 mountPoint = "\\\\" + storagePort.getPortNetworkId() + "\\" + exp.getName();
                String cifsShareId = exp.getId();
                associateCifsExportWithUMFS(unManagedFs, mountPoint, exp, storagePort);
                List<UnManagedCifsShareACL> cifsACLs = applyCifsSecurityRules(unManagedFs, mountPoint, exp, storagePort);
                log.info("Number of export rules discovered for file system {} is {}", unManagedFs.getId() + ":" + unManagedFs.getLabel(), cifsACLs.size());
                for (UnManagedCifsShareACL cifsAcl : cifsACLs) {
                    log.info("Unmanaged File share acls : {}", cifsAcl);
                    String fsShareNativeId = cifsAcl.getFileSystemShareACLIndex();
                    log.info("UMFS Share ACL index {}", fsShareNativeId);
                    String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
                    log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
                    cifsAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
                    // Check whether the CIFS share ACL was present in ViPR DB.
                    UnManagedCifsShareACL existingACL = checkUnManagedFsCifsACLExistsInDB(dbClient, cifsAcl.getNativeGuid());
                    if (existingACL == null) {
                        unManagedCifsAclInsert.add(cifsAcl);
                    } else {
                        unManagedCifsAclInsert.add(cifsAcl);
                        existingACL.setInactive(true);
                        unManagedCifsAclUpdate.add(existingACL);
                    }
                }
                // Persist the UMFS as it changed the SMB Share Map.
                unManagedFs.setHasShares(true);
                unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), Boolean.TRUE.toString());
                dbClient.persistObject(unManagedFs);
            } catch (IOException e) {
                log.error("IOException occured in discoverAllCifsShares()", e);
            }
        }
    }
    if (!unManagedCifsAclInsert.isEmpty()) {
        // Add UnManagedFileSystem
        partitionManager.insertInBatches(unManagedCifsAclInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_CIFS_SHARE_ACL);
        unManagedCifsAclInsert.clear();
    }
    if (!unManagedCifsAclUpdate.isEmpty()) {
        // Update UnManagedFilesystem
        partitionManager.updateInBatches(unManagedCifsAclUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_CIFS_SHARE_ACL);
        unManagedCifsAclUpdate.clear();
    }
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) IOException(java.io.IOException) VNXeCifsShare(com.emc.storageos.vnxe.models.VNXeCifsShare) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 18 with UnManagedFileSystem

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

the class VNXeUnManagedObjectDiscoverer method discoverUnManagedFileSystems.

public void discoverUnManagedFileSystems(AccessProfile accessProfile, DbClient dbClient, CoordinatorClient coordinator, PartitionManager partitionManager) throws Exception {
    log.info("Started discovery of UnManagedFilesystems for system {}", accessProfile.getSystemId());
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxeClient(accessProfile);
    unManagedFilesystemsInsert = new ArrayList<UnManagedFileSystem>();
    unManagedFilesystemsUpdate = new ArrayList<UnManagedFileSystem>();
    List<VNXeFileSystem> filesystems = apiClient.getAllFileSystems();
    if (filesystems != null && !filesystems.isEmpty()) {
        Map<String, StoragePool> pools = getStoragePoolMap(storageSystem, dbClient);
        for (VNXeFileSystem fs : filesystems) {
            StoragePort storagePort = getStoragePortPool(storageSystem, dbClient, apiClient, fs);
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fs.getId());
            StoragePool pool = getStoragePoolOfUnManagedObject(fs.getPool().getId(), storageSystem, pools);
            if (null == pool) {
                log.error("Skipping unmanaged volume discovery as the file system {} storage pool doesn't exist in ViPR", fs.getId());
                continue;
            }
            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);
            unManagedFs = createUnManagedFileSystem(unManagedFs, fsUnManagedFsNativeGuid, storageSystem, pool, storagePort, fs, dbClient);
            unManagedFilesystemsReturnedFromProvider.add(unManagedFs.getId());
        }
        if (!unManagedFilesystemsInsert.isEmpty()) {
            // Add UnManagedFileSystem
            partitionManager.insertInBatches(unManagedFilesystemsInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
        }
        if (!unManagedFilesystemsUpdate.isEmpty()) {
            // Update UnManagedFilesystem
            partitionManager.updateAndReIndexInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
        }
        // Process those active unmanaged fs objects available in database but not in newly discovered items, to mark them inactive.
        performStorageUnManagedFSBookKeeping(storageSystem, dbClient, partitionManager);
    } else {
        log.info("There are no file systems found on the system: {}", storageSystem.getId());
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileSystem(com.emc.storageos.vnxe.models.VNXeFileSystem) StoragePort(com.emc.storageos.db.client.model.StoragePort) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with UnManagedFileSystem

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

the class VNXeUnManagedObjectDiscoverer method checkUnManagedFileSystemExistsInDB.

/**
 * check Pre Existing Storage filesystem exists in DB
 *
 * @param nativeGuid
 * @return unManageFileSystem
 * @throws IOException
 */
protected UnManagedFileSystem checkUnManagedFileSystemExistsInDB(DbClient dbClient, String nativeGuid) throws IOException {
    UnManagedFileSystem filesystemInfo = null;
    URIQueryResultList result = new URIQueryResultList();
    dbClient.queryByConstraint(AlternateIdConstraint.Factory.getFileSystemInfoNativeGUIdConstraint(nativeGuid), result);
    Iterator<URI> iter = result.iterator();
    while (iter.hasNext()) {
        URI unFileSystemtURI = iter.next();
        filesystemInfo = dbClient.queryObject(UnManagedFileSystem.class, unFileSystemtURI);
        return filesystemInfo;
    }
    return filesystemInfo;
}
Also used : URI(java.net.URI) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 20 with UnManagedFileSystem

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

the class VNXeUnManagedObjectDiscoverer method discoverAllExportRules.

public void discoverAllExportRules(AccessProfile accessProfile, DbClient dbClient, PartitionManager partitionManager) {
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
    VNXeApiClient apiClient = getVnxeClient(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.getParentFilesystem() != null) {
            fs = apiClient.getFileSystemByFSId(exp.getParentFilesystem().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() && unManagedExportRulesInsert.size() >= Constants.DEFAULT_PARTITION_SIZE) {
            // Add UnManage export rules
            partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
            unManagedExportRulesInsert.clear();
        }
        if (!unManagedExportRulesUpdate.isEmpty() && unManagedExportRulesUpdate.size() >= Constants.DEFAULT_PARTITION_SIZE) {
            // Update UnManage export rules
            partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
            unManagedExportRulesUpdate.clear();
        }
        if (!unManagedFilesystemsUpdate.isEmpty() && unManagedFilesystemsUpdate.size() >= Constants.DEFAULT_PARTITION_SIZE) {
            // Update UnManagedFilesystem
            partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
            unManagedFilesystemsUpdate.clear();
        }
    }
    if (!unManagedExportRulesInsert.isEmpty()) {
        // Add UnManage export rules
        partitionManager.insertInBatches(unManagedExportRulesInsert, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
        unManagedExportRulesInsert.clear();
    }
    if (!unManagedExportRulesUpdate.isEmpty()) {
        // Update UnManage export rules
        partitionManager.updateInBatches(unManagedExportRulesUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_EXPORT_RULE);
        unManagedExportRulesUpdate.clear();
    }
    if (!unManagedFilesystemsUpdate.isEmpty()) {
        // Update UnManagedFilesystem
        partitionManager.updateInBatches(unManagedFilesystemsUpdate, Constants.DEFAULT_PARTITION_SIZE, dbClient, UNMANAGED_FILESYSTEM);
        unManagedFilesystemsUpdate.clear();
    }
}
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

UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)48 URI (java.net.URI)27 ArrayList (java.util.ArrayList)27 HashMap (java.util.HashMap)25 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)21 IOException (java.io.IOException)21 StoragePort (com.emc.storageos.db.client.model.StoragePort)20 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 StringMap (com.emc.storageos.db.client.model.StringMap)18 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)18 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)16 StringSet (com.emc.storageos.db.client.model.StringSet)14 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)13 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)12 HashSet (java.util.HashSet)12 UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)11 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)10 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)10 Map (java.util.Map)10 StoragePool (com.emc.storageos.db.client.model.StoragePool)9