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));
}
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()));
}
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()));
}
}
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()));
}
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);
}
}
}
Aggregations