Search in sources :

Example 1 with ComputeSystemBulkRep

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

the class VirtualArrayService method mapValidServiceProfileTemplatesToComputeSystem.

private ComputeSystemBulkRep mapValidServiceProfileTemplatesToComputeSystem(ComputeSystemBulkRep bulkRep, URI varrayId) {
    _log.debug("mapping Service Profile Templates valid for varray to the Compute Systems");
    ComputeSystemBulkRep rep = new ComputeSystemBulkRep();
    List<ComputeSystemRestRep> computeSystemList = new ArrayList<ComputeSystemRestRep>();
    for (ComputeSystemRestRep computeSystem : bulkRep.getComputeSystems()) {
        computeSystem.setServiceProfileTemplates(getServiceProfileTemplatesForComputeSystem(computeSystem.getId(), varrayId));
        computeSystemList.add(computeSystem);
    }
    rep.setComputeSystems(computeSystemList);
    return rep;
}
Also used : ArrayList(java.util.ArrayList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep)

Example 2 with ComputeSystemBulkRep

use of com.emc.storageos.model.compute.ComputeSystemBulkRep 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 3 with ComputeSystemBulkRep

use of com.emc.storageos.model.compute.ComputeSystemBulkRep 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 4 with ComputeSystemBulkRep

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

the class VirtualArrayService method getComputeSystems.

