use of com.emc.storageos.db.client.model.ComputeBootDef in project coprhd-controller by CoprHD.
the class ComputeSystemService method isUpdatingSPTValidForVarrays.
private boolean isUpdatingSPTValidForVarrays(StringSet varrayIds, UCSServiceProfileTemplate serviceProfileTemplate) {
boolean isValid = true;
_log.debug("Is uSPT:" + serviceProfileTemplate.getLabel() + " valid for varrays");
URIQueryResultList uriBootPolicies = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(serviceProfileTemplate.getComputeSystem()), uriBootPolicies);
List<ComputeBootPolicy> bootPolicyList = _dbClient.queryObject(ComputeBootPolicy.class, uriBootPolicies, true);
ComputeBootDef bootDef = null;
URIQueryResultList bootDefUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
if (!bootDefs.isEmpty()) {
_log.debug("has boot def");
bootDef = bootDefs.get(0);
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootDef.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
isValid = isSanBootValidForVarrays(varrayIds, computeSanBoot);
}
} else if (serviceProfileTemplate.getAssociatedBootPolicy() != null) {
_log.debug("has boot policy:" + serviceProfileTemplate.getAssociatedBootPolicy());
for (ComputeBootPolicy bootPolicy : bootPolicyList) {
if (bootPolicy.getDn().equals(serviceProfileTemplate.getAssociatedBootPolicy())) {
URIQueryResultList uriSanBoot = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootPolicyComputeSanBootConstraint(bootPolicy.getId()), uriSanBoot);
List<ComputeSanBoot> computeSanBoots = _dbClient.queryObject(ComputeSanBoot.class, uriSanBoot, true);
for (ComputeSanBoot computeSanBoot : computeSanBoots) {
isValid = isSanBootValidForVarrays(varrayIds, computeSanBoot);
}
}
}
} else {
_log.info("Updating SPT with no boot policy or boot def set is invalid");
}
_log.info("SPT:" + serviceProfileTemplate.getLabel() + "isValid:" + isValid);
return isValid;
}
use of com.emc.storageos.db.client.model.ComputeBootDef 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.ComputeBootDef in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileServiceProfileTemplatesBootDefinitions.
private void reconcileServiceProfileTemplatesBootDefinitions(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);
LsbootDef lsbootDef = (LsbootDef) serviceProfileTemplateDetails.get("associatedBootPolicy");
if (lsbootDef != null) {
_log.debug("Reconcile bootdef for SPT:" + serviceProfileTemplate.getLabel());
ComputeBootDef computeBootDef = reconcileComputeBootDef(lsbootDef, serviceProfileTemplate, cs);
} else {
// Remove any computeBootDefs that are no longer needed.
URIQueryResultList bootDefUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
deleteComputeBootDefs(bootDefs);
}
}
}
use of com.emc.storageos.db.client.model.ComputeBootDef 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));
}
use of com.emc.storageos.db.client.model.ComputeBootDef in project coprhd-controller by CoprHD.
the class ComputeSystemService method isUpdatingSPTValid.
public boolean isUpdatingSPTValid(UCSServiceProfileTemplate serviceProfileTemplate, DbClient dbClient) {
boolean valid = false;
// Check whether boot definition or boot policy is specified
// If so, check if enforce vnic names is specified and if so validate vnic names.
URIQueryResultList uriBootPolicies = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(serviceProfileTemplate.getComputeSystem()), uriBootPolicies);
List<ComputeBootPolicy> bootPolicyList = dbClient.queryObject(ComputeBootPolicy.class, uriBootPolicies, true);
ComputeBootDef bootDef = null;
URIQueryResultList bootDefUris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getServiceProfileTemplateComputeBootDefsConstraint(serviceProfileTemplate.getId()), bootDefUris);
List<ComputeBootDef> bootDefs = _dbClient.queryObject(ComputeBootDef.class, bootDefUris, true);
if (!bootDefs.isEmpty()) {
_log.debug("has boot def");
bootDef = bootDefs.get(0);
valid = isSPTBootDefinitionValid(serviceProfileTemplate, bootDef);
} else if (serviceProfileTemplate.getAssociatedBootPolicy() != null) {
_log.debug("has boot policy:" + serviceProfileTemplate.getAssociatedBootPolicy());
for (ComputeBootPolicy bootPolicy : bootPolicyList) {
if (bootPolicy.getDn().equals(serviceProfileTemplate.getAssociatedBootPolicy())) {
valid = isSPTBootPolicyValid(serviceProfileTemplate, bootPolicy);
}
}
} else {
_log.info("Updating SPT with no boot policy or boot def set is invalid");
}
return valid;
}
Aggregations