Search in sources :

Example 21 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method deleteBootPolicies.

private void deleteBootPolicies(List<ComputeBootPolicy> bootPolicies) {
    List<ComputeSanBootImagePath> removeSanBootImagePaths = new ArrayList<ComputeSanBootImagePath>();
    List<ComputeSanBootImage> removeSanBootImages = new ArrayList<ComputeSanBootImage>();
    List<ComputeSanBoot> removeSanBoots = new ArrayList<ComputeSanBoot>();
    List<ComputeLanBootImagePath> removeLanBootImagePaths = new ArrayList<ComputeLanBootImagePath>();
    List<ComputeLanBoot> removeLanBoots = new ArrayList<ComputeLanBoot>();
    for (ComputeBootPolicy bootPolicy : bootPolicies) {
        // Retrieve associated ComputeSanBoot and delete it
        URIQueryResultList sanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeSanBootConstraint(bootPolicy.getId()), sanBootUris);
        List<ComputeSanBoot> sanBootList = _dbClient.queryObject(ComputeSanBoot.class, sanBootUris, true);
        if (sanBootList != null && !sanBootList.isEmpty()) {
            for (ComputeSanBoot sanBoot : sanBootList) {
                URIQueryResultList sanImageUris = new URIQueryResultList();
                _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImageConstraint(sanBoot.getId()), sanImageUris);
                List<ComputeSanBootImage> sanBootImageList = _dbClient.queryObject(ComputeSanBootImage.class, sanImageUris, true);
                if (sanBootImageList != null && !sanBootImageList.isEmpty()) {
                    for (ComputeSanBootImage computeSanImage : sanBootImageList) {
                        URIQueryResultList sanImagePathUris = new URIQueryResultList();
                        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSanBootImagePathConstraint(computeSanImage.getId()), sanImagePathUris);
                        List<ComputeSanBootImagePath> sanBootPathList = _dbClient.queryObject(ComputeSanBootImagePath.class, sanImagePathUris, true);
                        if (sanBootPathList != null && !sanBootPathList.isEmpty()) {
                            removeSanBootImagePaths.addAll(sanBootPathList);
                        }
                        removeSanBootImages.add(computeSanImage);
                    }
                }
                removeSanBoots.add(sanBoot);
            }
        }
        // Retrieve associated ComputeLanBoot and delete it
        URIQueryResultList lanBootUris = new URIQueryResultList();
        _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeBootDefComputeLanBootConstraint(bootPolicy.getId()), lanBootUris);
        List<ComputeLanBoot> lanBootList = _dbClient.queryObject(ComputeLanBoot.class, lanBootUris, true);
        if (lanBootList != null && !lanBootList.isEmpty()) {
            ComputeLanBoot lanBoot = lanBootList.get(0);
            URIQueryResultList lanImageUris = new URIQueryResultList();
            _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeLanBootImagePathsConstraint(lanBoot.getId()), lanImageUris);
            List<ComputeLanBootImagePath> lanBootPathList = _dbClient.queryObject(ComputeLanBootImagePath.class, lanImageUris, true);
            if (lanBootPathList != null && !lanBootPathList.isEmpty()) {
                removeLanBootImagePaths.addAll(lanBootPathList);
            }
            removeLanBoots.add(lanBoot);
        }
    }
    deleteDataObjects(new ArrayList<DataObject>(removeLanBootImagePaths));
    deleteDataObjects(new ArrayList<DataObject>(removeLanBoots));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBootImagePaths));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBootImages));
    deleteDataObjects(new ArrayList<DataObject>(removeSanBoots));
    deleteDataObjects(new ArrayList<DataObject>(bootPolicies));
}
Also used : ArrayList(java.util.ArrayList) ComputeSanBootImage(com.emc.storageos.db.client.model.ComputeSanBootImage) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBoot(com.emc.storageos.db.client.model.ComputeLanBoot) DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) ComputeSanBoot(com.emc.storageos.db.client.model.ComputeSanBoot) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) ComputeBootPolicy(com.emc.storageos.db.client.model.ComputeBootPolicy)

Example 22 with DataObject

use of com.emc.storageos.db.client.model.DataObject 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)

Example 23 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method reconcileComputeBlades.

private void reconcileComputeBlades(ComputeSystem cs, List<ComputeBlade> computeBlades, Map<String, LsServer> associatedLsServers) {
    _log.info("reconciling ComputeBlades");
    Map<String, ComputeElement> removeBlades = new HashMap<>();
    Map<String, ComputeElement> updateBlades = new HashMap<>();
    Map<String, ComputeElement> addBlades = new HashMap<>();
    URIQueryResultList uris = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), uris);
    List<ComputeElement> elements = _dbClient.queryObject(ComputeElement.class, uris, true);
    for (ComputeElement element : elements) {
        removeBlades.put(element.getLabel(), element);
    }
    for (ComputeBlade computeBlade : computeBlades) {
        ComputeElement ce = removeBlades.get(computeBlade.getDn());
        LsServer lsServer = associatedLsServers.get(computeBlade.getDn());
        if (ce != null) {
            updateComputeElement(ce, computeBlade, lsServer);
            updateBlades.put(ce.getLabel(), ce);
            removeBlades.remove(computeBlade.getDn());
        } else {
            ce = new ComputeElement();
            createComputeElement(cs, ce, computeBlade, lsServer);
            addBlades.put(computeBlade.getDn(), ce);
        }
    }
    createDataObjects(new ArrayList<DataObject>(addBlades.values()));
    persistDataObjects(new ArrayList<DataObject>(updateBlades.values()));
    if (!removeBlades.isEmpty()) {
        for (String name : removeBlades.keySet()) {
            _log.info("Marked for deletion ComputeElement name:" + name);
        }
        removeBladesFromComputeVirtualPools(removeBlades.values());
        removeBladesFromHosts(removeBlades.values());
        deleteDataObjects(new ArrayList<DataObject>(removeBlades.values()));
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) HashMap(java.util.HashMap) ComputeBlade(com.emc.cloud.platform.ucs.out.model.ComputeBlade) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) LsServer(com.emc.cloud.platform.ucs.out.model.LsServer) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Example 24 with DataObject

