Search in sources :

Example 1 with UCSServiceProfileTemplate

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

the class ComputeSystemService method getServiceProfileTemplatesForComputeSystem.

public List<NamedRelatedResourceRep> getServiceProfileTemplatesForComputeSystem(ComputeSystem cs, DbClient dbClient) {
    List<NamedRelatedResourceRep> serviceProfileTemplates = new ArrayList<NamedRelatedResourceRep>();
    URIQueryResultList sptIdList = new URIQueryResultList();
    dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), sptIdList);
    List<UCSServiceProfileTemplate> profileTemplateList = dbClient.queryObject(UCSServiceProfileTemplate.class, sptIdList, true);
    for (UCSServiceProfileTemplate serviceProfileTemplate : profileTemplateList) {
        if (!serviceProfileTemplate.getUpdating()) {
            NamedRelatedResourceRep sptNamedRelatedResource = new NamedRelatedResourceRep();
            sptNamedRelatedResource.setId(serviceProfileTemplate.getId());
            sptNamedRelatedResource.setName(serviceProfileTemplate.getLabel() + " (Initial Template)");
            serviceProfileTemplates.add(sptNamedRelatedResource);
        } else {
            _log.info(" updating service profile template:" + serviceProfileTemplate.getLabel() + " id:" + serviceProfileTemplate.getId().toString());
            boolean valid = isUpdatingSPTValid(serviceProfileTemplate, dbClient);
            if (valid) {
                NamedRelatedResourceRep sptNamedRelatedResource = new NamedRelatedResourceRep();
                sptNamedRelatedResource.setId(serviceProfileTemplate.getId());
                sptNamedRelatedResource.setName(serviceProfileTemplate.getLabel() + " (Updating Template)");
                serviceProfileTemplates.add(sptNamedRelatedResource);
            } else {
                _log.info("invalid uSPT");
            }
        }
    // TODO: Check if SPT uses updating vnic templates here. If so, it is invalid for use.
    }
    return serviceProfileTemplates;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 2 with UCSServiceProfileTemplate

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

the class ComputeVirtualPoolService method checkServiceProfileTemplateURIs.

/**
 * Validates that each of the passed virtual array ids reference an existing
 * virtual array in the database and throws a bad request exception when
 * an invalid id is found.
 *
 * @param dbClient A reference to a DB client.
 */
private void checkServiceProfileTemplateURIs(Set<String> sptIds, DbClient dbClient) {
    Set<String> invalidIds = new HashSet<String>();
    if ((sptIds != null) && (!sptIds.isEmpty())) {
        Iterator<String> sptIdsIter = sptIds.iterator();
        while (sptIdsIter.hasNext()) {
            URI sptURI = null;
            try {
                sptURI = URI.create(sptIdsIter.next());
                UCSServiceProfileTemplate serviceProfileTemplate = dbClient.queryObject(UCSServiceProfileTemplate.class, sptURI);
                if (serviceProfileTemplate == null) {
                    invalidIds.add(sptURI.toString());
                }
            } catch (DatabaseException e) {
                if (sptURI != null) {
                    invalidIds.add(sptURI.toString());
                }
            }
        }
    }
    if (!invalidIds.isEmpty()) {
        throw APIException.badRequests.theURIsOfParametersAreNotValid("service profile templates", invalidIds);
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) URI(java.net.URI) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) HashSet(java.util.HashSet)

Example 3 with UCSServiceProfileTemplate

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

the class ComputeVirtualPoolService method updateComputeVirtualPool.

