Search in sources :

Example 26 with Recommendation

use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.

the class StorageScheduler method prepareRecommendedVolumes.

/**
 * Create volumes from recommendation object.
 *
 * @param param volume creation parameters
 * @param task task
 * @param taskList task list
 * @param project project
 * @param neighborhood virtual array
 * @param vPool virtual pool
 * @param volumeCount number of volumes to create
 * @param recommendations recommendation structures
 * @param consistencyGroup consistency group to use
 * @param volumeCounter how many volumes are created
 * @param volumeLabel volume label
 * @param preparedVolumes volumes that have been prepared
 * @param cosCapabilities virtual pool wrapper
 * @param createInactive create the device in an inactive state
 */
/**
 * Create volumes from recommendations objects.
 *
 * @param size -- size of volumes in bytes
 * @param task -- overall task id
 * @param taskList -- a TaskList new tasks may be inserted into
 * @param project -- Project object
 * @param neighborhood -- Virtual array
 * @param vPool -- Virtual pool
 * @param volumeCount -- number of like volumes to be created
 * @param recommendations -- List of Recommendation objects describing pools to use for volumes
 * @param consistencyGroup -- The BlockConsistencyGroup object to be used for the volumes
 * @param volumeCounter -- The current volume counter, used to generate unique names for like volumes
 * @param volumeLabel -- Label (prefix) of the volumes to be created
 * @param preparedVolumes -- Output argument that receives the prepared volumes
 * @param cosCapabilities - VirtualPoolCapabilityValuesWrapper contains parameters for volume creation
 * @param createInactive-- used to set the Volume syncActive flag (to the inverted sense of createInactive)
 */
public void prepareRecommendedVolumes(Long size, String task, TaskList taskList, Project project, VirtualArray neighborhood, VirtualPool vPool, Integer volumeCount, List<Recommendation> recommendations, BlockConsistencyGroup consistencyGroup, int volumeCounter, String volumeLabel, List<Volume> preparedVolumes, VirtualPoolCapabilityValuesWrapper cosCapabilities, Boolean createInactive) {
    Iterator<Recommendation> recommendationsIter = recommendations.iterator();
    while (recommendationsIter.hasNext()) {
        VolumeRecommendation recommendation = (VolumeRecommendation) recommendationsIter.next();
        // if id is already set in recommendation, do not prepare the volume (volume already exists)
        if (recommendation.getId() != null) {
            continue;
        }
        // prepare block volume
        if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_VOLUME.toString())) {
            String newVolumeLabel = AbstractBlockServiceApiImpl.generateDefaultVolumeLabel(volumeLabel, volumeCounter++, volumeCount);
            // Grab the existing volume and task object from the incoming task list
            Volume volume = getPrecreatedVolume(_dbClient, taskList, newVolumeLabel);
            boolean volumePrecreated = false;
            if (volume != null) {
                volumePrecreated = true;
            }
            long thinVolumePreAllocationSize = 0;
            if (null != vPool.getThinVolumePreAllocationPercentage()) {
                thinVolumePreAllocationSize = VirtualPoolUtil.getThinVolumePreAllocationSize(vPool.getThinVolumePreAllocationPercentage(), size);
            }
            volume = prepareVolume(_dbClient, volume, size, thinVolumePreAllocationSize, project, neighborhood, vPool, recommendation, newVolumeLabel, consistencyGroup, cosCapabilities, createInactive);
            // set volume id in recommendation
            recommendation.setId(volume.getId());
            // add volume to reserved capacity map of storage pool
            addVolumeCapacityToReservedCapacityMap(_dbClient, volume);
            preparedVolumes.add(volume);
            if (!volumePrecreated) {
                Operation op = _dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, ResourceOperationTypeEnum.CREATE_BLOCK_VOLUME);
                volume.getOpStatus().put(task, op);
                TaskResourceRep volumeTask = toTask(volume, task, op);
                // This task addition is inconsequential since we've already returned the source volume tasks.
                // It is good to continue to have a task associated with this volume AND store its status in the volume.
                taskList.getTaskList().add(volumeTask);
            }
        } else if (recommendation.getType().toString().equals(VolumeRecommendation.VolumeType.BLOCK_LOCAL_MIRROR.toString())) {
            // prepare local mirror based on source volume and storage pool recommendation
            VolumeRecommendation volumeRecommendation = (VolumeRecommendation) recommendation.getParameter(VolumeRecommendation.BLOCK_VOLUME);
            URI volumeId = volumeRecommendation.getId();
            Volume volume = _dbClient.queryObject(Volume.class, volumeId);
            String mirrorLabel = volumeLabel;
            if (volume.isInCG()) {
                mirrorLabel = ControllerUtils.getMirrorLabel(volume.getLabel(), volumeLabel);
            }
            if (volumeCount > 1) {
                mirrorLabel = ControllerUtils.getMirrorLabel(mirrorLabel, volumeCounter++);
            }
            // Prepare a single mirror based on source volume and storage pool recommendation
            BlockMirror mirror = initializeMirror(volume, vPool, recommendation.getCandidatePools().get(0), mirrorLabel, _dbClient);
            // set mirror id in recommendation
            recommendation.setId(mirror.getId());
            preparedVolumes.add(mirror);
            // add mirror to reserved capacity map of storage pool
            addVolumeCapacityToReservedCapacityMap(_dbClient, mirror);
        }
    }
}
Also used : BlockMirror(com.emc.storageos.db.client.model.BlockMirror) Volume(com.emc.storageos.db.client.model.Volume) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation)

