Search in sources :

Example 21 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doExpandFS - start");
        long newFsExpandSize = args.getNewFSCapacity();
        String volumeName = args.getFsName();
        if (args.getNewFSCapacity() % BYTESPERMB == 0) {
            newFsExpandSize = newFsExpandSize / BYTESPERMB;
        } else {
            newFsExpandSize = newFsExpandSize / BYTESPERMB + 1;
        }
        _log.info("FileSystem new size translation : {} : {}", args.getNewFSCapacity(), newFsExpandSize);
        String strNewFsSize = String.valueOf(newFsExpandSize) + "m";
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
        if (!nApi.setVolumeSize(volumeName, strNewFsSize)) {
            _log.error("NetAppFileStorageDevice doExpandFS - failed");
            ServiceError serviceError = DeviceControllerErrors.netapp.unableToExpandFileSystem();
            result = BiosCommandResult.createErrorResult(serviceError);
        } else {
            _log.info("NetAppFileStorageDevice doExpandFS - complete");
            result = BiosCommandResult.createSuccessfulResult();
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doExpandFS failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToExpandFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doExpandFS failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToExpandFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 22 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doCheckFSExists.

/**
 * Checking a file system: - Check if the FS exists on Array or not
 *
 * @param StorageSystem storage
 * @param args FileDeviceInputOutput
 * @return boolean true if exists else false
 * @throws ControllerException
 */
@Override
public boolean doCheckFSExists(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _log.info("checking file system existence on array: ", args.getFsName());
    boolean isFSExists = true;
    try {
        String portGroup = findVfilerName(args.getFs());
        NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
        List<String> fs = nApi.listFileSystems();
        if (!fs.isEmpty() && fs.contains(args.getFsName())) {
            isFSExists = true;
        } else {
            isFSExists = false;
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doCheckFSExists failed with an Exception", e);
    }
    return isFSExists;
}
Also used : NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 23 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppClusterModeCommIntf method discoverUmanagedFileQuotaDirectory.

private void discoverUmanagedFileQuotaDirectory(AccessProfile profile) {
    URI storageSystemId = profile.getSystemId();
    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, storageSystemId);
    if (null == storageSystem) {
        return;
    }
    NetAppClusterApi netAppCApi = new NetAppClusterApi.Builder(storageSystem.getIpAddress(), storageSystem.getPortNumber(), storageSystem.getUsername(), storageSystem.getPassword()).https(true).build();
    try {
        // Retrieve all the qtree info.
        List<Qtree> qtrees = netAppCApi.listQtrees();
        List<Quota> quotas;
        try {
            // Currently there are no API's available to check the quota status in general
            // TODO check weather quota is on before doing this call
            quotas = netAppCApi.listQuotas();
        } catch (Exception e) {
            _logger.error("Error while fetching quotas", e.getMessage());
            return;
        }
        if (quotas != null) {
            Map<String, Qtree> qTreeNameQTreeMap = new HashMap<>();
            qtrees.forEach(qtree -> {
                if (qtree.getQtree() != null && !qtree.getQtree().equals("")) {
                    qTreeNameQTreeMap.put(qtree.getVolume() + qtree.getQtree(), qtree);
                }
            });
            List<UnManagedFileQuotaDirectory> unManagedFileQuotaDirectories = new ArrayList<>();
            List<UnManagedFileQuotaDirectory> existingUnManagedFileQuotaDirectories = new ArrayList<>();
            String tempVolume = null;
            String tempQuotaTree = null;
            String tempQuotaTarget = null;
            for (Quota quota : quotas) {
                /* Temporary fix TODO 
                     * Fix for situations where QuotaTree is null
                     * Extracting QuotaTree id from quotaTarget.
                     */
                if ("".equals(quota.getQtree())) {
                    tempQuotaTarget = quota.getQuotaTarget();
                    tempVolume = quota.getVolume();
                    if (!"".equals(tempVolume)) {
                        Pattern pattern = Pattern.compile(tempVolume + "/(.*$)");
                        Matcher matcher = pattern.matcher(tempQuotaTarget);
                        if (matcher.find()) {
                            tempQuotaTree = matcher.group(1);
                        }
                        if ("".equals(tempQuotaTree)) {
                            continue;
                        }
                        quota.setQtree(tempQuotaTree);
                    } else {
                        continue;
                    }
                }
                String fsNativeId;
                if (quota.getVolume().startsWith(VOL_ROOT)) {
                    fsNativeId = quota.getVolume();
                } else {
                    fsNativeId = VOL_ROOT + quota.getVolume();
                }
                if (fsNativeId.contains(ROOT_VOL)) {
                    _logger.info("Ignore and not discover root filesystem on NTP array");
                    continue;
                }
                String fsNativeGUID = NativeGUIDGenerator.generateNativeGuid(storageSystem.getSystemType(), storageSystem.getSerialNumber(), fsNativeId);
                String nativeGUID = NativeGUIDGenerator.generateNativeGuidForQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quota.getQtree(), quota.getVolume());
                String nativeUnmanagedGUID = NativeGUIDGenerator.generateNativeGuidForUnManagedQuotaDir(storageSystem.getSystemType(), storageSystem.getSerialNumber(), quota.getQtree(), quota.getVolume());
                if (checkStorageQuotaDirectoryExistsInDB(nativeGUID)) {
                    continue;
                }
                UnManagedFileQuotaDirectory unManagedFileQuotaDirectory = new UnManagedFileQuotaDirectory();
                unManagedFileQuotaDirectory.setId(URIUtil.createId(UnManagedFileQuotaDirectory.class));
                unManagedFileQuotaDirectory.setLabel(quota.getQtree());
                unManagedFileQuotaDirectory.setNativeGuid(nativeUnmanagedGUID);
                unManagedFileQuotaDirectory.setParentFSNativeGuid(fsNativeGUID);
                unManagedFileQuotaDirectory.setNativeId("/vol/" + quota.getVolume() + "/" + quota.getQtree());
                if ("enabled".equals(qTreeNameQTreeMap.get(quota.getVolume() + quota.getQtree()).getOplocks())) {
                    unManagedFileQuotaDirectory.setOpLock(true);
                }
                unManagedFileQuotaDirectory.setSize(Long.valueOf(quota.getDiskLimit()));
                if (!checkUnManagedQuotaDirectoryExistsInDB(nativeUnmanagedGUID)) {
                    unManagedFileQuotaDirectories.add(unManagedFileQuotaDirectory);
                } else {
                    existingUnManagedFileQuotaDirectories.add(unManagedFileQuotaDirectory);
                }
            }
            if (!unManagedFileQuotaDirectories.isEmpty()) {
                _partitionManager.insertInBatches(unManagedFileQuotaDirectories, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILEQUOTADIR);
            }
            if (!existingUnManagedFileQuotaDirectories.isEmpty()) {
                _partitionManager.updateAndReIndexInBatches(existingUnManagedFileQuotaDirectories, Constants.DEFAULT_PARTITION_SIZE, _dbClient, UNMANAGED_FILEQUOTADIR);
            }
        }
    } catch (NetAppException ve) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        _logger.error("discoverStorage failed.  Storage system: " + storageSystemId);
        throw ve;
    } catch (Exception e) {
        if (null != storageSystem) {
            cleanupDiscovery(storageSystem);
        }
        _logger.error("discoverStorage failed. Storage system: " + storageSystemId, e);
        throw NetAppException.exceptions.discoveryFailed(storageSystemId.toString(), e);
    }
}
Also used : Pattern(java.util.regex.Pattern) Qtree(com.iwave.ext.netapp.model.Qtree) HashMap(java.util.HashMap) Matcher(java.util.regex.Matcher) ImplicitPoolMatcher(com.emc.storageos.volumecontroller.impl.utils.ImplicitPoolMatcher) UnManagedFileQuotaDirectory(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedFileQuotaDirectory) ArrayList(java.util.ArrayList) 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) NetAppCException(com.emc.storageos.netappc.NetAppCException) IOException(java.io.IOException) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) Quota(com.iwave.ext.netapp.model.Quota) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 24 with NetAppException

