Use the timeout from the heat templates for 49/115149/3
authorBoslet, Cory <cory.boslet@att.com>
Thu, 19 Nov 2020 23:10:56 +0000 (18:10 -0500)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Tue, 5 Jan 2021 15:38:41 +0000 (10:38 -0500)
Use the timeout from the heat templates for polling
Removed unused imports and code from base
Added to get timeout from the rest client
Fixed unit test for polling to account for changes

Issue-ID: SO-3397
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: If633f4f49d88eb797020b7d72c6edd0fbee0926c

adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/orchestration/PollService.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/orchestration/PollServiceTest.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/NetworkResourceRepository.java

index c4ef367..ba4b309 100644 (file)
@@ -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;
+    }
+
 }
index 5bd7c29..f20f6f1 100644 (file)
@@ -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");
+    }
+
 }
index 489585c..9123ac9 100644 (file)
@@ -962,31 +962,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             pollForCompletion = true;
         }
 
-        // Retrieve the Network Resource definition
-        NetworkResource networkResource = null;
-        if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
-            if (!commonUtils.isNullOrEmpty(networkType)) {
-                networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
-            }
-        } else {
-            NetworkResourceCustomization nrc =
-                    networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
-            if (nrc != null) {
-                networkResource = nrc.getNetworkResource();
-            }
-        }
-
-        int timeoutMinutes = 118;
-        if (networkResource != null) {
-            logger.debug(LOG_DEBUG_MSG, networkResource.toString());
-            networkResource.getHeatTemplate().getTimeoutMinutes();
-            HeatTemplate heat = networkResource.getHeatTemplate();
-            if (heat != null && heat.getTimeoutMinutes() != null) {
-                if (heat.getTimeoutMinutes() < 118) {
-                    timeoutMinutes = heat.getTimeoutMinutes();
-                }
-            }
-        }
+        int timeoutMinutes = heat.getNetworkHeatTimeoutValue(modelCustomizationUuid, networkType);
 
         try {
             StackInfo stack =
index c319fdc..ddbda5d 100644 (file)
@@ -90,7 +90,9 @@ public class PollService extends ExternalTaskUtils {
                             JAXB.unmarshal(new StringReader(xmlRequest), DeleteVfModuleRequest.class);
                     boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
                     if (!isMulticloud) {
-                        pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                        int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
+                        pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask,
+                                success);
                     } else {
                         success.setTrue();
                     }
@@ -100,7 +102,7 @@ public class PollService extends ExternalTaskUtils {
                             JAXB.unmarshal(new StringReader(xmlRequest), DeleteVolumeGroupRequest.class);
                     boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
                     if (!isMulticloud) {
-                        pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                        pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                     } else {
                         success.setTrue();
                     }
@@ -109,7 +111,7 @@ public class PollService extends ExternalTaskUtils {
                 } else if ("deleteNetworkRequest".equals(requestType.get())) {
                     logger.debug("Executing External Task Poll Service for Delete Network");
                     DeleteNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), DeleteNetworkRequest.class);
-                    pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                    pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
                 } else if ("updateNetworkRequest".equals(requestType.get())) {
                     UpdateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), UpdateNetworkRequest.class);
                     pollUpdateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