Example 27 with Recommendation

use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.

the class StorageScheduler method getRecommendationsForVolumeClones.

public List<VolumeRecommendation> getRecommendationsForVolumeClones(VirtualArray vArray, VirtualPool vPool, BlockObject blockObject, VirtualPoolCapabilityValuesWrapper capabilities) {
    _log.debug("Schedule storage for {} block volume copies {} of size {}.", capabilities.getResourceCount(), capabilities.getSize());
    List<VolumeRecommendation> volumeRecommendations = new ArrayList<VolumeRecommendation>();
    // Initialize a list of recommendations to be returned.
    List<Recommendation> recommendations = new ArrayList<Recommendation>();
    // For volume clones, candidate pools should be on the same storage system as the source volume
    URI storageSystemId = blockObject.getStorageController();
    Map<String, Object> attributeMap = new HashMap<String, Object>();
    Set<String> storageSystemSet = new HashSet<String>();
    storageSystemSet.add(storageSystemId.toString());
    attributeMap.put(AttributeMatcher.Attributes.storage_system.name(), storageSystemSet);
    Set<String> virtualArraySet = new HashSet<String>();
    virtualArraySet.add(vArray.getId().toString());
    attributeMap.put(AttributeMatcher.Attributes.varrays.name(), virtualArraySet);
    // Get all storage pools that match the passed CoS params and
    // protocols. In addition, the pool must have enough capacity
    // to hold at least one resource of the requested size.
    // In addition, we need to only select pools from the
    // StorageSystem that the source volume was created against.
    List<StoragePool> matchedPools = getMatchingPools(vArray, vPool, capabilities, attributeMap);
    if (matchedPools == null || matchedPools.isEmpty()) {
        StringBuffer errMes = new StringBuffer();
        if (attributeMap.get(AttributeMatcher.ERROR_MESSAGE) != null) {
            errMes = (StringBuffer) attributeMap.get(AttributeMatcher.ERROR_MESSAGE);
        }
        _log.warn("VArray {} does not have storage pools which match VPool {} to clone volume {}. {}", new Object[] { vArray.getId(), vPool.getId(), blockObject.getId(), errMes });
        throw APIException.badRequests.noMatchingStoragePoolsForVpoolAndVarrayForClones(vPool.getLabel(), vArray.getLabel(), blockObject.getId(), errMes.toString());
    }
    _log.info(String.format("Found %s candidate pools for placement of %s clone(s) of volume %s .", String.valueOf(matchedPools.size()), String.valueOf(capabilities.getResourceCount()), blockObject.getId()));
    // Get the recommendations for the candidate pools.
    recommendations = getRecommendationsForPools(vArray.getId().toString(), matchedPools, capabilities);
    // log an error and clear the list of recommendations.
    if (recommendations.isEmpty()) {
        String msg = String.format("Could not find placement for %s clones of volume %s with capacity %s", capabilities.getResourceCount(), blockObject.getId(), capabilities.getSize());
        _log.error(msg);
        throw APIException.badRequests.invalidParameterNoStorageFoundForVolume(vArray.getId(), vPool.getId(), blockObject.getId());
    }
    // create list of VolumeRecommendation(s) for volumes
    for (Recommendation recommendation : recommendations) {
        int count = recommendation.getResourceCount();
        while (count > 0) {
            VolumeRecommendation volumeRecommendation = new VolumeRecommendation(VolumeRecommendation.VolumeType.BLOCK_COPY, capabilities.getSize(), vPool, vArray.getId());
            volumeRecommendation.addStoragePool(recommendation.getSourceStoragePool());
            volumeRecommendation.addStorageSystem(recommendation.getSourceStorageSystem());
            volumeRecommendations.add(volumeRecommendation);
            if (capabilities.getBlockConsistencyGroup() != null) {
                volumeRecommendation.setParameter(VolumeRecommendation.ARRAY_CG, capabilities.getBlockConsistencyGroup());
            }
            count--;
        }
    }
    return volumeRecommendations;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) ContainmentPrefixConstraint(com.emc.storageos.db.client.constraint.ContainmentPrefixConstraint) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashSet(java.util.HashSet)