use of com.emc.storageos.netapp.NetAppException in project coprhd-controller by CoprHD.

the class NetAppFileCommunicationInterface method collectStatisticsInformation.

@Override
public void collectStatisticsInformation(AccessProfile accessProfile) throws BaseCollectionException {
    URI storageSystemId = null;
    String fsName = null;
    try {
        _logger.info("Metering for {} using ip {}", accessProfile.getSystemId(), accessProfile.getIpAddress());
        String arrayIp = accessProfile.getIpAddress();
        String arrayUser = accessProfile.getUserName();
        String arrayPassword = accessProfile.getPassword();
        int arrayPort = accessProfile.getPortNumber();
        NetAppApi netAppApi = new NetAppApi.Builder(arrayIp, arrayPort, arrayUser, arrayPassword).https(true).build();
        long latestSampleTime = accessProfile.getLastSampleTime();
        storageSystemId = accessProfile.getSystemId();
        StorageSystem NetAppArray = _dbClient.queryObject(StorageSystem.class, storageSystemId);
        String serialNumber = NetAppArray.getSerialNumber();
        String deviceType = NetAppArray.getSystemType();
        initializeKeyMap(accessProfile);
        List<Stat> stats = new ArrayList<Stat>();
        ZeroRecordGenerator zeroRecordGenerator = new FileZeroRecordGenerator();
        CassandraInsertion statsColumnInjector = new FileDBInsertion();
        /* Get Stats from the NTAP array */
        List<Map<String, String>> usageStats = new ArrayList<Map<String, String>>();
        NetAppStatsRecorder recorder = new NetAppStatsRecorder(zeroRecordGenerator, statsColumnInjector);
        _keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
        Map<String, Number> metrics = new ConcurrentHashMap<String, Number>();
        List<URI> storageSystemIds = new ArrayList<URI>();
        storageSystemIds.add(storageSystemId);
        List<FileShare> fsObjs = _dbClient.queryObjectField(FileShare.class, Constants.STORAGE_DEVICE, storageSystemIds);
        List<URI> fsUris = zeroRecordGenerator.extractVolumesOrFileSharesFromDB(storageSystemId, _dbClient, FileShare.class);
        for (URI fsUri : fsUris) {
            FileShare fsObj = _dbClient.queryObject(FileShare.class, fsUri);
            if (fsObj.getInactive()) {
                continue;
            }
            fsName = fsObj.getName();
            String fsNativeGuid = NativeGUIDGenerator.generateNativeGuid(deviceType, serialNumber, fsObj.getPath());
            try {
                usageStats = netAppApi.listVolumeInfo(fsName, null);
                for (Map<String, String> map : usageStats) {
                    /*
                         * TODO: usageStats usually contains a single element. If
                         * the list consists of multiple elements, all but one
                         * element will get overwritten.
                         */
                    metrics.put(Constants.SIZE_TOTAL, 0);
                    if (map.get(Constants.SIZE_TOTAL) != null) {
                        metrics.put(Constants.SIZE_TOTAL, Long.valueOf(map.get(Constants.SIZE_TOTAL)));
                    }
                    metrics.put(Constants.SIZE_USED, 0);
                    if (map.get(Constants.SIZE_USED) != null) {
                        metrics.put(Constants.SIZE_USED, Long.valueOf(map.get(Constants.SIZE_USED)));
                    }
                    /*
                         * TODO: Bytes per block on NTAP is hard coded for now. If
                         * possible, we should to get this from the array.
                         */
                    Long snapshotBytesReserved = 0L;
                    if (map.get(Constants.SNAPSHOT_BLOCKS_RESERVED) != null) {
                        snapshotBytesReserved = Long.valueOf(map.get(Constants.SNAPSHOT_BLOCKS_RESERVED)) * Constants.NETAPP_BYTES_PER_BLOCK;
                    }
                    metrics.put(Constants.SNAPSHOT_BYTES_RESERVED, snapshotBytesReserved);
                    Integer snapshotCount = _dbClient.countObjects(Snapshot.class, Constants.PARENT, fsObj.getId());
                    metrics.put(Constants.SNAPSHOT_COUNT, snapshotCount);
                    Stat stat = recorder.addUsageStat(fsNativeGuid, _keyMap, metrics);
                    if (stat != null) {
                        stats.add(stat);
                        // Persists the file system, only if change in used capacity.
                        if (fsObj.getUsedCapacity() != stat.getAllocatedCapacity()) {
                            fsObj.setUsedCapacity(stat.getAllocatedCapacity());
                            _dbClient.persistObject(fsObj);
                        }
                    }
                }
            } catch (NetAppException ne) {
                String arg = fsName.toString() + ", " + accessProfile.getIpAddress().toString() + ", " + accessProfile.getSystemType().toString();
                _logger.info("Failed to retrieve stats for FileShare, Syste, Type: {}", arg);
            }
        }
        if (!stats.isEmpty()) {
            zeroRecordGenerator.identifyRecordstobeZeroed(_keyMap, stats, FileShare.class);
            persistStatsInDB(stats);
            latestSampleTime = System.currentTimeMillis();
            accessProfile.setLastSampleTime(latestSampleTime);
        }
        _logger.info("Done metering device {}", storageSystemId);
    } catch (Exception e) {
        String message = "collectStatisticsInformation failed. Storage system: " + storageSystemId;
        _logger.error(message, e);
        throw NetAppException.exceptions.collectStatsFailed(accessProfile.getIpAddress(), accessProfile.getSystemType(), message);
    }
}
Also used : ArrayList(java.util.ArrayList) FileZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileZeroRecordGenerator) URI(java.net.URI) NetAppException(com.emc.storageos.netapp.NetAppException) Stat(com.emc.storageos.db.client.model.Stat) NetAppApi(com.emc.storageos.netapp.NetAppApi) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) NetAppStatsRecorder(com.emc.storageos.volumecontroller.impl.plugins.metering.netapp.NetAppStatsRecorder) FileShare(com.emc.storageos.db.client.model.FileShare) UnManagedSMBFileShare(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedSMBFileShare) 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) NetAppFileCollectionException(com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException) IOException(java.io.IOException) CassandraInsertion(com.emc.storageos.volumecontroller.impl.plugins.metering.CassandraInsertion) FileZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileZeroRecordGenerator) ZeroRecordGenerator(com.emc.storageos.volumecontroller.impl.plugins.metering.ZeroRecordGenerator) 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) FileDBInsertion(com.emc.storageos.volumecontroller.impl.plugins.metering.file.FileDBInsertion)

Example 25 with NetAppException

use of com.emc.storageos.netapp.NetAppException 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)

Aggregations

NetAppException (com.emc.storageos.netapp.NetAppException)27 NetAppApi (com.emc.storageos.netapp.NetAppApi)23 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)16 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)16 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 URI (java.net.URI)11 ArrayList (java.util.ArrayList)10 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)9 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)9 IOException (java.io.IOException)9 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)8 NetAppFileCollectionException (com.emc.storageos.plugins.metering.netapp.NetAppFileCollectionException)8 HashMap (java.util.HashMap)8 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)7 FileShare (com.emc.storageos.db.client.model.FileShare)6 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)6 VFilerInfo (com.iwave.ext.netapp.VFilerInfo)6 StoragePort (com.emc.storageos.db.client.model.StoragePort)5 StringMap (com.emc.storageos.db.client.model.StringMap)5