Search in sources :

Example 71 with NamedURI

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

the class BlockStorageDeviceTest method createConsistencyGroup.

private BlockConsistencyGroup createConsistencyGroup() {
    BlockConsistencyGroup cg = new BlockConsistencyGroup();
    cg.setId(URIUtil.createId(BlockConsistencyGroup.class));
    cg.setType(BlockConsistencyGroup.Types.LOCAL.name());
    cg.setLabel("ViPRTest");
    cg.setProject(new NamedURI(_project.getId(), _project.getLabel()));
    cg.setTenant(_project.getTenantOrg());
    cg.setInactive(false);
    _dbClient.createObject(cg);
    return cg;
}
Also used : NamedURI(com.emc.storageos.db.client.model.NamedURI) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 72 with NamedURI

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

the class WorkflowTest method createVolumeResource.

/**
 * creates a volume resource
 *
 * @return
 */
private Volume createVolumeResource() {
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URIUtil.createId(TenantOrg.class));
    dbClient.createObject(tenant);
    Project project = new Project();
    project.setId(URIUtil.createId(Project.class));
    project.setLabel("project1");
    project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
    dbClient.createObject(project);
    Volume vol = new Volume();
    vol.setId(URIUtil.createId(Volume.class));
    vol.setLabel("volumeObject");
    vol.setProject(new NamedURI(project.getId(), vol.getLabel()));
    vol.setTenant(new NamedURI(tenant.getId(), vol.getLabel()));
    dbClient.createObject(vol);
    return vol;
}
Also used : Project(com.emc.storageos.db.client.model.Project) NamedURI(com.emc.storageos.db.client.model.NamedURI) Volume(com.emc.storageos.db.client.model.Volume) TenantOrg(com.emc.storageos.db.client.model.TenantOrg)

Example 73 with NamedURI

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

the class SRDFOperations method updateSourceAndTargetPairings.

/**
 * Checks with the SMI-S provider to ensure that ViPR's source and target volumes are paired up
 * correctly and fixes any inconsistencies.
 *
 * @param sourceURIs The source volumes
 * @param targetURIs The target volumes
 */
