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