Search in sources :

Example 6 with RemoteDirectorGroup

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

the class SRDFDeviceController method createCGSRDFVolumes.

protected void createCGSRDFVolumes(Workflow workflow, String waitFor, List<VolumeDescriptor> sourceDescriptors, List<VolumeDescriptor> targetDescriptors, Map<URI, Volume> uriVolumeMap) {
    RemoteDirectorGroup group = getRAGroup(targetDescriptors, uriVolumeMap);
    StorageSystem system = dbClient.queryObject(StorageSystem.class, group.getSourceStorageSystemUri());
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, group.getRemoteStorageSystemUri());
    // finding actual volumes from Provider
    Set<String> volumes = findVolumesPartOfRDFGroups(system, group);
    if (group.getVolumes() == null) {
        group.setVolumes(new StringSet());
    }
    /*
         * Check the following 2 conditions.
         * 1. If there are no volumes in RDFGroup on Array & volumes in RDFGroup in ViPR DB.
         * 2. If there are volumes in RDFGroup on Array & no volumes in RDFGroup in ViPR DB.
         */
    if ((group.getVolumes().isEmpty() && !volumes.isEmpty()) || (!group.getVolumes().isEmpty() && volumes.isEmpty())) {
        // throw Exception rediscover source and target arrays.
        log.warn("RDF Group {} out of sync with Array", group.getNativeGuid());
        List<URI> sourceURIs = VolumeDescriptor.getVolumeURIs(sourceDescriptors);
        List<URI> targetURIs = VolumeDescriptor.getVolumeURIs(targetDescriptors);
        URI vpoolChangeUri = getVirtualPoolChangeVolume(sourceDescriptors);
        for (URI sourceUri : sourceURIs) {
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceUri);
            if (null != sourceVolume) {
                log.info("Clearing source volume {}-->{}", sourceVolume.getNativeGuid(), sourceVolume.getId());
                if (null == vpoolChangeUri) {
                    // clear everything if not vpool change
                    sourceVolume.setPersonality(NullColumnValueGetter.getNullStr());
                    sourceVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                    sourceVolume.setInactive(true);
                    sourceVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                }
                if (null != sourceVolume.getSrdfTargets()) {
                    sourceVolume.getSrdfTargets().clear();
                }
                dbClient.updateObject(sourceVolume);
            }
        }
        for (URI targetUri : targetURIs) {
            Volume targetVolume = dbClient.queryObject(Volume.class, targetUri);
            if (null != targetVolume) {
                log.info("Clearing target volume {}-->{}", targetVolume.getNativeGuid(), targetVolume.getId());
                targetVolume.setPersonality(NullColumnValueGetter.getNullStr());
                targetVolume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
                targetVolume.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
                targetVolume.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
                targetVolume.setSrdfGroup(NullColumnValueGetter.getNullURI());
                targetVolume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
                targetVolume.setInactive(true);
                dbClient.updateObject(targetVolume);
            }
        }
        throw DeviceControllerException.exceptions.srdfAsyncStepCreationfailed(group.getNativeGuid());
    }
    group.getVolumes().replace(volumes);
    dbClient.updateObject(group);
    if (volumes.isEmpty() && SupportedCopyModes.ALL.toString().equalsIgnoreCase(group.getSupportedCopyMode())) {
        log.info("RA Group {} was empty", group.getId());
        waitFor = createSrdfCgPairStepsOnEmptyGroup(sourceDescriptors, targetDescriptors, group, waitFor, workflow);
    } else {
        log.info("RA Group {} not empty", group.getId());
        waitFor = createSrdfCGPairStepsOnPopulatedGroup(sourceDescriptors, group, uriVolumeMap, waitFor, workflow);
    }
    // Generate workflow step to refresh target system after CG creation.
    if (null != system) {
        waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, system, null, waitFor, workflow);
    }
    if (null != targetSystem) {
        waitFor = addStepToRefreshSystem(CREATE_SRDF_MIRRORS_STEP_GROUP, targetSystem, null, waitFor, workflow);
    }
    // Refresh target volume properties
    Mode SRDFMode = getSRDFMode(sourceDescriptors, uriVolumeMap);
    if (Mode.ACTIVE.equals(SRDFMode)) {
        refreshVolumeProperties(targetDescriptors, targetSystem, waitFor, workflow);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) Mode(com.emc.storageos.volumecontroller.impl.smis.SRDFOperations.Mode) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) FCTN_STRING_TO_URI(com.emc.storageos.db.client.util.CommonTransformerFunctions.FCTN_STRING_TO_URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 7 with RemoteDirectorGroup

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

the class StorageSystemService method getAllRAGroups.

/**
 * Get All RA Groups
 *
 * @param id
 * @brief List RDF groups names in a storage system
 * @return
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/rdf-groups")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public RDFGroupList getAllRAGroups(@PathParam("id") URI id) {
    // Make sure storage system is registered.
    ArgValidator.checkFieldUriType(id, StorageSystem.class, "id");
    StorageSystem system = queryResource(id);
    ArgValidator.checkEntity(system, id, isIdEmbeddedInURL(id));
    RDFGroupList rdfGroupList = new RDFGroupList();
    URIQueryResultList rdfGroupURIs = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getStorageDeviceRemoteGroupsConstraint(id), rdfGroupURIs);
    Iterator<URI> rdfGroupIter = rdfGroupURIs.iterator();
    while (rdfGroupIter.hasNext()) {
        URI rdfGroupURI = rdfGroupIter.next();
        RemoteDirectorGroup rdfGroup = _dbClient.queryObject(RemoteDirectorGroup.class, rdfGroupURI);
        if (rdfGroup != null && !rdfGroup.getInactive()) {
            rdfGroupList.getRdfGroups().add(toNamedRelatedResource(rdfGroup, rdfGroup.getNativeGuid()));
        }
    }
    return rdfGroupList;
}
Also used : RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) RDFGroupList(com.emc.storageos.model.rdfgroup.RDFGroupList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 8 with RemoteDirectorGroup

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

the class PlacementTestUtils method createSRDFStorageSystems.

/**
 * Create SRDF paired vmax arrays.
 * @param dbClient
 * @param label1
 * @param network1
 * @param portWWNs1
 * @param varray1
 * @param label2
 * @param network2
 * @param portWWNs2
 * @param varray2
 * @return StorageSystem[1] and StorageSystem[2]; StorageSystem[0] not used.
 */
public static StorageSystem[] createSRDFStorageSystems(DbClient dbClient, String label1, Network network1, String[] portWWNs1, VirtualArray varray1, String label2, Network network2, String[] portWWNs2, VirtualArray varray2) {
    StorageSystem[] storageSystems = new StorageSystem[3];
    // Create 2 storage systems
    StorageSystem storageSystem1 = PlacementTestUtils.createStorageSystem(dbClient, "vmax", label1);
    storageSystems[1] = storageSystem1;
    StorageSystem storageSystem2 = PlacementTestUtils.createStorageSystem(dbClient, "vmax", label2);
    storageSystems[2] = storageSystem2;
    // Mark them SRDF capable
    StringSet supportedAsynchronousActions = new StringSet();
    supportedAsynchronousActions.add(StorageSystem.AsyncActions.CreateElementReplica.name());
    supportedAsynchronousActions.add(StorageSystem.AsyncActions.CreateGroupReplica.name());
    storageSystem1.setSupportedAsynchronousActions(supportedAsynchronousActions);
    storageSystem2.setSupportedAsynchronousActions(supportedAsynchronousActions);
    StringSet supportedReplicationTypes = new StringSet();
    supportedReplicationTypes.add(StorageSystem.SupportedReplicationTypes.SRDF.name());
    storageSystem1.setSupportedReplicationTypes(supportedReplicationTypes);
    storageSystem2.setSupportedReplicationTypes(supportedReplicationTypes);
    // Set connected to.
    StringSet connectedTo = new StringSet();
    connectedTo.add(storageSystem2.getId().toString());
    storageSystem1.setRemotelyConnectedTo(connectedTo);
    connectedTo = new StringSet();
    connectedTo.add(storageSystem1.getId().toString());
    storageSystem2.setRemotelyConnectedTo(connectedTo);
    dbClient.updateObject(storageSystem1, storageSystem2);
    // Create RemoteDirectorGroups
    RemoteDirectorGroup rdg1 = new RemoteDirectorGroup();
    rdg1.setActive(true);
    rdg1.setConnectivityStatus(RemoteDirectorGroup.ConnectivityStatus.UP.name());
    rdg1.setLabel("RDG1");
    rdg1.setId(URI.create("RDG1" + label1));
    rdg1.setNativeGuid("$label1+$label2+6");
    rdg1.setRemoteGroupId("6");
    rdg1.setRemoteStorageSystemUri(storageSystem2.getId());
    rdg1.setSourceGroupId("6");
    rdg1.setSourceStorageSystemUri(storageSystem1.getId());
    rdg1.setSupportedCopyMode(RemoteDirectorGroup.SupportedCopyModes.ASYNCHRONOUS.name());
    dbClient.createObject(rdg1);
    RemoteDirectorGroup rdg2 = new RemoteDirectorGroup();
    rdg2.setActive(true);
    rdg2.setConnectivityStatus(RemoteDirectorGroup.ConnectivityStatus.UP.name());
    rdg2.setLabel("RDG2");
    rdg2.setId(URI.create("RDG2" + label1));
    rdg2.setNativeGuid("$label2+$label1+6");
    rdg2.setRemoteGroupId("6");
    rdg2.setRemoteStorageSystemUri(storageSystem1.getId());
    rdg2.setSourceGroupId("6");
    rdg2.setSourceStorageSystemUri(storageSystem2.getId());
    rdg2.setSupportedCopyMode(RemoteDirectorGroup.SupportedCopyModes.ASYNCHRONOUS.name());
    dbClient.createObject(rdg2);
    // Create two front-end storage ports system1.
    List<StoragePort> system1Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < portWWNs1.length; i++) {
        system1Ports.add(PlacementTestUtils.createStoragePort(dbClient, storageSystem1, network1, portWWNs1[i], varray1, StoragePort.PortType.frontend.name(), "portGroupSite1vmax" + i, "C0+FC0" + i));
    }
    // Create two front-end storage ports system2
    List<StoragePort> system2Ports = new ArrayList<StoragePort>();
    for (int i = 0; i < portWWNs2.length; i++) {
        system2Ports.add(PlacementTestUtils.createStoragePort(dbClient, storageSystem2, network2, portWWNs2[i], varray2, StoragePort.PortType.frontend.name(), "portGroupSite2vmax" + i, "D0+FC0" + i));
    }
    return storageSystems;
}
Also used : StringSet(com.emc.storageos.db.client.model.StringSet) StoragePort(com.emc.storageos.db.client.model.StoragePort) ArrayList(java.util.ArrayList) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 9 with RemoteDirectorGroup

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

