use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method updateComputeBootPolicy.
private void updateComputeBootPolicy(ComputeBootPolicy bootPolicy, LsbootPolicy lsBootPolicy) {
bootPolicy.setDn(lsBootPolicy.getDn());
bootPolicy.setName(lsBootPolicy.getName());
if (lsBootPolicy.getEnforceVnicName().equals("yes")) {
bootPolicy.setEnforceVnicVhbaNames(true);
} else {
bootPolicy.setEnforceVnicVhbaNames(false);
}
_dbClient.persistObject(bootPolicy);
ComputeSanBoot sanBoot = null;
ComputeLanBoot lanBoot = null;
URIQueryResultList sanBootUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.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.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.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 (lsBootPolicy.getContent() != null && !lsBootPolicy.getContent().isEmpty()) {
for (Serializable element : lsBootPolicy.getContent()) {
if (element instanceof JAXBElement<?>) {
if (((JAXBElement) element).getValue() instanceof LsbootLan) {
LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, null, bootPolicy);
hasLanBoot = true;
// This looks crazy, but there were some profiles on the UCS, where bootOrder did not start at 1; this should handle
// that case too
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, null, bootPolicy);
hasSanBoot = true;
sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
} else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, null, bootPolicy);
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);
}
}
use of com.emc.storageos.db.client.model.ComputeLanBoot 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;
}
use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteComputeBootDefs.
private void deleteComputeBootDefs(List<ComputeBootDef> bootDefs) {
for (ComputeBootDef bootDef : bootDefs) {
// Retrieve associated ComputeSanBoot and delete it
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()) {
deleteComputeSanBoot(sanBootList);
}
// Retrieve associated ComputeLanBoot and delete it
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()) {
deleteComputeLanBoot(lanBootList);
}
}
deleteDataObjects(new ArrayList<DataObject>(bootDefs));
}
Aggregations