Search in sources :

Example 26 with RelatedResourceRep

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

the class VMWareProvider method listVcentersForCluster.

protected List<VcenterRestRep> listVcentersForCluster(AssetOptionsContext context, URI clusterId) {
    ClusterRestRep clusterRestRep = api(context).clusters().get(clusterId);
    RelatedResourceRep vcenterDatacenter = clusterRestRep.getVcenterDataCenter();
    if (vcenterDatacenter == null) {
        // return all vcenters
        return api(context).vcenters().getByTenant(context.getTenant(), REGISTERED.and(INCOMPATIBLE.not()));
    } else {
        // return the vcenter this vipr cluster is already associated with in vcenter
        RelatedResourceRep vcenterRelatedRestRep = api(context).vcenterDataCenters().get(vcenterDatacenter.getId()).getVcenter();
        VcenterRestRep vcenterRestRep = api(context).vcenters().get(vcenterRelatedRestRep.getId());
        return Arrays.asList(vcenterRestRep);
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep)

Example 27 with RelatedResourceRep

use of com.emc.storageos.model.RelatedResourceRep 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 28 with RelatedResourceRep

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

the class ComputeVirtualPools method listComputePoolElements.

public static void listComputePoolElements(String id) {
    List<ComputeVirtualElementInfo> results = Lists.newArrayList();
    List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
    ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
    List<RelatedResourceRep> matchedElements = computePool.getMatchedComputeElements();
    for (RelatedResourceRep poolElement : matchedElements) {
        for (ComputeElementRestRep element : allComputeElements) {
            if (element.getId().equals(poolElement.getId())) {
                results.add(new ComputeVirtualElementInfo(element, computePool.getName(), (String) "No Name yet"));
                break;
            }
        }
    }
    renderJSON(DataTablesSupport.createJSON(results, params));
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) List(java.util.List) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) ComputeVirtualElementInfo(models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)

Example 29 with RelatedResourceRep

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

the class ComputeVirtualPools method computeVirtualPoolDetails.

public static void computeVirtualPoolDetails(String id) {
    ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
    if (computeVirtualPool == null) {
        error(MessagesUtils.get(UNKNOWN, id));
    }
    List<NamedRelatedResourceRep> temps = computeVirtualPool.getServiceProfileTemplates();
    List<RelatedResourceRep> varrays = computeVirtualPool.getVirtualArrays();
    StringBuilder selectedTemplatesBuilder = new StringBuilder();
    for (RelatedResourceRep varray : varrays) {
        List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(varray.getId());
        for (ComputeSystemRestRep acomp : arrayComputes) {
            for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
                if (CollectionUtils.isNotEmpty(temps)) {
                    for (NamedRelatedResourceRep template : temps) {
                        if (spt.getId().equals(template.getId())) {
                            selectedTemplatesBuilder.append(acomp.getName()).append(" - ").append(template.getName()).append(", ");
                        }
                    }
                }
            }
        }
    }
    String selectedTemplatesString = StringUtils.stripEnd(selectedTemplatesBuilder.toString(), ", ");
    render(computeVirtualPool, selectedTemplatesString);
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 30 with RelatedResourceRep

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

the class BlockProvider method getAddMobilityGroupResources.

@Asset("addMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getAddMobilityGroupResources(AssetOptionsContext ctx, final URI mobilityGroupId) {
    final ViPRCoreClient client = api(ctx);
    VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
    if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
        // VPLEX volumes that don't have reference to this mobility group
        List<URI> volumeIds = client.blockVolumes().listBulkIds();
        final ResourceFilter<VolumeRestRep> vplexFilter = new VplexVolumeFilter();
        List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, new ResourceFilter<VolumeRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(VolumeRestRep item) {
                boolean accept = (item.getVolumeGroups() == null || !contains(item, mobilityGroupId)) && vplexFilter.accept(item);
                if (accept) {
                    boolean rpProtection = (item.getProtection() != null && item.getProtection().getRpRep() != null && item.getProtection().getRpRep().getPersonality() != null);
                    if (rpProtection) {
                        // If RP+VPLEX protection specified, only allow RP SOURCE volumes to be listed
                        // as candidates for mobility groups. Exclude TARGETs and JOURNALs.
                        String personality = item.getProtection().getRpRep().getPersonality();
                        if (Volume.PersonalityTypes.TARGET.name().equals(personality) || Volume.PersonalityTypes.METADATA.name().equals(personality)) {
                            accept = false;
                        }
                    }
                }
                return accept;
            }

            private boolean contains(VolumeRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(volumes);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
        List<URI> hostIds = client.hosts().listBulkIds();
        List<HostRestRep> hosts = client.hosts().getByIds(hostIds, new ResourceFilter<HostRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(HostRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(HostRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(hosts);
    } else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
        List<URI> clusterIds = client.clusters().listBulkIds();
        List<ClusterRestRep> clusters = client.clusters().getByIds(clusterIds, new ResourceFilter<ClusterRestRep>() {

            @Override
            public boolean acceptId(URI id) {
                return true;
            }

            @Override
            public boolean accept(ClusterRestRep item) {
                return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
            }

            private boolean contains(ClusterRestRep item, URI mobilityGroup) {
                for (RelatedResourceRep vg : item.getVolumeGroups()) {
                    if (vg.getId().equals(mobilityGroup)) {
                        return true;
                    }
                }
                return false;
            }
        });
        return createBaseResourceOptions(clusters);
    } else {
        return Lists.newArrayList();
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) URI(java.net.URI) VplexVolumeFilter(com.emc.vipr.client.core.filters.VplexVolumeFilter) DefaultResourceFilter(com.emc.vipr.client.core.filters.DefaultResourceFilter) ResourceFilter(com.emc.vipr.client.core.filters.ResourceFilter) HostRestRep(com.emc.storageos.model.host.HostRestRep) VolumeGroupRestRep(com.emc.storageos.model.application.VolumeGroupRestRep) StoragePortGroupRestRepList(com.emc.storageos.model.portgroup.StoragePortGroupRestRepList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) StoragePortList(com.emc.storageos.model.ports.StoragePortList) ArrayList(java.util.ArrayList) VolumeGroupList(com.emc.storageos.model.application.VolumeGroupList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) SnapshotList(com.emc.storageos.model.SnapshotList) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)41 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)25 ArrayList (java.util.ArrayList)19 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)14 URI (java.net.URI)12 Asset (com.emc.sa.asset.annotation.Asset)8 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)5 BlockSnapshotSessionRestRep (com.emc.storageos.model.block.BlockSnapshotSessionRestRep)5 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)5 BlockSnapshotSessionList (com.emc.storageos.model.block.BlockSnapshotSessionList)4 StoragePortList (com.emc.storageos.model.ports.StoragePortList)4 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)3