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