aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java
diff options
context:
space:
mode:
authorAvi Ziv <AVIZI@amdocs.com>2017-07-26 17:37:57 +0300
committerAvi Ziv <avi.ziv@amdocs.com>2017-07-26 18:27:22 +0300
commit61070c9c6b665fdea79b3ccdfeafc3a6b50d262e (patch)
treedfe9c169cfac91d6c72ac9ff23375f2aafac6405 /openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java
parentb824a997e19f6ee9627cb1b1e124c756bd8183fc (diff)
[SDC] Full OnBoard health-check and NFoD support
Change-Id: I606f8a52c7e6d2bd5558f824957d890e552c5423 Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java')
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java175
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java8
-rw-r--r--openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java7
3 files changed, 156 insertions, 34 deletions
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
index c759d21f01..2e63a8d50a 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/ComponentQuestionnaireHealer.java
@@ -1,5 +1,6 @@
package org.openecomp.sdc.healing.healers;
+import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.openecomp.sdc.common.utils.SdcCommon;
@@ -7,9 +8,15 @@ import org.openecomp.sdc.healing.interfaces.Healer;
import org.openecomp.sdc.logging.context.impl.MdcDataDebugMessage;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.ComponentDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ComputeDaoFactory;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDao;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.ImageDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDao;
import org.openecomp.sdc.vendorsoftwareproduct.dao.VendorSoftwareProductDaoFactory;
import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComponentEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ComputeEntity;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.ImageEntity;
import org.openecomp.sdc.versioning.dao.types.Version;
import java.util.Collection;
@@ -17,13 +24,31 @@ import java.util.Map;
public class ComponentQuestionnaireHealer implements Healer {
- /*private static final VendorSoftwareProductDao vendorSoftwareProductDao =
- VendorSoftwareProductDaoFactory.getInstance().createInterface();*/
private static final ComponentDao componentDao =
ComponentDaoFactory.getInstance().createInterface();
+ private static final ComputeDao computeDao =
+ ComputeDaoFactory.getInstance().createInterface();
+ private static final ImageDao imageDao =
+ ImageDaoFactory.getInstance().createInterface();
+
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ public static final String GENERAL = "general";
+ public static final String IMAGE = "image";
+ public static final String FORMAT = "format";
+ public static final String CPU_OVER_SUBSCRIPTION_RATIO = "CpuOverSubscriptionRatio";
+ public static final String MEMORY_RAM = "MemoryRAM";
+ public static final String VM_SIZING = "vmSizing";
+ public static final String COMPUTE = "compute";
+ public static final String NUM_OF_VMS = "numOfVMs";
+ public static final String DISK = "disk";
+ public static final String IO_OP_PER_SEC = "IOOperationsPerSec";
+
+ public static final String COMPUTE_CPU_OVER_SUBSCRIPTION_RATIO = "cpuOverSubscriptionRatio";
+ public static final String COMPUTE_MEMORY_RAM = "memoryRAM";
+ public static final String COMPUTE_IO_OP_PER_SEC = "ioOperationsPerSec";
+
public ComponentQuestionnaireHealer(){
}
@@ -36,43 +61,133 @@ public class ComponentQuestionnaireHealer implements Healer {
Collection<ComponentEntity> componentEntities =
componentDao.list(new ComponentEntity(vspId, version, null));
componentEntities.forEach(componentEntity -> {
- /*String questionnaire=vendorSoftwareProductDao.getComponent(vspId, version, componentEntity
- .getId()).getQuestionnaireData();*/
String questionnaire = componentDao.getQuestionnaireData(vspId, version, componentEntity
.getId()).getQuestionnaireData();
+
if (questionnaire != null) {
- JsonParser jsonParser = new JsonParser();
- JsonObject json = (JsonObject) jsonParser.parse(questionnaire);
- if (json.getAsJsonObject("compute") != null && json.getAsJsonObject("compute")
- .getAsJsonObject("vmSizing") != null) {
- json.getAsJsonObject("compute").remove("vmSizing");
- }
+ JsonParser jsonParser = new JsonParser();
+ JsonObject json = (JsonObject) jsonParser.parse(questionnaire);
- if (json.getAsJsonObject("compute") != null && json.getAsJsonObject("compute")
- .getAsJsonObject("numOfVMs") != null ) {
- if (json.getAsJsonObject("compute").getAsJsonObject("numOfVMs").
- get("CpuOverSubscriptionRatio") != null ) {
- json.getAsJsonObject("compute").getAsJsonObject("numOfVMs").remove
- ("CpuOverSubscriptionRatio");
- }
- if (json.getAsJsonObject("compute").getAsJsonObject("numOfVMs").
- get("MemoryRAM") != null ) {
- json.getAsJsonObject("compute").getAsJsonObject("numOfVMs").remove("MemoryRAM");
- }
- }
+ Collection<ComputeEntity> computeEntities = computeDao.list(new ComputeEntity(vspId,
+ version, componentEntity.getId(), null));
+ computeEntities.stream().forEach(
+ computeEntity -> {
+ populateComputeQuestionnaire(json, computeEntity);
+ }
+ );
- if (json.getAsJsonObject("general") != null && json.getAsJsonObject("general")
- .getAsJsonObject("image") != null && json.getAsJsonObject("general").getAsJsonObject
- ("image").get("format") != null) {
- json.getAsJsonObject("general").getAsJsonObject("image").remove("format");
- }
- String questionnaireData = json.toString();
- /*vendorSoftwareProductDao.updateComponentQuestionnaire(vspId, version, componentEntity
- .getId(),questionnaireData);*/
+ Collection<ImageEntity> imageEntities = imageDao.list(new ImageEntity(vspId,
+ version, componentEntity.getId(), null));
+ imageEntities.stream().forEach(
+ imageEntity -> {
+ populateImageQuestionnaire(json, imageEntity);
+ }
+ );
+
+ processDiskAttribute(json, "bootDiskSizePerVM");
+ processDiskAttribute(json, "ephemeralDiskSizePerVM");
+
+ String questionnaireData = json.toString();
componentDao.updateQuestionnaireData(vspId, version, componentEntity.getId(),
questionnaireData);
}
});
return componentEntities;
}
+
+ /**
+ * Move Disk Atributes from genral/image/ to genral/disk in component questionnaire itself
+ * @param json
+ * @param diskAttrName
+ * @param diskJsonObject
+ * @return
+ */
+ private void processDiskAttribute(JsonObject json, String diskAttrName) {
+ boolean isBootDisksizePerVM = isDiskAttributePresent(json, diskAttrName);
+ if (isBootDisksizePerVM) {
+ JsonObject diskJsonObject = json.getAsJsonObject(GENERAL).getAsJsonObject(DISK);
+ if (diskJsonObject == null) {
+ diskJsonObject = new JsonObject();
+ }
+
+ diskJsonObject.addProperty(diskAttrName, json.getAsJsonObject(GENERAL).getAsJsonObject(IMAGE)
+ .get(diskAttrName).getAsNumber());
+
+ json.getAsJsonObject(GENERAL).add(DISK, diskJsonObject);
+ json.getAsJsonObject(GENERAL).getAsJsonObject(IMAGE).remove(diskAttrName);
+ }
+ }
+
+ private boolean isDiskAttributePresent(JsonObject json, String diskAttrName) {
+ return json.getAsJsonObject(GENERAL) != null &&
+ json.getAsJsonObject(GENERAL).getAsJsonObject(IMAGE) != null &&
+ json.getAsJsonObject(GENERAL).getAsJsonObject (IMAGE).get(diskAttrName)
+ != null;
+ }
+
+ /**
+ * Move the required attributes from component to Image Questionnaire
+ * @param json
+ * @param imageEntity
+ */
+ private void populateImageQuestionnaire(JsonObject json, ImageEntity imageEntity) {
+ JsonObject general = getJsonObject(json, GENERAL);
+ boolean isImageFormat = general != null && json
+ .getAsJsonObject(GENERAL)
+ .getAsJsonObject(IMAGE) != null && json.getAsJsonObject(GENERAL).getAsJsonObject
+ (IMAGE).get(FORMAT) != null;
+ if (isImageFormat) {
+ JsonObject image = getJsonObject(general, IMAGE);
+ JsonElement jsonElement = image.get(FORMAT);
+ JsonObject jsonObject = new JsonObject();
+ jsonObject.add(FORMAT, jsonElement);
+ imageDao.updateQuestionnaireData(imageEntity.getVspId(), imageEntity.getVersion(), imageEntity
+ .getComponentId(),imageEntity.getId(), jsonObject.toString());
+ image.remove(FORMAT);
+ }
+ }
+
+ /**
+ * Move the required attributes from component to Compute Questionnaire
+ * @param json
+ * @param computeEntity
+ */
+ private void populateComputeQuestionnaire(JsonObject json, ComputeEntity computeEntity) {
+ JsonObject compute = getJsonObject(json, COMPUTE);
+ JsonObject vmSizing = getJsonObject(compute, VM_SIZING);
+ if (compute != null && vmSizing != null) {
+ JsonElement ioOperationsPerSec = vmSizing.get(IO_OP_PER_SEC);
+ if (ioOperationsPerSec != null) {
+ vmSizing.addProperty(COMPUTE_IO_OP_PER_SEC, ioOperationsPerSec.getAsNumber());
+ vmSizing.remove(IO_OP_PER_SEC);
+ }
+
+ JsonObject numberOfVms = getJsonObject(compute, NUM_OF_VMS);
+ if (numberOfVms != null ) {
+ JsonElement cpuRatio = numberOfVms.get(CPU_OVER_SUBSCRIPTION_RATIO);
+ if (cpuRatio != null ) {
+ vmSizing.addProperty(COMPUTE_CPU_OVER_SUBSCRIPTION_RATIO, cpuRatio.getAsString());
+ numberOfVms.remove(CPU_OVER_SUBSCRIPTION_RATIO);
+ }
+ JsonElement memoryRam = numberOfVms.get(MEMORY_RAM);
+ if (memoryRam != null ) {
+ vmSizing.addProperty(COMPUTE_MEMORY_RAM, memoryRam.getAsString());
+ numberOfVms.remove(MEMORY_RAM);
+ }
+ }
+
+ JsonObject computeQuestionnaireJsonObject = new JsonObject();
+ computeQuestionnaireJsonObject.add(VM_SIZING, vmSizing);
+ String computeQuestionnaire = computeQuestionnaireJsonObject != null ?
+ computeQuestionnaireJsonObject.toString() : null;
+ computeDao.updateQuestionnaireData(computeEntity.getVspId(), computeEntity.getVersion(),
+ computeEntity.getComponentId(), computeEntity.getId(), computeQuestionnaire);
+ compute.remove(VM_SIZING);
+
+ }
+ }
+
+ private JsonObject getJsonObject(JsonObject json, String name) {
+ return json.getAsJsonObject(name);
+ }
}
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
index 6fdf14451f..bdb7bc3a93 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/CompositionDataHealer.java
@@ -174,8 +174,8 @@ public class CompositionDataHealer implements Healer {
Collection<ComputeEntity> computeEntities = computeDao.listByVsp(vspId, version);
Collection<ImageEntity> imageEntities = imageDao.listByVsp(vspId, version);
- Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deloymentFlavorDao.list(new
- DeploymentFlavorEntity(vspId, version, null));
+ //Collection<DeploymentFlavorEntity> deploymentFlavorEntities = deloymentFlavorDao.list(new
+ //DeploymentFlavorEntity(vspId, version, null));
if (CollectionUtils.isEmpty(computeEntities) && CollectionUtils.isEmpty(imageEntities)) {
for (Component component : compositionData.getComponents()) {
@@ -195,9 +195,9 @@ public class CompositionDataHealer implements Healer {
}
- if (CollectionUtils.isEmpty(deploymentFlavorEntities)) {
+ /*if (CollectionUtils.isEmpty(deploymentFlavorEntities)) {
compositionEntityDataManager.saveDeploymentFlavors(vspId,version,compositionData);
- }
+ }*/
}
private CompositionData healCompositionData(String vspId, Version version,
diff --git a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
index 5eb15bf9ba..6a82d8fa49 100644
--- a/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
+++ b/openecomp-be/lib/openecomp-healing-lib/openecomp-sdc-healing-impl/src/main/java/org/openecomp/sdc/healing/healers/VlmVersionHealer.java
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Optional;
/**
@@ -44,6 +45,11 @@ public class VlmVersionHealer implements Healer {
VspDetails vspDetails = vspInfoDao.get(new VspDetails(vspId, version));
VersionedVendorLicenseModel vendorLicenseModel;
+
+ if(!Objects.isNull(vspDetails.getVlmVersion())) {
+ return Optional.empty();
+ }
+
try{
vendorLicenseModel =
@@ -61,6 +67,7 @@ public class VlmVersionHealer implements Healer {
new ArrayList<>(
licenseAgreementDao.list(new LicenseAgreementEntity(vlmId, vlmVersion, null)));
+
vspDetails.setVlmVersion(vlmVersion);
vspDetails.setLicenseAgreement(laList.get(0).getId());
vspDetails.setFeatureGroups(new ArrayList<>(laList.get(0).getFeatureGroupIds()));