Search in sources :

Example 46 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class StorageVolumeInfoProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    CloseableIterator<CIMInstance> volumeInstances = null;
    EnumerateResponse<CIMInstance> volumeInstanceChunks = null;
    CIMObjectPath storagePoolPath = null;
    WBEMClient client = null;
    try {
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        client = SMICommunicationInterface.getCIMClient(keyMap);
        _profile = (AccessProfile) keyMap.get(Constants.ACCESSPROFILE);
        Map<String, VolHostIOObject> exportedVolumes = (Map<String, VolHostIOObject>) keyMap.get(Constants.EXPORTED_VOLUMES);
        Set<String> existingVolumesInCG = (Set<String>) keyMap.get(Constants.VOLUMES_PART_OF_CG);
        @SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
        @SuppressWarnings("unchecked") Map<String, LocalReplicaObject> volumeToLocalReplicaMap = (Map<String, LocalReplicaObject>) keyMap.get(Constants.UN_VOLUME_LOCAL_REPLICA_MAP);
        @SuppressWarnings("unchecked") Map<String, Map<String, String>> volumeToSyncAspectMap = (Map<String, Map<String, String>>) keyMap.get(Constants.SNAPSHOT_NAMES_SYNCHRONIZATION_ASPECT_MAP);
        @SuppressWarnings("unchecked") Map<String, Set<String>> duplicateSyncAspectElementNameMap = (Map<String, Set<String>>) keyMap.get(Constants.DUPLICATE_SYNC_ASPECT_ELEMENT_NAME_MAP);
        @SuppressWarnings("unchecked") Map<String, Set<String>> vmax2ThinPoolToBoundVolumesMap = (Map<String, Set<String>>) keyMap.get(Constants.VMAX2_THIN_POOL_TO_BOUND_VOLUMES);
        Set<String> boundVolumes = null;
        storagePoolPath = getObjectPathfromCIMArgument(_args);
        String poolNativeGuid = NativeGUIDGenerator.generateNativeGuidForPool(storagePoolPath);
        StoragePool pool = checkStoragePoolExistsInDB(poolNativeGuid, _dbClient);
        if (pool == null) {
            _logger.error("Skipping unmanaged volume discovery as the storage pool with path {} doesn't exist in ViPR", storagePoolPath.toString());
            return;
        }
        StorageSystem system = _dbClient.queryObject(StorageSystem.class, _profile.getSystemId());
        _unManagedVolumesInsert = new ArrayList<UnManagedVolume>();
        _unManagedVolumesUpdate = new ArrayList<UnManagedVolume>();
        _unManagedExportMasksUpdate = new ArrayList<UnManagedExportMask>();
        // get bound volumes list for VMAX2 Thin pools
        boundVolumes = vmax2ThinPoolToBoundVolumesMap.get(storagePoolPath.toString());
        Set<String> poolSupportedSLONames = (Set<String>) keyMap.get(poolNativeGuid);
        _logger.debug("Pool Supporting SLO Names:{}", poolSupportedSLONames);
        _metaVolumeViewPaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES_VIEWS);
        if (_metaVolumeViewPaths == null) {
            _metaVolumeViewPaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES_VIEWS, _metaVolumeViewPaths);
        }
        // create empty place holder list for meta volume paths (cannot
        // define this in xml)
        _metaVolumePaths = (List<CIMObjectPath>) keyMap.get(Constants.META_VOLUMES);
        if (_metaVolumePaths == null) {
            _metaVolumePaths = new ArrayList<CIMObjectPath>();
            keyMap.put(Constants.META_VOLUMES, _metaVolumePaths);
        }
        _volumeToSpaceConsumedMap = (Map<String, String>) keyMap.get(Constants.VOLUME_SPACE_CONSUMED_MAP);
        // get VolumeInfo Object and inject Fast Policy Name.
        volumeInstanceChunks = (EnumerateResponse<CIMInstance>) resultObj;
        volumeInstances = volumeInstanceChunks.getResponses();
        Set<URI> srdfEnabledTargetVPools = SRDFUtils.fetchSRDFTargetVirtualPools(_dbClient);
        processVolumes(volumeInstances, keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
        while (!volumeInstanceChunks.isEnd()) {
            _logger.info("Processing Next Volume Chunk of size {}", BATCH_SIZE);
            volumeInstanceChunks = client.getInstancesWithPath(storagePoolPath, volumeInstanceChunks.getContext(), new UnsignedInteger32(BATCH_SIZE));
            processVolumes(volumeInstanceChunks.getResponses(), keyMap, operation, pool, system, exportedVolumes, existingVolumesInCG, volumeToRAGroupMap, volumeToLocalReplicaMap, volumeToSyncAspectMap, poolSupportedSLONames, boundVolumes, srdfEnabledTargetVPools, duplicateSyncAspectElementNameMap);
        }
        if (null != _unManagedVolumesUpdate && !_unManagedVolumesUpdate.isEmpty()) {
            _partitionManager.updateAndReIndexInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
        }
        if (null != _unManagedVolumesInsert && !_unManagedVolumesInsert.isEmpty()) {
            _partitionManager.insertInBatches(_unManagedVolumesInsert, getPartitionSize(keyMap), _dbClient, UNMANAGED_VOLUME);
        }
        if (null != _unManagedExportMasksUpdate && !_unManagedExportMasksUpdate.isEmpty()) {
            _partitionManager.updateAndReIndexInBatches(_unManagedExportMasksUpdate, getPartitionSize(keyMap), _dbClient, UNMANAGED_EXPORT_MASK);
        }
        performStorageUnManagedVolumeBookKeeping(pool.getId());
    } catch (Exception e) {
        _logger.error("Processing Storage Volume Information failed :", e);
    } finally {
        _unManagedVolumesInsert = null;
        _unManagedVolumesUpdate = null;
        if (null != volumeInstances) {
            volumeInstances.close();
        }
        if (null != volumeInstanceChunks) {
            try {
                client.closeEnumeration(storagePoolPath, volumeInstanceChunks.getContext());
            } catch (Exception e) {
                _logger.debug("Exception occurred while closing enumeration", e);
            }
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) StringSet(com.emc.storageos.db.client.model.StringSet) StoragePool(com.emc.storageos.db.client.model.StoragePool) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) WBEMClient(javax.wbem.client.WBEMClient) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) CIMObjectPath(javax.cim.CIMObjectPath) UnsignedInteger32(javax.cim.UnsignedInteger32) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) IOException(java.io.IOException) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Map(java.util.Map) HashMap(java.util.HashMap) StringSetMap(com.emc.storageos.db.client.model.StringSetMap)

