Search in sources :

Example 16 with BlockVirtualPoolRestRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolRestRep in project coprhd-controller by CoprHD.

the class GeoTest method createVirtualPools.

private void createVirtualPools() {
    System.out.println("create a virtualPool");
    BlockVirtualPoolParam paramCosBlock = new BlockVirtualPoolParam();
    paramCosBlock.setName("foobar-block");
    paramCosBlock.setProtocols(new HashSet<String>());
    paramCosBlock.getProtocols().add(StorageProtocol.Block.FC.name());
    paramCosBlock.setMaxPaths(2);
    paramCosBlock.setProvisionType("Thick");
    BlockVirtualPoolRestRep cos = rSys.path("/block/vpools").post(BlockVirtualPoolRestRep.class, paramCosBlock);
    virtualPoolId = cos.getId();
    Assert.assertNotNull(virtualPoolId);
    System.out.println("The VirtualPool ID:" + virtualPoolId);
}
Also used : BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) BlockVirtualPoolParam(com.emc.storageos.model.vpool.BlockVirtualPoolParam)

Example 17 with BlockVirtualPoolRestRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolRestRep in project coprhd-controller by CoprHD.

the class BlockVirtualPools method createAllFlashAuto.

/**
 * This method create virtual pool according to storage system types
 * @param types : List of storage system types discovered
 */
