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;
}
}
}
}
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);
}
}
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);
}
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;
}
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);
}
Aggregations