/**
 * Update a Compute Virtual Pool
 *
 * @brief Update a compute virtual pool
 * @param param The Compute Virtual Pool update spec
 * @return ComputeVirtualPoolRestRep The updated Compute Virtual Pool
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public ComputeVirtualPoolRestRep updateComputeVirtualPool(@PathParam("id") URI id, ComputeVirtualPoolUpdateParam param) {
    ComputeVirtualPool cvp = null;
    _log.debug("Update Parameters:\n" + param.toString());
    // Validate that Virtual Pool exists
    ArgValidator.checkFieldUriType(id, ComputeVirtualPool.class, "id");
    cvp = this.queryObject(ComputeVirtualPool.class, id, true);
    boolean nicOrHbaRangeChanges = false;
    // If current value not set OR if param is more restrictive then change is more restrictive
    boolean moreRestrictiveChange = false;
    // Process the update parameters
    // If a name is specified on request and that value is different that current name
    boolean nameChange = (param.getName() != null && !(cvp.getLabel().equals(param.getName())));
    if (nameChange) {
        checkForDuplicateName(param.getName(), ComputeVirtualPool.class);
        cvp.setLabel(param.getName());
    }
    if (null != param.getDescription()) {
        cvp.setDescription(param.getDescription());
    }
    if (null != param.getSystemType()) {
        ArgValidator.checkFieldValueFromEnum(param.getSystemType(), "system_type", ComputeVirtualPool.SupportedSystemTypes.class);
        // Don't allow changes of system type if there are service profile templates already set
        if (cvp.getServiceProfileTemplates() != null) {
            if (!cvp.getServiceProfileTemplates().isEmpty()) {
                throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "Cannot change system type when Service Profile Temples are associated");
            }
        }
        cvp.setSystemType(param.getSystemType());
    }
    if (isParamSet(param.getMinProcessors()) && ((cvp.getMinProcessors() == null) || (cvp.getMinProcessors() < param.getMinProcessors()))) {
        moreRestrictiveChange = true;
        _log.debug("Min Processors increased from " + cvp.getMinProcessors() + " to " + param.getMinProcessors());
    }
    cvp.setMinProcessors(getParamValue(param.getMinProcessors()));
    if (isParamSet(param.getMaxProcessors()) && ((cvp.getMaxProcessors() == null) || (cvp.getMaxProcessors() == -1) || (cvp.getMaxProcessors() > param.getMaxProcessors()))) {
        moreRestrictiveChange = true;
        _log.debug("Max Processors decreased from " + cvp.getMaxProcessors() + " to " + param.getMaxProcessors());
    }
    cvp.setMaxProcessors(getParamMaxValue(param.getMaxProcessors()));
    validateMinMaxIntValues(cvp.getMinProcessors(), cvp.getMaxProcessors(), "min_processors", "max_processors");
    if (isParamSet(param.getMinTotalCores()) && ((cvp.getMinTotalCores() == null) || (cvp.getMinTotalCores() < param.getMinTotalCores()))) {
        moreRestrictiveChange = true;
        _log.debug("Min TotalCores increased from " + cvp.getMinTotalCores() + " to " + param.getMinTotalCores());
    }
    cvp.setMinTotalCores(getParamValue(param.getMinTotalCores()));
    if (isParamSet(param.getMaxTotalCores()) && ((cvp.getMaxTotalCores() == null) || (cvp.getMaxTotalCores() == -1) || (cvp.getMaxTotalCores() > param.getMaxTotalCores()))) {
        moreRestrictiveChange = true;
        _log.debug("Max TotalCores decreased from " + cvp.getMaxTotalCores() + " to " + param.getMaxTotalCores());
    }
    cvp.setMaxTotalCores(getParamMaxValue(param.getMaxTotalCores()));
    validateMinMaxIntValues(cvp.getMinTotalCores(), cvp.getMaxTotalCores(), "min_total_cores", "max_total_cores");
    if (isParamSet(param.getMinTotalThreads()) && ((cvp.getMinTotalThreads() == null) || (cvp.getMinTotalThreads() < param.getMinTotalThreads()))) {
        moreRestrictiveChange = true;
        _log.debug("Min TotalThreads increased from " + cvp.getMinTotalThreads() + " to " + param.getMinTotalThreads());
    }
    cvp.setMinTotalThreads(getParamValue(param.getMinTotalThreads()));
    if (isParamSet(param.getMaxTotalThreads()) && ((cvp.getMaxTotalThreads() == null) || (cvp.getMaxTotalThreads() == -1) || (cvp.getMaxTotalThreads() > param.getMaxTotalThreads()))) {
        moreRestrictiveChange = true;
        _log.debug("Max TotalThreads decreased from " + cvp.getMaxTotalThreads() + " to " + param.getMaxMemory());
    }
    cvp.setMaxTotalThreads(getParamMaxValue(param.getMaxTotalThreads()));
    validateMinMaxIntValues(cvp.getMinTotalThreads(), cvp.getMaxTotalThreads(), "min_total_threads", "max_total_threads");
    if (isParamSet(param.getMinCpuSpeed()) && ((cvp.getMinCpuSpeed() == null) || (cvp.getMinCpuSpeed() < param.getMinCpuSpeed()))) {
        moreRestrictiveChange = true;
        _log.debug("Min CpuSpeed increased from " + cvp.getMinCpuSpeed() + " to " + param.getMinCpuSpeed());
    }
    cvp.setMinCpuSpeed(getParamValue(param.getMinCpuSpeed()));
    if (isParamSet(param.getMaxCpuSpeed()) && ((cvp.getMaxCpuSpeed() == null) || (cvp.getMaxCpuSpeed() == -1) || (cvp.getMaxCpuSpeed() > param.getMaxCpuSpeed()))) {
        moreRestrictiveChange = true;
        _log.debug("Max CpuSpeed decreased from " + cvp.getMaxCpuSpeed() + " to " + param.getMaxCpuSpeed());
    }
    cvp.setMaxCpuSpeed(getParamMaxValue(param.getMaxCpuSpeed()));
    validateMinMaxIntValues(cvp.getMinCpuSpeed(), cvp.getMaxCpuSpeed(), "min_processor_speed", "max_processor_speed");
    if (isParamSet(param.getMinMemory()) && ((cvp.getMinMemory() == null) || (cvp.getMinMemory() < param.getMinMemory()))) {
        moreRestrictiveChange = true;
        _log.debug("Min Memory increased from " + cvp.getMinMemory() + " to " + param.getMinMemory());
    }
    cvp.setMinMemory(getParamValue(param.getMinMemory()));
    if (isParamSet(param.getMaxMemory()) && ((cvp.getMaxMemory() == null) || (cvp.getMaxMemory() == -1) || (cvp.getMaxMemory() > param.getMaxMemory()))) {
        moreRestrictiveChange = true;
        _log.debug("Max Memory decreased from " + cvp.getMaxMemory() + " to " + param.getMaxMemory());
    }
    cvp.setMaxMemory(getParamMaxValue(param.getMaxMemory()));
    validateMinMaxIntValues(cvp.getMinMemory(), cvp.getMaxMemory(), "min_memory", "max_memory");
    // If current value not set OR if param is more restrictive then change is more
    boolean moreRestrictiveNicHbaChange = false;
    if (isParamSet(param.getMinNics()) && ((cvp.getMinNics() == null) || (cvp.getMinNics() < param.getMinNics()))) {
        moreRestrictiveNicHbaChange = true;
        _log.debug("Min nic increased from " + cvp.getMinNics() + " to " + param.getMinNics());
    }
    cvp.setMinNics(getParamValue(param.getMinNics()));
    if (isParamSet(param.getMaxNics()) && ((cvp.getMaxNics() == null) || (cvp.getMaxNics() == -1) || (cvp.getMaxNics() > param.getMaxNics()))) {
        moreRestrictiveNicHbaChange = true;
        _log.debug("Max nic decreased from " + cvp.getMaxNics() + " to " + param.getMaxNics());
    }
    cvp.setMaxNics(getParamMaxValue(param.getMaxNics()));
    validateMinMaxIntValues(cvp.getMinNics(), cvp.getMaxNics(), "min_nics", "max_nics");
    if (isParamSet(param.getMinHbas()) && ((cvp.getMinHbas() == null) || (cvp.getMinHbas() < param.getMinHbas()))) {
        moreRestrictiveNicHbaChange = true;
        _log.debug("Min hba increased from " + cvp.getMinHbas() + " to " + param.getMinHbas());
    }
    cvp.setMinHbas(getParamValue(param.getMinHbas()));
    if (isParamSet(param.getMaxHbas()) && ((cvp.getMaxHbas() == null) || (cvp.getMaxHbas() == -1) || (cvp.getMaxHbas() > param.getMaxHbas()))) {
        moreRestrictiveNicHbaChange = true;
        _log.debug("Max hba decreased from " + cvp.getMaxHbas() + " to " + param.getMaxHbas());
    }
    cvp.setMaxHbas(getParamMaxValue(param.getMaxHbas()));
    validateMinMaxIntValues(cvp.getMinHbas(), cvp.getMaxHbas(), "min_hbas", "max_hbas");
    boolean changeToStaticAssignment = false;
    boolean changeToDynamicAssignment = false;
    Collection<ComputeElement> staticElements = new HashSet<ComputeElement>();
    if (!cvp.getUseMatchedElements() && cvp.getMatchedComputeElements() != null && !cvp.getMatchedComputeElements().isEmpty()) {
        staticElements.addAll(_dbClient.queryObject(ComputeElement.class, toUriList(cvp.getMatchedComputeElements())));
        _log.debug("static elements count:" + staticElements.size());
    }
    if (null != param.getUseMatchedElements()) {
        // Will need to clear current matches when changing to static assignment
        changeToStaticAssignment = (param.getUseMatchedElements() == false) && (param.getUseMatchedElements() != cvp.getUseMatchedElements());
        changeToDynamicAssignment = (param.getUseMatchedElements() == true) && (param.getUseMatchedElements() != cvp.getUseMatchedElements());
        cvp.setUseMatchedElements(param.getUseMatchedElements());
    }
    if (changeToStaticAssignment) {
        // Clear dynamic matches when changing to static to get ready for upcoming assignments
        if (cvp.getMatchedComputeElements() != null) {
            cvp.getMatchedComputeElements().clear();
        }
    }
    if (null != param.getVarrayChanges()) {
        updateVirtualArrays(cvp, param.getVarrayChanges());
    }
    if (null != param.getSptChanges()) {
        if (cvp.getSystemType().contentEquals(ComputeVirtualPool.SupportedSystemTypes.Cisco_UCSM.toString())) {
            updateServiceProfileTemplates(cvp, param.getSptChanges());
        }
    }
    // Check SPTs meet criteria after updates above
    if (moreRestrictiveNicHbaChange) {
        if (isComputeVirtualPoolInUse(cvp)) {
            _log.warn("VCP is in use; more restrictive Nic or Hba change is not allowed");
            throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "More restrictive updates to network adapter and hba range not allowed because compute virtual pool is already in use.");
        }
        Set<String> sptsNotMeetingCriteria = new HashSet<String>();
        Collection<UCSServiceProfileTemplate> templates = _dbClient.queryObject(UCSServiceProfileTemplate.class, toUriList(cvp.getServiceProfileTemplates()));
        for (UCSServiceProfileTemplate template : templates) {
            boolean inUse = isServiceProfileTemplateInUse(cvp, template);
            try {
                validateServiceProfileTemplate(cvp, template);
            } catch (APIException e) {
                _log.warn("SPT " + template.getLabel() + ":" + template.getDn() + " is in use(" + inUse + ") and does not meet criteria " + e.toString());
                /*
                     * Since we are disallowing more restrictive changes if the VCP is in use, the if block below will not be used for the
                     * 2.2 release.
                     */
                if (inUse) {
                    throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "Updates to pool not allowed because service profile template(s) already in use do not meet requested criteria.");
                }
                // if spt not in use then simply remove
                sptsNotMeetingCriteria.add(template.getId().toString());
                _log.warn("SPT does not meet criteria; so being removed");
            }
        }
        cvp.removeServiceProfileTemplates(sptsNotMeetingCriteria);
    }
    if (cvp.getUseMatchedElements()) {
        _log.debug("Compute pool " + cvp.getLabel() + " configured to use dynamic matching");
        getMatchingCEsforCVPAttributes(cvp);
    }
    if (changeToDynamicAssignment && !staticElements.isEmpty()) {
        // to possibly include them
        for (ComputeElement computeElement : staticElements) {
            if (!isAvailable(computeElement)) {
                _log.error("Cannot change to dynamic matching because statically assigned compute element(s) have been used in pool " + cvp.getId());
                throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "Cannot change to automatic matching because manually assigned compute element(s) already in use.");
            }
        }
        updateOtherPoolsComputeElements(cvp);
    }
    if (moreRestrictiveChange) {
        if (isComputeVirtualPoolInUse(cvp)) {
            _log.warn("VCP is in use; more restrictive change is not allowed");
            throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "More restrictive updates to qualifiers not allowed because compute virtual pool is already in use.");
        }
        // VCP is not in use. So check if there are statically assigned members that need to be removed from vcp membership
        _log.info("VCP is not in use. So check if there are statically assigned members that need to be removed from vcp membership");
        if (!cvp.getUseMatchedElements() && !staticElements.isEmpty()) {
            Set<ComputeElement> cesNotMeetingCriteria = new HashSet<ComputeElement>();
            Collection<ComputeElement> computeElements = _dbClient.queryObject(ComputeElement.class, getURIs(staticElements));
            for (ComputeElement element : computeElements) {
                _log.debug("Blade:" + element.getChassisId() + "/" + element.getSlotId());
                boolean inUse = (element.getAvailable() == false);
                try {
                    validateComputeElement(cvp, element);
                } catch (APIException e) {
                    _log.warn("Compute Element " + element.getLabel() + ":" + element.getDn() + " is in use(" + inUse + ") and does not meet criteria " + e.toString());
                    /*
                         * Since we are disallowing more restrictive changes if the VCP is in use, the if block below will not be used for
                         * the 2.2 release.
                         */
                    if (inUse) {
                        throw APIException.badRequests.changeToComputeVirtualPoolNotSupported(cvp.getLabel(), "Updates to pool not allowed because compute element(s) already in use do not meet requested criteria.");
                    }
                    // if ces not in use then simply remove
                    cesNotMeetingCriteria.add(element);
                    _log.warn("Compute Element does not meet criteria; so being removed");
                }
            }
        }
    }
    updateHostToCVPRelation(cvp);
    _dbClient.updateAndReindexObject(cvp);
    recordOperation(OperationTypeEnum.UPDATE_COMPUTE_VPOOL, VPOOL_UPDATED_DESCRIPTION, cvp);
    return toComputeVirtualPool(_dbClient, cvp, isComputeVirtualPoolInUse(cvp));
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) ComputeVirtualPoolMapper.toComputeVirtualPool(com.emc.storageos.api.mapper.ComputeVirtualPoolMapper.toComputeVirtualPool) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with UCSServiceProfileTemplate

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

