use of com.emc.storageos.db.client.model.ComputeBootPolicy 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.ComputeBootPolicy 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));
}
use of com.emc.storageos.db.client.model.ComputeBootPolicy in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileBootPolicies.
private void reconcileBootPolicies(ComputeSystem cs, List<LsbootPolicy> lsBootPolicies) {
_log.info("Reconciling BootPolicies");
Map<String, ComputeBootPolicy> removeBootPolicies = new HashMap<>();
Map<String, ComputeBootPolicy> updateBootPolicies = new HashMap<>();
Map<String, ComputeBootPolicy> addBootPolicies = new HashMap<>();
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemBootPolicyConstraint(cs.getId()), uris);
List<ComputeBootPolicy> bootPolicies = _dbClient.queryObject(ComputeBootPolicy.class, uris, true);
for (ComputeBootPolicy bootPolicy : bootPolicies) {
removeBootPolicies.put(bootPolicy.getDn(), bootPolicy);
}
// discovered data
for (LsbootPolicy lsbootPolicy : lsBootPolicies) {
ComputeBootPolicy bootPolicy = removeBootPolicies.get(lsbootPolicy.getDn());
if (bootPolicy != null) {
updateBootPolicies.put(lsbootPolicy.getDn(), bootPolicy);
removeBootPolicies.remove(bootPolicy.getDn());
updateComputeBootPolicy(bootPolicy, lsbootPolicy);
} else {
bootPolicy = new ComputeBootPolicy();
addBootPolicies.put(lsbootPolicy.getDn(), bootPolicy);
createComputeBootPolicy(cs, bootPolicy, lsbootPolicy);
}
}
createDataObjects(new ArrayList<DataObject>(addBootPolicies.values()));
persistDataObjects(new ArrayList<DataObject>(updateBootPolicies.values()));
for (String key : removeBootPolicies.keySet()) {
_log.info("Marked for deletion BootPolicy: " + key);
}
deleteBootPolicies(new ArrayList<ComputeBootPolicy>(removeBootPolicies.values()));
}
use of com.emc.storageos.db.client.model.ComputeBootPolicy 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