Search in sources :

Example 6 with ComputeElementRestRep

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

the class ComputeVirtualPools method listComputeElementsJson.

public static void listComputeElementsJson(String cvpid, ComputeVirtualPoolsForm computeVirtualPool) {
    List<ComputeVirtualElementInfo> results = Lists.newArrayList();
    computeVirtualPool.validateQualifiers("computeVirtualPool");
    if (Validation.hasErrors()) {
        // cannot call the errorhandler from inside the json call
        Logger.info("has errors error: %s", Validation.errors().toString());
    } else {
        List<ComputeSystemRestRep> allComputes = ComputeSystemUtils.getComputeSystems();
        List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
        if (NullColumnValueGetter.isNotNullValue(cvpid)) {
            computeVirtualPool.id = NullColumnValueGetter.getStringValue(cvpid);
            // We always show the full list of matching elements - in case of manual - selected ones will be checked
            List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
            for (ComputeElementRestRep element : allComputeElements) {
                String computeSystemName = ": " + element.getName();
                for (ComputeSystemRestRep compSys : allComputes) {
                    if (compSys.getId().equals(element.getComputeSystem().getId())) {
                        computeSystemName = compSys.getName() + computeSystemName;
                        break;
                    }
                }
                for (ComputeElementRestRep filteredElement : matchedElements) {
                    if (filteredElement.getId().equals(element.getId())) {
                        results.add(new ComputeVirtualElementInfo(element, element.getName(), computeSystemName));
                        break;
                    }
                }
            }
        } else {
            List<ComputeElementRestRep> matchedElements = ComputeVirtualPoolUtils.listMatchingComputeElements(computeVirtualPool.createMatch());
            for (ComputeElementRestRep elementA : allComputeElements) {
                String computeSystemName = ": " + elementA.getName();
                for (ComputeSystemRestRep compSys : allComputes) {
                    if (compSys.getId().equals(elementA.getComputeSystem().getId())) {
                        computeSystemName = compSys.getName() + computeSystemName;
                        break;
                    }
                }
                for (ComputeElementRestRep elementM : matchedElements) {
                    if (elementM.getId().toString().equals(elementA.getId().toString())) {
                        results.add(new ComputeVirtualElementInfo(elementA, elementA.getName(), computeSystemName));
                    }
                }
            }
        }
    }
    renderJSON(DataTablesSupport.createJSON(results, params));
}
Also used : ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) List(java.util.List) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) ComputeVirtualElementInfo(models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)

Example 7 with ComputeElementRestRep

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

the class ComputeVirtualPools method elementDetails.

public static void elementDetails(String id) {
    ComputeElementRestRep computeElement = ComputeSystemUtils.getComputeElement(id);
    if (computeElement == null) {
        error(MessagesUtils.get(UNKNOWN, id));
    }
    render(computeElement);
}
Also used : ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep)

Example 8 with ComputeElementRestRep

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

the class HostService method findComputeElementsMatchingVarrayAndCVP.

/*
     * Returns a map of compute system URI to compute elements available on that compute system
     */
