Search in sources :

Example 51 with CIMInstance

use of javax.cim.CIMInstance 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 52 with CIMInstance

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

Example 53 with CIMInstance

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

the class AbstractMirrorOperations method resumeSingleVolumeMirror.

@Override
public void resumeSingleVolumeMirror(StorageSystem storage, URI mirror, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("resumeSingleVolumeMirror operation START");
    CloseableIterator<CIMObjectPath> storageSyncRefs = null;
    try {
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        CIMObjectPath mirrorPath = _cimPath.getBlockObjectPath(storage, mirrorObj);
        // Get reference to the CIM_StorageSynchronized instance
        storageSyncRefs = _helper.getReference(storage, mirrorPath, SmisConstants.CIM_STORAGE_SYNCHRONIZED, null);
        if (!storageSyncRefs.hasNext()) {
            _log.error("No synchronization instance found for {}", mirror);
            taskCompleter.error(_dbClient, DeviceControllerException.exceptions.resumeVolumeMirrorFailed(mirror));
            return;
        }
        boolean isVmax3 = storage.checkIfVmax3();
        while (storageSyncRefs.hasNext()) {
            CIMObjectPath storageSync = storageSyncRefs.next();
            _log.debug(storageSync.toString());
            /**
             * JIRA CTRL-11855
             * User created mirror and did pause operation using SMI 4.6.2.
             * Then He upgraded to SMI 8.0.3. While doing mirror resume getting exception from SMI because of the
             * existing mirrorObj.getSynchronizedInstance() contains SystemName=\"SYMMETRIX+000195701573\""
             * This is wrong with 8.0.3 as SystemName=\"SYMMETRIX-+-000195701573\"".
             * To resolve this issue setting new value collected from current smis provider here.
             */
            mirrorObj.setSynchronizedInstance(storageSync.toString());
            _dbClient.persistObject(mirrorObj);
            CIMArgument[] inArgs = isVmax3 ? _helper.getResumeSynchronizationInputArgumentsWithCopyState(storageSync) : _helper.getResumeSynchronizationInputArguments(storageSync);
            CIMArgument[] outArgs = new CIMArgument[5];
            _helper.callModifyReplica(storage, inArgs, outArgs);
            CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
            if (job != null) {
                ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockResumeMirrorJob(job, storage.getId(), taskCompleter)));
            } else {
                CIMInstance syncObject = _helper.getInstance(storage, storageSync, false, false, new String[] { SmisConstants.CP_SYNC_STATE });
                mirrorObj.setSyncState(CIMPropertyFactory.getPropertyValue(syncObject, SmisConstants.CP_SYNC_STATE));
                _dbClient.persistObject(mirrorObj);
                taskCompleter.ready(_dbClient);
            }
        }
    } catch (Exception e) {
        _log.error("Failed to resume single volume mirror: {}", mirror);
        ServiceError serviceError = DeviceControllerException.errors.jobFailed(e);
        taskCompleter.error(_dbClient, serviceError);
    } finally {
        if (storageSyncRefs != null) {
            storageSyncRefs.close();
        }
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockResumeMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockResumeMirrorJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) CIMArgument(javax.cim.CIMArgument)

Example 54 with CIMInstance

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

the class AbstractMirrorOperations method createSingleVolumeMirror.

