use of com.emc.cloud.platform.ucs.out.model.LsbootSanImagePath 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