Example 47 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class VolumeAccessStateProcessor method processVolumes.

private void processVolumes(Iterator<CIMInstance> it, Map<String, Object> keyMap, Operation operation) {
    while (it.hasNext()) {
        try {
            CIMInstance volumeInstance = it.next();
            CIMObjectPath volumePath = volumeInstance.getObjectPath();
            // TODO add logic to get Access
            String access = null;
            Object value = volumeInstance.getPropertyValue(SupportedVolumeInformation.ACCESS.toString());
            if (value != null) {
                access = value.toString();
            }
            StringSet statusDesc = new StringSet();
            String[] descriptions = null;
            value = volumeInstance.getPropertyValue(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString());
            if (value != null) {
                descriptions = (String[]) value;
                for (String desc : descriptions) {
                    statusDesc.add(desc);
                }
            }
            String volumeNativeGuid = getVolumeNativeGuid(volumePath);
            Volume volume = checkStorageVolumeExistsInDB(volumeNativeGuid, _dbClient);
            if (null != volume) {
                _logger.debug("Skipping discovery, as this Volume is already being managed by ViPR :" + volumeNativeGuid);
                continue;
            }
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            UnManagedVolume unManagedVolume = checkUnManagedVolumeExistsInDB(unManagedVolumeNativeGuid, _dbClient);
            if (null != unManagedVolume) {
                _logger.debug("Adding Access {}", unManagedVolumeNativeGuid);
                StringSet accessSet = new StringSet();
                if (access != null) {
                    accessSet.add(access);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.ACCESS.toString(), accessSet);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.ACCESS.toString()).replace(accessSet);
                }
                if (null == unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString())) {
                    unManagedVolume.getVolumeInformation().put(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString(), statusDesc);
                } else {
                    unManagedVolume.getVolumeInformation().get(SupportedVolumeInformation.STATUS_DESCRIPTIONS.toString()).replace(statusDesc);
                }
                _unManagedVolumesUpdate.add(unManagedVolume);
            }
            if (_unManagedVolumesUpdate.size() > BATCH_SIZE) {
                _partitionManager.updateInBatches(_unManagedVolumesUpdate, getPartitionSize(keyMap), _dbClient, "UnManagedVolume");
                _unManagedVolumesUpdate.clear();
            }
        } catch (Exception ex) {
            _logger.error("Processing UnManaged Storage Volume", ex);
        }
    }
}
Also used : UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) CIMObjectPath(javax.cim.CIMObjectPath) StringSet(com.emc.storageos.db.client.model.StringSet) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 48 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class ArrayAffinityProcessor method getPreferredPoolMap.

