Search in sources :

Example 21 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileVhbas.

private void reconcileVhbas(ComputeSystem cs, Map<String, LsServer> associatedLsServers, VhbaHelper lookUpVsan) {
    _log.info("Reconciling Vhbas");
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), uris);
    List<ComputeElement> elements = _dbClient.queryObject(ComputeElement.class, uris, true);
    for (ComputeElement computeElement : elements) {
        Map<String, ComputeElementHBA> removeVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> addVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> updateVhbas = new HashMap<>();
        URIQueryResultList uriVhbas = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeElementComputeElemetHBAsConstraint(computeElement.getId()), uriVhbas);
        List<ComputeElementHBA> vbhas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
        for (ComputeElementHBA hba : vbhas) {
            removeVhbas.put(hba.getLabel(), hba);
        }
        LsServer lsServer = associatedLsServers.get(computeElement.getLabel());
        if (lsServer != null && lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
            for (Serializable contentElement : lsServer.getContent()) {
                if (contentElement instanceof JAXBElement<?> && ((JAXBElement) contentElement).getValue() instanceof VnicFc) {
                    VnicFc vnicFc = (VnicFc) ((JAXBElement) contentElement).getValue();
                    ComputeElementHBA hba = removeVhbas.get(vnicFc.getName());
                    if (hba != null) {
                        updateVhbas.put(vnicFc.getName(), hba);
                        removeVhbas.remove(hba.getLabel());
                        updateComputeElementHBA(hba, vnicFc);
                    } else {
                        hba = new ComputeElementHBA();
                        addVhbas.put(vnicFc.getName(), hba);
                        createComputeElementHBA(cs, computeElement, hba, vnicFc);
                    }
                }
            }
        }
        createDataObjects(new ArrayList<DataObject>(addVhbas.values()));
        persistDataObjects(new ArrayList<DataObject>(updateVhbas.values()));
        // Do not delete vHBAs that are still linked to the ViPR host
        Iterator<Map.Entry<String, ComputeElementHBA>> vhbaIterator = removeVhbas.entrySet().iterator();
        while (vhbaIterator.hasNext()) {
            Map.Entry<String, ComputeElementHBA> entry = vhbaIterator.next();
            if (entry.getValue().getHost() != null) {
                vhbaIterator.remove();
            } else {
                _log.info("vHBA is marked for deletion {}", entry.getKey());
            }
        }
        deleteDataObjects(new ArrayList<DataObject>(removeVhbas.values()));
    }
}
Also used : Serializable(java.io.Serializable) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) JAXBElement(javax.xml.bind.JAXBElement) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) VnicFc(com.emc.cloud.platform.ucs.out.model.VnicFc) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Map(java.util.Map) HashMap(java.util.HashMap)

Example 22 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method removeBladesFromComputeVirtualPools.

