use of com.emc.storageos.db.client.model.ComputeVnic 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.ComputeVnic 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.ComputeVnic in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesVnics.
private void reconcileServiceProfileTemplatesVnics(ComputeSystem cs, List<LsServer> lsServers) {
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemServiceProfileTemplateConstraint(cs.getId()), uris);
Map<String, LsServer> lsServerMap = new HashMap<>();
for (LsServer lsServer : lsServers) {
lsServerMap.put(lsServer.getDn(), lsServer);
}
List<UCSServiceProfileTemplate> serviceTemplates = _dbClient.queryObject(UCSServiceProfileTemplate.class, uris, true);
for (UCSServiceProfileTemplate serviceProfileTemplate : serviceTemplates) {
LsServer lsServer = lsServerMap.get(serviceProfileTemplate.getDn());
if (lsServer == null) {
continue;
}
Map<String, Object> serviceProfileTemplateDetails = getServiceProfileTemplateDetails(lsServer);
Map<String, ComputeVnic> removeVnics = new HashMap<>();
Map<String, ComputeVnic> addVnics = new HashMap<>();
Map<String, ComputeVnic> updateVnics = new HashMap<>();
URIQueryResultList uriVnics = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeVnicsConstraint(serviceProfileTemplate.getId()), uriVnics);
List<ComputeVnic> vnics = _dbClient.queryObject(ComputeVnic.class, uriVnics, true);
for (ComputeVnic vnic : vnics) {
removeVnics.put(vnic.getName(), vnic);
}
for (VnicEther vnic : (List<VnicEther>) serviceProfileTemplateDetails.get("vnics")) {
ComputeVnic nic = removeVnics.get(vnic.getName());
if (nic != null) {
updateVnics.put(vnic.getName(), nic);
removeVnics.remove(nic.getLabel());
updateComputeVnics(nic, vnic);
} else {
nic = new ComputeVnic();
addVnics.put(vnic.getName(), nic);
createComputeVnics(serviceProfileTemplate, nic, vnic);
}
}
createDataObjects(new ArrayList<DataObject>(addVnics.values()));
persistDataObjects(new ArrayList<DataObject>(updateVnics.values()));
for (String name : removeVnics.keySet()) {
_log.info("Marked for deletion ComputeElementHBA: " + name);
}
deleteDataObjects(new ArrayList<DataObject>(removeVnics.values()));
}
}
Aggregations