public static void createAllFlashAuto(List<String> types) {
    List<String> vaIds4allflash = new ArrayList<String>();
    List<String> vaIds4vmax = new ArrayList<String>();
    List<String> vaIds4xio = new ArrayList<String>();
    List<String> vaIds4unity = new ArrayList<String>();
    JsonArray vpools = new JsonArray();
    // Read cookies for storage systems and virtual pools
    JsonObject dataObject = getCookieAsJson(GUIDE_DATA);
    if (dataObject != null) {
        JsonArray varrays = dataObject.getAsJsonArray(VARRAYS);
        if (varrays != null) {
            for (Object varray : varrays) {
                JsonObject jsonvarray = (JsonObject) varray;
                String varrayid = jsonvarray.get("id").getAsString();
                // Check virtual array first
                VirtualArrayRestRep varrayRest = VirtualArrayUtils.getVirtualArray(varrayid);
                if (varrayRest != null) {
                    // Get virtual array attributes
                    Map<String, Set<String>> attributes = VirtualArrayUtils.getAvailableAttributes(uris(varrayid));
                    Set<String> system_type = attributes.get(ATTRIBUTE_SYSTEM_TYPES);
                    if (system_type != null && !system_type.isEmpty()) {
                        if (system_type.size() > 1) {
                            vaIds4allflash.add(varrayid);
                        } else {
                            // It has one system type
                            for (String vasystemtype : system_type) {
                                if (StringUtils.equals(UNITY, vasystemtype)) {
                                    vaIds4unity.add(varrayid);
                                }
                                if (StringUtils.equals(VMAX, vasystemtype)) {
                                    vaIds4vmax.add(varrayid);
                                }
                                if (StringUtils.equals(XTREMIO, vasystemtype)) {
                                    vaIds4xio.add(varrayid);
                                }
                            }
                        }
                    } else {
                        // Control should not reach here but let add in all flash
                        vaIds4allflash.add(varrayid);
                    }
                }
            }
        }
    }
    if (!vaIds4allflash.isEmpty()) {
        Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
        String vpid = virtualpoolAllFlashMap.get(VP_ALL_FLASH);
        if (vpid != null) {
            BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
            List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
            for (String vaid : vaIds4allflash) {
                RelatedResourceRep newVaId = new RelatedResourceRep();
                newVaId.setId(URI.create(vaid));
                virtualarrays.add(newVaId);
            }
            blockvpool.setVirtualArrays(virtualarrays);
            updateAutoVirtualPool(vpid, blockvpool, vpools);
        } else {
            createBaseVPool(VP_ALL_FLASH, StorageSystemTypes.NONE, vaIds4allflash, Messages.get("gettingStarted.vpool.allflash.desc"), vpools);
        }
    }
    if (!vaIds4vmax.isEmpty()) {
        Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
        // Check if we should add in existing compressed vpool
        boolean isCompression = isCompressionEnable(vaIds4vmax);
        String vpid = virtualpoolAllFlashMap.get(VP_VMAX_DIAMOND);
        if (vpid != null && !isCompression) {
            BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
            List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
            for (String vaid : vaIds4vmax) {
                RelatedResourceRep newVaId = new RelatedResourceRep();
                newVaId.setId(URI.create(vaid));
                virtualarrays.add(newVaId);
            }
            blockvpool.setVirtualArrays(virtualarrays);
            updateAutoVirtualPool(vpid, blockvpool, vpools);
        } else {
            // Check compressed vpool
            vpid = virtualpoolAllFlashMap.get(VP_VMAX_DIAMOND_COMPRESSED);
            if (vpid != null && isCompression) {
                BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
                List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
                for (String vaid : vaIds4vmax) {
                    RelatedResourceRep newVaId = new RelatedResourceRep();
                    newVaId.setId(URI.create(vaid));
                    virtualarrays.add(newVaId);
                }
                blockvpool.setVirtualArrays(virtualarrays);
                updateAutoVirtualPool(vpid, blockvpool, vpools);
            } else {
                createBaseVPool(VP_VMAX_DIAMOND, StorageSystemTypes.VMAX, vaIds4vmax, Messages.get("gettingStarted.vpool.vmax.desc"), vpools);
            }
        }
    }
    if (!vaIds4xio.isEmpty()) {
        Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
        String vpid = virtualpoolAllFlashMap.get(VP_XIO_DIAMOND);
        if (vpid != null) {
            BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
            List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
            for (String vaid : vaIds4xio) {
                RelatedResourceRep newVaId = new RelatedResourceRep();
                newVaId.setId(URI.create(vaid));
                virtualarrays.add(newVaId);
            }
            blockvpool.setVirtualArrays(virtualarrays);
            updateAutoVirtualPool(vpid, blockvpool, vpools);
        } else {
            createBaseVPool(VP_XIO_DIAMOND, StorageSystemTypes.XTREMIO, vaIds4xio, Messages.get("gettingStarted.vpool.xio.desc"), vpools);
        }
    }
    if (!vaIds4unity.isEmpty()) {
        Map<String, String> virtualpoolAllFlashMap = allFlashVirtualPool();
        String vpid = virtualpoolAllFlashMap.get(VP_UNITY_DIAMOND);
        if (vpid != null) {
            BlockVirtualPoolRestRep blockvpool = VirtualPoolUtils.getBlockVirtualPool(vpid);
            List<RelatedResourceRep> virtualarrays = blockvpool.getVirtualArrays();
            for (String vaid : vaIds4unity) {
                RelatedResourceRep newVaId = new RelatedResourceRep();
                newVaId.setId(URI.create(vaid));
                virtualarrays.add(newVaId);
            }
            blockvpool.setVirtualArrays(virtualarrays);
            updateAutoVirtualPool(vpid, blockvpool, vpools);
        } else {
            createBaseVPool(VP_UNITY_DIAMOND, StorageSystemTypes.UNITY, vaIds4unity, Messages.get("gettingStarted.vpool.unity.desc"), vpools);
        }
    }
    dataObject.add(VPOOL_COOKIES, vpools);
    saveJsonAsCookie(GUIDE_DATA, dataObject);
    list();
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject) JsonArray(com.google.gson.JsonArray) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) JsonObject(com.google.gson.JsonObject) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)

Example 18 with BlockVirtualPoolRestRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolRestRep in project coprhd-controller by CoprHD.

the class BlockVirtualPools method createBaseVPool.

