use of com.emc.storageos.db.client.constraint.URIQueryResultList 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.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeBootDef.
private ComputeBootDef reconcileComputeBootDef(LsbootDef lsBootDef, UCSServiceProfileTemplate spt, ComputeSystem cs) {
ComputeBootDef bootDef = null;
URIQueryResultList bootDefUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(spt.getId()), bootDefUris);
List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
if (!bootDefs.isEmpty()) {
bootDef = bootDefs.get(0);
bootDef.setComputeSystem(cs.getId());
bootDef.setServiceProfileTemplate(spt.getId());
// bootDef.setDn(lsBootDef.getDn());
if (lsBootDef.getEnforceVnicName().equals("yes")) {
bootDef.setEnforceVnicVhbaNames(true);
} else {
bootDef.setEnforceVnicVhbaNames(false);
}
_dbClient.persistObject(bootDef);
}
if (bootDef == null) {
bootDef = new ComputeBootDef();
URI uri = URIUtil.createId(ComputeBootDef.class);
bootDef.setId(uri);
bootDef.setComputeSystem(cs.getId());
bootDef.setServiceProfileTemplate(spt.getId());
// bootDef.setDn(lsBootDef.getDn());
if (lsBootDef.getEnforceVnicName().equals("yes")) {
bootDef.setEnforceVnicVhbaNames(true);
} else {
bootDef.setEnforceVnicVhbaNames(false);
}
_dbClient.createObject(bootDef);
}
ComputeSanBoot sanBoot = null;
ComputeLanBoot lanBoot = null;
URIQueryResultList sanBootUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), sanBootUris);
List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
if (sanBootList != null && !sanBootList.isEmpty()) {
sanBoot = sanBootList.get(0);
}
URIQueryResultList lanBootUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootDef.getId()), lanBootUris);
List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
if (lanBootList != null && !lanBootList.isEmpty()) {
lanBoot = lanBootList.get(0);
}
boolean hasLanBoot = false;
boolean hasSanBoot = false;
Integer nonSanBootOrder = null;
Integer sanBootOrder = null;
if (lsBootDef.getContent() != null && !lsBootDef.getContent().isEmpty()) {
for (Serializable element : lsBootDef.getContent()) {
if (element instanceof JAXBElement<?>) {
if (((JAXBElement) element).getValue() instanceof LsbootLan) {
LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, bootDef, null);
hasLanBoot = true;
Integer order = Integer.parseInt(lsbootLan.getOrder());
if (nonSanBootOrder == null) {
nonSanBootOrder = order;
} else if (order < nonSanBootOrder) {
nonSanBootOrder = order;
}
} else if (((JAXBElement) element).getValue() instanceof LsbootStorage) {
LsbootStorage lsbootStorage = (LsbootStorage) ((JAXBElement) element).getValue();
sanBoot = reconcileComputeSanBoot(lsbootStorage, sanBoot, bootDef, null);
hasSanBoot = true;
sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
} else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, bootDef, null);
hasSanBoot = true;
sanBootOrder = Integer.parseInt(lsbootSan.getOrder());
} else if (((JAXBElement) element).getValue() instanceof LsbootVirtualMedia) {
LsbootVirtualMedia lsbootVirtualMedia = (LsbootVirtualMedia) ((JAXBElement) element).getValue();
Integer order = Integer.parseInt(lsbootVirtualMedia.getOrder());
if (nonSanBootOrder == null) {
nonSanBootOrder = order;
} else if (order < nonSanBootOrder) {
nonSanBootOrder = order;
}
} else if (((JAXBElement) element).getValue() instanceof LsbootIScsi) {
LsbootIScsi lsbootIScsi = (LsbootIScsi) ((JAXBElement) element).getValue();
Integer order = Integer.parseInt(lsbootIScsi.getOrder());
if (nonSanBootOrder == null) {
nonSanBootOrder = order;
} else if (order < nonSanBootOrder) {
nonSanBootOrder = order;
}
}
}
}
}
if (hasSanBoot && nonSanBootOrder != null) {
sanBoot = (ComputeSanBoot) _dbClient.queryObject(sanBoot.getId());
if (nonSanBootOrder < sanBootOrder) {
sanBoot.setIsFirstBootDevice(false);
} else {
sanBoot.setIsFirstBootDevice(true);
}
_dbClient.persistObject(sanBoot);
}
if (!hasSanBoot && sanBoot != null) {
List<ComputeSanBoot> sanBoots = new ArrayList<ComputeSanBoot>();
sanBoots.add(sanBoot);
deleteComputeSanBoot(sanBoots);
}
if (!hasLanBoot && lanBoot != null) {
List<ComputeLanBoot> lanBoots = new ArrayList<ComputeLanBoot>();
lanBoots.add(lanBoot);
deleteComputeLanBoot(lanBoots);
}
return bootDef;
}
use of com.emc.storageos.db.client.constraint.URIQueryResultList 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.constraint.URIQueryResultList 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.constraint.URIQueryResultList in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeSanBootImage.
private ComputeSanBootImage reconcileComputeSanBootImage(LsbootSanImage sanImage, ComputeSanBootImage computeSanImage, ComputeSanBoot sanBoot) {
if (computeSanImage != null) {
computeSanImage.setDn(sanImage.getDn());
computeSanImage.setVnicName(sanImage.getVnicName());
_dbClient.persistObject(computeSanImage);
}
if (computeSanImage == null) {
computeSanImage = new ComputeSanBootImage();
URI uriSanBootImage = URIUtil.createId(ComputeSanBootImage.class);
computeSanImage.setId(uriSanBootImage);
computeSanImage.setType(sanImage.getType());
computeSanImage.setVnicName(sanImage.getVnicName());
computeSanImage.setDn(sanImage.getDn());
computeSanImage.setComputeSanBoot(sanBoot.getId());
_dbClient.createObject(computeSanImage);
}
Map<String, ComputeSanBootImagePath> computeSanBootImagePathMap = new HashMap<String, ComputeSanBootImagePath>();
URIQueryResultList sanImagePathUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(computeSanImage.getId()), sanImagePathUris);
List<ComputeSanBootImagePath> sanBootPathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
if (sanBootPathList != null && !sanBootPathList.isEmpty()) {
for (ComputeSanBootImagePath sanBootImagePath : sanBootPathList) {
computeSanBootImagePathMap.put(sanBootImagePath.getType(), sanBootImagePath);
}
}
if (sanImage.getContent() != null && !sanImage.getContent().isEmpty()) {
for (Serializable e2 : sanImage.getContent()) {
if (e2 instanceof JAXBElement<?>) {
if (((JAXBElement) e2).getValue() instanceof LsbootSanImagePath) {
LsbootSanImagePath lsSanImagePath = (LsbootSanImagePath) ((JAXBElement) e2).getValue();
ComputeSanBootImagePath sanBootImagePath = computeSanBootImagePathMap.get(lsSanImagePath.getType());
computeSanBootImagePathMap.remove(lsSanImagePath.getType());
sanBootImagePath = reconcileComputeSanBootImagePath(lsSanImagePath, sanBootImagePath, computeSanImage);
}
}
}
}
deleteComputeSanBootImagePaths(new ArrayList<ComputeSanBootImagePath>(computeSanBootImagePathMap.values()));
return computeSanImage;
}
Aggregations