use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class ComputeSystemService method isSPTBootDefinitionValid.
private boolean isSPTBootDefinitionValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootDef bootDef) {
boolean valid = true;
_log.debug("validating SPT Boot Def " + bootDef.getId().toString());
if (bootDef.getEnforceVnicVhbaNames() == true) {
_log.debug("enforce vhba vnic names -- true");
URIQueryResultList uriVhbas = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
if (computeSanBoots == null || computeSanBoots.isEmpty()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
valid = false;
}
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
if (!computeSanBoot.getIsFirstBootDevice()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
valid = false;
}
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
for (ComputeSanBootImage image : sanBootImageList) {
boolean matched = false;
for (ComputeElementHBA hba : vhbas) {
if (hba.getLabel().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
URIQueryResultList uriVnics = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
URIQueryResultList uriLanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootDef.getId()), uriLanBoot);
List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
for (ComputeLanBoot computeLanBoot : computeLanBoots) {
URIQueryResultList lanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
for (ComputeLanBootImagePath image : lanBootImageList) {
boolean matched = false;
for (ComputeVnic nic : vnics) {
if (nic.getName().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
}
return valid;
}
use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class ComputeSystemService method isSPTBootPolicyValid.
private boolean isSPTBootPolicyValid(UCSServiceProfileTemplate serviceProfileTemplate, ComputeBootPolicy bootPolicy) {
boolean valid = true;
_log.debug("validating SPT Boot Policy" + bootPolicy.getId().toString());
if (bootPolicy.getEnforceVnicVhbaNames() == true) {
_log.debug("enforce vhba vnic names -- true");
URIQueryResultList uriVhbas = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeElemetHBAsConstraint(serviceProfileTemplate.getId()), uriVhbas);
List<ComputeElementHBA> vhbas = _dbClient.queryObject(ComputeElementHBA.class, uriVhbas, true);
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
if (computeSanBoots == null || computeSanBoots.isEmpty()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " no san boot policy specified");
valid = false;
}
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
if (!computeSanBoot.getIsFirstBootDevice()) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " san is not the first boot device");
valid = false;
}
URIQueryResultList sanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(computeSanBoot.getId()), sanImageUris);
List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
for (ComputeSanBootImage image : sanBootImageList) {
boolean matched = false;
for (ComputeElementHBA hba : vhbas) {
if (hba.getLabel().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but hba names in san boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
URIQueryResultList uriVnics = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
URIQueryResultList uriLanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeLanBootConstraint(bootPolicy.getId()), uriLanBoot);
List<ComputeLanBoot> computeLanBoots = _dbClient.queryObject(ComputeLanBoot.class, uriLanBoot, true);
for (ComputeLanBoot computeLanBoot : computeLanBoots) {
URIQueryResultList lanImageUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(computeLanBoot.getId()), lanImageUris);
List<ComputeLanBootImagePath> lanBootImageList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
for (ComputeLanBootImagePath image : lanBootImageList) {
boolean matched = false;
for (ComputeVnic nic : vnics) {
if (nic.getName().equals(image.getVnicName())) {
matched = true;
}
}
if (!matched) {
_log.error("SPT: " + serviceProfileTemplate.getLabel() + " enforces vnic and vhba names,but vnic names in lan boot policy do not match the names of the hbas on the template");
valid = false;
}
}
}
}
return valid;
}
use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileComputeBootDef.
private ComputeBootDef reconcileComputeBootDef(LsbootDef lsBootDef, UCSServiceProfileTemplate spt, ComputeSystem cs) {
ComputeBootDef bootDef = null;
URIQueryResultList bootDefUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(spt.getId()), bootDefUris);
List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
if (!bootDefs.isEmpty()) {
bootDef = bootDefs.get(0);
bootDef.setComputeSystem(cs.getId());
bootDef.setServiceProfileTemplate(spt.getId());
// bootDef.setDn(lsBootDef.getDn());
if (lsBootDef.getEnforceVnicName().equals("yes")) {
bootDef.setEnforceVnicVhbaNames(true);
} else {
bootDef.setEnforceVnicVhbaNames(false);
}
_dbClient.persistObject(bootDef);
}
if (bootDef == null) {
bootDef = new ComputeBootDef();
URI uri = URIUtil.createId(ComputeBootDef.class);
bootDef.setId(uri);
bootDef.setComputeSystem(cs.getId());
bootDef.setServiceProfileTemplate(spt.getId());
// bootDef.setDn(lsBootDef.getDn());
if (lsBootDef.getEnforceVnicName().equals("yes")) {
bootDef.setEnforceVnicVhbaNames(true);
} else {
bootDef.setEnforceVnicVhbaNames(false);
}
_dbClient.createObject(bootDef);
}
ComputeSanBoot sanBoot = null;
ComputeLanBoot lanBoot = null;
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()) {
sanBoot = sanBootList.get(0);
}
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()) {
lanBoot = lanBootList.get(0);
}
boolean hasLanBoot = false;
boolean hasSanBoot = false;
Integer nonSanBootOrder = null;
Integer sanBootOrder = null;
if (lsBootDef.getContent() != null && !lsBootDef.getContent().isEmpty()) {
for (Serializable element : lsBootDef.getContent()) {
if (element instanceof JAXBElement<?>) {
if (((JAXBElement) element).getValue() instanceof LsbootLan) {
LsbootLan lsbootLan = (LsbootLan) ((JAXBElement) element).getValue();
lanBoot = reconcileComputeLanBoot(lsbootLan, lanBoot, bootDef, null);
hasLanBoot = true;
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, bootDef, null);
hasSanBoot = true;
sanBootOrder = Integer.parseInt(lsbootStorage.getOrder());
} else if (((JAXBElement) element).getValue() instanceof LsbootSan) {
LsbootSan lsbootSan = (LsbootSan) ((JAXBElement) element).getValue();
sanBoot = reconcileComputeSanBoot(lsbootSan, sanBoot, bootDef, null);
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);
}
return bootDef;
}
use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteComputeLanBoot.
private void deleteComputeLanBoot(List<ComputeLanBoot> lanBootList) {
List<ComputeLanBoot> removeLanBoots = new ArrayList<ComputeLanBoot>();
for (ComputeLanBoot lanBoot : lanBootList) {
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()) {
deleteComputeLanBootImagePaths(lanBootPathList);
}
removeLanBoots.add(lanBoot);
}
deleteDataObjects(new ArrayList<DataObject>(removeLanBoots));
}
use of com.emc.storageos.db.client.model.ComputeLanBoot in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method deleteBootPolicies.
private void deleteBootPolicies(List<ComputeBootPolicy> bootPolicies) {
List<ComputeSanBootImagePath> removeSanBootImagePaths = new ArrayList<ComputeSanBootImagePath>();
List<ComputeSanBootImage> removeSanBootImages = new ArrayList<ComputeSanBootImage>();
List<ComputeSanBoot> removeSanBoots = new ArrayList<ComputeSanBoot>();
List<ComputeLanBootImagePath> removeLanBootImagePaths = new ArrayList<ComputeLanBootImagePath>();
List<ComputeLanBoot> removeLanBoots = new ArrayList<ComputeLanBoot>();
for (ComputeBootPolicy bootPolicy : bootPolicies) {
// Retrieve associated ComputeSanBoot and delete it
URIQueryResultList sanBootUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootPolicy.getId()), sanBootUris);
List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
if (sanBootList != null && !sanBootList.isEmpty()) {
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()) {
for (ComputeSanBootImage computeSanImage : sanBootImageList) {
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()) {
removeSanBootImagePaths.addAll(sanBootPathList);
}
removeSanBootImages.add(computeSanImage);
}
}
removeSanBoots.add(sanBoot);
}
}
// Retrieve associated ComputeLanBoot and delete it
URIQueryResultList lanBootUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootPolicy.getId()), lanBootUris);
List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
if (lanBootList != null && !lanBootList.isEmpty()) {
ComputeLanBoot lanBoot = lanBootList.get(0);
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()) {
removeLanBootImagePaths.addAll(lanBootPathList);
}
removeLanBoots.add(lanBoot);
}
}
deleteDataObjects(new ArrayList<DataObject>(removeLanBootImagePaths));
deleteDataObjects(new ArrayList<DataObject>(removeLanBoots));
deleteDataObjects(new ArrayList<DataObject>(removeSanBootImagePaths));
deleteDataObjects(new ArrayList<DataObject>(removeSanBootImages));
deleteDataObjects(new ArrayList<DataObject>(removeSanBoots));
deleteDataObjects(new ArrayList<DataObject>(bootPolicies));
}
Aggregations