/**
 * Get preferred pool to export type map for a host
 *
 * @param hostId Id of Host instance
 * @param profile AccessProfile
 * @param cimClient WBEMClient
 * @param dbClient DbClient
 * @return preferred pool to export type map
 */
private Map<String, String> getPreferredPoolMap(URI hostId, AccessProfile profile, WBEMClient cimClient, DbClient dbClient) {
    Map<String, String> preferredPoolMap = new HashMap<String, String>();
    List<Initiator> allInitiators = CustomQueryUtility.queryActiveResourcesByConstraint(dbClient, Initiator.class, ContainmentConstraint.Factory.getContainedObjectsConstraint(hostId, Initiator.class, Constants.HOST));
    Set<CIMObjectPath> hardwareIdPaths = new HashSet<CIMObjectPath>();
    for (Initiator initiator : allInitiators) {
        _logger.info("Processing initiator {}", initiator.getLabel());
        String normalizedPortName = Initiator.normalizePort(initiator.getInitiatorPort());
        String query = String.format("SELECT %s.%s FROM %s where %s.%s ='%s'", SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_INSTANCE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CIM_STORAGE_HARDWARE_ID, SmisConstants.CP_ELEMENT_NAME, normalizedPortName);
        CIMObjectPath hardwareIdPath = CimObjectPathCreator.createInstance(SmisConstants.CIM_STORAGE_HARDWARE_ID, Constants.EMC_NAMESPACE, null);
        List<CIMInstance> hardwareIds = DiscoveryUtils.executeQuery(cimClient, hardwareIdPath, query, CQL);
        if (!hardwareIds.isEmpty()) {
            hardwareIdPaths.add(hardwareIds.get(0).getObjectPath());
        }
    }
    Set<CIMObjectPath> maskPaths = new HashSet<CIMObjectPath>();
    for (CIMObjectPath hardwareIdPath : hardwareIdPaths) {
        maskPaths.addAll(DiscoveryUtils.getAssociatorNames(cimClient, hardwareIdPath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null));
    }
    Set<CIMObjectPath> volumePathsInMasks = new HashSet<CIMObjectPath>();
    Map<CIMObjectPath, String> volumeToPool = new HashMap<CIMObjectPath, String>();
    for (CIMObjectPath path : maskPaths) {
        _logger.info("Processing masking view {}", path.toString());
        List<CIMObjectPath> hardwareIdsInMask = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_HARDWARE_ID, null, null);
        // check if the mask is shared or exclusive
        String maskType = hardwareIdPaths.containsAll(hardwareIdsInMask) ? ExportGroup.ExportGroupType.Host.name() : ExportGroup.ExportGroupType.Cluster.name();
        List<CIMObjectPath> volumePaths = DiscoveryUtils.getAssociatorNames(cimClient, path, null, SmisConstants.CIM_STORAGE_VOLUME, null, null);
        for (CIMObjectPath volumePath : volumePaths) {
            if (ArrayAffinityDiscoveryUtils.isUnmanagedVolume(volumePath, dbClient)) {
                URI poolURI = ArrayAffinityDiscoveryUtils.getStoragePool(volumePath, cimClient, dbClient);
                if (!NullColumnValueGetter.isNullURI(poolURI)) {
                    if (ExportGroup.ExportGroupType.Host.name().equals(maskType)) {
                        volumePathsInMasks.add(volumePath);
                        volumeToPool.put(volumePath, poolURI.toString());
                    }
                    ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, poolURI.toString(), maskType);
                }
            }
        }
    }
    for (CIMObjectPath volumePath : volumePathsInMasks) {
        // get masks from the volume path
        List<CIMObjectPath> masks = DiscoveryUtils.getAssociatorNames(cimClient, volumePath, null, SmisConstants.CIM_PROTOCOL_CONTROLLER, null, null);
        if (!maskPaths.containsAll(masks)) {
            // shared volumes
            _logger.info("Volume {} is shared by multiple hosts", volumePath);
            ArrayAffinityDiscoveryUtils.addPoolToPreferredPoolMap(preferredPoolMap, volumeToPool.get(volumePath), ExportGroup.ExportGroupType.Cluster.name());
        }
    }
    return preferredPoolMap;
}
Also used : HashMap(java.util.HashMap) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) Initiator(com.emc.storageos.db.client.model.Initiator) HashSet(java.util.HashSet)