the class ComputeDeviceControllerImpl method addStepsPreOsInstall.

/**
 * Create/Add Pre-OS install steps to the workflow.
 *
 * @param workflow
 *            {@link Workflow} instance
 * @param waitFor
 *            If non-null, the step will not be queued for execution in the
 *            Dispatcher until the Step or StepGroup indicated by the
 *            waitFor has completed. The waitFor may either be a string
 *            representation of a Step UUID, or the name of a StepGroup.
 * @param computeSystemId
 *            {@link URI} computeSystem Id
 * @param hostId
 *            {@link URI} host Id
 * @param prepStepId
 *            {@link String} step Id
 * @return waitFor step name
 */
@Override
public String addStepsPreOsInstall(Workflow workflow, String waitFor, URI computeSystemId, URI hostId, String prepStepId) {
    log.info("addStepsPreOsInstall");
    ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, computeSystemId);
    Host host = _dbClient.queryObject(Host.class, hostId);
    ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
    // TODO COP-28960 check for null ce
    URI computeElementId = ce.getId();
    log.info("sptId:" + ce.getSptId());
    if (ce.getSptId() != null) {
        URI sptId = URI.create(ce.getSptId());
        UCSServiceProfileTemplate template = _dbClient.queryObject(UCSServiceProfileTemplate.class, sptId);
        // TODO COP-28960 check template not null
        log.info("is updating:" + template.getUpdating());
        if (template.getUpdating()) {
            waitFor = workflow.createStep(UNBIND_HOST_FROM_TEMPLATE, "prepare host for os install by unbinding it from service profile template", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("unbindHostFromTemplateStep", computeSystemId, hostId), new Workflow.Method("rollbackUnbindHostFromTemplate", computeSystemId, hostId), null);
        }
        // Set host to boot from lan
        waitFor = workflow.createStep(OS_INSTALL_SET_LAN_BOOT, "Set the host to boot from LAN", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("setLanBootTargetStep", computeSystemId, computeElementId, hostId), new Workflow.Method("setNoBootStep", computeSystemId, computeElementId, hostId), null);
        // Set the OS install Vlan on the first vnic
        waitFor = workflow.createStep(OS_INSTALL_PREPARE_OS_NETWORK, "prepare network for os install", waitFor, cs.getId(), cs.getSystemType(), this.getClass(), new Workflow.Method("prepareOsInstallNetworkStep", computeSystemId, computeElementId), new Workflow.Method("rollbackOsInstallNetwork", computeSystemId, computeElementId, prepStepId), prepStepId);
    } else {
        log.error("sptId is null!");
        throw new IllegalArgumentException("addStepsPreOsInstall method failed.  Could not find Serviceprofile template id from computeElement" + ce.getLabel());
    }
    return waitFor;
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Example 5 with UCSServiceProfileTemplate

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

