Search in sources :

Example 11 with UCSServiceProfileTemplate

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

the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesBootDefinitions.

private void reconcileServiceProfileTemplatesBootDefinitions(ComputeSystem cs, List<LsServer> lsServers) {
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    Map<String, LsServer> lsServerMap = new HashMap<>();
    for (LsServer lsServer : lsServers) {
        lsServerMap.put(lsServer.getDn(), lsServer);
    }
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceProfileTemplate : serviceTemplates) {
        LsServer lsServer = lsServerMap.get(serviceProfileTemplate.getDn());
        if (lsServer == null) {
            continue;
        }
        Map<String, Object> serviceProfileTemplateDetails = getServiceProfileTemplateDetails(lsServer);
        LsbootDef lsbootDef = (LsbootDef) serviceProfileTemplateDetails.get("associatedBootPolicy");
        if (lsbootDef != null) {
            _log.debug("Reconcile bootdef for SPT:" + serviceProfileTemplate.getLabel());
            ComputeBootDef computeBootDef = reconcileComputeBootDef(lsbootDef, serviceProfileTemplate, cs);
        } else {
            // Remove any computeBootDefs that are no longer needed.
            URIQueryResultList bootDefUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
            List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
            deleteComputeBootDefs(bootDefs);
        }
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeBootDef(com.emc.storageos.db.client.model.ComputeBootDef) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) LsbootDef(com.emc.cloud.platform.ucs.out.model.LsbootDef) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 12 with UCSServiceProfileTemplate

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

the class UcsDiscoveryWorker method removeServiceProfileTemplatesFromComputeVirtualPool.

private void removeServiceProfileTemplatesFromComputeVirtualPool(Collection<UCSServiceProfileTemplate> removeTemplates) {
    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 (UCSServiceProfileTemplate template : removeTemplates) {
            if (cvp.getServiceProfileTemplates() != null && cvp.getServiceProfileTemplates().contains(template.getId().toString())) {
                _log.info("Removing UCSServiceProfileTemplate {} from ComputePool", template.getDn());
                cvp.removeServiceProfileTemplate(template.getId().toString());
                dbUpdateRequired = true;
            }
        }
        if (dbUpdateRequired) {
            _log.info("Persisting ComputeVirtualPool {},after UCSServiceProfileTemplate removal", cvp.getId());
            _dbClient.persistObject(cvp);
        }
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) URI(java.net.URI) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool)

Example 13 with UCSServiceProfileTemplate

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

the class UcsDiscoveryWorker method reconcileServiceProfileTemplates.

private void reconcileServiceProfileTemplates(ComputeSystem cs, List<LsServer> serviceProfileTemplates) {
    _log.info("Reconciling ServiceProfileTemplates");
    Map<String, UCSServiceProfileTemplate> removeTemplates = new HashMap<>();
    Map<String, UCSServiceProfileTemplate> updateTemplates = new HashMap<>();
    Map<String, UCSServiceProfileTemplate> addTemplates = new HashMap<>();
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceTemplate : serviceTemplates) {
        removeTemplates.put(serviceTemplate.getDn(), serviceTemplate);
    }
    // discovered data
    for (LsServer lsServer : serviceProfileTemplates) {
        UCSServiceProfileTemplate spt = removeTemplates.get(lsServer.getDn());
        if (spt != null) {
            updateTemplates.put(lsServer.getDn(), spt);
            removeTemplates.remove(spt.getDn());
            updateUCSServiceProfileTemplate(spt, lsServer);
        } else {
            spt = new UCSServiceProfileTemplate();
            addTemplates.put(lsServer.getDn(), spt);
            createUCSServiceProfileTemplate(cs, spt, lsServer);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addTemplates.values()));
    persistDataObjects(new ArrayList<DataObject>(updateTemplates.values()));
    for (String profileName : removeTemplates.keySet()) {
        _log.info("Marked for deletion UCSServiceProfileTemplate: " + profileName);
    }
    // Handle SPTs that are removed on the device.
    // Step1: Remove all references to the SPT in the Compute Virtual Pool.
    // Step2: Delete the SPT from the list of existing SPTs.
    removeServiceProfileTemplatesFromComputeVirtualPool(removeTemplates.values());
    deleteDataObjects(new ArrayList<DataObject>(removeTemplates.values()));
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 14 with UCSServiceProfileTemplate

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

the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesVnics.

private void reconcileServiceProfileTemplatesVnics(ComputeSystem cs, List<LsServer> lsServers) {
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
    Map<String, LsServer> lsServerMap = new HashMap<>();
    for (LsServer lsServer : lsServers) {
        lsServerMap.put(lsServer.getDn(), lsServer);
    }
    List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
    for (UCSServiceProfileTemplate serviceProfileTemplate : serviceTemplates) {
        LsServer lsServer = lsServerMap.get(serviceProfileTemplate.getDn());
        if (lsServer == null) {
            continue;
        }
        Map<String, Object> serviceProfileTemplateDetails = getServiceProfileTemplateDetails(lsServer);
        Map<String, ComputeVnic> removeVnics = new HashMap<>();
        Map<String, ComputeVnic> addVnics = new HashMap<>();
        Map<String, ComputeVnic> updateVnics = new HashMap<>();
        URIQueryResultList uriVnics = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
        List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
        for (ComputeVnic vnic : vnics) {
            removeVnics.put(vnic.getName(), vnic);
        }
        for (VnicEther vnic : (List<VnicEther>) serviceProfileTemplateDetails.get("vnics")) {
            ComputeVnic nic = removeVnics.get(vnic.getName());
            if (nic != null) {
                updateVnics.put(vnic.getName(), nic);
                removeVnics.remove(nic.getLabel());
                updateComputeVnics(nic, vnic);
            } else {
                nic = new ComputeVnic();
                addVnics.put(vnic.getName(), nic);
                createComputeVnics(serviceProfileTemplate, nic, vnic);
            }
        }
        createDataObjects(new ArrayList<DataObject>(addVnics.values()));
        persistDataObjects(new ArrayList<DataObject>(updateVnics.values()));
        for (String name : removeVnics.keySet()) {
            _log.info("Marked for deletion ComputeElementHBA: " + name);
        }
        deleteDataObjects(new ArrayList<DataObject>(removeVnics.values()));
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) VnicEther(com.emc.cloud.platform.ucs.out.model.VnicEther) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeVnic(com.emc.storageos.db.client.model.ComputeVnic) DiscoveredSystemObject(com.emc.storageos.db.client.model.DiscoveredSystemObject) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) List(java.util.List) ArrayList(java.util.ArrayList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 15 with UCSServiceProfileTemplate

use of com.emc.storageos.db.client.model.UCSServiceProfileTemplate 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)

Aggregations

UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)19 URI (java.net.URI)11 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)8 LsServer (com.emc.cloud.platform.ucs.out.model.LsServer)6 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)6 HashMap (java.util.HashMap)6 ArrayList (java.util.ArrayList)5 HashSet (java.util.HashSet)5 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)4 DataObject (com.emc.storageos.db.client.model.DataObject)4 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)4 StringSet (com.emc.storageos.db.client.model.StringSet)4 ComputeElementHBA (com.emc.storageos.db.client.model.ComputeElementHBA)3 DiscoveredSystemObject (com.emc.storageos.db.client.model.DiscoveredSystemObject)3 Host (com.emc.storageos.db.client.model.Host)3 List (java.util.List)3 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)2 VnicFc (com.emc.cloud.platform.ucs.out.model.VnicFc)2 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)2 ComputeSystemControllerTimeoutException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerTimeoutException)2