Use the timeout from the heat template instead of 49/100349/1
authorBoslet, Cory <cory.boslet@att.com>
Wed, 15 Jan 2020 21:05:12 +0000 (16:05 -0500)
committerBenjamin, Max (mb388a) <mb388a@att.com>
Wed, 15 Jan 2020 21:05:12 +0000 (16:05 -0500)
Use the timeout from the heat template instead of hardcode WIP
Added custom uuid to vf adapter delete rest request
Added and fixed compilations errors due to interface change
added logic to check that the timeout is less than 120
Set the cust model uuid in bpmn so its avaiable to adapter.
Added to use timeout from heat template for network.
Updated unit test to account for new param change to method.
Fixed and added missing param to deletevf in vnfadapterrestv2
Fixed failing junits due to adding model cust id to request

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

15 files changed:
adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/DeleteVfModuleRequest.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/vnf/MsoVnfAdapter.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java
adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterImplTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java
adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java
bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/VnfAndVfModuleMapper/vnfAdapterDeleteVfModuleRequest.json

index 75a8ca0..16639d9 100644 (file)
@@ -127,12 +127,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
 
     // Properties names and variables (with default values)
     protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval";
-    private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval";
-    private String deletePollTimeoutProp = "org.onap.so.adapters.po.pollTimeout";
     private String pollingMultiplierProp = "org.onap.so.adapters.po.pollMultiplier";
 
     protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15";
-    private static final String DELETE_POLL_INTERVAL_DEFAULT = "15";
     private static final String POLLING_MULTIPLIER_DEFAULT = "60";
 
     private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -177,7 +174,6 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
      * @throws MsoOpenstackException Thrown if the Openstack API call returns an exception.
      */
 
-    @SuppressWarnings("unchecked")
     public StackInfo createStack(String cloudSiteId, String cloudOwner, String tenantId, String stackName,
             VduModelInfo vduModel, String heatTemplate, Map<String, ?> stackInputs, boolean pollForCompletion,
             int timeoutMinutes, String environment, Map<String, Object> nestedTemplates, Map<String, Object> heatFiles,
@@ -848,7 +844,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
      * Boolean if any of the conversions should fail, we will default to adding it to the inputs as a string - see if
      * Openstack can handle it. Also, will remove any params that are extra. Any aliases will be converted to their
      * appropriate name (anyone use this feature?)
-     * 
+     *
      * @param inputs - the Map<String, String> of the inputs received on the request
      * @param template the HeatTemplate object - this is so we can also verify if the param is valid for this template
      * @return HashMap<String, Object> of the inputs, cleaned and converted
index 6a979d7..7e10bb3 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -30,7 +30,7 @@ import com.fasterxml.jackson.annotation.JsonRootName;
 @XmlRootElement(name = "deleteVfModuleRequest")
 public class DeleteVfModuleRequest extends VfRequestCommon implements Serializable {
     /**
-     * 
+     *
      */
     private static final long serialVersionUID = -8504083539107392561L;
     private String cloudSiteId;
@@ -39,6 +39,7 @@ public class DeleteVfModuleRequest extends VfRequestCommon implements Serializab
     private String vnfId;
     private String vfModuleId;
     private String vfModuleStackId;
+    private String modelCustomizationUuid;
 
     private MsoRequest msoRequest = new MsoRequest();
 
@@ -94,6 +95,14 @@ public class DeleteVfModuleRequest extends VfRequestCommon implements Serializab
         this.vfModuleStackId = vfModuleStackId;
     }
 
+    public String getModelCustomizationUuid() {
+        return modelCustomizationUuid;
+    }
+
+    public void setModelCustomizationUuid(String modelCustomizationUuid) {
+        this.modelCustomizationUuid = modelCustomizationUuid;
+    }
+
     public MsoRequest getMsoRequest() {
         return msoRequest;
     }
index 97c715b..ef04ee9 100644 (file)
@@ -1017,7 +1017,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
 
         // Retrieve the Network Resource definition
         NetworkResource networkResource = null;
-
         if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
             if (!commonUtils.isNullOrEmpty(networkType)) {
                 networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
@@ -1030,10 +1029,18 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             }
         }
 
