Search in sources :

Example 71 with CIMInstance

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

the class QueryStatisticsProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    try {
        final Iterator<?> it = (Iterator<?>) resultObj;
        // Only 1 entry per each Array always
        while (it.hasNext()) {
            final CIMInstance queryInstance = (CIMInstance) it.next();
            keyMap.put(Constants._TimeCollected, System.currentTimeMillis());
            addPath(keyMap, operation.getResult(), queryInstance.getObjectPath());
        }
    } catch (Exception e) {
        _logger.error("Failed while processing QueryStatistics :", e);
    }
    resultObj = null;
}
Also used : Iterator(java.util.Iterator) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 72 with CIMInstance

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

the class SPProcessor method processResult.

@Override
public void processResult(Operation operation, Object resultObj, Map<String, Object> keyMap) throws BaseCollectionException {
    final Iterator<?> it = (Iterator<?>) resultObj;
    while (it.hasNext()) {
        try {
            final CIMInstance allocatedfrompool = (CIMInstance) it.next();
            CIMObjectPath path = (CIMObjectPath) allocatedfrompool.getProperty("Dependent").getValue();
            if (path.getObjectName().contains(_volume)) {
                String key = createKeyfromPath(path);
                // this check means, validating whether this Volume is
                // managed by Bourne
                Stat metrics = (Stat) getMetrics(keyMap, key);
                _logger.debug("Processing Volume to extract Allocated Capacity: {}", key);
                // Allocated Capacity =
                // CIM_AllocatedFromStoragePool.SpaceConsumed (in bytes)
                metrics.setAllocatedCapacity(Long.parseLong(allocatedfrompool.getProperty(_spaceConsumed).getValue().toString()));
            }
        } catch (Exception e) {
            if (!(e instanceof BaseCollectionException)) {
                _logger.error(" Allocated Capacity : ", e);
            }
        }
    }
    resultObj = null;
}
Also used : Stat(com.emc.storageos.db.client.model.Stat) Iterator(java.util.Iterator) CIMObjectPath(javax.cim.CIMObjectPath) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) CIMInstance(javax.cim.CIMInstance) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) SMIPluginException(com.emc.storageos.plugins.metering.smis.SMIPluginException)

Example 73 with CIMInstance

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

the class VmaxMirrorOperations method establishVolumeNativeContinuousCopyGroupRelation.

