Search in sources :

Example 41 with ComputeElement

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

the class UcsDiscoveryWorker method removeBladesFromHosts.

private void removeBladesFromHosts(Collection<ComputeElement> removeBlades) {
    List<URI> ids = _dbClient.queryByType(Host.class, true);
    Iterator<Host> iter = _dbClient.queryIterativeObjects(Host.class, ids);
    while (iter.hasNext()) {
        Host host = iter.next();
        for (ComputeElement computeElement : removeBlades) {
            if (host.getComputeElement() != null && host.getComputeElement().equals(computeElement.getId())) {
                _log.info("Removing ComputeElement {} association from Host {} ", computeElement.getDn(), host.getLabel());
                host.setComputeElement(NullColumnValueGetter.getNullURI());
                _dbClient.persistObject(host);
                break;
            }
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) URI(java.net.URI)

Example 42 with ComputeElement

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

the class ComputeSystemControllerImpl method setHostSanBootTargets.

public void setHostSanBootTargets(URI hostId, URI volumeId, String stepId) throws ControllerException {
    Host host = null;
    try {
        WorkflowStepCompleter.stepExecuting(stepId);
        host = _dbClient.queryObject(Host.class, hostId);
        if (host == null) {
            throw ComputeSystemControllerException.exceptions.hostNotFound(hostId.toString());
        }
        if (host.getComputeElement() != null) {
            ComputeElement computeElement = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
            if (computeElement != null) {
                computeDeviceController.setSanBootTarget(computeElement.getComputeSystem(), computeElement.getId(), hostId, volumeId, false);
            } else {
                _log.error("Invalid compute element association");
                throw ComputeSystemControllerException.exceptions.cannotSetSanBootTargets(host.getHostName(), "Invalid compute elemnt association");
            }
        } else {
            _log.error("Host " + host.getHostName() + " does not have a compute element association.");
            throw ComputeSystemControllerException.exceptions.cannotSetSanBootTargets(host.getHostName(), "Host does not have a blade association");
        }
        WorkflowStepCompleter.stepSucceded(stepId);
    } catch (Exception e) {
        _log.error("unexpected exception: " + e.getMessage(), e);
        String hostString = hostId.toString();
        if (host != null) {
            hostString = host.getHostName();
        }
        ServiceCoded serviceCoded = ComputeSystemControllerException.exceptions.unableToSetSanBootTargets(hostString, e);
        WorkflowStepCompleter.stepFailed(stepId, serviceCoded);
    }
}
Also used : ServiceCoded(com.emc.storageos.svcs.errorhandling.model.ServiceCoded) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Host(com.emc.storageos.db.client.model.Host) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ComputeSystemControllerException(com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) WorkflowException(com.emc.storageos.workflow.WorkflowException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) RemoteException(java.rmi.RemoteException) CoordinatorException(com.emc.storageos.coordinator.exceptions.CoordinatorException) ClientControllerException(com.emc.storageos.exceptions.ClientControllerException)

Example 43 with ComputeElement

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

the class HostToComputeElementMatcher method removeDuplicateUuids.

private static void removeDuplicateUuids(URI computeSystem) {
    Map<String, URI> ceDuplicateMap = new HashMap<>();
    List<URI> ceDuplicateIds = new ArrayList<>();
    for (ComputeElement ce : computeElementMap.values()) {
        if (NullColumnValueGetter.isNotNullValue(ce.getUuid()) && isValidUuid(ce.getUuid())) {
            if (!ceDuplicateMap.containsKey(ce.getUuid())) {
                ceDuplicateMap.put(ce.getUuid(), ce.getId());
            } else {
                ComputeElement duplicateCe = computeElementMap.get(ceDuplicateMap.get(ce.getUuid()));
                String errMsg = "ComputeElements found having the same UUID " + info(ce) + " and " + info(duplicateCe);
                if (NullColumnValueGetter.isNullURI(computeSystem) || ce.getComputeSystem().equals(computeSystem) || duplicateCe.getComputeSystem().equals(computeSystem)) {
                    // fail discovery if no UCS or for affected UCS only
                    failureMessages.append(errMsg);
                } else {
                    // if neither in UCS, just log warning
                    _log.warn(errMsg);
                }
                ceDuplicateIds.add(ce.getId());
                ceDuplicateIds.add(ceDuplicateMap.get(ce.getUuid()));
            }
        }
    }
    computeElementMap.keySet().removeAll(ceDuplicateIds);
    Map<String, URI> spDuplicateMap = new HashMap<>();
    List<URI> spDuplicateIds = new ArrayList<>();
    for (UCSServiceProfile sp : serviceProfileMap.values()) {
        if (NullColumnValueGetter.isNotNullValue(sp.getUuid()) && isValidUuid(sp.getUuid())) {
            if (!spDuplicateMap.containsKey(sp.getUuid())) {
                spDuplicateMap.put(sp.getUuid(), sp.getId());
            } else {
                UCSServiceProfile duplicateSp = serviceProfileMap.get(spDuplicateMap.get(sp.getUuid()));
                String errMsg = "UCS Service Profiles found having the same UUID " + info(sp) + " and " + info(duplicateSp);
                if (NullColumnValueGetter.isNullURI(computeSystem) || sp.getComputeSystem().equals(computeSystem) || duplicateSp.getComputeSystem().equals(computeSystem)) {
                    // fail discovery if no UCS or for affected UCS only
                    failureMessages.append(errMsg);
                } else {
                    // if neither in UCS, just log warning
                    _log.warn(errMsg);
                }
                spDuplicateIds.add(sp.getId());
                spDuplicateIds.add(spDuplicateMap.get(sp.getUuid()));
            }
        }
    }
    serviceProfileMap.keySet().removeAll(spDuplicateIds);
}
Also used : UCSServiceProfile(com.emc.storageos.db.client.model.UCSServiceProfile) HashMap(java.util.HashMap) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 44 with ComputeElement

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

the class HostToComputeElementMatcher method getMatchingComputeElement.

private static ComputeElement getMatchingComputeElement(Host host, Map<String, ComputeElement> ceMap) {
    if (!isValidUuid(host.getUuid())) {
        return null;
    }
    // check for matching UUID
    String uuid = host.getUuid();
    ComputeElement ceWithSameUuid = null;
    if (ceMap.containsKey(uuid) && hostNameMatches(ceMap.get(uuid).getDn(), host) && !isUnregistered(ceMap.get(uuid))) {
        ceWithSameUuid = ceMap.get(uuid);
    }
    // check for matching UUID in mixed-endian format
    String uuidReversed = reverseUuidBytes(host.getUuid());
    ComputeElement ceWithReversedUuid = null;
    if (ceMap.containsKey(uuidReversed) && hostNameMatches(ceMap.get(uuidReversed).getDn(), host) && !isUnregistered(ceMap.get(uuidReversed))) {
        ceWithReversedUuid = ceMap.get(uuidReversed);
    }
    if (// found blade with UUID
    (ceWithSameUuid != null) && // found blade with reversed UUID
    (ceWithReversedUuid != null) && !uuid.equalsIgnoreCase(uuidReversed)) {
        // UUID is not same when reversed
        String errMsg = "Host match failed for ComputeElement because host " + info(host) + " matches multiple blades " + info(ceWithSameUuid) + " and " + info(ceWithReversedUuid);
        _log.error(errMsg);
        failureMessages.append(errMsg);
        return null;
    }
    return ceWithSameUuid != null ? ceWithSameUuid : ceWithReversedUuid;
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement)

Example 45 with ComputeElement

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

the class HostService method setCeUnavailable.

private void setCeUnavailable(List<String> ceUriStrs) {
    List<URI> ceUris = URIUtil.toURIList(ceUriStrs);
    if (ceUris == null) {
        return;
    }
    List<ComputeElement> ceList = _dbClient.queryObject(ComputeElement.class, ceUris);
    for (ComputeElement ce : ceList) {
        ce.setAvailable(false);
    }
    _dbClient.persistObject(ceList);
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) URI(java.net.URI)

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