private static void createBaseVPool(String vpoolName, String storageType, List<String> virtualarrayIds, String vpdesc, JsonArray vpools) {
    BlockVirtualPoolForm vpool = new BlockVirtualPoolForm();
    // defaults
    vpool.provisioningType = ProvisioningTypes.THIN;
    vpool.protocols = Sets.newHashSet(BlockProtocols.FC);
    vpool.minPaths = 1;
    vpool.maxPaths = 1;
    vpool.initiatorPaths = 1;
    vpool.expandable = true;
    vpool.rpJournalSizeUnit = SizeUnit.x;
    vpool.rpJournalSize = RPCopyForm.JOURNAL_DEFAULT_MULTIPLIER;
    vpool.rpRpoValue = Long.valueOf(25);
    vpool.rpRpoType = RpoType.SECONDS;
    vpool.protectSourceSite = true;
    vpool.enableAutoCrossConnExport = true;
    vpool.poolAssignment = PoolAssignmentTypes.AUTOMATIC;
    vpool.maxSnapshots = 10;
    vpool.name = vpoolName;
    vpool.systemType = storageType;
    vpool.virtualArrays = virtualarrayIds;
    vpool.description = vpdesc;
    vpool.enableCompression = false;
    // Check if creating a vmax AFA virtual pool, need to set auto-tiering
    if (StringUtils.equals(VMAX, storageType)) {
        vpool.uniqueAutoTierPolicyNames = true;
        boolean isAutoTier = false;
        AutoTierPolicyNamesCall auto_tiering = vpool.autoTierPolicyNames();
        List<String> autoPolicyList = auto_tiering.call();
        for (String policy : autoPolicyList) {
            if (StringUtils.equals(DEFAULT_AUTO_TIER, policy)) {
                vpool.autoTierPolicy = policy;
                isAutoTier = true;
                break;
            }
        }
        if (!isAutoTier) {
            // This means we did not find the pattern, set random
            for (String policy : autoPolicyList) {
                vpool.autoTierPolicy = policy;
                break;
            }
        }
        for (String virtualArrayId : virtualarrayIds) {
            List<StoragePoolRestRep> spList = StoragePoolUtils.getStoragePoolsAssignedToVirtualArray(virtualArrayId);
            for (StoragePoolRestRep sp : spList) {
                if (sp.getCompressionEnabled() != null && sp.getCompressionEnabled()) {
                    vpool.enableCompression = true;
                    // rename with compression enable
                    vpool.name = VP_VMAX_DIAMOND_COMPRESSED;
                    break;
                }
            }
            if (vpool.enableCompression) {
                break;
            }
        }
    }
    BlockVirtualPoolRestRep vpoolTask = vpool.save();
    if (vpoolTask != null) {
        buildVpoolCookies(vpoolTask.getId().toString(), vpool.name, vpools);
    }
}
Also used : AutoTierPolicyNamesCall(jobs.vipr.AutoTierPolicyNamesCall) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) StoragePoolRestRep(com.emc.storageos.model.pools.StoragePoolRestRep) BlockVirtualPoolForm(models.virtualpool.BlockVirtualPoolForm)

Example 19 with BlockVirtualPoolRestRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolRestRep in project coprhd-controller by CoprHD.

the class BlockVirtualPools method duplicate.

public static void duplicate(String ids) {
    BlockVirtualPoolRestRep targetVPool = VirtualPoolUtils.getBlockVirtualPool(ids);
    if (targetVPool == null) {
        flash.error(MessagesUtils.get(UNKNOWN, ids));
        backToReferrer();
    }
    BlockVirtualPoolForm copy = new BlockVirtualPoolForm();
    copy.load(targetVPool);
    copy.id = null;
    copy.name = Messages.get("virtualPools.duplicate.name", copy.name);
    // Target VPool could have resources, set resources to 0 on the new Copy VPool so user can modify form
    copy.numResources = 0;
    edit(copy);
}
Also used : BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep) BlockVirtualPoolForm(models.virtualpool.BlockVirtualPoolForm)

Example 20 with BlockVirtualPoolRestRep

use of com.emc.storageos.model.vpool.BlockVirtualPoolRestRep in project coprhd-controller by CoprHD.

the class BlockVirtualPools method listJson.

public static void listJson() {
    List<VirtualPoolInfo> items = Lists.newArrayList();
    for (BlockVirtualPoolRestRep virtualPool : VirtualPoolUtils.getBlockVirtualPools()) {
        items.add(new VirtualPoolInfo(virtualPool));
    }
    renderJSON(DataTablesSupport.createJSON(items, params));
}
Also used : VirtualPoolInfo(models.datatable.VirtualPoolDataTable.VirtualPoolInfo) BlockVirtualPoolRestRep(com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)

Aggregations

BlockVirtualPoolRestRep (com.emc.storageos.model.vpool.BlockVirtualPoolRestRep)26 URI (java.net.URI)10 Asset (com.emc.sa.asset.annotation.Asset)6 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)5 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)5 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 BlockVirtualPoolForm (models.virtualpool.BlockVirtualPoolForm)4 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)3 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)3 Map (java.util.Map)3 StringSet (com.emc.storageos.db.client.model.StringSet)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)2 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)2 BlockVirtualPoolParam (com.emc.storageos.model.vpool.BlockVirtualPoolParam)2