/**
 * Fetches all Compute Systems that are visible in the vArray
 *
 * First determine physical connectivity to any switches in the vArrray.
 * 1. From the vArray, determine the networks. (Call this Network Set)
 * 2. From the networks, get the physical switches that are attached.
 * 3. For each physical switch, iterate through the networks and get the FC endpoints.
 * 4. Look for any of the FIC ports in any of the FC endpoints on any of the
 * networks on the physical switch. When a FIC port matches, call this FIC
 * Port.
 * 5. If found, then there is physical connectivity.
 *
 * With physical connectivity Established:
 * 1. Given the FIC Port from step (4), pull the VSAN or VSANs assigned to
 * it on UCS.
 * 2. If the set contains one of the networks from the Network
 * Set in (1), we have connectivity to that vArray.
 *
 * @param id
 *            the URN of a ViPR VirtualArray.
 * @brief List all Compute Systems that are visible in the vArray
 * @return List of Compute Systems
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/compute-systems")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public ComputeSystemBulkRep getComputeSystems(@PathParam("id") URI id) {
    _log.info("get connected CS for vArray: {}", id);
    // Get and validate the varray with the passed id.
    ArgValidator.checkFieldUriType(id, VirtualArray.class, "id");
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, id);
    ArgValidator.checkEntityNotNull(varray, id, isIdEmbeddedInURL(id));
    BulkIdParam matchingCsIds = new BulkIdParam();
    // get varray networks
    List<Network> networks = CustomQueryUtility.queryActiveResourcesByRelation(_dbClient, id, Network.class, "connectedVirtualArrays");
    // collect network vsanIds and switch ids
    Set<String> networkVsanIds = new HashSet<>();
    Set<String> nsIds = new HashSet<>();
    for (Network network : networks) {
        if (StorageProtocol.Transport.FC.name().equalsIgnoreCase(network.getTransportType()) && DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(network.getRegistrationStatus())) {
            networkVsanIds.add(network.getNativeId());
            if (network.getNetworkSystems() != null) {
                nsIds.addAll(network.getNetworkSystems());
            }
        }
    }
    _log.info("vArray has these networks: {}", networkVsanIds);
    // use only registered network systems
    Set<URI> nsUris = new HashSet<>();
    for (String nsUri : nsIds) {
        nsUris.add(URI.create(nsUri));
    }
    List<NetworkSystem> nsList = _dbClient.queryObject(NetworkSystem.class, nsUris);
    for (NetworkSystem ns : nsList) {
        if (!DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(ns.getRegistrationStatus())) {
            nsIds.remove(ns.getId().toString());
        }
    }
    _log.info("the networks run on these network systems: {}", nsIds);
    if (networkVsanIds.isEmpty() || nsIds.isEmpty()) {
        // no networks in the array - exit early
        return new ComputeSystemBulkRep();
    }
    // for every switch get FCEndpoint.remotePortName(s)
    Set<String> connectedEndpoints = new HashSet<String>();
    for (String nsId : nsIds) {
        URIQueryResultList uriList = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getNetworkSystemFCPortConnectionConstraint(URI.create(nsId)), uriList);
        List<URI> epIds = new ArrayList<URI>();
        Iterator<URI> iter = uriList.iterator();
        while (iter.hasNext()) {
            epIds.add(iter.next());
        }
        List<FCEndpoint> eps = _dbClient.queryObjectField(FCEndpoint.class, "remotePortName", epIds);
        for (FCEndpoint ep : eps) {
            connectedEndpoints.add(ep.getRemotePortName());
        }
    }
    _log.debug("all connected endpoints: {}", connectedEndpoints);
    // get all CS
    List<URI> csIds = _dbClient.queryByType(ComputeSystem.class, true);
    List<ComputeSystem> csList = _dbClient.queryObject(ComputeSystem.class, csIds);
    for (ComputeSystem cs : csList) {
        if (!DiscoveredSystemObject.RegistrationStatus.REGISTERED.name().equals(cs.getRegistrationStatus())) {
            // skip not registered CS
            continue;
        }
        boolean connected = false;
        _log.info("evaluating uplinks of cs: {}", cs.getLabel());
        // loop thru UplinkPorts to find matches
        URIQueryResultList uris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeFabricUplinkPortConstraint(cs.getId()), uris);
        List<ComputeFabricUplinkPort> uplinkPorts = _dbClient.queryObject(ComputeFabricUplinkPort.class, uris, true);
        for (ComputeFabricUplinkPort port : uplinkPorts) {
            if (connectedEndpoints.contains(port.getWwpn())) {
                _log.info("found matching endpoint: {}", port.getWwpn());
                if (!Collections.disjoint(port.getVsans(), networkVsanIds)) {
                    _log.info("and networks overlap: {}", port.getVsans());
                    matchingCsIds.getIds().add(cs.getId());
                    connected = true;
                    break;
                }
            }
        }
        if (connected) {
            // skip uplink port channel matching as we are already connected
            continue;
        }
        // now loop thru UplinkPortChannels to find matches
        uris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeUplinkPortChannelConstraint(cs.getId()), uris);
        List<ComputeFabricUplinkPortChannel> uplinkPortChannels = _dbClient.queryObject(ComputeFabricUplinkPortChannel.class, uris, true);
        for (ComputeFabricUplinkPortChannel port : uplinkPortChannels) {
            if (connectedEndpoints.contains(port.getWwpn())) {
                _log.info("found matching endpoint: {}", port.getWwpn());
                if (!Collections.disjoint(port.getVsans(), networkVsanIds)) {
                    _log.info("and networks overlap: {}", port.getVsans());
                    matchingCsIds.getIds().add(cs.getId());
                    connected = true;
                    break;
                }
            }
        }
    }
    _log.info("these CS are connected to the vArray: {}", matchingCsIds.getIds());
    if (matchingCsIds.getIds().isEmpty()) {
        return new ComputeSystemBulkRep();
    }
    ComputeSystemBulkRep computeSystemReps = computeSystemService.getBulkResources(matchingCsIds);
    return mapValidServiceProfileTemplatesToComputeSystem(computeSystemReps, varray.getId());
}
Also used : MapVirtualArray(com.emc.storageos.api.mapper.functions.MapVirtualArray) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) BulkIdParam(com.emc.storageos.model.BulkIdParam) ComputeFabricUplinkPort(com.emc.storageos.db.client.model.ComputeFabricUplinkPort) ArrayList(java.util.ArrayList) VirtualArrayList(com.emc.storageos.model.varray.VirtualArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Network(com.emc.storageos.db.client.model.Network) ComputeSystemBulkRep(com.emc.storageos.model.compute.ComputeSystemBulkRep) ComputeFabricUplinkPortChannel(com.emc.storageos.db.client.model.ComputeFabricUplinkPortChannel) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) HashSet(java.util.HashSet) NetworkSystem(com.emc.storageos.db.client.model.NetworkSystem) FCEndpoint(com.emc.storageos.db.client.model.FCEndpoint) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ComputeSystemBulkRep (com.emc.storageos.model.compute.ComputeSystemBulkRep)4 ArrayList (java.util.ArrayList)4 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)3 URI (java.net.URI)3 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)2 ComputeElementListRestRep (com.emc.storageos.model.compute.ComputeElementListRestRep)2 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)2 VirtualArrayList (com.emc.storageos.model.varray.VirtualArrayList)2 MapVirtualArray (com.emc.storageos.api.mapper.functions.MapVirtualArray)1 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 NamedElementQueryResultList (com.emc.storageos.db.client.constraint.NamedElementQueryResultList)1 ComputeFabricUplinkPort (com.emc.storageos.db.client.model.ComputeFabricUplinkPort)1 ComputeFabricUplinkPortChannel (com.emc.storageos.db.client.model.ComputeFabricUplinkPortChannel)1 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)1 FCEndpoint (com.emc.storageos.db.client.model.FCEndpoint)1 Network (com.emc.storageos.db.client.model.Network)1 NetworkSystem (com.emc.storageos.db.client.model.NetworkSystem)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1