the class SRDFChangeCopyModeTaskCompleter method complete.

@Override
protected void complete(DbClient dbClient, Status status, ServiceCoded coded) throws DeviceControllerException {
    try {
        setDbClient(dbClient);
        switch(status) {
            case ready:
                RemoteDirectorGroup rdfGrp = null;
                for (Volume target : tgtVolumes) {
                    target.setSrdfCopyMode(newCopyMode);
                    dbClient.persistObject(target);
                    log.info(String.format("SRDF Device source %s and target %s copy mode got changed into %s", target.getSrdfParent().toString(), target.getId().toString(), newCopyMode));
                    if (rdfGrp == null) {
                        rdfGrp = dbClient.queryObject(RemoteDirectorGroup.class, target.getSrdfGroup());
                    }
                }
                if (rdfGrp != null) {
                    rdfGrp.setSupportedCopyMode(newCopyMode);
                    dbClient.persistObject(rdfGrp);
                    log.info("RDF Group {} copy mode got changed into : {}", rdfGrp.getId(), newCopyMode);
                }
                break;
            default:
                log.info("Unable to handle SRDF Link Change Copy Mode Operational status: {}", status);
        }
    } catch (Exception e) {
        log.error("Failed change copy mode. SRDFMirror {}, for task " + getOpId(), getId(), e);
    } finally {
        super.complete(dbClient, status, coded);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 10 with RemoteDirectorGroup

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

the class ConnectivityCollectionRelationshipsProcessor 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;
        boolean volumeAdded = false;
        DbClient dbClient = (DbClient) keyMap.get(Constants.dbClient);
        CIMObjectPath raGroupPath = getObjectPathfromCIMArgument(args);
        String ragGroupId = NativeGUIDGenerator.generateRAGroupNativeGuid(raGroupPath);
        _log.debug("RA Group Id : {}", ragGroupId);
        RemoteDirectorGroup rg = getRAGroupUriFromDB(dbClient, ragGroupId);
        if (null == rg) {
            _log.info("RA Group Not found : {}", ragGroupId);
            return;
        }
        URI raGroupUri = rg.getId();
        @SuppressWarnings("unchecked") Map<String, URI> rAGroupMap = (Map<String, URI>) keyMap.get(Constants.RAGROUP);
        Set<String> volumeNativeGuids = new StringSet();
        while (it.hasNext()) {
            CIMObjectPath connCollectionRelationPaths = it.next();
            String cimClass = connCollectionRelationPaths.getObjectName();
            if (PROTOCOL_END_POINT.equals(cimClass)) {
                String endPointId = connCollectionRelationPaths.getKey(Constants.NAME).getValue().toString();
                _log.info("End Point Added {}", connCollectionRelationPaths);
                addPath(keyMap, Constants.ENDPOINTS_RAGROUP, connCollectionRelationPaths);
                rAGroupMap.put(endPointId, raGroupUri);
            } else if (VOLUME.equals(cimClass)) {
                String volumeNativeGuid = getVolumeNativeGuid(connCollectionRelationPaths);
                if (!volumeAdded && !rAGroupMap.containsKey(volumeNativeGuid)) {
                    volumeAdded = true;
                    _log.info("Volume Added {}", connCollectionRelationPaths);
                    addPath(keyMap, Constants.VOLUME_RAGROUP, connCollectionRelationPaths);
                    rAGroupMap.put(volumeNativeGuid, raGroupUri);
                } else {
                    _log.info("Volume {} is part of multiple RA Groups", volumeNativeGuid);
                }
                volumeNativeGuids.add(volumeNativeGuid);
            }
        }
        RemoteDirectorGroup remoteGroup = dbClient.queryObject(RemoteDirectorGroup.class, raGroupUri);
        // async
        if (!volumeAdded) {
            remoteGroup.setSupportedCopyMode(SupportedCopyModes.ALL.toString());
        }
        if (null == remoteGroup.getVolumes() || remoteGroup.getVolumes().isEmpty()) {
            remoteGroup.setVolumes(new StringSet(volumeNativeGuids));
        } else {
            _log.debug("Existing Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
            _log.debug("New Volumes {}", Joiner.on("\t").join(volumeNativeGuids));
            remoteGroup.getVolumes().replace(volumeNativeGuids);
            _log.debug("Updated Volumes {}", Joiner.on("\t").join(remoteGroup.getVolumes()));
        }
        dbClient.persistObject(remoteGroup);
    } catch (Exception e) {
        _log.error("Exception occurred while processing remote connectivity information.", e);
    }
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) CIMObjectPath(javax.cim.CIMObjectPath) URI(java.net.URI) BaseCollectionException(com.emc.storageos.plugins.BaseCollectionException) Iterator(java.util.Iterator) StringSet(com.emc.storageos.db.client.model.StringSet) RemoteDirectorGroup(com.emc.storageos.db.client.model.RemoteDirectorGroup) Map(java.util.Map)

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