use of com.emc.cloud.platform.ucs.out.model.VnicFc 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.cloud.platform.ucs.out.model.VnicFc 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()));
}
}
use of com.emc.cloud.platform.ucs.out.model.VnicFc in project coprhd-controller by CoprHD.
the class UcsComputeDevice method setComputeElementAttrFromBoundLsServer.
private void setComputeElementAttrFromBoundLsServer(DbClient dbClient, ComputeElement computeElement, LsServer lsServer, Host host, String systemType, boolean markUnregistered) {
List<ComputeElementHBA> computeElementHBAs = new ArrayList<ComputeElementHBA>();
computeElement.setUuid(lsServer.getUuid());
computeElement.setDn(lsServer.getDn());
String sptName = lsServer.getSrcTemplName();
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(computeElement.getComputeSystem()), uris);
List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
for (UCSServiceProfileTemplate serviceTemplate : serviceTemplates) {
if (serviceTemplate.getLabel().equals(sptName)) {
computeElement.setSptId(serviceTemplate.getId().toString());
}
}
if (markUnregistered) {
computeElement.setRegistrationStatus(DiscoveredDataObject.RegistrationStatus.UNREGISTERED.name());
}
computeElement.setAvailable(false);
if (lsServer.getContent() != null && !lsServer.getContent().isEmpty()) {
for (Serializable contentElement : lsServer.getContent()) {
if (contentElement instanceof JAXBElement<?>) {
if (((JAXBElement) contentElement).getValue() instanceof VnicFc) {
VnicFc vnicFc = (VnicFc) ((JAXBElement) contentElement).getValue();
ComputeElementHBA computeElementHBA = new ComputeElementHBA();
computeElementHBA.setComputeElement(computeElement.getId());
computeElementHBA.setHost(host.getId());
computeElementHBA.setCreationTime(Calendar.getInstance());
computeElementHBA.setDn(vnicFc.getDn());
computeElementHBA.setId(URIUtil.createId(ComputeElementHBA.class));
computeElementHBA.setInactive(false);
computeElementHBA.setLabel(vnicFc.getName());
computeElementHBA.setProtocol(vnicFc.getType());
computeElementHBA.setNativeGuid(NativeGUIDGenerator.generateNativeGuid(computeElementHBA, systemType));
computeElementHBA.setNode(vnicFc.getNodeAddr());
computeElementHBA.setPort(vnicFc.getAddr());
computeElementHBA.setVsanId(getVsanIdFromvnicFC(vnicFc));
computeElementHBAs.add(computeElementHBA);
}
}
}
}
if (!computeElementHBAs.isEmpty()) {
dbClient.createObject(computeElementHBAs);
}
/**
* For the case where the compute element exists, but we are updating
* it:
*/
if (dbClient.queryObject(ComputeElement.class, computeElement.getId()) != null) {
dbClient.updateObject(computeElement);
}
}
use of com.emc.cloud.platform.ucs.out.model.VnicFc in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method getServiceProfileTemplateDetails.
private Map<String, Object> getServiceProfileTemplateDetails(LsServer spt) {
Map<String, Object> serviceProfileTemplateDetails = new HashMap<>();
int vhbaCount = 0;
int vnicCount = 0;
List<VnicEther> vnics = new ArrayList<>();
List<VnicFc> vhbas = new ArrayList<>();
if (spt.getContent() != null && !spt.getContent().isEmpty()) {
for (Serializable element : spt.getContent()) {
if (element instanceof JAXBElement<?>) {
if (((JAXBElement) element).getValue() instanceof LsRequirement) {
LsRequirement lsRequirement = (LsRequirement) ((JAXBElement) element).getValue();
serviceProfileTemplateDetails.put("associatedServerPool", lsRequirement.getName());
} else if (((JAXBElement) element).getValue() instanceof VnicEther) {
vnics.add(((VnicEther) ((JAXBElement) element).getValue()));
vnicCount++;
} else if (((JAXBElement) element).getValue() instanceof VnicFc) {
vhbas.add(((VnicFc) ((JAXBElement) element).getValue()));
vhbaCount++;
} else if (((JAXBElement) element).getValue() instanceof LsbootDef) {
LsbootDef lsbootDef = (LsbootDef) ((JAXBElement) element).getValue();
serviceProfileTemplateDetails.put("associatedBootPolicy", lsbootDef);
}
}
}
serviceProfileTemplateDetails.put("vhbaCount", vhbaCount);
serviceProfileTemplateDetails.put("vnicCount", vnicCount);
serviceProfileTemplateDetails.put("vhbas", vhbas);
serviceProfileTemplateDetails.put("vnics", vnics);
}
return serviceProfileTemplateDetails;
}
Aggregations