the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesHBAs.

private void reconcileServiceProfileTemplatesHBAs(ComputeSystem cs, List<LsServer> lsServers, VhbaHelper vsanLookupMap) {
    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, ComputeElementHBA> removeVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> addVhbas = new HashMap<>();
        Map<String, ComputeElementHBA> updateVhbas = new HashMap<>();
        URIQueryResultList uriVhbas = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
        List<ComputeElementHBA> vbhas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
        for (ComputeElementHBA hba : vbhas) {
            removeVhbas.put(hba.getLabel(), hba);
        }
        for (VnicFc vnicFc : (List<VnicFc>) serviceProfileTemplateDetails.get("vhbas")) {
            ComputeElementHBA hba = removeVhbas.get(vnicFc.getName());
            if (hba != null) {
                updateVhbas.put(vnicFc.getName(), hba);
                removeVhbas.remove(hba.getLabel());
                updateComputeElementHBA(hba, vsanLookupMap, vnicFc);
            } else {
                hba = new ComputeElementHBA();
                addVhbas.put(vnicFc.getName(), hba);
                createComputeElementHBA(cs, serviceProfileTemplate, hba, vsanLookupMap, vnicFc);
            }
        }
        createDataObjects(new ArrayList<DataObject>(addVhbas.values()));
        persistDataObjects(new ArrayList<DataObject>(updateVhbas.values()));
        for (String name : removeVhbas.keySet()) {
            _log.info("Marked for deletion ComputeElementHBA: " + name);
        }
        deleteDataObjects(new ArrayList<DataObject>(removeVhbas.values()));
    }
}
Also used : UCSServiceProfileTemplate(com.emc.storageos.db.client.model.UCSServiceProfileTemplate) HashMap(java.util.HashMap) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) ComputeElementHBA(com.emc.storageos.db.client.model.ComputeElementHBA) 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) 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)

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