summaryrefslogtreecommitdiffstats
path: root/adapters/mso-adapter-utils
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2021-01-05 19:22:26 +0000
committerGerrit Code Review <gerrit@onap.org>2021-01-05 19:22:26 +0000
commit88f5917edae8c50ddfbe9b0538c2e33502bf50a3 (patch)
treebaabed103156da11ca693b6e434706dbc180b4a0 /adapters/mso-adapter-utils
parentef992713f2ab47facf2eea820cbcfad0a9bcbd4b (diff)
parent8bc7057f9b23555ba78c9f656743c57fa3d62a64 (diff)
Merge "Use the timeout from the heat templates for"
Diffstat (limited to 'adapters/mso-adapter-utils')
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java85
-rw-r--r--adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java43
2 files changed, 122 insertions, 6 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index c4ef3678c3..ba4b30903d 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -31,9 +31,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import static org.apache.commons.lang3.StringUtils.isBlank;
+import static org.apache.commons.lang3.StringUtils.isNotBlank;
import org.onap.logging.filter.base.ErrorCode;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
import org.onap.so.adapters.vdu.CloudInfo;
@@ -49,6 +50,11 @@ import org.onap.so.adapters.vdu.VduStatus;
import org.onap.so.cloud.authentication.KeystoneAuthHolder;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.HeatTemplateParam;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -108,6 +114,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
public static final String EXCEPTION_ROLLING_BACK_STACK =
"{} Create Stack: Nested exception rolling back stack: {} ";
public static final String IN_PROGRESS = "in_progress";
+ private static final int DEFAULT_POLLING_TIMEOUT = 118;
@Autowired
private Environment environment;
@@ -121,6 +128,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
@Autowired
RequestsDbClient requestDBClient;
+ @Autowired
+ private CatalogDbClient catalogClient;
+
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtils.class);
// Properties names and variables (with default values)
@@ -898,11 +908,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
if (inputs == null) {
return new HashMap<>();
}
- try {
- Set<HeatTemplateParam> paramSet = template.getParameters();
- } catch (Exception e) {
- logger.debug("Exception occurred in convertInputMap {} :", e.getMessage(), e);
- }
for (HeatTemplateParam htp : template.getParameters()) {
params.put(htp.getParamName(), htp);
@@ -1232,4 +1237,72 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
}
+ public int getVfHeatTimeoutValue(String modelCustomizationUuid, boolean isVolumeGroup) {
+ int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+ try {
+ VfModuleCustomization vfmc = null;
+ if (modelCustomizationUuid != null) {
+ vfmc = catalogClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUuid);
+ if (vfmc != null) {
+ VfModule vf = vfmc.getVfModule();
+ if (vf != null) {
+ HeatTemplate heat = vf.getModuleHeatTemplate();
+ if (isVolumeGroup) {
+ heat = vf.getVolumeHeatTemplate();
+ }
+ if (heat != null && heat.getTimeoutMinutes() != null) {
+ if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+ timeoutMinutes = heat.getTimeoutMinutes();
+ }
+ }
+ }
+ } else {
+ logger.debug(
+ "Unable to find Vf Module Customization with model customization uuid {}. Using default timeout {}",
+ modelCustomizationUuid, timeoutMinutes);
+ }
+ }
+ } catch (Exception e) {
+ logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+ e);
+ }
+ return timeoutMinutes;
+ }
+
+ public int getNetworkHeatTimeoutValue(String modelCustomizationUuid, String networkType) {
+ int timeoutMinutes = DEFAULT_POLLING_TIMEOUT;
+ try {
+ NetworkResource networkResource = null;
+ if (isBlank(modelCustomizationUuid)) {
+ if (isNotBlank(networkType)) {
+ networkResource = catalogClient.getNetworkResourceByModelName(networkType);
+ }
+ } else {
+ NetworkResourceCustomization nrc =
+ catalogClient.getNetworkResourceCustomizationByModelCustomizationUUID(modelCustomizationUuid);
+ if (nrc != null) {
+ networkResource = nrc.getNetworkResource();
+ }
+ }
+
+ if (networkResource != null) {
+ networkResource.getHeatTemplate().getTimeoutMinutes();
+ HeatTemplate heat = networkResource.getHeatTemplate();
+ if (heat != null && heat.getTimeoutMinutes() != null) {
+ if (heat.getTimeoutMinutes() < DEFAULT_POLLING_TIMEOUT) {
+ timeoutMinutes = heat.getTimeoutMinutes();
+ }
+ }
+ } else {
+ logger.debug(
+ "Unable to find Network Resource with model customization uuid {} or network type {}. Using default timeout {}",
+ modelCustomizationUuid, networkType, timeoutMinutes);
+ }
+ } catch (Exception e) {
+ logger.warn("Exception occured while getting heat timeout value. Using default timeout {}", timeoutMinutes,
+ e);
+ }
+ return timeoutMinutes;
+ }
+
}
diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
index 5bd7c29313..f20f6f1448 100644
--- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
+++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
@@ -46,6 +46,12 @@ import org.mockito.Mockito;
import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.logging.ref.slf4j.ONAPLogConstants;
+import org.onap.so.db.catalog.beans.HeatTemplate;
+import org.onap.so.db.catalog.beans.NetworkResource;
+import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.VfModule;
+import org.onap.so.db.catalog.beans.VfModuleCustomization;
+import org.onap.so.db.catalog.client.CatalogDbClient;
import org.onap.so.db.request.beans.CloudApiRequests;
import org.onap.so.db.request.beans.InfraActiveRequests;
import org.onap.so.db.request.client.RequestsDbClient;
@@ -103,6 +109,9 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
@Mock
private CreateStack mockCreateStack;
+ @Mock
+ private CatalogDbClient catalogDbClient;
+
private String cloudSiteId = "cloudSiteId";
private String tenantId = "tenantId";
@@ -564,4 +573,38 @@ public class MsoHeatUtilsTest extends MsoHeatUtils {
Mockito.verify(heatUtils, times(0)).handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId);
}
+ @Test
+ public void testGetVfHeatTimeoutValue() {
+
+ VfModuleCustomization vfmc = new VfModuleCustomization();
+ VfModule vf = new VfModule();
+ HeatTemplate heat = new HeatTemplate();
+ heat.setTimeoutMinutes(110);
+ vf.setModuleHeatTemplate(heat);
+ vfmc.setVfModule(vf);
+
+ Mockito.when(catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID("uuid")).thenReturn(vfmc);
+
+ int timeout = heatUtils.getVfHeatTimeoutValue("uuid", false);
+ assertEquals(110, timeout);
+ Mockito.verify(catalogDbClient, times(1)).getVfModuleCustomizationByModelCuztomizationUUID("uuid");
+ }
+
+ @Test
+ public void testGetNetworkHeatTimeoutValue() {
+
+ NetworkResourceCustomization mc = new NetworkResourceCustomization();
+ NetworkResource nr = new NetworkResource();
+ HeatTemplate heat = new HeatTemplate();
+ heat.setTimeoutMinutes(110);
+ nr.setHeatTemplate(heat);
+ mc.setNetworkResource(nr);
+
+ Mockito.when(catalogDbClient.getNetworkResourceCustomizationByModelCustomizationUUID("uuid")).thenReturn(mc);
+
+ int timeout = heatUtils.getNetworkHeatTimeoutValue("uuid", "type");
+ assertEquals(110, timeout);
+ Mockito.verify(catalogDbClient, times(1)).getNetworkResourceCustomizationByModelCustomizationUUID("uuid");
+ }
+
}