Search in sources :

Example 16 with DbClient

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

the class ConnectivityCollectionRelationshipsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        @SuppressWarnings("unchecked") final Iterator<CIMObjectPath> it = (Iterator<CIMObjectPath>) resultObj;
        boolean volumeAdded = false;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
        String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
        _log.debug("RA Group Id : {}", ragGroupId);
        RemoteDirectorGroup rg = getRAGroupUriFromDB(dbClient, ragGroupId);
        if (null == rg) {
            _log.info("RA Group Not found : {}", ragGroupId);
            return;
        }
        URI raGroupUri = rg.getId();
        @SuppressWarnings("unchecked") Map<String, URI> rAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
        Set<String> volumeNativeGuids = new StringSet();
        while (it.hasNext()) {
            CIMObjectPath connCollectionRelationPaths = it.next();
            String cimClass = connCollectionRelationPaths.getObjectName();
            if (PROTOCOL_END_POINT.equals(cimClass)) {
                String endPointId = connCollectionRelationPaths.getKey(Constants.NAME).getValue().toString();
                _log.info("End Point Added {}", connCollectionRelationPaths);
                addPath(keyMap, Constants.ENDPOINTS_RAGROUP, connCollectionRelationPaths);
                rAGroupMap.put(endPointId, raGroupUri);
            } else if (VOLUME.equals(cimClass)) {
                String volumeNativeGuid = getVolumeNativeGuid(connCollectionRelationPaths);
                if (!volumeAdded && !rAGroupMap.containsKey(volumeNativeGuid)) {
                    volumeAdded = true;
                    _log.info("Volume Added {}", connCollectionRelationPaths);
                    addPath(keyMap, Constants.VOLUME_RAGROUP, connCollectionRelationPaths);
                    rAGroupMap.put(volumeNativeGuid, raGroupUri);
                } else {
                    _log.info("Volume {} is part of multiple RA Groups", volumeNativeGuid);
                }
                volumeNativeGuids.add(volumeNativeGuid);
            }
        }
        RemoteDirectorGroup remoteGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupUri);
        // async
        if (!volumeAdded) {
            remoteGroup.setSupportedCopyMode(SupportedCopyModes.ALL.toString());
        }
        if (null == remoteGroup.getVolumes() || remoteGroup.getVolumes().isEmpty()) {
            remoteGroup.setVolumes(new StringSet(volumeNativeGuids));
        } else {
            _log.debug("Existing Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
            _log.debug("New Volumes {}", Joiner.on("\t").join(volumeNativeGuids));
            remoteGroup.getVolumes().replace(volumeNativeGuids);
            _log.debug("Updated Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
        }
        dbClient.persistObject(remoteGroup);
    } catch (Exception e) {
        _log.error("Exception occurred while processing remote connectivity information.", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Map(java.util.Map)

Example 17 with DbClient

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

the class SRDFStorageSyncProcessor method processStorageSynchronizedPaths.

private void processStorageSynchronizedPaths(Operation operation, Iterator<CIMObjectPath> it, Object resultObj, Map<String, Object> keyMap) {
    while (it.hasNext()) {
        try {
            DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
            CIMObjectPath volumePath = it.next();
            CIMObjectPath sourcePath = (CIMObjectPath) volumePath.getKey(Constants._SystemElement).getValue();
            CIMObjectPath destPath = (CIMObjectPath) volumePath.getKey(Constants._SyncedElement).getValue();
            CIMProperty<?> prop = sourcePath.getKey(Constants._SystemName);
            String[] serialNumber_split = prop.getValue().toString().split(Constants.PATH_DELIMITER_REGEX);
            if (serialNumber_split[1].equalsIgnoreCase((String) keyMap.get(Constants._serialID))) {
                // If mirror
                String sourceVolumeNativeGuid = getVolumeNativeGuid(sourcePath);
                Volume sourceVolume = checkStorageVolumeExistsInDB(sourceVolumeNativeGuid, dbClient);
                if (null == sourceVolume || !isSRDFProtectedVolume(sourceVolume)) {
                    continue;
                }
                String targetVolumeNativeGuid = getVolumeNativeGuid(destPath);
                Volume targetVolume = checkStorageVolumeExistsInDB(targetVolumeNativeGuid, dbClient);
                if (null == targetVolume || !isSRDFProtectedVolume(targetVolume)) {
                    continue;
                }
                if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(sourceVolume.getPersonality())) {
                    if (null == sourceVolume.getSrdfTargets() || !sourceVolume.getSrdfTargets().contains(targetVolume.getId().toString())) {
                        _log.info("target volume {} is not part of ViPR managed targtes for given source {}", targetVolumeNativeGuid, sourceVolumeNativeGuid);
                        continue;
                    }
                } else if (PersonalityTypes.SOURCE.toString().equalsIgnoreCase(targetVolume.getPersonality())) {
                    if (null == targetVolume.getSrdfTargets() || !targetVolume.getSrdfTargets().contains(sourceVolume.getId().toString())) {
                        _log.info("target volume {} is not part of ViPR managed targtes for given source {}", sourceVolumeNativeGuid, targetVolumeNativeGuid);
                        continue;
                    }
                }
                addPath(keyMap, operation.getResult(), volumePath);
            }
        } catch (Exception e) {
            _log.error("Prerequiste Step for getting srdf storage synchronized relations failed :", e);
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 18 with DbClient

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

the class VmaxSLOBookkeepingProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
    Set<String> policyNames = (Set<String>) keyMap.get(Constants.SLO_NAMES);
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    StorageSystem storageSystem = dbClient.queryObject(StorageSystem.class, profile.getSystemId());
    boolean isVmax3 = storageSystem.checkIfVmax3();
    if (isVmax3 && policyNames != null && !policyNames.isEmpty()) {
        try {
            performPolicyBookKeeping(dbClient, policyNames, storageSystem);
        } catch (IOException e) {
            log.error("Exception caught while trying to run bookkeeping on VMAX3 SLO AutoTieringPolicies", e);
        }
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) Set(java.util.Set) AccessProfile(com.emc.storageos.plugins.AccessProfile) IOException(java.io.IOException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 19 with DbClient

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

the class VolumeSizeProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    DbClient _dbClient;
    AccessProfile profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
    try {
        String minVolSize = null;
        String maxVolSize = null;
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        StorageSystem device = getStorageSystem(_dbClient, profile.getSystemId());
        if (resultObj instanceof CIMArgument<?>[]) {
            CIMArgument<?>[] outputArguments = (CIMArgument<?>[]) resultObj;
            for (CIMArgument<?> outArg : outputArguments) {
                if (null == outArg) {
                    continue;
                }
                if (outArg.getName().equalsIgnoreCase(MINIMUM_VOLUME_SIZE)) {
                    minVolSize = outArg.getValue().toString();
                } else if (outArg.getName().equalsIgnoreCase(MAXIMUM_VOLUME_SIZE)) {
                    maxVolSize = outArg.getValue().toString();
                }
            }
            // we are setting at compile time, hence value will be there always.
            CIMObjectPath poolObjectPath = getObjectPathfromCIMArgument();
            String instanceID = poolObjectPath.getKey(Constants.INSTANCEID).getValue().toString();
            StoragePool pool = checkStoragePoolExistsInDB(getNativeIDFromInstance(instanceID), _dbClient, device);
            if (null != pool) {
                Long maxVolumeSize = ControllerUtils.convertBytesToKBytes(maxVolSize);
                Long minVolumeSize = ControllerUtils.convertBytesToKBytes(minVolSize);
                if (Type.ibmxiv.name().equals((device.getSystemType()))) {
                    String supportedResourceType = pool.getSupportedResourceTypes();
                    if (SupportedResourceTypes.THIN_ONLY.name().equals(supportedResourceType)) {
                        pool.setMaximumThinVolumeSize(maxVolumeSize);
                        pool.setMinimumThinVolumeSize(minVolumeSize);
                    } else if (SupportedResourceTypes.THICK_ONLY.name().equals(supportedResourceType)) {
                        pool.setMaximumThickVolumeSize(maxVolumeSize);
                        pool.setMinimumThickVolumeSize(minVolumeSize);
                    }
                } else {
                    // TODO - could this be changed to use the same logic as for IBM pool?
                    // if the result is obtained from calling on Thick, use thick volume size else thin
                    String elementType = determineCallType();
                    if (elementType.equalsIgnoreCase(FIVE)) {
                        pool.setMaximumThinVolumeSize(maxVolumeSize);
                        pool.setMinimumThinVolumeSize(minVolumeSize);
                    } else if (elementType.equalsIgnoreCase(THREE)) {
                        pool.setMaximumThickVolumeSize(maxVolumeSize);
                        pool.setMinimumThickVolumeSize(minVolumeSize);
                    }
                }
                _logger.info(String.format("Maximum limits for volume capacity in storage pool: %s  %n   max thin volume capacity: %s, max thick volume capacity: %s ", pool.getId(), pool.getMaximumThinVolumeSize(), pool.getMaximumThickVolumeSize()));
                _dbClient.persistObject(pool);
            }
        }
    } catch (Exception e) {
        _logger.error("Failed while processing Result : ", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) StoragePool(com.emc.storageos.db.client.model.StoragePool) CIMObjectPath(javax.cim.CIMObjectPath) AccessProfile(com.emc.storageos.plugins.AccessProfile) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 20 with DbClient

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

the class MetaVolumeMembersProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        WBEMClient client = SMICommunicationInterface.getCIMClient(keyMap);
        CIMObjectPath[] metaMembersPaths = (CIMObjectPath[]) getFromOutputArgs((CIMArgument[]) resultObj, "OutElements");
        if (metaMembersPaths == null || (metaMembersPaths.length == 0)) {
            _logger.info(String.format("There are no meta members to process"));
        } else {
            _logger.debug(String.format("Processing meta members: %s", Arrays.toString(metaMembersPaths)));
            // Get volume from db
            _logger.debug(String.format("Args size: %s", _args.size()));
            Object[] arguments = (Object[]) _args.get(0);
            CIMArgument theElement = ((CIMArgument[]) arguments[2])[1];
            _logger.info(String.format("TheElement: %s, type %s", theElement.getValue().toString(), theElement.getValue().getClass().toString()));
            CIMObjectPath theElementPath = (CIMObjectPath) theElement.getValue();
            UnManagedVolume preExistingVolume = null;
            String isMetaVolume = "true";
            String nativeGuid;
            // Check if storage volume exists in db (the method is called from re-discovery context).
            nativeGuid = getVolumeNativeGuid(theElementPath);
            Volume storageVolume = checkStorageVolumeExistsInDB(nativeGuid, dbClient);
            if (null == storageVolume || storageVolume.getInactive()) {
                // Check if unmanaged volume exists in db (the method is called from unmanaged volumes discovery context).
                nativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(theElementPath);
                _logger.debug("Volume nativeguid :" + nativeGuid);
                preExistingVolume = checkUnManagedVolumeExistsInDB(nativeGuid, dbClient);
                if (null == preExistingVolume) {
                    _logger.debug("Volume Info Object not found :" + nativeGuid);
                    return;
                }
                isMetaVolume = preExistingVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_METAVOLUME.toString());
            } else {
                _logger.debug("Volume managed by Bourne :" + storageVolume.getNativeGuid());
                isMetaVolume = storageVolume.getIsComposite().toString();
            }
            if (isMetaVolume.equalsIgnoreCase("false")) {
                _logger.error(String.format("MetaVolumeMembersProcessor called for regular volume: %s", nativeGuid));
                return;
            }
            Integer membersCount = metaMembersPaths.length;
            // get meta member size. use second member --- the first member will show size of meta volume itself.
            CIMObjectPath metaMemberPath = metaMembersPaths[1];
            CIMInstance cimVolume = client.getInstance(metaMemberPath, false, false, META_MEMBER_SIZE_INFO);
            CIMProperty consumableBlocks = cimVolume.getProperty(SmisConstants.CP_CONSUMABLE_BLOCKS);
            CIMProperty blockSize = cimVolume.getProperty(SmisConstants.CP_BLOCK_SIZE);
            // calculate size = consumableBlocks * block size
            Long size = Long.valueOf(consumableBlocks.getValue().toString()) * Long.valueOf(blockSize.getValue().toString());
            // set meta member count and meta members size for meta volume (required for volume expansion)
            if (null != preExistingVolume) {
                StringSet metaMembersCount = new StringSet();
                metaMembersCount.add(membersCount.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_COUNT.toString(), metaMembersCount);
                StringSet metaMemberSize = new StringSet();
                metaMemberSize.add(size.toString());
                preExistingVolume.putVolumeInfo(UnManagedVolume.SupportedVolumeInformation.META_MEMBER_SIZE.toString(), metaMemberSize);
                // persist unmanaged volume in db
                dbClient.persistObject(preExistingVolume);
            } else {
                storageVolume.setMetaMemberCount(membersCount);
                storageVolume.setMetaMemberSize(size);
                storageVolume.setTotalMetaMemberCapacity(membersCount * size);
                // persist volume in db
                dbClient.persistObject(storageVolume);
            }
            _logger.info(String.format("Meta member info: meta member count --- %s, blocks --- %s, block size --- %s, size --- %s .", membersCount, consumableBlocks.getValue().toString(), blockSize.getValue().toString(), size));
        }
    } catch (Exception e) {
        _logger.error("Processing meta volume  information failed :", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) CIMProperty(javax.cim.CIMProperty) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) StringSet(com.emc.storageos.db.client.model.StringSet) WBEMClient(javax.wbem.client.WBEMClient) CIMArgument(javax.cim.CIMArgument)

Aggregations

DbClient (com.emc.storageos.db.client.DbClient)253 URI (java.net.URI)155 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)73 Volume (com.emc.storageos.db.client.model.Volume)67 ArrayList (java.util.ArrayList)58 Test (org.junit.Test)42 FileShare (com.emc.storageos.db.client.model.FileShare)34 NamedURI (com.emc.storageos.db.client.model.NamedURI)31 CIMObjectPath (javax.cim.CIMObjectPath)31 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 WBEMClient (javax.wbem.client.WBEMClient)29 StringSet (com.emc.storageos.db.client.model.StringSet)28 CIMConnectionFactory (com.emc.storageos.volumecontroller.impl.smis.CIMConnectionFactory)28 ContainmentConstraint (com.emc.storageos.db.client.constraint.ContainmentConstraint)26 MigrationCallbackException (com.emc.storageos.svcs.errorhandling.resources.MigrationCallbackException)25 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 InternalDbClient (com.emc.storageos.db.client.upgrade.InternalDbClient)22 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)21 CIMInstance (javax.cim.CIMInstance)21 BlockObject (com.emc.storageos.db.client.model.BlockObject)20