Search in sources :

Example 1 with UCSVnicTemplate

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()));
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) VnicLanConnTempl(com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl) UCSVnicTemplate(com.emc.storageos.db.client.model.UCSVnicTemplate) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

VnicLanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicLanConnTempl)1 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)1 DataObject (com.emc.storageos.db.client.model.DataObject)1 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)1 UCSVnicTemplate (com.emc.storageos.db.client.model.UCSVnicTemplate)1 HashMap (java.util.HashMap)1