Example 49 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class AbstractCloneOperations method fractureSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void fractureSingleClone(StorageSystem storageSystem, URI source, URI cloneVolume, TaskCompleter taskCompleter) {
    _log.info("START fractureSingleClone operation");
    Volume clone = null;
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
        clone = _dbClient.queryObject(Volume.class, cloneVolume);
        URI sourceUri = clone.getAssociatedSourceVolume();
        if (!NullColumnValueGetter.isNullURI(sourceUri)) {
            BlockObject sourceObj = BlockObject.fetch(_dbClient, sourceUri);
            if (sourceObj != null) {
                StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
                CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
                CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
                if (instance != null) {
                    fractureReplica(storageSystem, syncObject);
                } else {
                    String errorMsg = "The clone is already detached. fracture will not be performed.";
                    _log.info(errorMsg);
                    ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
                    taskCompleter.error(_dbClient, error);
                }
            } else {
                String errorMsg = "The clone's source volume cannot be found in the database. Fractrure will not be performed.";
                _log.info(errorMsg);
                ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
                taskCompleter.error(_dbClient, error);
            }
        } else {
            String errorMsg = "The clone does not have a source volume. Fracture will not be performed.";
            _log.info(errorMsg);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("fractureSingleClone", errorMsg);
            taskCompleter.error(_dbClient, error);
        }
        clone.setReplicaState(ReplicationState.SYNCHRONIZED.name());
        _dbClient.persistObject(clone);
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String errorMsg = String.format(FRACTURE_ERROR_MSG_FORMAT, cloneVolume, clone.getAssociatedSourceVolume());
        _log.error(errorMsg, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.fractureFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) BlockObject(com.emc.storageos.db.client.model.BlockObject) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 50 with CIMInstance

use of javax.cim.CIMInstance in project coprhd-controller by CoprHD.

the class AbstractCloneOperations method resyncSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void resyncSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    _log.info("START resyncSingleClone operation");
    Volume clone = null;
    try {
        callEMCRefreshIfRequired(_dbClient, _helper, storageSystem, Arrays.asList(cloneVolume));
        clone = _dbClient.queryObject(Volume.class, cloneVolume);
        URI sourceUri = clone.getAssociatedSourceVolume();
        Volume sourceObj = _dbClient.queryObject(Volume.class, sourceUri);
        StorageSystem sourceSystem = _dbClient.queryObject(StorageSystem.class, sourceObj.getStorageController());
        CIMObjectPath syncObject = _cimPath.getStorageSynchronized(sourceSystem, sourceObj, storageSystem, clone);
        CIMInstance instance = _helper.checkExists(storageSystem, syncObject, false, false);
        if (instance != null) {
            CIMArgument[] inArgs = _helper.getResyncReplicaInputArguments(syncObject);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storageSystem, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisCloneResyncJob(job, storageSystem.getId(), taskCompleter)));
            }
        } else {
            String errorMsg = "The clone is already detached. resync will not be performed.";
            _log.info(errorMsg);
            ServiceError error = DeviceControllerErrors.smis.methodFailed("resyncSingleClone", errorMsg);
            taskCompleter.error(_dbClient, error);
        }
    } catch (Exception e) {
        String errorMsg = String.format(RESYNC_ERROR_MSG_FORMAT, cloneVolume);
        _log.error(errorMsg, e);
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resynchronizeFullCopyFailed(e));
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) Volume(com.emc.storageos.db.client.model.Volume) SmisCloneResyncJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCloneResyncJob) CIMObjectPath(javax.cim.CIMObjectPath) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMInstance(javax.cim.CIMInstance) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMInstance (javax.cim.CIMInstance)370 CIMObjectPath (javax.cim.CIMObjectPath)254 WBEMException (javax.wbem.WBEMException)139 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)104 ArrayList (java.util.ArrayList)98 BaseCollectionException (com.emc.storageos.plugins.BaseCollectionException)79 URI (java.net.URI)79 CIMArgument (javax.cim.CIMArgument)71 WBEMClient (javax.wbem.client.WBEMClient)69 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)62 Volume (com.emc.storageos.db.client.model.Volume)62 HashSet (java.util.HashSet)60 IOException (java.io.IOException)53 HashMap (java.util.HashMap)52 Iterator (java.util.Iterator)50 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)48 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)48 CIMProperty (javax.cim.CIMProperty)37 StringSet (com.emc.storageos.db.client.model.StringSet)31 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)29