Search in sources :

Example 36 with RemoteDirectorGroup

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

the class SRDFLinkStartCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    _log.info("Completing with status: {}", status);
    try {
        setDbClient(dbClient);
        switch(status) {
            case ready:
                Volume target = getTargetVolume();
                // a target R2 for CG.
                if (null != sourceCGUri) {
                    URI targetSystemUri = target.getStorageController();
                    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, targetSystemUri);
                    if (targetSystem.getTargetCgs() == null) {
                        targetSystem.setTargetCgs(new StringSet());
                    }
                    targetSystem.getTargetCgs().add(sourceCGUri.toString());
                    dbClient.persistObject(targetSystem);
                }
                RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
                group.setSourceReplicationGroupName(sourceRepGroup);
                group.setTargetReplicationGroupName(targetRepGroup);
                dbClient.persistObject(group);
                break;
            default:
                _log.info("Unable to handle status: {}", status);
        }
        recordSRDFOperation(dbClient, OperationTypeEnum.CREATE_SRDF_LINK, status, getSourceVolume().getId().toString(), getTargetVolume().getId().toString());
    } catch (Exception e) {
        _log.error("Failed updating status. SRDFLinkStart {}, for task " + getOpId(), getId(), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 37 with RemoteDirectorGroup

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

the class StorageProcessor method checkRAGroupExistsInDB.

protected RemoteDirectorGroup checkRAGroupExistsInDB(DbClient dbClient, CIMInstance instance) {
    String raGroupNativeGuid = NativeGUIDGenerator.generateRAGroupNativeGuid(instance);
    _logger.info("RA Group Id :" + raGroupNativeGuid);
    @SuppressWarnings("deprecation") List<URI> raGroupUris = dbClient.queryByConstraint(AlternateIdConstraint.Factory.getRAGroupByNativeGuidConstraint(raGroupNativeGuid));
    for (URI raGroupURI : raGroupUris) {
        RemoteDirectorGroup raGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupURI);
        if (null != raGroup && !raGroup.getInactive()) {
            return raGroup;
        }
    }
    return null;
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) URI(java.net.URI)

Example 38 with RemoteDirectorGroup

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

the class RemoteConnCollectionToVolumeProcessor 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;
        @SuppressWarnings("unchecked") Map<String, RemoteMirrorObject> volumeToRAGroupMap = (Map<String, RemoteMirrorObject>) keyMap.get(Constants.UN_VOLUME_RAGROUP_MAP);
        _dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
        String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
        _log.debug("RA Group Id :" + ragGroupId);
        RemoteDirectorGroup remoteGroup = getRAGroupUriFromDB(_dbClient, ragGroupId);
        if (null == remoteGroup) {
            _log.warn("RA Group {} not found", ragGroupId);
            return;
        }
        boolean is80Provider = keyMap.containsKey(Constants.IS_NEW_SMIS_PROVIDER) && Boolean.valueOf(keyMap.get(Constants.IS_NEW_SMIS_PROVIDER).toString());
        RemoteDirectorGroup targetRemoteGroup = SRDFUtils.getAssociatedTargetRemoteDirectorGroup(_dbClient, is80Provider, ragGroupId);
        while (it.hasNext()) {
            CIMObjectPath volumePath = it.next();
            RemoteMirrorObject rmObj = new RemoteMirrorObject();
            addPath(keyMap, operation.getResult(), volumePath);
            String unManagedVolumeNativeGuid = getUnManagedVolumeNativeGuidFromVolumePath(volumePath);
            // Changes to copy mode in RemoteDirectorGroup is updated in StorageSynchronizedProcessor
            rmObj.setCopyMode(remoteGroup.getSupportedCopyMode());
            rmObj.setSourceRaGroupUri(remoteGroup.getId());
            if (targetRemoteGroup != null) {
                rmObj.setTargetRaGroupUri(targetRemoteGroup.getId());
            }
            if (!volumeToRAGroupMap.containsKey(unManagedVolumeNativeGuid)) {
                volumeToRAGroupMap.put(unManagedVolumeNativeGuid, rmObj);
            }
        }
    } catch (Exception e) {
        _log.error("Updating Copy Mode for UnManaged Volumes failed", e);
    }
}
Also used : CIMObjectPath(javax.cim.CIMObjectPath) Iterator(java.util.Iterator) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Map(java.util.Map) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException)

Example 39 with RemoteDirectorGroup

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

the class SRDFOperations method createListReplicas.

