Search in sources :

Example 1 with UnManagedSMBShareMap

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

the class PropertySetterUtil method convertUnManagedSMBMapToManaged.

/**
 * Extract SMB data from UnManaged to Managed
 *
 * @param unManagedSMBShareMap
 * @return
 */
public static SMBShareMap convertUnManagedSMBMapToManaged(UnManagedSMBShareMap unManagedSMBShareMap, StoragePort storagePort, StorageHADomain dataMover) {
    SMBShareMap smbShareMap = new SMBShareMap();
    if (unManagedSMBShareMap == null) {
        return smbShareMap;
    }
    SMBFileShare smbshare = null;
    for (UnManagedSMBFileShare unManagedSMBFileShare : unManagedSMBShareMap.values()) {
        smbshare = new SMBFileShare();
        smbshare.setName(unManagedSMBFileShare.getName());
        smbshare.setNativeId(unManagedSMBFileShare.getNativeId());
        smbshare.setDescription(unManagedSMBFileShare.getDescription());
        if (storagePort != null) {
            smbshare.setMountPoint("\\\\" + storagePort.getPortNetworkId() + "\\" + unManagedSMBFileShare.getName());
        } else {
            smbshare.setMountPoint(unManagedSMBFileShare.getMountPoint());
        }
        smbshare.setPath(unManagedSMBFileShare.getPath());
        // need to removed
        smbshare.setMaxUsers(unManagedSMBFileShare.getMaxUsers());
        smbshare.setPermission(unManagedSMBFileShare.getPermission());
        smbshare.setPermissionType(unManagedSMBFileShare.getPermissionType());
        smbshare.setPortGroup(storagePort.getPortGroup());
        // share name
        smbShareMap.put(unManagedSMBFileShare.getName(), smbshare);
    }
    return smbShareMap;
}
Also used : UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)

Example 2 with UnManagedSMBShareMap

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

the class DataDomainCommunicationInterface method associateCifsExportWithFS.

private void associateCifsExportWithFS(UnManagedFileSystem ddufs, DDShareInfoDetail share, StoragePort storagePort) {
    try {
        // Assign storage port to unmanaged FS
        if (storagePort != null) {
            StringSet storagePorts = new StringSet();
            storagePorts.add(storagePort.getId().toString());
            ddufs.getFileSystemInformation().remove(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
            ddufs.getFileSystemInformation().put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
        }
        String shareName = share.getName();
        String mountPoint = getMountPount(shareName, storagePort);
        UnManagedSMBFileShare unManagedSMBFileShare = new UnManagedSMBFileShare();
        unManagedSMBFileShare.setName(shareName);
        unManagedSMBFileShare.setMountPoint(mountPoint);
        // unManagedSMBFileShare.setDescription(share.ge);
        int maxUsers = Integer.MAX_VALUE;
        unManagedSMBFileShare.setMaxUsers(maxUsers);
        unManagedSMBFileShare.setPortGroup(storagePort.getPortGroup());
        unManagedSMBFileShare.setPermission(ShareACL.SupportedPermissions.change.toString());
        // setting to default permission type for DDMC
        unManagedSMBFileShare.setPermissionType(FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW);
        unManagedSMBFileShare.setPath(share.getPath());
        UnManagedSMBShareMap currUnManagedShareMap = ddufs.getUnManagedSmbShareMap();
        if (currUnManagedShareMap == null) {
            currUnManagedShareMap = new UnManagedSMBShareMap();
            ddufs.setUnManagedSmbShareMap(currUnManagedShareMap);
        }
        if (currUnManagedShareMap.get(shareName) == null) {
            currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
            _log.info("associateCifsExportWithFS - no SMBs already exists for share {}", shareName);
        } else {
            // Remove the existing and add the new share
            currUnManagedShareMap.remove(shareName);
            currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
            _log.warn("associateSMBShareMapWithFS - Identical export already exists for mount path {} Overwrite", shareName);
        }
    } catch (Exception ex) {
        _log.warn("VNX file share retrieve processor failed for path {}, cause {}", share.getPath(), ex);
    }
}
Also used : UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSet(com.emc.storageos.db.client.model.StringSet) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) IOException(java.io.IOException)

Example 3 with UnManagedSMBShareMap

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

the class NetAppClusterModeCommIntf method discoverUnManagedCifsShares.

/**
 * discover the unmanaged cifs shares and add shares to ViPR db
 *
 * @param profile
 */