@@ -152,9 +154,10 @@ public class PollService extends ExternalTaskUtils {
             boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
             if (pollRollbackStatus) {
                 logger.debug("Executing External Task Poll Service for Rollback Create Volume Group");
-                pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                pollDeleteResource(118, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
             } else {
-                pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), true);
+                pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
             }
         } else {
             success.setTrue();
@@ -167,12 +170,13 @@ public class PollService extends ExternalTaskUtils {
         boolean isMulticloud = vnfAdapterUtils.isMulticloudMode(null, req.getCloudSiteId());
         if (!isMulticloud) {
             boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+            int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(req.getModelCustomizationUuid(), false);
             if (pollRollbackStatus) {
                 logger.debug("Executing External Task Poll Service for Rollback Create Vf Module");
-                pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
             } else {
                 logger.debug("Executing External Task Poll Service for Create Vf Module");
-                pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+                pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
             }
         } else {
             success.setTrue();
@@ -183,29 +187,31 @@ public class PollService extends ExternalTaskUtils {
             throws MsoException {
         CreateNetworkRequest req = JAXB.unmarshal(new StringReader(xmlRequest), CreateNetworkRequest.class);
         boolean pollRollbackStatus = externalTask.getVariable("PollRollbackStatus");
+        int timeoutMinutes =
+                msoHeatUtils.getNetworkHeatTimeoutValue(req.getModelCustomizationUuid(), req.getNetworkType());
         if (pollRollbackStatus) {
             logger.debug("Executing External Task Poll Service for Rollback Create Network");
-            pollDeleteResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+            pollDeleteResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
         } else {
             logger.debug("Executing External Task Poll Service for Create Network");
-            pollCreateResource(req.getCloudSiteId(), req.getTenantId(), externalTask, success);
+            pollCreateResource(timeoutMinutes, req.getCloudSiteId(), req.getTenantId(), externalTask, success);
         }
     }
 
-    private void pollCreateResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+    private void pollCreateResource(int pollingTimeout, String cloudSiteId, String tenantId, ExternalTask externalTask,
             MutableBoolean success) throws MsoException {
         Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
-        Stack stack =
-                msoHeatUtils.pollStackForStatus(1, currentStack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false);
+        Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "CREATE_IN_PROGRESS", cloudSiteId,
+                tenantId, false);
         msoHeatUtils.postProcessStackCreate(stack, false, 0, false, cloudSiteId, tenantId, null);
         success.setTrue();
     }
 
-    private void pollDeleteResource(String cloudSiteId, String tenantId, ExternalTask externalTask,
+    private void pollDeleteResource(int pollingTimeout, String cloudSiteId, String tenantId, ExternalTask externalTask,
             MutableBoolean success) throws MsoException {
         Stack currentStack = createCurrentStack(externalTask.getVariable("stackId"));
-        Stack stack =
-                msoHeatUtils.pollStackForStatus(1, currentStack, "DELETE_IN_PROGRESS", cloudSiteId, tenantId, true);
+        Stack stack = msoHeatUtils.pollStackForStatus(pollingTimeout, currentStack, "DELETE_IN_PROGRESS", cloudSiteId,
+                tenantId, true);
         if (stack != null) { // if stack is null it was not found and no need to do post process
             msoHeatUtils.postProcessStackDelete(stack);
         }
@@ -245,5 +251,4 @@ public class PollService extends ExternalTaskUtils {
         currentStack.setStackName(stackName);
         return currentStack;
     }
-
 }
index 26bce5f..7acf953 100644 (file)
@@ -158,6 +158,7 @@ public class MsoVnfAdapterImpl {
      * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc)
      * @param rollback Holder for returning VnfRollback object
      */
+    @Deprecated
     public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion,
             String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs,
             Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId,
@@ -212,6 +213,7 @@ public class MsoVnfAdapterImpl {
      * @param vnfName VNF Name or Openstack ID
      * @param msoRequest Request tracking information for logs
      */
+    @Deprecated
     public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest)
             throws VnfException {
 
@@ -251,6 +253,7 @@ public class MsoVnfAdapterImpl {
      * @param vnfName VNF Name or Openstack ID
      * @param msoRequest Request tracking information for logs
      */
+    @Deprecated
     public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest,
             boolean pollStackStatus) throws VnfException {
 
@@ -988,29 +991,7 @@ public class MsoVnfAdapterImpl {
         // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected
         // Object types
         outputs.value = this.convertMapStringObjectToStringString(stackOutputs);
-        int timeoutMinutes = 118;
-        VfModule vf = null;
-        VfModuleCustomization vfmc = null;
-        if (modelCustomizationUuid != null) {
-            vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid);
-            if (vfmc != null) {
-                vf = vfmc.getVfModule();
-            }
-            if (vf != null) {
-                logger.trace("Found vfModuleCust entry {}", vfmc.toString());
-                HeatTemplate heat = vf.getModuleHeatTemplate();
-                if (heat != null && heat.getTimeoutMinutes() != null) {
-                    if (heat.getTimeoutMinutes() < 118) {
-                        timeoutMinutes = heat.getTimeoutMinutes();
-                    }
-                }
-
-            } else {
-                logger.debug(
-                        "Unable to find vfModuleCust with modelCustomizationUuid={} . Using default timeout for polling",
-                        modelCustomizationUuid);
-            }
-        }
+        int timeoutMinutes = msoHeatUtils.getVfHeatTimeoutValue(modelCustomizationUuid, false);
 
         try {
             StackInfo currentStack =
index 6082670..0214fdd 100644 (file)
@@ -52,15 +52,17 @@ public class PollServiceTest {
         Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
         Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(false);
         Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
-        Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"), eq("regionOne"),
-                eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+        Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+                eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false))).thenReturn(new Stack());
+        Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
         // Mockito.doNothing().when(msoHeatUtils).postProcessStackCreate(Mockito.any(), Mockito.any(), Mockito.any(),
         // Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any());
 
         pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
 
-        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(Stack.class), eq("CREATE_IN_PROGRESS"),
+        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(Stack.class), eq("CREATE_IN_PROGRESS"),
                 eq("regionOne"), eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(false));
+        Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
 
     }
 
@@ -72,16 +74,16 @@ public class PollServiceTest {
         Mockito.when(mockExternalTask.getVariable("openstackAdapterTaskRequest")).thenReturn(xmlString);
         Mockito.when(mockExternalTask.getVariable("PollRollbackStatus")).thenReturn(true);
         Mockito.when(mockExternalTask.getVariable("stackId")).thenReturn("stackId/stack123");
-        Mockito.when(msoHeatUtils.pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+        Mockito.when(msoHeatUtils.pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
                 eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true))).thenReturn(new Stack());
         Mockito.doNothing().when(msoHeatUtils).postProcessStackDelete(Mockito.any());
-
+        Mockito.when(msoHeatUtils.getVfHeatTimeoutValue(any(), eq(false))).thenReturn(118);
 
         pollService.executeExternalTask(mockExternalTask, mockExternalTaskService);
 
-        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(1), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
+        Mockito.verify(msoHeatUtils).pollStackForStatus(eq(118), any(), eq("DELETE_IN_PROGRESS"), eq("regionOne"),
                 eq("0422ffb57ba042c0800a29dc85ca70f8"), eq(true));
-
+        Mockito.verify(msoHeatUtils).getVfHeatTimeoutValue(any(), eq(false));
     }
 
 }
index ef90dd6..91cfb00 100644 (file)
@@ -47,6 +47,7 @@ import org.onap.so.db.catalog.beans.HomingInstance;
 import org.onap.so.db.catalog.beans.InstanceGroup;
 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
 import org.onap.so.db.catalog.beans.NetworkRecipe;
+import org.onap.so.db.catalog.beans.NetworkResource;
 import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
 import org.onap.so.db.catalog.beans.OrchestrationAction;
 import org.onap.so.db.catalog.beans.OrchestrationStatus;
@@ -98,6 +99,7 @@ public class CatalogDbClient {
     private static final String RAINY_DAY_HANDLER_MACRO = "/rainy_day_handler_macro";
     private static final String NORTHBOUND_REQUEST_REF_LOOKUP = "/northbound_request_ref_lookup";
     private static final String NETWORK_RESOURCE_CUSTOMIZATION = "/networkResourceCustomization";
+    private static final String NETWORK_RESOURCE = "/networkResource";
     private static final String COLLECTION_RESOURCE_INSTANCE_GROUP_CUSTOMIZATION =
             "/collectionResourceInstanceGroupCustomization";
     private static final String VNFC_INSTANCE_GROUP_CUSTOMIZATION = "/vnfcInstanceGroupCustomization";
@@ -223,6 +225,7 @@ public class CatalogDbClient {
     private String vnfResourceURI;
     private String networkCollectionResourceCustomizationURI;
     private String networkResourceCustomizationURI;
+    private String networkResourceURI;
     private String collectionNetworkResourceCustomizationURI;
     private String instanceGroupURI;
     private String cloudifyManagerURI;
@@ -375,6 +378,7 @@ public class CatalogDbClient {
         networkCollectionResourceCustomizationURI =
                 endpoint + NETWORK_COLLECTION_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
         networkResourceCustomizationURI = endpoint + NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
+        networkResourceURI = endpoint + NETWORK_RESOURCE + SEARCH;
         collectionNetworkResourceCustomizationURI =
                 endpoint + COLLECTION_NETWORK_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
         instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
@@ -607,6 +611,25 @@ public class CatalogDbClient {
         return networkResourceCustomization;
     }
 
+    public NetworkResource getNetworkResourceByModelName(String networkType) {
+        if (Strings.isNullOrEmpty(networkType)) {
+            throw new EntityNotFoundException("networkType passed as Null or Empty String");
+        }
+        try {
+            HttpEntity<?> entity = getHttpEntity();
+            return restTemplate.exchange(
+                    UriBuilder.fromUri(networkResourceURI + "/findFirstByModelNameOrderByModelVersionDesc")
+                            .queryParam("modelName", networkType).build(),
+                    HttpMethod.GET, entity, NetworkResource.class).getBody();
+        } catch (HttpClientErrorException e) {
+            if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) {
+                throw new EntityNotFoundException("Unable to find NetworkResource By networkType " + networkType);
+            }
+            throw e;
+        }
+    }
+
+
 
     public BuildingBlockDetail getBuildingBlockDetail(String buildingBlockName) {
         BuildingBlockDetail buildingBlockDetail =
index 42d107c..30f3df7 100644 (file)
@@ -23,6 +23,7 @@ package org.onap.so.db.catalog.data.repository;
 import org.onap.so.db.catalog.beans.NetworkResource;
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.data.jpa.repository.Query;
+import org.springframework.data.repository.query.Param;
 import org.springframework.data.rest.core.annotation.RepositoryRestResource;
 import org.springframework.stereotype.Repository;
 
@@ -38,7 +39,7 @@ public interface NetworkResourceRepository extends JpaRepository<NetworkResource
      */
     @Query(value = "SELECT * FROM network_resource WHERE MODEL_NAME = ?1 ORDER BY INET_ATON(SUBSTRING_INDEX(CONCAT(MODEL_VERSION,'.0.0.0'),'.',4)) DESC LIMIT 1;",
             nativeQuery = true)
-    NetworkResource findFirstByModelNameOrderByModelVersionDesc(String modelName);
+    NetworkResource findFirstByModelNameOrderByModelVersionDesc(@Param("modelName") String modelName);
 
     NetworkResource findResourceByModelUUID(String modelUUID);