use of com.emc.cloud.platform.ucs.out.model.LsbootSanImage in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeSanBoot.
private ComputeSanBoot reconcileComputeSanBoot(LsbootStorage lsbootStorage, ComputeSanBoot sanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
if (sanBoot != null) {
sanBoot.setLabel(lsbootStorage.getDn());
if (lsbootStorage.getOrder() != null) {
sanBoot.setOrder(Integer.valueOf(lsbootStorage.getOrder()));
}
_dbClient.persistObject(sanBoot);
}
if (sanBoot == null) {
sanBoot = new ComputeSanBoot();
URI uriSanBoot = URIUtil.createId(ComputeSanBoot.class);
sanBoot.setId(uriSanBoot);
if (bootDef != null) {
sanBoot.setComputeBootDef(bootDef.getId());
}
if (bootPolicy != null) {
sanBoot.setComputeBootPolicy(bootPolicy.getId());
}
sanBoot.setLabel(lsbootStorage.getDn());
if (lsbootStorage.getOrder() != null) {
sanBoot.setOrder(Integer.valueOf(lsbootStorage.getOrder()));
}
sanBoot.setIsFirstBootDevice(true);
_dbClient.createObject(sanBoot);
}
Map<String, ComputeSanBootImage> computeSanBootImageMap = new HashMap<String, ComputeSanBootImage>();
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(sanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
if (sanBootImageList != null && !sanBootImageList.isEmpty()) {
for (ComputeSanBootImage image : sanBootImageList) {
computeSanBootImageMap.put(image.getType(), image);
}
}
if (lsbootStorage.getContent() != null && !lsbootStorage.getContent().isEmpty()) {
for (Serializable e : lsbootStorage.getContent()) {
if (e instanceof JAXBElement<?>) {
if (((JAXBElement) e).getValue() instanceof LsbootSanImage) {
LsbootSanImage lsSanImage = (LsbootSanImage) ((JAXBElement) e).getValue();
ComputeSanBootImage sanBootImage = computeSanBootImageMap.get(lsSanImage.getType());
computeSanBootImageMap.remove(lsSanImage.getType());
sanBootImage = reconcileComputeSanBootImage(lsSanImage, sanBootImage, sanBoot);
}
}
}
}
deleteComputeSanBootImages(new ArrayList<ComputeSanBootImage>(computeSanBootImageMap.values()));
return sanBoot;
}
use of com.emc.cloud.platform.ucs.out.model.LsbootSanImage in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeSanBoot.
private ComputeSanBoot reconcileComputeSanBoot(LsbootSan lsbootSan, ComputeSanBoot sanBoot, ComputeBootDef bootDef, ComputeBootPolicy bootPolicy) {
if (sanBoot != null) {
sanBoot.setLabel(lsbootSan.getDn());
if (lsbootSan.getOrder() != null) {
sanBoot.setOrder(Integer.valueOf(lsbootSan.getOrder()));
}
_dbClient.persistObject(sanBoot);
}
if (sanBoot == null) {
sanBoot = new ComputeSanBoot();
URI uriSanBoot = URIUtil.createId(ComputeSanBoot.class);
sanBoot.setId(uriSanBoot);
sanBoot.setLabel(lsbootSan.getDn());
if (bootDef != null) {
sanBoot.setComputeBootDef(bootDef.getId());
}
if (bootPolicy != null) {
sanBoot.setComputeBootPolicy(bootPolicy.getId());
}
if (lsbootSan.getOrder() != null) {
sanBoot.setOrder(Integer.valueOf(lsbootSan.getOrder()));
}
sanBoot.setIsFirstBootDevice(true);
_dbClient.createObject(sanBoot);
}
Map<String, ComputeSanBootImage> computeSanBootImageMap = new HashMap<String, ComputeSanBootImage>();
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(sanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
if (sanBootImageList != null && !sanBootImageList.isEmpty()) {
for (ComputeSanBootImage image : sanBootImageList) {
computeSanBootImageMap.put(image.getType(), image);
}
}
if (lsbootSan.getContent() != null && !lsbootSan.getContent().isEmpty()) {
for (Serializable e : lsbootSan.getContent()) {
if (e instanceof JAXBElement<?>) {
if (((JAXBElement) e).getValue() instanceof LsbootSanImage) {
LsbootSanImage lsSanImage = (LsbootSanImage) ((JAXBElement) e).getValue();
ComputeSanBootImage sanBootImage = computeSanBootImageMap.get(lsSanImage.getType());
computeSanBootImageMap.remove(lsSanImage.getType());
sanBootImage = reconcileComputeSanBootImage(lsSanImage, sanBootImage, sanBoot);
}
}
}
}
deleteComputeSanBootImages(new ArrayList<ComputeSanBootImage>(computeSanBootImageMap.values()));
return sanBoot;
}
Aggregations