private void discoverUnManagedCifsShares(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.IN_PROGRESS.toString());
    String detailedStatusMessage = "Discovery of NetAppC Unmanaged Cifs started";
    NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    Collection<String> attrs = new ArrayList<String>();
    for (String property : ntpPropertiesList) {
        attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
    }
    try {
        // Used to Save the Acl to DB
        List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        List<UnManagedCifsShareACL> oldunManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet = null;
        List<Map<String, String>> fileSystemInfo = netAppCApi.listVolumeInfo(null, attrs);
        List<StorageVirtualMachineInfo> svms = netAppCApi.listSVM();
        for (StorageVirtualMachineInfo svmInfo : svms) {
            netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).svm(svmInfo.getName()).build();
            // Get All cifs shares and ACLs
            List<Map<String, String>> listShares = netAppCApi.listShares(null);
            if (listShares != null && !listShares.isEmpty()) {
                _logger.info("total no of shares in netappC system (s) {}", listShares.size());
            }
            // prepare the unmanagedSmbshare
            HashMap<String, HashSet<UnManagedSMBFileShare>> unMangedSMBFileShareMapSet = getAllCifsShares(listShares);
            for (String key : unMangedSMBFileShareMapSet.keySet()) {
                unManagedSMBFileShareHashSet = unMangedSMBFileShareMapSet.get(key);
                String fileSystem = key;
                String nativeId = fileSystem;
                // get a fileSystem name from the path
                int index = fileSystem.indexOf('/', 1);
                if (-1 != index) {
                    fileSystem = fileSystem.substring(0, index);
                    _logger.info("Unmanaged FileSystem Name {}", fileSystem);
                }
                // build native id
                String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), fileSystem);
                UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
                boolean fsAlreadyExists = unManagedFs == null ? false : true;
                if (fsAlreadyExists) {
                    _logger.debug("retrieve info for file system: " + fileSystem);
                    String svm = getOwningSVM(fileSystem, fileSystemInfo);
                    String addr = getSVMAddress(svm, svms);
                    UnManagedSMBShareMap tempUnManagedSMBShareMap = new UnManagedSMBShareMap();
                    // get the SMB shares
                    createSMBShareMap(unManagedSMBFileShareHashSet, tempUnManagedSMBShareMap, addr, nativeId);
                    // add shares to fs object and set hasShare to true
                    if (tempUnManagedSMBShareMap.size() > 0 && !tempUnManagedSMBShareMap.isEmpty()) {
                        unManagedFs.setUnManagedSmbShareMap(tempUnManagedSMBShareMap);
                        unManagedFs.setHasShares(true);
                        unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                        _logger.debug("SMB Share map for NetAppC UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getUnManagedSmbShareMap());
                    }
                    // get the acls details for given fileshare of given fs
                    UnManagedCifsShareACL existingACL = null;
                    List<UnManagedCifsShareACL> tempUnManagedCifsShareAclList = getACLs(unManagedSMBFileShareHashSet, netAppCApi, storageSystem, unManagedFs.getId());
                    if (tempUnManagedCifsShareAclList != null && !tempUnManagedCifsShareAclList.isEmpty()) {
                        for (UnManagedCifsShareACL unManagedCifsShareACL : tempUnManagedCifsShareAclList) {
                            // Check whether the CIFS share ACL was present in ViPR DB.
                            existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
                            if (existingACL == null) {
                                // add new acl
                                unManagedCifsShareACLList.add(unManagedCifsShareACL);
                            } else {
                                // delete the existing acl by setting object to inactive to true
                                existingACL.setInactive(true);
                                oldunManagedCifsShareACLList.add(existingACL);
                                // then add new acl and save
                                unManagedCifsShareACLList.add(unManagedCifsShareACL);
                            }
                        }
                    }
                    // store or update the FS object into DB
                    if (unManagedSMBFileShareHashSet != null && !unManagedSMBFileShareHashSet.isEmpty()) {
                        _dbClient.persistObject(unManagedFs);
                        _logger.info("File System {} has Shares and their Count is {}", unManagedFs.getId(), tempUnManagedSMBShareMap.size());
                    }
                    // Adding this additional logic to avoid OOM
                    if (unManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                        _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
                        _partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
                        unManagedCifsShareACLList.clear();
                    }
                    if (!oldunManagedCifsShareACLList.isEmpty() && oldunManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                        _logger.info("Update Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
                        _partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
                        oldunManagedCifsShareACLList.clear();
                    }
                } else {
                    _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + fileSystem + " share");
                }
            }
        }
        if (unManagedCifsShareACLList != null && !unManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
            _partitionManager.insertInBatches(unManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
            unManagedCifsShareACLList.clear();
        }
        if (oldunManagedCifsShareACLList != null && !oldunManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
            _partitionManager.updateInBatches(oldunManagedCifsShareACLList, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_SHARE_ACL);
            oldunManagedCifsShareACLList.clear();
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetAppC: %s", storageSystemId.toString());
    } catch (NetAppCException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed.  Storage system: " + storageSystemId);
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) ArrayList(java.util.ArrayList) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) NetAppCException(com.emc.storageos.netappc.NetAppCException) StorageVirtualMachineInfo(com.iwave.ext.netappc.StorageVirtualMachineInfo) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 4 with UnManagedSMBShareMap

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