@Override
public void establishVolumeNativeContinuousCopyGroupRelation(StorageSystem storage, URI sourceVolume, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("establishVolumeNativeContinuousCopyGroupRelation operation START");
    try {
        /**
         * get groupPath for source volume
         * get groupPath for mirror
         * get mirrors belonging to the same Replication Group
         * get Element synchronizations between volumes and mirrors
         * call CreateGroupReplicaFromElementSynchronizations
         */
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
        CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
        CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
        CIMObjectPath mirrorGroupPath = _cimPath.getReplicationGroupPath(storage, mirrorObj.getReplicationGroupInstance());
        CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, mirrorGroupPath);
        CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
        if (syncInstance == null) {
            // List<Volume> volumes = ControllerUtils.getVolumesPartOfCG(sourceVolume.getConsistencyGroup(), _dbClient);
            // get all mirrors belonging to a Replication Group. There may be multiple mirrors available for a Volume
            List<BlockMirror> mirrors = ControllerUtils.getMirrorsPartOfReplicationGroup(mirrorObj.getReplicationGroupInstance(), _dbClient);
            List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
            for (BlockMirror mirrorObject : mirrors) {
                Volume volume = _dbClient.queryObject(Volume.class, mirrorObject.getSource());
                elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, mirrorObject));
            }
            _log.info("Creating Group synchronization between volume group and mirror group");
            CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, mirrorGroupPath, elementSynchronizations);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
        // No Job returned
        } else {
            _log.info("Link already established..");
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _log.error("Failed to establish group relation between volume group and mirror group. Volume: {}, Mirror: {}", sourceVolume, mirror);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 74 with CIMInstance

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

the class VmaxSnapshotOperations method establishVolumeSnapshotGroupRelation.

@Override
public void establishVolumeSnapshotGroupRelation(StorageSystem storage, URI sourceVolume, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("establishVolumeSnapshotGroupRelation operation START");
    try {
        /**
         * get groupPath for source volume
         * get groupPath for snapshot
         * get snapshots belonging to the same Replication Group
         * get Element synchronizations between volumes and snapshots
         * call CreateGroupReplicaFromElementSynchronizations
         */
        BlockSnapshot snapshotObj = _dbClient.queryObject(BlockSnapshot.class, snapshot);
        Volume volumeObj = _dbClient.queryObject(Volume.class, sourceVolume);
        CIMObjectPath srcRepSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        String volumeGroupName = ConsistencyGroupUtils.getSourceConsistencyGroupName(volumeObj, _dbClient);
        CIMObjectPath volumeGroupPath = _cimPath.getReplicationGroupPath(storage, volumeGroupName);
        CIMObjectPath snapshotGroupPath = _cimPath.getReplicationGroupPath(storage, snapshotObj.getReplicationGroupInstance());
        // Check if snapshot is referenced by a BlockSnapshotSession
        // if so, we must pass in the RelationshipName with the value of the session name.
        // NB. a SourceGroup aspect must exist
        List<BlockSnapshotSession> snapshotSessions = queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, getLinkedTargetSnapshotSessionConstraint(snapshot));
        String relationshipName = null;
        if (!snapshotSessions.isEmpty()) {
            relationshipName = snapshotSessions.get(0).getSessionLabel();
            _log.info("Found snapshot session relationship: {}", relationshipName);
        }
        CIMObjectPath groupSynchronizedPath = _cimPath.getGroupSynchronized(volumeGroupPath, snapshotGroupPath);
        CIMInstance syncInstance = _helper.checkExists(storage, groupSynchronizedPath, false, false);
        if (syncInstance == null) {
            // get all snapshots belonging to a Replication Group. There may be multiple snapshots available for a Volume
            List<BlockSnapshot> snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshotObj, _dbClient);
            List<CIMObjectPath> elementSynchronizations = new ArrayList<CIMObjectPath>();
            for (BlockSnapshot snapshotObject : snapshots) {
                Volume volume = _dbClient.queryObject(Volume.class, snapshotObject.getParent());
                elementSynchronizations.add(_cimPath.getStorageSynchronized(storage, volume, storage, snapshotObject));
            }
            _log.info("Creating Group synchronization between volume group and snapshot group");
            CIMArgument[] inArgs = _helper.getCreateGroupReplicaFromElementSynchronizationsForSRDFInputArguments(volumeGroupPath, snapshotGroupPath, elementSynchronizations, relationshipName);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.invokeMethod(storage, srcRepSvcPath, SmisConstants.CREATE_GROUP_REPLICA_FROM_ELEMENT_SYNCHRONIZATIONS, inArgs, outArgs);
        // No Job returned
        } else {
            _log.info("Link already established..");
        }
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        String msg = String.format("Failed to establish group relation between volume group and snapshot group. Volume: %s, Snapshot: %s", sourceVolume, snapshot);
        _log.error(msg, e);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CIMObjectPath(javax.cim.CIMObjectPath) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) CIMInstance(javax.cim.CIMInstance) SmisException(com.emc.storageos.volumecontroller.impl.smis.SmisException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) CIMArgument(javax.cim.CIMArgument)

Example 75 with CIMInstance

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

the class VmaxSnapshotOperations method createStorageSetting.

/**
 * In order to create VDEV targets for snapshots, we need to have a StorageSetting
 * with a parameter set to enable it. This method will create an instance of this.
 * We will try to maintain a single StorageSetting for this purpose, per pool. To
 * that end, we'll first check for the existence of the setting (based on a
 * special name).
 *
 * @param storage - StorageSystem where the pool exists
 * @param poolPath - CIMObject representing the pool to allocate targets from
 * @return CIMInstance - null => error. Otherwise, will be the StorageSetting
 *         instance for creating VDEVs against the pool.
 * @throws DeviceControllerException
 */