Example 28 with Recommendation

use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.

the class BucketScheduler method selectMatchingStoragePool.

/**
 * Select the right matching storage pools
 *
 * @param vpool
 * @param poolRecommends recommendations after selecting matching storage pools.
 * @return list of Bucket Recommendation
 */
private List<BucketRecommendation> selectMatchingStoragePool(VirtualPool vpool, List<Recommendation> poolRecommends) {
    List<BucketRecommendation> baseResult = new ArrayList<BucketRecommendation>();
    for (Recommendation recommendation : poolRecommends) {
        BucketRecommendation rec = new BucketRecommendation(recommendation);
        URI storageUri = recommendation.getSourceStorageSystem();
        // Verify if the Storage System is an Object Store
        StorageSystem storage = _dbClient.queryObject(StorageSystem.class, storageUri);
        if (!Type.isObjectStorageSystem(StorageSystem.Type.valueOf(storage.getSystemType()))) {
            continue;
        }
        baseResult.add(rec);
    }
    List<BucketRecommendation> finalResult = null;
    // Make sure pool list is not empty
    if (!baseResult.isEmpty()) {
        finalResult = new ArrayList<BucketRecommendation>();
        // sort the storage pools based on the number of datacenters spread
        storagePoolSort(baseResult);
        // get the value of datacenters in the sorted first storage pool
        StoragePool pool = _dbClient.queryObject(StoragePool.class, baseResult.get(0).getSourceStoragePool());
        Integer baseDC = pool.getDataCenters();
        // make the first sub-set of pools
        for (BucketRecommendation bkRec : baseResult) {
            URI storagePoolUri = bkRec.getSourceStoragePool();
            pool = _dbClient.queryObject(StoragePool.class, storagePoolUri);
            if (pool.getDataCenters() == baseDC) {
                finalResult.add(bkRec);
            } else {
                break;
            }
        }
    } else {
        finalResult = baseResult;
    }
    return finalResult;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) URI(java.net.URI) Recommendation(com.emc.storageos.volumecontroller.Recommendation) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 29 with Recommendation