public void updateSourceAndTargetPairings(List<URI> sourceURIs, List<URI> targetURIs) {
    final String KEY = "%s:%s";
    List<Volume> sources = dbClient.queryObject(Volume.class, sourceURIs);
    List<Volume> targets = dbClient.queryObject(Volume.class, targetURIs);
    // Convenience maps
    Map<String, Volume> volumesMap = new HashMap<>();
    for (Volume v : Iterables.concat(sources, targets)) {
        String key = format(KEY, v.getStorageController(), v.getNativeId());
        volumesMap.put(key, v);
    }
    final Map<String, String> tgtURI2tgtDevId = new HashMap<>();
    for (Volume target : targets) {
        tgtURI2tgtDevId.put(target.getId().toString(), target.getNativeId());
    }
    Volume firstSource = sources.get(0);
    StorageSystem sourceSystem = dbClient.queryObject(StorageSystem.class, firstSource.getStorageController());
    Volume firstTarget = targets.get(0);
    StorageSystem targetSystem = dbClient.queryObject(StorageSystem.class, firstTarget.getStorageController());
    Collection<CIMObjectPath> syncPairs = null;
    try {
        // Note that we may have existing sync pairs in the consistency group.
        syncPairs = getConsistencyGroupSyncPairs(sourceSystem, firstSource, targetSystem, firstTarget);
    } catch (WBEMException e) {
        log.error("Failed to update SRDF pairings", e);
        return;
    }
    for (CIMObjectPath syncPair : syncPairs) {
        log.info("Checking {}", syncPair);
        // Get the deviceID for the system (source) element from SMI-S provider
        String srcEl = syncPair.getKeyValue(CP_SYSTEM_ELEMENT).toString();
        CIMObjectPath srcElPath = new CIMObjectPath(srcEl);
        String trustedSrcDevId = srcElPath.getKeyValue(CP_DEVICE_ID).toString();
        // Get the deviceID for the synced (target) element from SMI-S provider
        String tgtEl = syncPair.getKeyValue(CP_SYNCED_ELEMENT).toString();
        CIMObjectPath tgtElPath = new CIMObjectPath(tgtEl);
        String trustedTgtDevId = tgtElPath.getKeyValue(CP_DEVICE_ID).toString();
        // Get ViPR's side which requires validating...
        String srcKey = format(KEY, sourceSystem.getId(), trustedSrcDevId);
        Volume srcVolume = volumesMap.get(srcKey);
        if (srcVolume == null) {
            // Skip existing source volumes that were part of the consistency group.
            log.info("Skipping as {} is an existing consistency group member", srcKey);
            continue;
        }
        StringSet srdfTargets = srcVolume.getSrdfTargets();
        Collection<String> uncheckedTgtDevIds = transform(srdfTargets, new Function<String, String>() {

            @Override
            public String apply(String targetURI) {
                return tgtURI2tgtDevId.get(targetURI);
            }
        });
        if (!uncheckedTgtDevIds.contains(trustedTgtDevId)) {
            log.info("Found pairing inconsistency!");
            String msg = format("Source %s is paired with Target %s", trustedSrcDevId, trustedTgtDevId);
            log.info(msg);
            // The target found in the sync pair will need updating in ViPR (has wrong SRDF parent)
            Volume invalidTgt = volumesMap.get(format(KEY, targetSystem.getId(), trustedTgtDevId));
            // This SRDF parent will need its SRDF target list updating (remove the target)
            Volume invalidSrc = dbClient.queryObject(Volume.class, invalidTgt.getSrdfParent().getURI());
            // The source found in the sync pair will need its SRDF target list updating (add the real target)
            Volume trustedSrc = volumesMap.get(format(KEY, sourceSystem.getId(), trustedSrcDevId));
            invalidTgt.setSrdfParent(new NamedURI(trustedSrc.getId(), trustedSrc.getLabel()));
            trustedSrc.getSrdfTargets().add(invalidTgt.getId().toString());
            invalidSrc.getSrdfTargets().remove(invalidTgt.getId().toString());
            // Update the volume labels (and labels on associated Vplex volume if any)
            updateVolumeLabels(trustedSrc, invalidTgt);
            // Rename the volume on the vmax array itself and update the deviceLabel
            helper.renameVolume(dbClient, targetSystem, invalidTgt, invalidTgt.getLabel());
            dbClient.updateAndReindexObject(asList(invalidTgt, trustedSrc, invalidSrc));
        }
    }
}
Also used : HashMap(java.util.HashMap) NamedURI(com.emc.storageos.db.client.model.NamedURI) CIMObjectPath(javax.cim.CIMObjectPath) WBEMException(javax.wbem.WBEMException) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 74 with NamedURI

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

the class SRDFOperations method changeSRDFVolumeBehaviors.