public void createListReplicas(StorageSystem system, List<URI> sources, List<URI> targets, boolean addWaitForCopyState, TaskCompleter completer) {
    try {
        Volume firstTarget = dbClient.queryObject(Volume.class, targets.get(0));
        RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, firstTarget.getSrdfGroup());
        StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
        int modeValue = Mode.valueOf(firstTarget.getSrdfCopyMode()).getMode();
        CIMObjectPath srcRepSvcPath = cimPath.getControllerReplicationSvcPath(system);
        CIMObjectPath repCollectionPath = cimPath.getRemoteReplicationCollection(system, group);
        boolean formatVolumeFlagNeeded = ((SRDFMirrorCreateCompleter) completer).getVirtualPoolChangeURI() == null;
        boolean emptyRDFGroup = group.getVolumes() == null || group.getVolumes().isEmpty();
        CIMInstance replicationSettingDataInstance = getReplicationSettingDataInstance(system, modeValue, !emptyRDFGroup, formatVolumeFlagNeeded);
        List<CIMObjectPath> sourcePaths = new ArrayList<>();
        List<CIMObjectPath> targetPaths = new ArrayList<>();
        // Due to this reason code is changed to fetch one volume at a time in the loop.
        for (URI sourceVolumeURI : sources) {
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeURI);
            log.debug("sourceVolumeId:{} sourceNativeId {}", sourceVolume.getId(), sourceVolume.getNativeId());
            sourcePaths.add(cimPath.getVolumePath(system, sourceVolume.getNativeId()));
        }
        for (URI targetVolumeURI : targets) {
            Volume targetVolume = dbClient.queryObject(Volume.class, targetVolumeURI);
            log.debug("targetVolumeId:{} targetNativeId {}", targetVolume.getId(), targetVolume.getNativeId());
            targetPaths.add(cimPath.getVolumePath(targetSystem, targetVolume.getNativeId()));
        }
        CIMArgument[] inArgs = helper.getCreateListReplicaInputArguments(system, sourcePaths.toArray(new CIMObjectPath[sourcePaths.size()]), targetPaths.toArray(new CIMObjectPath[targetPaths.size()]), modeValue, repCollectionPath, replicationSettingDataInstance, addWaitForCopyState);
        CIMArgument[] outArgs = new CIMArgument[5];
        helper.invokeMethodSynchronously(system, srcRepSvcPath, SmisConstants.CREATE_LIST_REPLICA, inArgs, outArgs, new SmisSRDFCreateMirrorJob(null, system.getId(), completer));
        completer.ready(dbClient);
    } catch (WBEMException wbeme) {
        log.error("SMI-S error creating mirrors for {}", Joiner.on(',').join(sources), wbeme);
        ServiceError error = SmisException.errors.jobFailed(wbeme.getMessage());
        WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
        completer.error(dbClient, error);
    } catch (Exception e) {
        log.error("Error creating mirrors for {}", Joiner.on(',').join(sources), e);
        ServiceError error = SmisException.errors.jobFailed(e.getMessage());
        WorkflowStepCompleter.stepFailed(completer.getOpId(), error);
        completer.error(dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) PrefixConstraint(com.emc.storageos.db.client.constraint.PrefixConstraint) CustomQueryUtility.queryActiveResourcesByConstraint(com.emc.storageos.db.client.util.CustomQueryUtility.queryActiveResourcesByConstraint) CIMInstance(javax.cim.CIMInstance) RemoteGroupAssociationNotFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) NoSynchronizationsFoundException(com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException) SmisSRDFCreateMirrorJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisSRDFCreateMirrorJob) Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Example 40 with RemoteDirectorGroup

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

the class SRDFOperations method changeRemoteDirectorGroup.

private void changeRemoteDirectorGroup(URI remoteGroupUri) {
    RemoteDirectorGroup group = dbClient.queryObject(RemoteDirectorGroup.class, remoteGroupUri);
    // Swap names
    String srcName = group.getSourceReplicationGroupName();
    group.setSourceReplicationGroupName(group.getTargetReplicationGroupName());
    group.setTargetReplicationGroupName(srcName);
    // TODO Should we swap anything else here? Source/Remote system?
    dbClient.persistObject(group);
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup)

Aggregations

RemoteDirectorGroup (com.emc.storageos.db.client.model.RemoteDirectorGroup)53 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)30 URI (java.net.URI)30 Volume (com.emc.storageos.db.client.model.Volume)23 StringSet (com.emc.storageos.db.client.model.StringSet)16 ArrayList (java.util.ArrayList)15 CIMObjectPath (javax.cim.CIMObjectPath)13 NamedURI (com.emc.storageos.db.client.model.NamedURI)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)10 CIMInstance (javax.cim.CIMInstance)9 FCTN_STRING_TO_URI (com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI)8 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)6 NoSynchronizationsFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.NoSynchronizationsFoundException)6 RemoteGroupAssociationNotFoundException (com.emc.storageos.volumecontroller.impl.smis.srdf.exceptions.RemoteGroupAssociationNotFoundException)6 Workflow (com.emc.storageos.workflow.Workflow)6 Method (com.emc.storageos.workflow.Workflow.Method)6 CIMArgument (javax.cim.CIMArgument)6 WBEMException (javax.wbem.WBEMException)6 PrefixConstraint (com.emc.storageos.db.client.constraint.PrefixConstraint)5