use of com.emc.storageos.db.client.model.UCSVhbaTemplate in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method reconcileVhbaTemplates.
private void reconcileVhbaTemplates(ComputeSystem cs, List<VnicSanConnTempl> vhbaTemplates) {
_log.info("Reconciling VhbaTemplates");
Map<String, UCSVhbaTemplate> removeTemplates = new HashMap<>();
Map<String, UCSVhbaTemplate> updateTemplates = new HashMap<>();
Map<String, UCSVhbaTemplate> addTemplates = new HashMap<>();
URIQueryResultList uris = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemVhbaTemplateConstraint(cs.getId()), uris);
List<UCSVhbaTemplate> templates = _dbClient.queryObject(UCSVhbaTemplate.class, uris, true);
for (UCSVhbaTemplate vhbaTemplate : templates) {
removeTemplates.put(vhbaTemplate.getDn(), vhbaTemplate);
}
// discovered data
for (VnicSanConnTempl vhbaTemplate : vhbaTemplates) {
UCSVhbaTemplate template = removeTemplates.get(vhbaTemplate.getDn());
if (template != null) {
updateTemplates.put(vhbaTemplate.getDn(), template);
removeTemplates.remove(template.getDn());
updateUCSVhbaTemplate(template, vhbaTemplate);
} else {
template = new UCSVhbaTemplate();
addTemplates.put(vhbaTemplate.getDn(), template);
createUCSVhbaTemplate(cs, template, vhbaTemplate);
}
}
createDataObjects(new ArrayList<DataObject>(addTemplates.values()));
persistDataObjects(new ArrayList<DataObject>(updateTemplates.values()));
for (String key : removeTemplates.keySet()) {
_log.info("Marked for deletion UCSVhbaTemplate: " + key);
}
deleteDataObjects(new ArrayList<DataObject>(removeTemplates.values()));
}
Aggregations