use of com.emc.storageos.db.client.model.DataObject 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)

Example 25 with DataObject

use of com.emc.storageos.db.client.model.DataObject in project coprhd-controller by CoprHD.

the class BlockIngestOrchestrator method decorateCGInfoInVolumes.

/**
 * Decorates the BlockConsistencyGroup information in all other volumes ingested in the UnManagedConsistencyGroup
 * managed objects.
 *
 * For each unmanaged volume in unmanaged cg,
 * 1. We verify whether the BlockObject is available in the current createdBlockObjects in context or not.
 * If it is available, then set the CG properties
 * Else, verify in the current updatedBlockObjects in context.
 * 2. If the blockObject is available in updateBlockObjects, then update CG properties.
 * Else, blockObject might have ingested in previous requests, so, we should check from DB.
 * If blockObject is in DB, update CG properties else log a warning message.
 *
 * @param cg - cg object
 * @param blockObject - BlockObject to decorate
 * @param requestContext - current context of unmanagedVolume
 * @param unManagedVolume - current unmanagedVolume to ingest
 */
protected void decorateCGInfoInVolumes(BlockConsistencyGroup cg, BlockObject blockObject, IngestionRequestContext requestContext, UnManagedVolume unManagedVolume) {
    UnManagedConsistencyGroup umcg = requestContext.findUnManagedConsistencyGroup(cg.getLabel());
    Set<DataObject> blockObjectsToUpdate = new HashSet<DataObject>();
    if (null != umcg && null != umcg.getManagedVolumesMap() && !umcg.getManagedVolumesMap().isEmpty()) {
        for (Entry<String, String> managedVolumeEntry : umcg.getManagedVolumesMap().entrySet()) {
            BlockObject bo = requestContext.getRootIngestionRequestContext().findCreatedBlockObject(managedVolumeEntry.getKey());
            if (bo == null) {
                // Next look in the updated objects.
                bo = (BlockObject) requestContext.findInUpdatedObjects(URI.create(managedVolumeEntry.getKey()));
            }
            if (bo == null) {
                // Finally look in the DB itself. It may be from a previous ingestion operation.
                bo = BlockObject.fetch(_dbClient, URI.create(managedVolumeEntry.getValue()));
                // If blockObject is still not exists
                if (null == bo) {
                    _logger.warn("Volume {} is not yet ingested. Hence skipping", managedVolumeEntry.getKey());
                    continue;
                }
                blockObjectsToUpdate.add(bo);
            }
            bo.setConsistencyGroup(cg.getId());
            // Set the replication group instance only if it is not already populated during the block object's ingestion.
            if (bo.getReplicationGroupInstance() == null || bo.getReplicationGroupInstance().isEmpty()) {
                bo.setReplicationGroupInstance(cg.getLabel());
            }
        }
        if (!blockObjectsToUpdate.isEmpty()) {
            requestContext.getDataObjectsToBeUpdatedMap().put(unManagedVolume.getNativeGuid(), blockObjectsToUpdate);
        }
    }
    blockObject.setConsistencyGroup(cg.getId());
    blockObject.setReplicationGroupInstance(cg.getLabel());
    if (blockObject instanceof BlockSnapshot) {
        // Check if the unmanaged volume has SNAPSHOT_CONSISTENCY_GROUP_NAME property populated. If yes,
        // use that for replicationGroupInstance
        String snapsetName = PropertySetterUtil.extractValueFromStringSet(SupportedVolumeInformation.SNAPSHOT_CONSISTENCY_GROUP_NAME.toString(), unManagedVolume.getVolumeInformation());
        if (snapsetName != null && !snapsetName.isEmpty()) {
            blockObject.setReplicationGroupInstance(snapsetName);
        }
    }
}
Also used : DataObject(com.emc.storageos.db.client.model.DataObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) UnManagedConsistencyGroup(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedConsistencyGroup) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) BlockObject(com.emc.storageos.db.client.model.BlockObject) HashSet(java.util.HashSet)

Aggregations

DataObject (com.emc.storageos.db.client.model.DataObject)154 URI (java.net.URI)62 ArrayList (java.util.ArrayList)53 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)44 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)30 Volume (com.emc.storageos.db.client.model.Volume)26 NamedURI (com.emc.storageos.db.client.model.NamedURI)24 StringSet (com.emc.storageos.db.client.model.StringSet)23 HashMap (java.util.HashMap)22 BlockObject (com.emc.storageos.db.client.model.BlockObject)17 HashSet (java.util.HashSet)17 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)16 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)14 Operation (com.emc.storageos.db.client.model.Operation)13 List (java.util.List)10 Set (java.util.Set)10 BlockSnapshotSession (com.emc.storageos.db.client.model.BlockSnapshotSession)9 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)9 BlockConsistencyGroup (com.emc.storageos.db.client.model.BlockConsistencyGroup)8