the class NetAppFileCommunicationInterface method discoverUnManagedCifsShares.

/**
 * discover the unmanaged cifs shares and add shares to vipr db
 *
 * @param profile
 */
private void discoverUnManagedCifsShares(AccessProfile profile) {
    URI systemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, systemId);
    if (null == storageSystem) {
        return;
    }
    String detailedStatusMessage = "Discovery of NetApp Unmanaged Cifs shares started";
    NetAppApi netAppApi = new NetAppApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    Collection<String> attrs = new ArrayList<String>();
    for (String property : ntpPropertiesList) {
        attrs.add(SupportedNtpFileSystemInformation.getFileSystemInformation(property));
    }
    try {
        // Used to Save the Acl to DB
        List<UnManagedCifsShareACL> unManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        List<UnManagedCifsShareACL> oldunManagedCifsShareACLList = new ArrayList<UnManagedCifsShareACL>();
        List<Map<String, String>> fileSystemInfo = netAppApi.listVolumeInfo(null, attrs);
        List<VFilerInfo> vFilers = netAppApi.listVFilers(null);
        // Get All cifs shares and ACLs
        List<Map<String, String>> listShares = netAppApi.listShares(null);
        if (listShares != null && !listShares.isEmpty()) {
            _logger.info("total no of shares in netapp system (s) {}", listShares.size());
        }
        HashSet<UnManagedSMBFileShare> unManagedSMBFileShareHashSet = null;
        // prepare the unmanagedSmbshare
        HashMap<String, HashSet<UnManagedSMBFileShare>> unMangedSMBFileShareMapSet = getAllCifsShares(listShares);
        for (String key : unMangedSMBFileShareMapSet.keySet()) {
            String filesystem = key;
            unManagedSMBFileShareHashSet = unMangedSMBFileShareMapSet.get(key);
            _logger.info("FileSystem Path {}", filesystem);
            String nativeId = null;
            if (!filesystem.startsWith(VOL_ROOT_NO_SLASH)) {
                nativeId = VOL_ROOT_NO_SLASH + filesystem;
            } else {
                nativeId = filesystem;
            }
            // Ignore root volume and don't pull it into ViPR db.
            if (filesystem.contains(ROOT_VOL)) {
                _logger.info("Ignore and not discover root filesystem {} on NTP array", filesystem);
                continue;
            }
            // Ignore snapshots and don't pull it into ViPR db.
            if (filesystem.contains(SNAPSHOT)) {
                _logger.info("Ignore exports for snapshot {}", filesystem);
                continue;
            }
            String shareNativeId = getFSPathIfSubDirectoryExport(nativeId);
            String fsUnManagedFsNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileSystem(storageSystem.getSystemType(), storageSystem.getSerialNumber().toUpperCase(), shareNativeId);
            UnManagedFileSystem unManagedFs = checkUnManagedFileSystemExistsInDB(fsUnManagedFsNativeGuid);
            boolean fsAlreadyExists = unManagedFs == null ? false : true;
            if (fsAlreadyExists) {
                _logger.info("retrieve info for file system: " + filesystem);
                String vFiler = getOwningVfiler(filesystem, fileSystemInfo);
                if (vFiler != null && !vFiler.equalsIgnoreCase(DEFAULT_FILER)) {
                    _logger.info("Ignoring {} because it is owned by {}", filesystem, vFiler);
                    continue;
                }
                String addr = null;
                if (vFiler == null || vFiler.isEmpty()) {
                    // No vfilers, use system storage port
                    StoragePort port = getStoragePortPool(storageSystem);
                    addr = port.getPortName();
                } else {
                    // Use IP address of vFiler.
                    addr = getVfilerAddress(vFiler, vFilers);
                }
                UnManagedSMBShareMap tempUnManagedSMBShareMap = new UnManagedSMBShareMap();
                // add smb shares to FS object
                createShareMap(unManagedSMBFileShareHashSet, tempUnManagedSMBShareMap, addr, nativeId);
                // add shares to fs object
                if (!tempUnManagedSMBShareMap.isEmpty() && tempUnManagedSMBShareMap.size() > 0) {
                    unManagedFs.setUnManagedSmbShareMap(tempUnManagedSMBShareMap);
                    unManagedFs.setHasShares(true);
                    unManagedFs.putFileSystemCharacterstics(UnManagedFileSystem.SupportedFileSystemCharacterstics.IS_FILESYSTEM_EXPORTED.toString(), TRUE);
                    _logger.debug("SMB Share map for NetApp UMFS {} = {}", unManagedFs.getLabel(), unManagedFs.getUnManagedSmbShareMap());
                }
                List<UnManagedCifsShareACL> tempUnManagedCifsShareAclList = getACLs(unManagedSMBFileShareHashSet, netAppApi, unManagedFs.getId());
                // get the acl details for given fileshare
                UnManagedCifsShareACL existingACL = null;
                for (UnManagedCifsShareACL unManagedCifsShareACL : tempUnManagedCifsShareAclList) {
                    _logger.info("Unmanaged File share acls : {}", unManagedCifsShareACL);
                    String fsShareNativeId = unManagedCifsShareACL.getFileSystemShareACLIndex();
                    _logger.info("UMFS Share ACL index {}", fsShareNativeId);
                    String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
                    _logger.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
                    unManagedCifsShareACL.setNativeGuid(fsUnManagedFileShareNativeGuid);
                    // Check whether the CIFS share ACL was present in ViPR DB.
                    existingACL = checkUnManagedFsCifsACLExistsInDB(_dbClient, unManagedCifsShareACL.getNativeGuid());
                    if (existingACL == null) {
                        unManagedCifsShareACLList.add(unManagedCifsShareACL);
                    } else {
                        // delete the existing acl
                        existingACL.setInactive(true);
                        oldunManagedCifsShareACLList.add(existingACL);
                        // then add new acl
                        unManagedCifsShareACLList.add(unManagedCifsShareACL);
                    }
                }
                // save the object
                {
                    _dbClient.persistObject(unManagedFs);
                    _logger.info("File System {} has Shares and their Count is {}", unManagedFs.getId(), tempUnManagedSMBShareMap.size());
                }
                // Adding this additional logic to avoid OOM
                if (!unManagedCifsShareACLList.isEmpty() && unManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                    _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
                    _dbClient.createObject(unManagedCifsShareACLList);
                    unManagedCifsShareACLList.clear();
                }
                if (!oldunManagedCifsShareACLList.isEmpty() && oldunManagedCifsShareACLList.size() >= MAX_UMFS_RECORD_SIZE) {
                    _logger.info("Update Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
                    _dbClient.persistObject(oldunManagedCifsShareACLList);
                    oldunManagedCifsShareACLList.clear();
                }
            } else {
                _logger.info("FileSystem " + unManagedFs + "is not present in ViPR DB. Hence ignoring " + filesystem + " share");
            }
        }
        // 
        if (!unManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of New UnManagedCifsShareACL(s) {}", unManagedCifsShareACLList.size());
            _dbClient.createObject(unManagedCifsShareACLList);
        }
        if (!oldunManagedCifsShareACLList.isEmpty()) {
            _logger.info("Saving Number of Old UnManagedCifsShareACL(s) {}", oldunManagedCifsShareACLList.size());
            _dbClient.persistObject(oldunManagedCifsShareACLList);
        }
        storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.COMPLETE.toString());
        // discovery succeeds
        detailedStatusMessage = String.format("Discovery completed successfully for NetApp: %s", systemId.toString());
    } catch (NetAppException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed.  Storage system: " + systemId);
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
            storageSystem.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.ERROR.toString());
        }
        _logger.error("discoverStorage failed. Storage system: " + systemId, e);
    } finally {
        if (storageSystem != null) {
            try {
                // set detailed message
                storageSystem.setLastDiscoveryStatusMessage(detailedStatusMessage);
                _dbClient.persistObject(storageSystem);
            } catch (Exception ex) {
                _logger.error("Error while persisting object to DB", ex);
            }
        }
    }
}
Also used : UnManagedCifsShareACL(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) NetAppException(com.emc.storageos.netapp.NetAppException) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException) VFilerInfo(com.iwave.ext.netapp.VFilerInfo) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) NetAppApi(com.emc.storageos.netapp.NetAppApi) UnManagedFSExportMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringMap(com.emc.storageos.db.client.model.StringMap) UnManagedFileSystem(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) HashSet(java.util.HashSet)

