Search in sources :

Example 6 with CIMArgument

use of javax.cim.CIMArgument 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)

Example 7 with CIMArgument

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

the class AbstractCloneOperations method activateSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void activateSingleClone(StorageSystem storageSystem, URI fullCopy, TaskCompleter completer) {
    _log.info("START activateSingleClone for {}", fullCopy);
    try {
        Volume volume = _dbClient.queryObject(Volume.class, fullCopy);
        CIMArgument[] inArgs = _helper.getActivateFullCopyArguments(storageSystem, volume);
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.callModifyReplica(storageSystem, inArgs, outArgs);
        // Update sync active property
        volume.setSyncActive(true);
        volume.setRefreshRequired(true);
        volume.setReplicaState(ReplicationState.SYNCHRONIZED.name());
        _dbClient.persistObject(volume);
        completer.ready(_dbClient);
        _log.info("FINISH activateSingleClone for {}", fullCopy);
    } catch (Exception e) {
        String errorMsg = String.format(ACTIVATE_ERROR_MSG_FORMAT, fullCopy);
        _log.error(errorMsg, e);
        completer.error(_dbClient, DeviceControllerException.exceptions.activateVolumeFullCopyFailed(e));
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 8 with CIMArgument

use of javax.cim.CIMArgument 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)

Example 9 with CIMArgument

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

the class AbstractCloneOperations method getReplicationSettingDataInstanceForThinProvisioningPolicy.

@SuppressWarnings("rawtypes")
private CIMInstance getReplicationSettingDataInstanceForThinProvisioningPolicy(final StorageSystem storageSystem, int desiredValue) {
    CIMInstance modifiedInstance = null;
    try {
        CIMObjectPath replicationSettingCapabilities = _cimPath.getReplicationServiceCapabilitiesPath(storageSystem);
        CIMArgument[] inArgs = _helper.getReplicationSettingDataInstance();
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storageSystem, replicationSettingCapabilities, GET_DEFAULT_REPLICATION_SETTING_DATA, inArgs, outArgs);
        for (CIMArgument<?> outArg : outArgs) {
            if (null == outArg) {
                continue;
            }
            if (outArg.getName().equalsIgnoreCase(SmisConstants.DEFAULT_INSTANCE)) {
                CIMInstance repInstance = (CIMInstance) outArg.getValue();
                if (null != repInstance) {
                    CIMProperty<?> thinProvisioningPolicy = new CIMProperty<Object>(SmisConstants.THIN_PROVISIONING_POLICY, UINT16_T, new UnsignedInteger16(desiredValue));
                    CIMProperty<?> targetElementSupplier = new CIMProperty<Object>(TARGET_ELEMENT_SUPPLIER, UINT16_T, new UnsignedInteger16(CREATE_NEW_TARGET_VALUE));
                    CIMProperty<?>[] propArray = new CIMProperty<?>[] { thinProvisioningPolicy, targetElementSupplier };
                    modifiedInstance = repInstance.deriveInstance(propArray);
                    break;
                }
            }
        }
    } catch (Exception e) {
        _log.error("Error retrieving Replication Setting Data Instance ", e);
    }
    return modifiedInstance;
}
Also used : CIMProperty(javax.cim.CIMProperty) CIMObjectPath(javax.cim.CIMObjectPath) CIMInstance(javax.cim.CIMInstance) UnsignedInteger16(javax.cim.UnsignedInteger16) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) CIMArgument(javax.cim.CIMArgument)

Example 10 with CIMArgument

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

the class AbstractCloneOperations method detachSingleClone.

@Override
@SuppressWarnings("rawtypes")
public void detachSingleClone(StorageSystem storageSystem, URI cloneVolume, TaskCompleter taskCompleter) {
    _log.info("START detachSingleClone 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) {
                    CIMArgument[] inArgs = _helper.getDetachSynchronizationInputArguments(syncObject);
                    CIMArgument[] outArgs = new CIMArgument[5];
                    _helper.callModifyReplica(storageSystem, inArgs, outArgs);
                } else {
                    _log.info("The clone is already detached. Detach will not be performed.");
                }
            } else {
                _log.info("The clone's source volume cannot be found in the database. Detach will not be performed.");
            }
        } else {
            _log.info("The clone does not have a source volume. Detach will not be performed.");
        }
        // Update sync active property
        /**
         * cq:609984 - No need to reset sync active flag as its caused problem
         * when check for activated target volume.
         *
         * @see <code>BlockService#activateFullCopy
         * volume.setSyncActive(false);
         */
        ReplicationUtils.removeDetachedFullCopyFromSourceFullCopiesList(clone, _dbClient);
        clone.setAssociatedSourceVolume(NullColumnValueGetter.getNullURI());
        clone.setReplicaState(ReplicationState.DETACHED.name());
        _dbClient.persistObject(clone);
        if (taskCompleter != null) {
            taskCompleter.ready(_dbClient);
        }
    } catch (Exception e) {
        String errorMsg = String.format(DETACH_ERROR_MSG_FORMAT, cloneVolume, clone.getAssociatedSourceVolume());
        _log.error(errorMsg, e);
        if (taskCompleter != null) {
            taskCompleter.error(_dbClient, DeviceControllerException.exceptions.detachVolumeFullCopyFailed(e));
        }
    }
}
Also used : 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) CIMArgument(javax.cim.CIMArgument)

Aggregations

CIMArgument (javax.cim.CIMArgument)234 CIMObjectPath (javax.cim.CIMObjectPath)190 WBEMException (javax.wbem.WBEMException)129 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)127 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)80 ArrayList (java.util.ArrayList)74 CIMInstance (javax.cim.CIMInstance)71 Volume (com.emc.storageos.db.client.model.Volume)48 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)42 URI (java.net.URI)39 SmisException (com.emc.storageos.volumecontroller.impl.smis.SmisException)36 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)32 BlockObject (com.emc.storageos.db.client.model.BlockObject)29 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)29 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)26 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)23 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)22 HashSet (java.util.HashSet)16 List (java.util.List)16 CIMProperty (javax.cim.CIMProperty)16