Search in sources :

Example 1 with LsbootPolicy

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

Aggregations

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