use of com.emc.storageos.db.client.model.ComputeSanBootImage in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteComputeSanBootImages.
private void deleteComputeSanBootImages(List<ComputeSanBootImage> sanBootImageList) {
List<ComputeSanBootImage> removeSanBootImages = new ArrayList<ComputeSanBootImage>();
for (ComputeSanBootImage image : sanBootImageList) {
URIQueryResultList sanImagePathUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(image.getId()), sanImagePathUris);
List<ComputeSanBootImagePath> sanBootPathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
if (sanBootPathList != null && !sanBootPathList.isEmpty()) {
deleteComputeSanBootImagePaths(sanBootPathList);
}
removeSanBootImages.add(image);
}
deleteDataObjects(new ArrayList<DataObject>(removeSanBootImages));
}
use of com.emc.storageos.db.client.model.ComputeSanBootImage 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.storageos.db.client.model.ComputeSanBootImage 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;
}
use of com.emc.storageos.db.client.model.ComputeSanBootImage in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteComputeSanBoot.
private void deleteComputeSanBoot(List<ComputeSanBoot> sanBootList) {
List<ComputeSanBoot> removeSanBoots = new ArrayList<ComputeSanBoot>();
for (ComputeSanBoot sanBoot : sanBootList) {
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()) {
deleteComputeSanBootImages(sanBootImageList);
}
removeSanBoots.add(sanBoot);
}
deleteDataObjects(new ArrayList<DataObject>(removeSanBoots));
}
Aggregations