use of com.emc.storageos.db.client.model.DataObject 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.DataObject in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileUplinkPorts.
private void reconcileUplinkPorts(ComputeSystem cs, Map<String, FcPIo> uplinkMap, Map<String, SwFcSanEp> fcInterfaceMap, Map<String, Set<String>> unpinnedVsans) {
_log.info("Reconciling FIC uplink ports");
Map<String, ComputeFabricUplinkPort> removePorts = new HashMap<>();
Map<String, ComputeFabricUplinkPort> updatePorts = new HashMap<>();
Map<String, ComputeFabricUplinkPort> addPorts = new HashMap<>();
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeFabricUplinkPortConstraint(cs.getId()), uris);
List<ComputeFabricUplinkPort> uplinkPorts = _dbClient.queryObject(ComputeFabricUplinkPort.class, uris, true);
for (ComputeFabricUplinkPort port : uplinkPorts) {
removePorts.put(port.getDn(), port);
}
// discovered data
for (FcPIo fcPIo : uplinkMap.values()) {
ComputeFabricUplinkPort cfup = removePorts.get(fcPIo.getDn());
if (cfup != null) {
updatePorts.put(fcPIo.getDn(), cfup);
removePorts.remove(fcPIo.getDn());
updateUplinkPorts(cfup, fcPIo, fcInterfaceMap, unpinnedVsans);
} else {
cfup = new ComputeFabricUplinkPort();
addPorts.put(fcPIo.getDn(), cfup);
createUplinkPorts(cs, cfup, fcPIo, fcInterfaceMap, unpinnedVsans);
}
}
createDataObjects(new ArrayList<DataObject>(addPorts.values()));
persistDataObjects(new ArrayList<DataObject>(updatePorts.values()));
deleteDataObjects(new ArrayList<DataObject>(removePorts.values()));
}
use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteComputeLanBoot.
private void deleteComputeLanBoot(List<ComputeLanBoot> lanBootList) {
List<ComputeLanBoot> removeLanBoots = new ArrayList<ComputeLanBoot>();
for (ComputeLanBoot lanBoot : lanBootList) {
URIQueryResultList lanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(lanBoot.getId()), lanImageUris);
List<ComputeLanBootImagePath> lanBootPathList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
if (lanBootPathList != null && !lanBootPathList.isEmpty()) {
deleteComputeLanBootImagePaths(lanBootPathList);
}
removeLanBoots.add(lanBoot);
}
deleteDataObjects(new ArrayList<DataObject>(removeLanBoots));
}
use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileVhbaTemplates.
private void reconcileVhbaTemplates(ComputeSystem cs, List<VnicSanConnTempl> vhbaTemplates) {
_log.info("Reconciling VhbaTemplates");
Map<String, UCSVhbaTemplate> removeTemplates = new HashMap<>();
Map<String, UCSVhbaTemplate> updateTemplates = new HashMap<>();
Map<String, UCSVhbaTemplate> addTemplates = new HashMap<>();
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemVhbaTemplateConstraint(cs.getId()), uris);
List<UCSVhbaTemplate> templates = _dbClient.queryObject(UCSVhbaTemplate.class, uris, true);
for (UCSVhbaTemplate vhbaTemplate : templates) {
removeTemplates.put(vhbaTemplate.getDn(), vhbaTemplate);
}
// discovered data
for (VnicSanConnTempl vhbaTemplate : vhbaTemplates) {
UCSVhbaTemplate template = removeTemplates.get(vhbaTemplate.getDn());
if (template != null) {
updateTemplates.put(vhbaTemplate.getDn(), template);
removeTemplates.remove(template.getDn());
updateUCSVhbaTemplate(template, vhbaTemplate);
} else {
template = new UCSVhbaTemplate();
addTemplates.put(vhbaTemplate.getDn(), template);
createUCSVhbaTemplate(cs, template, vhbaTemplate);
}
}
createDataObjects(new ArrayList<DataObject>(addTemplates.values()));
persistDataObjects(new ArrayList<DataObject>(updateTemplates.values()));
for (String key : removeTemplates.keySet()) {
_log.info("Marked for deletion UCSVhbaTemplate: " + key);
}
deleteDataObjects(new ArrayList<DataObject>(removeTemplates.values()));
}
use of com.emc.storageos.db.client.model.DataObject 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()));
}
}
Aggregations