use of com.emc.cloud.platform.ucs.out.model.LsbootPolicy 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()));
}
Aggregations