+        int timeoutMinutes = 118;
         String mode = "";
         if (networkResource != null) {
             logger.debug(LOG_DEBUG_MSG, networkResource.toString());
             mode = networkResource.getOrchestrationMode();
+            networkResource.getHeatTemplate().getTimeoutMinutes();
+            HeatTemplate heat = networkResource.getHeatTemplate();
+            if (heat != null && heat.getTimeoutMinutes() != null) {
+                if (heat.getTimeoutMinutes() < 118) {
+                    timeoutMinutes = heat.getTimeoutMinutes();
+                }
+            }
         }
 
         if (NEUTRON_MODE.equals(mode)) {
@@ -1048,7 +1055,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
             }
         } else {
             try {
-                heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120);
+                heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes);
                 networkDeleted.value = true;
             } catch (MsoException me) {
                 me.addContext("DeleteNetwork");
@@ -1381,7 +1388,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
          * make these optional + "      ip_version: %ipversion%\n" + "      enable_dhcp: %enabledhcp%\n" +
          * "      gateway_ip: %gatewayip%\n" + "      allocation_pools:\n" + "       - start: %poolstart%\n" +
          * "         end: %poolend%\n";
-         * 
+         *
          */
 
         String outputTempl = "  subnet_id_%subnetId%:\n" + "    description: Openstack subnet identifier\n"
index 39a380d..0074dca 100644 (file)
@@ -123,6 +123,7 @@ public interface MsoVnfAdapter {
             @WebParam(name = "vfName") @XmlElement(required = true) String vfName,
             @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId,
             @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId,
+            @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid,
             @WebParam(name = "request") MsoRequest msoRequest,
             @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs)
             throws VnfException;
index fcb2d7c..4b90800 100644 (file)
@@ -1137,7 +1137,8 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
 
     @Override
     public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
-            String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+            String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
+            Holder<Map<String, String>> outputs) throws VnfException {
         Map<String, Object> stackOutputs;
         try {
             stackOutputs = msoHeatUtils.queryStackForOutputs(cloudSiteId, cloudOwner, tenantId, vnfName);
@@ -1166,8 +1167,32 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter {
                     msoRequest, failRequestOnValetFailure);
         }
 
+        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);
+            }
+        }
+
         try {
-            msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, 118);
+            msoHeatUtils.deleteStack(tenantId, cloudOwner, cloudSiteId, vnfName, true, timeoutMinutes);
         } catch (MsoException me) {
             me.addContext(DELETE_VNF);
             // Failed to query the Stack due to an openstack exception.
index d35c34a..abaf881 100644 (file)
@@ -1082,7 +1082,8 @@ public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter {
     }
 
     public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId,
-            String vfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+            String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
+            Holder<Map<String, String>> outputs) throws VnfException {
         logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
 
         // 1702 capture the output parameters on a delete
index 561b212..b1f4055 100644 (file)
@@ -1073,7 +1073,8 @@ public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter {
 
 
     public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId,
-            String aaiVfModuleId, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException {
+            String aaiVfModuleId, String modelCustomizationUuid, MsoRequest msoRequest,
+            Holder<Map<String, String>> outputs) throws VnfException {
 
         logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId);
 
index 58899b7..0fb11eb 100644 (file)
@@ -179,8 +179,8 @@ public class VnfAdapterRest {
                 Holder<Map<String, String>> outputs = new Holder<>();
                 if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) {
                     vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
-                            req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(),
-                            outputs);
+                            req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(),
+                            req.getModelCustomizationUuid(), req.getMsoRequest(), outputs);
                 }
                 response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
                         req.getMessageId(), outputs.value);
index 0e70c6b..fcb570f 100644 (file)
@@ -195,8 +195,8 @@ public class VnfAdapterRestV2 {
                     // Support different Adapter Implementations
                     MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite);
                     adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(),