Example 5 with UnManagedSMBShareMap

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

the class VNXFileCommunicationInterface method associateCifsExportWithFS.

private void associateCifsExportWithFS(UnManagedFileSystem vnxufs, String exportPath, Map<String, String> fsExportInfo, StoragePort storagePort) {
    try {
        // Assign storage port to unmanaged FS
        if (storagePort != null) {
            StringSet storagePorts = new StringSet();
            storagePorts.add(storagePort.getId().toString());
            vnxufs.getFileSystemInformation().remove(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString());
            vnxufs.getFileSystemInformation().put(UnManagedFileSystem.SupportedFileSystemInformation.STORAGE_PORT.toString(), storagePorts);
        }
        String shareName = fsExportInfo.get(VNXFileConstants.SHARE_NAME);
        String mountPoint = getMountPount(shareName, storagePort);
        UnManagedSMBFileShare unManagedSMBFileShare = new UnManagedSMBFileShare();
        unManagedSMBFileShare.setName(shareName);
        unManagedSMBFileShare.setMountPoint(mountPoint);
        unManagedSMBFileShare.setPath(exportPath);
        // setting to default permission type for VNX
        unManagedSMBFileShare.setPermissionType(FileControllerConstants.CIFS_SHARE_PERMISSION_TYPE_ALLOW);
        unManagedSMBFileShare.setDescription(fsExportInfo.get(VNXFileConstants.SHARE_COMMENT));
        int maxUsers = Integer.MAX_VALUE;
        if (Long.parseLong(fsExportInfo.get(VNXFileConstants.SHARE_MAXUSR)) < Integer.MAX_VALUE) {
            maxUsers = Integer.parseInt(fsExportInfo.get(VNXFileConstants.SHARE_MAXUSR));
        }
        unManagedSMBFileShare.setMaxUsers(maxUsers);
        unManagedSMBFileShare.setPortGroup(storagePort.getPortGroup());
        unManagedSMBFileShare.setPermission(ShareACL.SupportedPermissions.change.toString());
        UnManagedSMBShareMap currUnManagedShareMap = vnxufs.getUnManagedSmbShareMap();
        if (currUnManagedShareMap == null) {
            currUnManagedShareMap = new UnManagedSMBShareMap();
            vnxufs.setUnManagedSmbShareMap(currUnManagedShareMap);
        }
        if (currUnManagedShareMap.get(shareName) == null) {
            currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
            _logger.info("associateCifsExportWithFS - no SMBs already exists for share {}", shareName);
        } else {
            // Remove the existing and add the new share
            currUnManagedShareMap.remove(shareName);
            currUnManagedShareMap.put(shareName, unManagedSMBFileShare);
            _logger.warn("associateSMBShareMapWithFS - Identical export already exists for mount path {} Overwrite", shareName);
        }
    } catch (Exception ex) {
        _logger.warn("VNX file share retrieve processor failed for path {}, cause {}", exportPath, ex);
    }
}
Also used : UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) UnManagedSMBShareMap(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap) StringSet(com.emc.storageos.db.client.model.StringSet) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) URISyntaxException(java.net.URISyntaxException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) VNXException(com.emc.storageos.vnx.xmlapi.VNXException) IOException(java.io.IOException) VNXFileCollectionException(com.emc.storageos.plugins.metering.vnxfile.VNXFileCollectionException)

Aggregations

UnManagedSMBShareMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBShareMap)9 UnManagedSMBFileShare (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare)8 IOException (java.io.IOException)6 StringSet (com.emc.storageos.db.client.model.StringSet)5 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)4 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)4 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)4 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)4 StringMap (com.emc.storageos.db.client.model.StringMap)3 UnManagedCifsShareACL (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedCifsShareACL)3 UnManagedFSExportMap (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFSExportMap)3 UnManagedFileSystem (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileSystem)3 HashMap (java.util.HashMap)3 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)2 NetAppException (com.emc.storageos.netapp.NetAppException)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2