use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.

the class PlacementTests method testVPlexLocalSRDFBasicPlacement.

@Test
public void testVPlexLocalSRDFBasicPlacement() {
    String[] vmax1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
    String[] vmax2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
    String[] vplexFE = { "FE:FE:FE:FE:FE:FE:FE:00", "FE:FE:FE:FE:FE:FE:FE:01" };
    String[] vplexBE = { "BE:BE:BE:BE:BE:BE:BE:00", "BE:BE:BE:BE:BE:BE:BE:01" };
    // Create 2 Virtual Arrays
    VirtualArray srcVarray = PlacementTestUtils.createVirtualArray(_dbClient, "srcVarray");
    VirtualArray tgtVarray = PlacementTestUtils.createVirtualArray(_dbClient, "tgtVarray");
    // Create 2 Networks
    StringSet connVA = new StringSet();
    connVA.add(srcVarray.getId().toString());
    Network network1 = PlacementTestUtils.createNetwork(_dbClient, vmax1FE, "VSANSite1", "FC+BROCADE+FE", connVA);
    connVA = new StringSet();
    connVA.add(tgtVarray.getId().toString());
    Network network2 = PlacementTestUtils.createNetwork(_dbClient, vmax2FE, "VSANSite2", "FC+CISCO+FE", connVA);
    // Create 2 storage systems
    StorageSystem[] storageSystems = PlacementTestUtils.createSRDFStorageSystems(_dbClient, "vmax1", network1, vmax1FE, srcVarray, "vmax2", network2, vmax2FE, tgtVarray);
    StorageSystem storageSystem1 = storageSystems[1];
    StorageSystem storageSystem2 = storageSystems[2];
    StoragePool[] storagePools = PlacementTestUtils.createStoragePoolsForTwo(_dbClient, storageSystem1, srcVarray, storageSystem2, tgtVarray);
    StorageSystem vplexSystem = PlacementTestUtils.createVPlexOneCluster(_dbClient, "vplex1", srcVarray, network1, network1, vplexFE, vplexBE);
    // Create a target virtual pool
    VirtualPool tgtVpool = new VirtualPool();
    tgtVpool.setId(URI.create("tgtVpool"));
    tgtVpool.setLabel("Target Vpool");
    tgtVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    tgtVpool.setDriveType(SupportedDriveTypes.FC.name());
    StringSet matchedPools2 = new StringSet();
    matchedPools2.add(storagePools[4].getId().toString());
    matchedPools2.add(storagePools[5].getId().toString());
    matchedPools2.add(storagePools[6].getId().toString());
    tgtVpool.setMatchedStoragePools(matchedPools2);
    tgtVpool.setUseMatchedPools(true);
    StringSet virtualArrays2 = new StringSet();
    virtualArrays2.add(tgtVarray.getId().toString());
    tgtVpool.setVirtualArrays(virtualArrays2);
    _dbClient.createObject(tgtVpool);
    // Make a remote copy protection setting
    VpoolRemoteCopyProtectionSettings settings = new VpoolRemoteCopyProtectionSettings();
    settings.setId(URI.create("remoteCopySettings"));
    settings.setCopyMode(VpoolRemoteCopyProtectionSettings.CopyModes.ASYNCHRONOUS.name());
    settings.setVirtualArray(tgtVarray.getId());
    settings.setVirtualPool(tgtVpool.getId());
    _dbClient.createObject(settings);
    // Create an VPLEX Local/SRDF source virtual pool
    VirtualPool srcVpool = new VirtualPool();
    srcVpool.setId(URI.create("srcVpool"));
    srcVpool.setLabel("Source Vpool");
    srcVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    srcVpool.setDriveType(SupportedDriveTypes.FC.name());
    StringSet matchedPools1 = new StringSet();
    matchedPools1.add(storagePools[1].getId().toString());
    matchedPools1.add(storagePools[2].getId().toString());
    matchedPools1.add(storagePools[3].getId().toString());
    srcVpool.setMatchedStoragePools(matchedPools1);
    srcVpool.setUseMatchedPools(true);
    StringSet virtualArrays1 = new StringSet();
    virtualArrays1.add(srcVarray.getId().toString());
    srcVpool.setVirtualArrays(virtualArrays1);
    StringMap remoteProtectionSettings = new StringMap();
    remoteProtectionSettings.put(tgtVarray.getId().toString(), settings.getId().toString());
    srcVpool.setProtectionRemoteCopySettings(remoteProtectionSettings);
    srcVpool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_local.name());
    _dbClient.createObject(srcVpool);
    // Create Tenant
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URI.create("tenant"));
    _dbClient.createObject(tenant);
    // Create a project object
    Project project = new Project();
    project.setId(URI.create("project"));
    project.setLabel("RDG1");
    project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
    _dbClient.createObject(project);
    // Create capabilities
    VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("2GB", 1, null);
    // Run single volume placement: Run 10 times to make sure pool3 never comes up for source and pool6 for target.
    for (int i = 0; i < 10; i++) {
        Map<VpoolUse, List<Recommendation>> recommendationsMap = PlacementTestUtils.invokePlacementForVpool(_dbClient, _coordinator, srcVarray, project, srcVpool, capabilities);
        List<Recommendation> recommendations = recommendationsMap.get(VpoolUse.ROOT);
        assertNotNull(recommendations);
        assertTrue(!recommendations.isEmpty());
        assertNotNull(recommendations.get(0));
        assert (recommendations.get(0) instanceof VPlexRecommendation);
        VPlexRecommendation vplexRecommendation = (VPlexRecommendation) recommendations.get(0);
        URI srcStoragePool = vplexRecommendation.getSourceStoragePool();
        assert (srcStoragePool.equals(storagePools[1].getId()) || srcStoragePool.equals(storagePools[2].getId()));
        assert (vplexRecommendation.getRecommendation() instanceof SRDFRecommendation);
        recommendations = recommendationsMap.get(VpoolUse.SRDF_COPY);
        assertTrue(!recommendations.isEmpty());
        assertNotNull(recommendations.get(0));
        assert (recommendations.get(0) instanceof SRDFCopyRecommendation);
        SRDFCopyRecommendation srdfCopyRecommendation = (SRDFCopyRecommendation) recommendations.get(0);
        URI tgtStoragePool = srdfCopyRecommendation.getSourceStoragePool();
        assert (tgtStoragePool.equals(storagePools[4].getId()) || tgtStoragePool.equals(storagePools[5].getId()));
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Test(org.junit.Test)

Example 30 with Recommendation

use of com.emc.storageos.volumecontroller.Recommendation in project coprhd-controller by CoprHD.

the class PlacementTests method testVPlexDistributedSRDFVPlexTargetBasicPlacement.

@Test
public void testVPlexDistributedSRDFVPlexTargetBasicPlacement() {
    String[] vmax1FE = { "50:FE:FE:FE:FE:FE:FE:00", "50:FE:FE:FE:FE:FE:FE:01" };
    String[] vmax2FE = { "51:FE:FE:FE:FE:FE:FE:00", "51:FE:FE:FE:FE:FE:FE:01" };
    String[] vmax3FE = { "52:FE:FE:FE:FE:FE:FE:00", "52:FE:FE:FE:FE:FE:FE:01" };
    String[] vplex1FE = { "FE:FE:FE:FE:FE:FE:FE:00", "FE:FE:FE:FE:FE:FE:FE:01" };
    String[] vplex1BE = { "BE:BE:BE:BE:BE:BE:BE:00", "BE:BE:BE:BE:BE:BE:BE:01" };
    String[] vplex2FE = { "FE:FE:FE:FE:FE:FE:FE:02", "FE:FE:FE:FE:FE:FE:FE:03" };
    String[] vplex2BE = { "BE:BE:BE:BE:BE:BE:BE:02", "BE:BE:BE:BE:BE:BE:BE:03" };
    String[] vplex3FE = { "FE:FE:FE:FE:FE:FE:FE:04", "FE:FE:FE:FE:FE:FE:FE:05" };
    String[] vplex3BE = { "BE:BE:BE:BE:BE:BE:BE:04", "BE:BE:BE:BE:BE:BE:BE:05" };
    // Create 3 Virtual Arrays
    VirtualArray srcVarray = PlacementTestUtils.createVirtualArray(_dbClient, "srcVarray");
    VirtualArray tgtVarray = PlacementTestUtils.createVirtualArray(_dbClient, "tgtVarray");
    VirtualArray haVarray = PlacementTestUtils.createVirtualArray(_dbClient, "haVarray");
    // Create 2 Networks
    StringSet connVA = new StringSet();
    connVA.add(srcVarray.getId().toString());
    Network network1 = PlacementTestUtils.createNetwork(_dbClient, vmax1FE, "VSANSite1", "FC+BROCADE+FE", connVA);
    network1.addEndpoints(Arrays.asList(vplex1BE), true);
    connVA = new StringSet();
    connVA.add(tgtVarray.getId().toString());
    Network network2 = PlacementTestUtils.createNetwork(_dbClient, vmax2FE, "VSANSite2", "FC+CISCO+FE", connVA);
    connVA = new StringSet();
    connVA.add(tgtVarray.getId().toString());
    Network network3 = PlacementTestUtils.createNetwork(_dbClient, vmax2FE, "VSANSite2", "FC+CISCO+FE", connVA);
    // Create 2 storage systems in SRDF pair
    StorageSystem[] storageSystems = PlacementTestUtils.createSRDFStorageSystems(_dbClient, "vmax1", network1, vmax1FE, srcVarray, "vmax2", network2, vmax2FE, tgtVarray);
    StorageSystem storageSystem1 = storageSystems[1];
    StorageSystem storageSystem2 = storageSystems[2];
    StoragePool[] storagePools = PlacementTestUtils.createStoragePoolsForTwo(_dbClient, storageSystem1, srcVarray, storageSystem2, tgtVarray);
    // Create ha StorageSystem
    StorageSystem storageSystem3 = PlacementTestUtils.createStorageSystem(_dbClient, "vmax3", network3, vmax3FE, haVarray);
    StoragePool[] haPools = PlacementTestUtils.createStoragePools(_dbClient, storageSystem3, haVarray);
    StorageSystem vplexSystem = PlacementTestUtils.createVPlexTwoCluster(_dbClient, "vplex1", srcVarray, network1, network1, vplex1FE, vplex1BE, haVarray, network3, network3, vplex3FE, vplex3BE);
    StorageSystem vplexSystem2 = PlacementTestUtils.createVPlexOneCluster(_dbClient, "vplex2", tgtVarray, network2, network2, vplex2FE, vplex2BE);
    // Create HA vpool.
    VirtualPool haVpool = new VirtualPool();
    haVpool.setId(URIUtil.createId(VirtualPool.class));
    haVpool.setLabel("haVpool");
    haVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    haVpool.setDriveType(SupportedDriveTypes.FC.name());
    haVpool.setType(VirtualPool.Type.block.name());
    StringSet matchedPools3 = new StringSet();
    matchedPools3.add(haPools[1].getId().toString());
    haVpool.setMatchedStoragePools(matchedPools3);
    haVpool.setUseMatchedPools(true);
    StringSet virtualArrays3 = new StringSet();
    virtualArrays3.add(haVpool.getId().toString());
    _dbClient.createObject(haVpool);
    // Create a target virtual pool
    VirtualPool tgtVpool = new VirtualPool();
    tgtVpool.setId(URI.create("tgtVpool"));
    tgtVpool.setLabel("Target Vpool");
    tgtVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    tgtVpool.setDriveType(SupportedDriveTypes.FC.name());
    haVpool.setType(VirtualPool.Type.block.name());
    StringSet matchedPools2 = new StringSet();
    matchedPools2.add(storagePools[4].getId().toString());
    matchedPools2.add(storagePools[5].getId().toString());
    matchedPools2.add(storagePools[6].getId().toString());
    tgtVpool.setMatchedStoragePools(matchedPools2);
    tgtVpool.setUseMatchedPools(true);
    StringSet virtualArrays2 = new StringSet();
    virtualArrays2.add(tgtVarray.getId().toString());
    tgtVpool.setVirtualArrays(virtualArrays2);
    tgtVpool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_local.name());
    _dbClient.createObject(tgtVpool);
    // Make a remote copy protection setting
    VpoolRemoteCopyProtectionSettings settings = new VpoolRemoteCopyProtectionSettings();
    settings.setId(URI.create("remoteCopySettings"));
    settings.setCopyMode(VpoolRemoteCopyProtectionSettings.CopyModes.ASYNCHRONOUS.name());
    settings.setVirtualArray(tgtVarray.getId());
    settings.setVirtualPool(tgtVpool.getId());
    _dbClient.createObject(settings);
    // Create an VPLEX Local/SRDF source virtual pool
    VirtualPool srcVpool = new VirtualPool();
    srcVpool.setId(URI.create("srcVpool"));
    srcVpool.setLabel("Source Vpool");
    srcVpool.setSupportedProvisioningType(VirtualPool.ProvisioningType.Thin.name());
    srcVpool.setDriveType(SupportedDriveTypes.FC.name());
    haVpool.setType(VirtualPool.Type.block.name());
    StringSet matchedPools1 = new StringSet();
    matchedPools1.add(storagePools[1].getId().toString());
    matchedPools1.add(storagePools[2].getId().toString());
    matchedPools1.add(storagePools[3].getId().toString());
    srcVpool.setMatchedStoragePools(matchedPools1);
    srcVpool.setUseMatchedPools(true);
    StringSet virtualArrays1 = new StringSet();
    virtualArrays1.add(srcVarray.getId().toString());
    srcVpool.setVirtualArrays(virtualArrays1);
    StringMap remoteProtectionSettings = new StringMap();
    remoteProtectionSettings.put(tgtVarray.getId().toString(), settings.getId().toString());
    srcVpool.setProtectionRemoteCopySettings(remoteProtectionSettings);
    srcVpool.setHighAvailability(VirtualPool.HighAvailabilityType.vplex_distributed.name());
    StringMap haVarrayMap = new StringMap();
    haVarrayMap.put(haVarray.getId().toString(), haVpool.getId().toString());
    srcVpool.setHaVarrayVpoolMap(haVarrayMap);
    _dbClient.createObject(srcVpool);
    // Create Tenant
    TenantOrg tenant = new TenantOrg();
    tenant.setId(URI.create("tenant"));
    _dbClient.createObject(tenant);
    // Create a project object
    Project project = new Project();
    project.setId(URI.create("project"));
    project.setLabel("RDG1");
    project.setTenantOrg(new NamedURI(tenant.getId(), project.getLabel()));
    _dbClient.createObject(project);
    // Create capabilities
    VirtualPoolCapabilityValuesWrapper capabilities = PlacementTestUtils.createCapabilities("2GB", 1, null);
    // Run single volume placement: Run 10 times to make sure pool3 never comes up for source and pool6 for target.
    for (int i = 0; i < 10; i++) {
        Map<VpoolUse, List<Recommendation>> recommendationsMap = PlacementTestUtils.invokePlacementForVpool(_dbClient, _coordinator, srcVarray, project, srcVpool, capabilities);
        List<Recommendation> recommendations = recommendationsMap.get(VpoolUse.ROOT);
        assertNotNull(recommendations);
        assertTrue(recommendations.size() == 2);
        assertNotNull(recommendations.get(0));
        // Check source side recommendation
        assert (recommendations.get(0) instanceof VPlexRecommendation);
        VPlexRecommendation vplexRecommendation = (VPlexRecommendation) recommendations.get(0);
        URI srcStoragePool = vplexRecommendation.getSourceStoragePool();
        assert (srcStoragePool.equals(storagePools[1].getId()) || srcStoragePool.equals(storagePools[2].getId()));
        assert (vplexRecommendation.getVPlexStorageSystem().equals(vplexSystem.getId()));
        assert (vplexRecommendation.getRecommendation() instanceof SRDFRecommendation);
        // Check HA side recommendation
        vplexRecommendation = (VPlexRecommendation) recommendations.get(1);
        assert (vplexRecommendation.getSourceStoragePool().equals(haPools[1].getId()));
        assert (vplexRecommendation.getVPlexStorageSystem().equals(vplexSystem.getId()));
        recommendations = recommendationsMap.get(VpoolUse.SRDF_COPY);
        assertTrue(!recommendations.isEmpty());
        // Check SRDF recommendation
        assertNotNull(recommendations.get(0));
        assert (recommendations.get(0) instanceof VPlexRecommendation);
        VPlexRecommendation vplex2Recommendation = (VPlexRecommendation) recommendations.get(0);
        URI tgtStoragePool = vplex2Recommendation.getSourceStoragePool();
        assert (tgtStoragePool.equals(storagePools[4].getId()) || tgtStoragePool.equals(storagePools[5].getId()));
        assert (vplex2Recommendation.getVPlexStorageSystem().equals(vplexSystem2.getId()));
        assert (vplex2Recommendation.getRecommendation() instanceof SRDFCopyRecommendation);
        ;
    }
}
Also used : VirtualPoolCapabilityValuesWrapper(com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) StringMap(com.emc.storageos.db.client.model.StringMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) Network(com.emc.storageos.db.client.model.Network) StringSet(com.emc.storageos.db.client.model.StringSet) List(java.util.List) ArrayList(java.util.ArrayList) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) VPlexRecommendation(com.emc.storageos.volumecontroller.VPlexRecommendation) SRDFCopyRecommendation(com.emc.storageos.volumecontroller.SRDFCopyRecommendation) Recommendation(com.emc.storageos.volumecontroller.Recommendation) SRDFRecommendation(com.emc.storageos.volumecontroller.SRDFRecommendation) RPRecommendation(com.emc.storageos.volumecontroller.RPRecommendation) RPProtectionRecommendation(com.emc.storageos.volumecontroller.RPProtectionRecommendation) Project(com.emc.storageos.db.client.model.Project) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Test(org.junit.Test)

Aggregations

Recommendation (com.emc.storageos.volumecontroller.Recommendation)70 ArrayList (java.util.ArrayList)62 URI (java.net.URI)49 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)37 VPlexRecommendation (com.emc.storageos.volumecontroller.VPlexRecommendation)36 NamedURI (com.emc.storageos.db.client.model.NamedURI)28 StoragePool (com.emc.storageos.db.client.model.StoragePool)28 List (java.util.List)28 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)27 RPProtectionRecommendation (com.emc.storageos.volumecontroller.RPProtectionRecommendation)27 RPRecommendation (com.emc.storageos.volumecontroller.RPRecommendation)27 Volume (com.emc.storageos.db.client.model.Volume)24 SRDFRecommendation (com.emc.storageos.volumecontroller.SRDFRecommendation)23 HashMap (java.util.HashMap)23 SRDFCopyRecommendation (com.emc.storageos.volumecontroller.SRDFCopyRecommendation)21 VirtualPoolCapabilityValuesWrapper (com.emc.storageos.volumecontroller.impl.utils.VirtualPoolCapabilityValuesWrapper)21 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)19 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)18 Project (com.emc.storageos.db.client.model.Project)17 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)16