private void removeBladesFromComputeVirtualPools(Collection<ComputeElement> removeBlades) {
    List<URI> ids = _dbClient.queryByType(ComputeVirtualPool.class, true);
    Iterator<ComputeVirtualPool> iter = _dbClient.queryIterativeObjects(ComputeVirtualPool.class, ids);
    while (iter.hasNext()) {
        Boolean dbUpdateRequired = false;
        ComputeVirtualPool cvp = iter.next();
        for (ComputeElement computeElement : removeBlades) {
            if (cvp.getMatchedComputeElements() != null && cvp.getMatchedComputeElements().contains(computeElement.getId().toString())) {
                _log.info("Removing ComputeElement {} from ComputeVirtualPool {} ", computeElement.getDn(), cvp.getLabel());
                cvp.removeMatchedComputeElement(computeElement.getId().toString());
                dbUpdateRequired = true;
            }
        }
        if (dbUpdateRequired) {
            _log.info("Persisting ComputeVirtualPool {},after ComputeElement removal", cvp.getLabel());
            _dbClient.persistObject(cvp);
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) URI(java.net.URI) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool)

Example 23 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileComputeBlades.

private void reconcileComputeBlades(ComputeSystem cs, List<ComputeBlade> computeBlades, Map<String, LsServer> associatedLsServers) {
    _log.info("reconciling ComputeBlades");
    Map<String, ComputeElement> removeBlades = new HashMap<>();
    Map<String, ComputeElement> updateBlades = new HashMap<>();
    Map<String, ComputeElement> addBlades = new HashMap<>();
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), uris);
    List<ComputeElement> elements = _dbClient.queryObject(ComputeElement.class, uris, true);
    for (ComputeElement element : elements) {
        removeBlades.put(element.getLabel(), element);
    }
    for (ComputeBlade computeBlade : computeBlades) {
        ComputeElement ce = removeBlades.get(computeBlade.getDn());
        LsServer lsServer = associatedLsServers.get(computeBlade.getDn());
        if (ce != null) {
            updateComputeElement(ce, computeBlade, lsServer);
            updateBlades.put(ce.getLabel(), ce);
            removeBlades.remove(computeBlade.getDn());
        } else {
            ce = new ComputeElement();
            createComputeElement(cs, ce, computeBlade, lsServer);
            addBlades.put(computeBlade.getDn(), ce);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addBlades.values()));
    persistDataObjects(new ArrayList<DataObject>(updateBlades.values()));
    if (!removeBlades.isEmpty()) {
        for (String name : removeBlades.keySet()) {
            _log.info("Marked for deletion ComputeElement name:" + name);
        }
        removeBladesFromComputeVirtualPools(removeBlades.values());
        removeBladesFromHosts(removeBlades.values());
        deleteDataObjects(new ArrayList<DataObject>(removeBlades.values()));
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 24 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolMapper method getAvailableComputeElements.

private static Set<RelatedResourceRep> getAvailableComputeElements(DbClient dbClient, StringSet matchedComputeElements) {
    Set<RelatedResourceRep> returnSet = new HashSet<RelatedResourceRep>();
    Collection<ComputeElement> computeElements = dbClient.queryObject(ComputeElement.class, toUriList(matchedComputeElements));
    for (ComputeElement computeElement : computeElements) {
        if (computeElement.getAvailable()) {
            returnSet.add(toRelatedResource(ResourceTypeEnum.COMPUTE_ELEMENT, computeElement.getId()));
        }
    }
    return returnSet;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) HashSet(java.util.HashSet)

Example 25 with ComputeElement

use of com.emc.storageos.db.client.model.ComputeElement in project coprhd-controller by CoprHD.

the class ComputeElementsCreateTest method createComputeElements.

/*
     * Create Volume/BlockSnapshot for all Storage Systems
     */
@Test
public void createComputeElements() {
    List<URI> computeSystems = _dbClient.queryByType(ComputeSystem.class, true);
    while (computeSystems.iterator().hasNext()) {
        computeSystemURI = computeSystems.iterator().next();
    }
    for (int i = 0; i < computeElementCount; i++) {
        URI computeElementURI = URIUtil.createId(ComputeElement.class);
        ComputeElement computeElement = new ComputeElement();
        computeElement.setComputeSystem(computeSystemURI);
        computeElement.setId(computeElementURI);
        computeElement.setCreationTime(Calendar.getInstance());
        computeElement.setInactive(false);
        computeElement.setRam(67108864L);
        computeElement.setNativeGuid(computeSystemURI.toASCIIString());
        computeElementsObjects.add(computeElement);
    }
    _dbClient.createObject(computeElementsObjects);
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) URI(java.net.URI) Test(org.junit.Test)

Aggregations

ComputeElement (com.emc.storageos.db.client.model.ComputeElement)52 Host (com.emc.storageos.db.client.model.Host)24 URI (java.net.URI)20 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)15 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)12 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)11 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)10 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)10 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)9 MalformedURLException (java.net.MalformedURLException)9 Produces (javax.ws.rs.Produces)9 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)8 HashMap (java.util.HashMap)8 Path (javax.ws.rs.Path)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 ComputeVirtualPool (com.emc.storageos.db.client.model.ComputeVirtualPool)6 UCSServiceProfile (com.emc.storageos.db.client.model.UCSServiceProfile)6 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)6 Cluster (com.emc.storageos.db.client.model.Cluster)4