private CIMInstance createStorageSetting(StorageSystem storage, CIMObjectPath poolPath) throws Exception {
    CloseableIterator<CIMObjectPath> capabilities = null;
    CloseableIterator<CIMObjectPath> poolSettings = null;
    CIMInstance instance = null;
    try {
        // From the storage pool, get its capability (assuming there is only
        // one per pool). Get associated storage settings from the capability,
        // loop through each and find one that has the special name. If it
        // doesn't exist, create it and modify the StorageExtentInitialUsage
        // and ElementName.
        capabilities = _helper.getAssociatorNames(storage, poolPath, null, SYMM_STORAGE_POOL_CAPABILITIES, null, null);
        if (capabilities != null && capabilities.hasNext()) {
            CIMObjectPath poolCapabilities = capabilities.next();
            poolSettings = _helper.getAssociatorNames(storage, poolCapabilities, null, SYMM_STORAGE_POOL_SETTING, null, null);
            CIMInstance foundVdevSettingForThisPool = null;
            while (poolSettings != null && poolSettings.hasNext()) {
                CIMInstance it = _helper.getInstance(storage, poolSettings.next(), false, false, PL_STORAGE_EXTENT_INITIAL_USAGE);
                int storageExtentInitialUsage = Integer.valueOf(CIMPropertyFactory.getPropertyValue(it, CP_STORAGE_EXTENT_INITIAL_USAGE));
                if (storageExtentInitialUsage == DELTA_REPLICA_TARGET_VALUE) {
                    // We found a setting that has the "Delta Replica Target" value
                    // for the StorageExtentInitialUsage attribute
                    foundVdevSettingForThisPool = it;
                    break;
                }
            }
            if (foundVdevSettingForThisPool != null) {
                instance = foundVdevSettingForThisPool;
                _log.info(String.format("Found existing StorageSetting for VDEV %s", instance.toString()));
            } else {
                // It wasn't found ==> create it
                // TODO: How do we prevent concurrent operations from creating duplicates?
                _log.info("Could not find existing StorageSetting for VDEV, going to create it and modify it...");
                CIMArgument[] inArgs = _helper.getCreateDefaultStoragePoolSettingsArguments();
                CIMArgument[] outArgs = new CIMArgument[5];
                _helper.invokeMethod(storage, poolCapabilities, CREATE_SETTING, inArgs, outArgs);
                CIMObjectPath newSetting = _cimPath.getCimObjectPathFromOutputArgs(outArgs, NEW_SETTING);
                instance = _cimPath.getStoragePoolVdevSettings(newSetting);
                _helper.modifyInstance(storage, instance, PL_STORAGE_EXTENT_INITIAL_USAGE);
                // Get the unique ID for display
                CIMInstance newSettingInstance = _helper.getInstance(storage, newSetting, false, false, PL_ONLY_EMC_UNIQUE_ID);
                String emcUniqueId = CIMPropertyFactory.getPropertyValue(newSettingInstance, CP_EMC_UNIQUE_ID);
                _log.info(String.format("Created StorageSetting for VDEV %s (EMCUniqueID = %s)", instance.toString(), emcUniqueId));
            }
        } else {
            String message = String.format("Could not find any %s instances for StoragePool %s. Will not be able to create a StorageSetting.", SYMM_STORAGE_POOL_CAPABILITIES, poolPath.toString());
            _log.error(message);
            throw DeviceControllerExceptions.smis.noStoragePoolInstances(message, null);
        }
    } finally {
        if (capabilities != null) {
            capabilities.close();
        }
        if (poolSettings != null) {
            poolSettings.close();
        }
    }
    return instance;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) Factory.getLinkedTargetSnapshotSessionConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint.Factory.getLinkedTargetSnapshotSessionConstraint) 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