private Map<URI, List<URI>> findComputeElementsMatchingVarrayAndCVP(ComputeVirtualPool cvp, VirtualArray varray) {
    Map<URI, List<URI>> computeSystemToComputeElementsMap = new HashMap<URI, List<URI>>();
    _log.debug("Look up compute elements for cvp " + cvp.getId());
    List<String> cvpCEList = new ArrayList<String>();
    if (cvp.getMatchedComputeElements() != null) {
        Iterator<String> iter = cvp.getMatchedComputeElements().iterator();
        while (iter.hasNext()) {
            String uriStr = iter.next();
            cvpCEList.add(uriStr);
        }
    }
    // Find all SPTs assigned for this CVP and their corresponding ComputeSystems
    Map<URI, URI> cvpTemplatesMap = new HashMap<URI, URI>();
    if (cvp.getServiceProfileTemplates() != null) {
        for (String templateIdString : cvp.getServiceProfileTemplates()) {
            URI templateId = URI.create(templateIdString);
            UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, templateId);
            if (template.getUpdating() == true) {
                if (!computeSystemService.isUpdatingSPTValid(template, _dbClient)) {
                    throw APIException.badRequests.invalidUpdatingSPT(template.getLabel());
                }
                StringSet varrayIds = new StringSet();
                varrayIds.add(varray.getId().toString());
                if (!computeSystemService.isServiceProfileTemplateValidForVarrays(varrayIds, templateId)) {
                    throw APIException.badRequests.incompatibleSPT(template.getLabel(), varray.getLabel());
                }
            }
            cvpTemplatesMap.put(template.getComputeSystem(), templateId);
        }
    }
    _log.debug("Look up compute systems for virtual array " + varray.getId());
    ComputeSystemBulkRep computeSystemBulkRep = virtualArrayService.getComputeSystems(varray.getId());
    if (computeSystemBulkRep.getComputeSystems() != null) {
        for (ComputeSystemRestRep computeSystemRestRep : computeSystemBulkRep.getComputeSystems()) {
            _log.debug("Found compute system " + computeSystemRestRep.getId() + " for virtual array " + varray.getId());
            if (!cvpTemplatesMap.containsKey(computeSystemRestRep.getId())) {
                _log.info("The CVP has no service profile templates assigned from compute system " + computeSystemRestRep.getName() + ". So no blades will be used from this compute system.");
                continue;
            }
            ComputeElementListRestRep computeElementListRestRep = computeSystemService.getComputeElements(computeSystemRestRep.getId());
            if (computeElementListRestRep.getList() != null) {
                List<URI> computeElementList = new ArrayList<URI>();
                for (ComputeElementRestRep computeElementRestRep : computeElementListRestRep.getList()) {
                    _log.debug("Compute system contains compute element " + computeElementRestRep.getId());
                    for (String computeElement : cvpCEList) {
                        if (computeElement.equals(computeElementRestRep.getId().toString())) {
                            if (computeElementRestRep.getAvailable() && computeElementRestRep.getRegistrationStatus().equals(RegistrationStatus.REGISTERED.name())) {
                                computeElementList.add(computeElementRestRep.getId());
                                _log.debug("Added compute element " + computeElementRestRep.getId());
                            } else {
                                _log.debug("found unavailable compute element" + computeElementRestRep.getId());
                            }
                        }
                    }
                }
                computeSystemToComputeElementsMap.put(computeSystemRestRep.getId(), computeElementList);
            }
        }
    } else {
        throw APIException.badRequests.noComputeSystemsFoundForVarray();
    }
    return computeSystemToComputeElementsMap;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI) ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) StringSet(com.emc.storageos.db.client.model.StringSet) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) UnManagedExportMaskList(com.emc.storageos.model.block.UnManagedExportMaskList) UnManagedVolumeList(com.emc.storageos.model.block.UnManagedVolumeList) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList) InitiatorList(com.emc.storageos.model.host.InitiatorList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) MountInfoList(com.emc.storageos.model.file.MountInfoList) HostList(com.emc.storageos.model.host.HostList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) BulkList(com.emc.storageos.api.service.impl.response.BulkList) LinkedList(java.util.LinkedList) IpInterfaceList(com.emc.storageos.model.host.IpInterfaceList) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 9 with ComputeElementRestRep

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

the class ComputeVirtualPoolService method findComputeElementsFromDeviceAssociations.

private List<URI> findComputeElementsFromDeviceAssociations(ComputeVirtualPool computeVirtualPool) {
    // Get CEs from associated varrays
    List<URI> ceList = new ArrayList<URI>();
    if (computeVirtualPool.getVirtualArrays() != null) {
        for (String virtualArrayId : computeVirtualPool.getVirtualArrays()) {
            URI virtualArrayURI = URI.create(virtualArrayId);
            ArgValidator.checkUri(virtualArrayURI);
            this.queryObject(VirtualArray.class, virtualArrayURI, true);
            _log.debug("Look up compute systems for virtual array " + virtualArrayURI);
            ComputeSystemBulkRep computeSystemBulkRep = virtualArrayService.getComputeSystems(virtualArrayURI);
            if (computeSystemBulkRep.getComputeSystems() != null) {
                for (ComputeSystemRestRep computeSystemRestRep : computeSystemBulkRep.getComputeSystems()) {
                    _log.debug("Found compute system " + computeSystemRestRep.getId() + " for virtual array " + virtualArrayURI);
                    ComputeElementListRestRep computeElementListRestRep = computeSystemService.getComputeElements(computeSystemRestRep.getId());
                    if (computeElementListRestRep.getList() != null) {
                        for (ComputeElementRestRep computeElementRestRep : computeElementListRestRep.getList()) {
                            _log.debug("Compute system contains compute element " + computeElementRestRep.getId());
                            ceList.add(computeElementRestRep.getId());
                        }
                    }
                }
            }
        }
    }
    return ceList;
}
Also used : ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) ArrayList(java.util.ArrayList) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI)

Example 10 with ComputeElementRestRep

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

the class ComputeSystems method computeElementsJson.

public static void computeElementsJson(String id) {
    List<ComputeElementInfo> results = Lists.newArrayList();
    List<ComputeElementRestRep> computeElements = ComputeSystemUtils.getComputeElements(id);
    String computeSystemName = ComputeSystemUtils.getComputeSystem(id).getName();
    for (ComputeElementRestRep computeElement : computeElements) {
        results.add(new ComputeElementInfo(computeElement, computeSystemName));
    }
    renderJSON(DataTablesSupport.createJSON(results, params));
}
Also used : ComputeElementInfo(models.datatable.ComputeSystemElementDataTable.ComputeElementInfo) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep)

Aggregations

ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)14 ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)7 ArrayList (java.util.ArrayList)6 URI (java.net.URI)5 Host (com.emc.storageos.db.client.model.Host)4 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)3 Cluster (com.emc.storageos.db.client.model.Cluster)3 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)3 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)3 List (java.util.List)3 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)2 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)2 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)2 StringSet (com.emc.storageos.db.client.model.StringSet)2 ComputeSystemBulkRep (com.emc.storageos.model.compute.ComputeSystemBulkRep)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 ComputeVirtualElementInfo (models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1