private void changeSRDFVolumeBehaviors(Volume sourceVolume, Volume targetVolume, DbClient dbClient, String status) {
    List<Volume> volumes = new ArrayList<>();
    if (sourceVolume.hasConsistencyGroup()) {
        List<URI> srcVolumeUris = dbClient.queryByConstraint(getVolumesByConsistencyGroup(sourceVolume.getConsistencyGroup()));
        List<Volume> cgSrcVolumes = dbClient.queryObject(Volume.class, srcVolumeUris);
        volumes.addAll(cgSrcVolumes);
    } else {
        volumes.add(sourceVolume);
        /**
         * Swap operation will happen for all volumes under ra group for Async without CG.
         * Adding the missing source volumes to change the personalities of the missing volumes
         */
        if (Mode.ASYNCHRONOUS.name().equalsIgnoreCase(targetVolume.getSrdfCopyMode())) {
            volumes.addAll(utils.getRemainingSourceVolumesForAsyncRAGroup(sourceVolume, targetVolume));
        }
    }
    log.debug("volumes size:{}", volumes.size());
    for (Volume sourceVol : volumes) {
        StringSet srdfTargets = new StringSet();
        String copyMode = null;
        if (sourceVol.getSrdfTargets() == null) {
            // This may happen if a target volume is not deleted properly
            continue;
        }
        srdfTargets.addAll(sourceVol.getSrdfTargets());
        // CG cannot have different RA Groups and copyMode
        URI raGroupUri = null;
        for (String targetUri : srdfTargets) {
            Volume targetVol = dbClient.queryObject(Volume.class, URI.create(targetUri));
            raGroupUri = targetVol.getSrdfGroup();
            copyMode = targetVol.getSrdfCopyMode();
            targetVol.setPersonality(SOURCE.toString());
            targetVol.setAccessState(Volume.VolumeAccessState.READWRITE.name());
            srdfTargets.add(sourceVol.getId().toString());
            srdfTargets.remove(targetVol.getId().toString());
            if (null == targetVol.getSrdfTargets()) {
                targetVol.setSrdfTargets(new StringSet());
            }
            targetVol.getSrdfTargets().addAll(srdfTargets);
            targetVol.setSrdfParent(new NamedURI(NullColumnValueGetter.getNullURI(), NullColumnValueGetter.getNullStr()));
            targetVol.setSrdfCopyMode(NullColumnValueGetter.getNullStr());
            targetVol.setSrdfGroup(NullColumnValueGetter.getNullURI());
            targetVol.setLinkStatus(status);
            // Set source fields
            sourceVol.setLinkStatus(status);
            sourceVol.setSrdfParent(new NamedURI(targetVol.getId(), targetVol.getLabel()));
            dbClient.persistObject(targetVol);
        }
        sourceVol.setPersonality(TARGET.toString());
        sourceVol.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
        sourceVol.setSrdfCopyMode(copyMode);
        sourceVol.setSrdfGroup(raGroupUri);
        sourceVol.getSrdfTargets().clear();
        dbClient.persistObject(sourceVol);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI)

Example 75 with NamedURI

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

the class SRDFOperations method refreshStorageSystem.

public void refreshStorageSystem(final URI storageSystemURI, List<URI> volumeURIs) {
    StorageSystem system = null;
    try {
        system = utils.getStorageSystem(storageSystemURI);
        // 60 sec
        long waitTime = 60000;
        if (null != volumeURIs && !volumeURIs.isEmpty()) {
            List<Volume> volumes = dbClient.queryObject(Volume.class, volumeURIs);
            if (null == volumes || volumes.isEmpty()) {
                return;
            }
            Collection<String> nativeGuids = transform(volumes, fctnBlockObjectToNativeGuid());
            NamedURI sourceVolumeURI = volumes.get(0).getSrdfParent();
            if (NullColumnValueGetter.isNullURI(sourceVolumeURI.getURI())) {
                return;
            }
            Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeURI);
            BlockConsistencyGroup cgObj = dbClient.queryObject(BlockConsistencyGroup.class, sourceVolume.getConsistencyGroup());
            String cgName = cgObj.getAlternateLabel();
            if (null == cgName) {
                cgName = cgObj.getLabel();
            }
            while (waitTime > 0) {
                log.debug("Entering loop to check volume exists on replication group.");
                CIMObjectPath groupPath = helper.checkDeviceGroupExists(cgName, system, system);
                if (null == groupPath) {
                    log.info("No group found with name {}", cgName);
                    break;
                }
                Set<String> commonElements = new HashSet<String>();
                Set<String> deviceNativeGuids = getVolumesPartOfRG(groupPath, system, system);
                log.info("Found volumes {} in RG {}", deviceNativeGuids, cgName);
                if (null == deviceNativeGuids) {
                    log.info("No volumes found in the RG");
                    break;
                }
                Sets.intersection(new HashSet<String>(nativeGuids), deviceNativeGuids).copyInto(commonElements);
                if (!commonElements.isEmpty()) {
                    log.info("Volumes {} still exists in RG {}.", Arrays.toString(commonElements.toArray()), cgName);
                    Thread.sleep(SLEEP_TIME);
                    waitTime = waitTime - SLEEP_TIME;
                } else {
                    log.debug("Volumes not exist in RG {}", cgName);
                    break;
                }
            }
        }
        callEMCRefresh(helper, system, true);
    } catch (Exception ex) {
        log.error("SMI-S error while refreshing target system {}", storageSystemURI, ex);
    }
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) CIMObjectPath(javax.cim.CIMObjectPath) 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) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) HashSet(java.util.HashSet)

Aggregations

NamedURI (com.emc.storageos.db.client.model.NamedURI)196 URI (java.net.URI)98 Volume (com.emc.storageos.db.client.model.Volume)74 StringSet (com.emc.storageos.db.client.model.StringSet)65 Project (com.emc.storageos.db.client.model.Project)54 ArrayList (java.util.ArrayList)46 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)43 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)42 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)36 Test (org.junit.Test)32 StoragePool (com.emc.storageos.db.client.model.StoragePool)31 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)31 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)27 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)26 StringMap (com.emc.storageos.db.client.model.StringMap)26 List (java.util.List)23 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)20 StringSetMap (com.emc.storageos.db.client.model.StringSetMap)20 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)18 FileShare (com.emc.storageos.db.client.model.FileShare)17