-                            req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), req.getMsoRequest(),
-                            outputs);
+                            req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(),
+                            req.getModelCustomizationUuid(), req.getMsoRequest(), outputs);
                 }
                 response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE,
                         req.getMessageId(), outputs.value);
index 01726ac..a058378 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -485,7 +485,7 @@ public class MsoVnfAdapterImplTest extends BaseRestTestUtils {
         MsoRequest msoRequest = getMsoRequest();
         try {
             instance.deleteVfModule("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
-                    "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
+                    "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", null, msoRequest,
                     new Holder<Map<String, String>>());
         } catch (Exception e) {
 
index e7ef9d9..45504fc 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -67,30 +67,30 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
      * msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); Holder<Map<String, String>> outputs =
      * new Holder<>(); instance.queryVnf("siteid", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new
      * Holder<>(), new Holder<>(), outputs);
-     * 
+     *
      * assertTrue(outputs.value.isEmpty()); }
      */
 
     /*
      * @Test public void queryVnfTest() throws Exception {
-     * 
-     * 
+     *
+     *
      * MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345");
      * msoRequest.setServiceInstanceId("12345");
      * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname"))
      * .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK)));
-     * 
+     *
      * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs"))
      * .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }")
      * .withStatus(HttpStatus.SC_OK)));
-     * 
+     *
      * wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse()
      * .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ")
      * .withStatus(HttpStatus.SC_OK)));
-     * 
+     *
      * instance.queryVnf("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new Holder<>(), new
      * Holder<>(), new Holder<>());
-     * 
+     *
      * }
      */
 
@@ -102,7 +102,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
         msoRequest.setServiceInstanceId("12345");
 
         instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
-                "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
+                "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
     }
 
     @Test
@@ -126,7 +126,7 @@ public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils {
                 .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK)));
 
         instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157",
-                "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
+                "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
     }
 
     @Test
index 0ac30cb..3bf784c 100644 (file)
@@ -211,7 +211,7 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils {
                 .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT)));
 
         instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157",
-                "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest, new Holder<>());
+                "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>());
     }
 
     @Test
index ede25c5..a68efbe 100644 (file)
@@ -134,8 +134,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
         expectedException.expect(VnfException.class);
         MsoRequest msoRequest = getMsoRequest();
         msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
-                "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
-                new Holder<Map<String, String>>());
+                "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
+                msoRequest, new Holder<Map<String, String>>());
     }
 
     @Test
@@ -152,8 +152,8 @@ public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils {
                                 .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR)));
         MsoRequest msoRequest = getMsoRequest();
         msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12",
-                "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", msoRequest,
-                new Holder<Map<String, String>>());
+                "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId",
+                msoRequest, new Holder<Map<String, String>>());
     }
 
     private MsoRequest getMsoRequest() {
index 9857adb..bc618e1 100644 (file)
@@ -879,6 +879,10 @@ public class VnfAdapterVfModuleObjectMapper {
         deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
         deleteVfModuleRequest.setVnfId(genericVnf.getVnfId());
         deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
+        if (vfModule.getModelInfoVfModule() != null) {
+            deleteVfModuleRequest
+                    .setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
+        }
         if (!StringUtils.isEmpty(vfModule.getHeatStackId())) {
             deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());// DoDVfMod_heatStackId
         } else {
index 1d2e7d0..9a39226 100644 (file)
@@ -1,12 +1,13 @@
-{      
+{
                "cloudSiteId" : "cloudRegionId",
-               "tenantId" : "tenantId",                
+               "tenantId" : "tenantId",
                "vnfId" :       "vnfId",
                "vfModuleId" : "vfModuleId",
                "vfModuleStackId" : "vfModuleName",
                "skipAAI" : true,
+               "modelCustomizationUuid": "vfModuleModelCustomizationUuid",
                "msoRequest" : {
                        "requestId" : "requestId",
-                       "serviceInstanceId" : "serviceInstanceId" 
+                       "serviceInstanceId" : "serviceInstanceId"
                }
 }
\ No newline at end of file