@Override
public void createSingleVolumeMirror(StorageSystem storage, URI mirror, Boolean createInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _log.info("createSingleVolumeMirror operation START");
    try {
        BlockMirror mirrorObj = _dbClient.queryObject(BlockMirror.class, mirror);
        StoragePool targetPool = _dbClient.queryObject(StoragePool.class, mirrorObj.getPool());
        Volume source = _dbClient.queryObject(Volume.class, mirrorObj.getSource());
        TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, source.getTenant().getURI());
        String tenantName = tenant.getLabel();
        String targetLabelToUse = _nameGenerator.generate(tenantName, mirrorObj.getLabel(), mirror.toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
        CIMObjectPath replicationSvcPath = _cimPath.getControllerReplicationSvcPath(storage);
        CIMArgument[] inArgs = null;
        if (storage.checkIfVmax3()) {
            CIMObjectPath volumeGroupPath = _helper.getVolumeGroupPath(storage, storage, source, targetPool);
            CIMInstance replicaSettingData = getDefaultReplicationSettingData(storage);
            inArgs = _helper.getCreateElementReplicaMirrorInputArguments(storage, source, targetPool, createInactive, targetLabelToUse, volumeGroupPath, replicaSettingData);
        } else {
            inArgs = _helper.getCreateElementReplicaMirrorInputArguments(storage, source, targetPool, createInactive, targetLabelToUse);
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(storage, replicationSvcPath, SmisConstants.CREATE_ELEMENT_REPLICA, inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            ControllerServiceImpl.enqueueJob(new QueueJob(new SmisBlockCreateMirrorJob(job, storage.getId(), !createInactive, taskCompleter)));
            // Resynchronizing state applies to the initial copy as well as future
            // re-synchronization's.
            mirrorObj.setSyncState(SynchronizationState.RESYNCHRONIZING.toString());
            _dbClient.persistObject(mirrorObj);
        }
    } catch (final InternalException e) {
        _log.info("Problem making SMI-S call: ", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception e) {
        _log.info("Problem making SMI-S call: ", e);
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BlockMirror(com.emc.storageos.db.client.model.BlockMirror) StoragePool(com.emc.storageos.db.client.model.StoragePool) CIMObjectPath(javax.cim.CIMObjectPath) SmisBlockCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisBlockCreateMirrorJob) CIMInstance(javax.cim.CIMInstance) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) CIMArgument(javax.cim.CIMArgument)

Example 55 with CIMInstance

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

the class CIMObjectPathCreatorFactory method getTargetPortPaths.

@Override
public CIMObjectPath[] getTargetPortPaths(StorageSystem storageDevice, List<URI> targetURIList) throws Exception {
    List<CIMObjectPath> objectPaths = new ArrayList<CIMObjectPath>();
    Set<String> portSet = new HashSet<String>();
    for (URI target : targetURIList) {
        StoragePort storagePort = dbClient.queryObject(StoragePort.class, target);
        String portName;
        if (storagePort.getTransportType().equals("FC")) {
            portName = storagePort.getPortNetworkId().replaceAll(":", "");
        } else {
            portName = storagePort.getPortEndPointID();
        }
        portSet.add(portName);
    }
    CIMObjectPath storageSystemPath = getStorageSystem(storageDevice);
    CloseableIterator<CIMInstance> storageProcessorSystemItr = null;
    CloseableIterator<CIMInstance> protocolEndpointItr = null;
    try {
        // Get all of the Storage Processor Systems associated with the Storage System
        storageProcessorSystemItr = cimConnectionFactory.getConnection(storageDevice).getCimClient().associatorInstances(storageSystemPath, null, EMC_STORAGE_PROCESSOR_SYSTEM, null, null, false, null);
        while (storageProcessorSystemItr.hasNext()) {
            CIMInstance cimSPSInstance = storageProcessorSystemItr.next();
            // Get all of the Protocol Endpoints associated with the Storage Processor System
            protocolEndpointItr = cimConnectionFactory.getConnection(storageDevice).getCimClient().associatorInstances(cimSPSInstance.getObjectPath(), null, CIM_PROTOCOL_ENDPOINT, null, null, false, null);
            while (protocolEndpointItr.hasNext()) {
                CIMInstance cimPEInstance = protocolEndpointItr.next();
                String protocolEndpointName = CIMPropertyFactory.getPropertyValue(cimPEInstance, SmisConstants.CP_NAME);
                if (portSet.contains(protocolEndpointName)) {
                    objectPaths.add(cimPEInstance.getObjectPath());
                }
            }
        }
    } catch (Exception e) {
        _log.error("Failed trying to find suitable target protocol endpoints for Storage System {}", storageDevice.getId(), e);
        throw e;
    } finally {
        closeCIMIterator(storageProcessorSystemItr);
        closeCIMIterator(protocolEndpointItr);
    }
    CIMObjectPath[] objectPathArray = {};
    objectPathArray = objectPaths.toArray(objectPathArray);
    return objectPathArray;
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) StoragePort(com.emc.storageos.db.client.model.StoragePort) URI(java.net.URI) CIMInstance(javax.cim.CIMInstance) HashSet(java.util.HashSet)

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