use of com.emc.cloud.platform.ucs.out.model.LsbootLanImagePath in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeLanBoot.
private ComputeLanBoot reconcileComputeLanBoot(LsbootLan lsbootLan, ComputeLanBoot lanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
if (lanBoot != null) {
if (lsbootLan.getOrder() != null) {
lanBoot.setOrder(Integer.valueOf(lsbootLan.getOrder()));
}
lanBoot.setProt(lsbootLan.getProt());
lanBoot.setLabel(lsbootLan.getDn());
_dbClient.persistObject(lanBoot);
}
if (lanBoot == null) {
lanBoot = new ComputeLanBoot();
URI uriLanBoot = URIUtil.createId(ComputeLanBoot.class);
lanBoot.setId(uriLanBoot);
if (bootDef != null) {
lanBoot.setComputeBootDef(bootDef.getId());
}
if (bootPolicy != null) {
lanBoot.setComputeBootPolicy(bootPolicy.getId());
}
if (lsbootLan.getOrder() != null) {
lanBoot.setOrder(Integer.valueOf(lsbootLan.getOrder()));
}
lanBoot.setProt(lsbootLan.getProt());
lanBoot.setLabel(lsbootLan.getDn());
_dbClient.createObject(lanBoot);
}
Map<String, ComputeLanBootImagePath> lanBootImageMap = new HashMap<String, ComputeLanBootImagePath>();
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()) {
for (ComputeLanBootImagePath lanImage : lanBootPathList) {
lanBootImageMap.put(lanImage.getType(), lanImage);
}
}
if (lsbootLan.getContent() != null && !lsbootLan.getContent().isEmpty()) {
for (Serializable e : lsbootLan.getContent()) {
if (e instanceof JAXBElement<?>) {
if (((JAXBElement) e).getValue() instanceof LsbootLanImagePath) {
LsbootLanImagePath lanImagePath = (LsbootLanImagePath) ((JAXBElement) e).getValue();
ComputeLanBootImagePath lanBootImagePath = lanBootImageMap.get(lanImagePath.getType());
lanBootImageMap.remove(lanImagePath.getType());
lanBootImagePath = reconcileComputeLanBootImagePath(lanImagePath, lanBootImagePath, lanBoot);
}
}
}
}
deleteComputeLanBootImagePaths(new ArrayList<ComputeLanBootImagePath>(lanBootImageMap.values()));
return lanBoot;
}
Aggregations