Search in sources :

Example 1 with UCSVhbaTemplate

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

Aggregations

VnicSanConnTempl (com.emc.cloud.platform.ucs.out.model.VnicSanConnTempl)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 UCSVhbaTemplate (com.emc.storageos.db.client.model.UCSVhbaTemplate)1 HashMap (java.util.HashMap)1