Merge "update INFO.yaml" into dublin
authorMarcus Williams <marcus.williams@intel.com>
Fri, 31 May 2019 18:02:00 +0000 (18:02 +0000)
committerGerrit Code Review <gerrit@onap.org>
Fri, 31 May 2019 18:02:00 +0000 (18:02 +0000)
12 files changed:
adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__WorkflowDesignerData.sql
adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java
adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java
adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
asdc-controller/src/main/java/org/onap/so/asdc/Application.java
asdc-controller/src/main/java/org/onap/so/asdc/activity/DeployActivitySpecs.java
asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java [new file with mode: 0644]
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmCreateJobTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/MonitorVnfmDeleteJobTask.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImpl.java
bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/mapper/VnfAdapterVfModuleObjectMapper.java
bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/adapter/vnfm/tasks/VnfmAdapterServiceProviderImplTest.java

index fd7fcd4..3f76334 100644 (file)
@@ -196,4 +196,10 @@ VALUES
 ((select ID from activity_spec where NAME='VNFUpgradeSoftwareActivity' and VERSION=1.0),
 (select ID from user_parameters where NAME='existing_software_version')),
 ((select ID from activity_spec where NAME='VNFUpgradeSoftwareActivity' and VERSION=1.0),
-(select ID from user_parameters where NAME='new_software_version'));
\ No newline at end of file
+(select ID from user_parameters where NAME='new_software_version'));
+
+INSERT INTO `workflow` (`ARTIFACT_UUID`,`ARTIFACT_NAME`,`NAME`,`OPERATION_NAME`,`VERSION`,`DESCRIPTION`,`RESOURCE_TARGET`,`SOURCE`)
+VALUES
+('9d45cd30-1a89-4993-87c1-6dd09c1696cf','VFModule-ScaleOut','VNF Scale Out','ScaleOut',1.0,'native static workflow to support ScaleOut','vfModule','native'),
+('da6478e4-ea33-3346-ac12-ab121284a333','VnfInPlaceUpdate.bpmn','VNF In Place Software Update','inPlaceSoftwareUpdate',1.0,'native static workflow to support inPlaceSoftwareUpdate','vnf','native'),
+('fdb3ac48-70f9-4584-bd92-253bdbdec1e1','VnfConfigUpdate.bpmn','VNF Config Update','applyConfigModify',1.0,'native static workflow to support applyConfigModify','vnf','native');
\ No newline at end of file
index 164f12e..2aee1c0 100644 (file)
 
 package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
 
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import com.google.gson.Gson;
+import java.util.Iterator;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON;
 import org.onap.so.configuration.rest.BasicHttpHeadersProvider;
 import org.onap.so.configuration.rest.HttpHeadersProvider;
 import org.onap.so.rest.service.HttpRestServiceProvider;
@@ -32,8 +36,6 @@ import org.springframework.http.converter.HttpMessageConverter;
 import org.springframework.http.converter.json.GsonHttpMessageConverter;
 import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
 import org.springframework.web.client.RestTemplate;
-import java.util.Iterator;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
 
 /**
  * Configures the HttpRestServiceProvider for REST call to a VNFM.
@@ -60,7 +62,8 @@ public class VnfmServiceProviderConfiguration {
                 iterator.remove();
             }
         }
-        restTemplate.getMessageConverters().add(new GsonHttpMessageConverter());
+        final Gson gson = new JSON().getGson();
+        restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson));
     }
 
 }
index 345ff51..b3552c7 100644 (file)
@@ -93,6 +93,10 @@ public class JobManager {
 
         logger.debug("Job Id: " + jobId + ", operationId: " + operation.getId() + ", operation details: " + operation);
 
+        if (operation.getOperationState() == null) {
+            return response.operationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.WAITING_FOR_STATUS);
+        }
+
         response.setOperationStatusRetrievalStatus(OperationStatusRetrievalStatusEnum.STATUS_FOUND);
         response.setId(operation.getId());
         response.setOperation(OperationEnum.fromValue(operation.getOperation().getValue()));
index 73a49e9..b48de30 100644 (file)
@@ -52,6 +52,7 @@ import org.onap.aai.domain.yang.RelationshipData;
 import org.onap.aai.domain.yang.RelationshipList;
 import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
 import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON;
 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
 import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
@@ -115,7 +116,7 @@ public class VnfmAdapterControllerTest {
 
     @Autowired
     VnfmAdapterController controller;
-    Gson gson = new Gson();
+    Gson gson = new JSON().getGson();
 
     @Before
     public void setUp() throws Exception {
index a05eeea..eb2957c 100644 (file)
@@ -22,6 +22,8 @@ package org.onap.so.asdc;
 
 import javax.annotation.PostConstruct;
 import org.onap.so.asdc.activity.DeployActivitySpecs;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -32,7 +34,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
 @EnableScheduling
 @EnableJpaRepositories("org.onap.so.db.catalog.data.repository")
 public class Application {
-
+    private static final Logger logger = LoggerFactory.getLogger(Application.class);
     private static final String MSO_CONFIG_PATH = "mso.config.path";
     private static final String LOGS_DIR = "logs_dir";
 
@@ -55,6 +57,7 @@ public class Application {
         try {
             deployActivitySpecs.deployActivities();
         } catch (Exception e) {
+            logger.warn("{} {}", "Exception on deploying activitySpecs: ", e.getMessage());
         }
 
     }
index 87008f1..54da1b9 100644 (file)
@@ -25,6 +25,7 @@ import java.util.List;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
 import org.onap.so.asdc.activity.beans.ActivitySpec;
 import org.onap.so.asdc.activity.beans.Input;
 import org.onap.so.asdc.activity.beans.Output;
@@ -52,14 +53,16 @@ public class DeployActivitySpecs {
 
     protected static final Logger logger = LoggerFactory.getLogger(DeployActivitySpecs.class);
 
-
+    @Transactional
     public void deployActivities() throws Exception {
         String hostname = env.getProperty(SDC_ENDPOINT);
+        logger.debug("{} {}", "SDC ActivitySpec endpoint: ", hostname);
         if (hostname == null || hostname.isEmpty()) {
             return;
         }
         List<org.onap.so.db.catalog.beans.ActivitySpec> activitySpecsFromCatalog = activitySpecRepository.findAll();
         for (org.onap.so.db.catalog.beans.ActivitySpec activitySpecFromCatalog : activitySpecsFromCatalog) {
+            logger.debug("{} {}", "Attempting to create activity ", activitySpecFromCatalog.getName());
             ActivitySpec activitySpec = mapActivitySpecFromCatalogToSdc(activitySpecFromCatalog);
             String activitySpecId = activitySpecsActions.createActivitySpec(hostname, activitySpec);
             if (activitySpecId != null) {
diff --git a/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java b/asdc-controller/src/test/java/org/onap/asdc/activity/DeployActivitySpecsITTest.java
new file mode 100644 (file)
index 0000000..81977da
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.asdc.activity;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
+import static com.github.tomakehurst.wiremock.client.WireMock.post;
+import static com.github.tomakehurst.wiremock.client.WireMock.put;
+import static com.github.tomakehurst.wiremock.client.WireMock.urlPathMatching;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.when;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.onap.so.asdc.BaseTest;
+import org.onap.so.asdc.activity.DeployActivitySpecs;
+import org.onap.so.asdc.activity.beans.ActivitySpecCreateResponse;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.core.env.Environment;
+import org.springframework.http.HttpHeaders;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import javax.ws.rs.core.MediaType;
+
+public class DeployActivitySpecsITTest extends BaseTest {
+    @Mock
+    protected Environment env;
+
+    @Value("${wiremock.server.port}")
+    private String wiremockPort;
+
+    @Autowired
+    private DeployActivitySpecs deployActivitySpecs;
+
+    @Test
+    public void deployActivitySpecsIT_Test() throws Exception {
+        ActivitySpecCreateResponse activitySpecCreateResponse = new ActivitySpecCreateResponse();
+        activitySpecCreateResponse.setId("testActivityId");
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Accept", MediaType.APPLICATION_JSON);
+        headers.set("Content-Type", MediaType.APPLICATION_JSON);
+
+        ObjectMapper mapper = new ObjectMapper();
+        String body = mapper.writeValueAsString(activitySpecCreateResponse);
+
+        wireMockServer.stubFor(post(urlPathMatching("/v1.0/activity-spec"))
+                .willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withStatus(org.springframework.http.HttpStatus.OK.value()).withBody(body)));
+
+        when(env.getProperty("mso.asdc.config.activity.endpoint")).thenReturn("http://localhost:8090");
+
+        String urlPath = "/v1.0/activity-spec/testActivityId/versions/latest/actions";
+
+        wireMockServer.stubFor(
+                put(urlPathMatching(urlPath)).willReturn(aResponse().withHeader("Content-Type", "application/json")
+                        .withStatus(org.springframework.http.HttpStatus.OK.value())));
+
+        deployActivitySpecs.deployActivities();
+        assertTrue(activitySpecCreateResponse.getId().equals("testActivityId"));
+    }
+}
index 4645680..4c84bca 100644 (file)
@@ -55,11 +55,18 @@ public class MonitorVnfmCreateJobTask extends MonitorVnfmJobTask {
      * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
      */
     public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
-        LOGGER.debug("Executing getCurrentOperationStatus  ...");
-        final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
-        execution.setVariable(OPERATION_STATUS_PARAM_NAME,
-                getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
-        LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        try {
+            LOGGER.debug("Executing getCurrentOperationStatus  ...");
+            final CreateVnfResponse vnfInstantiateResponse = execution.getVariable(CREATE_VNF_RESPONSE_PARAM_NAME);
+            execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+                    getOperationStatus(execution, vnfInstantiateResponse.getJobId()));
+            LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        } catch (final Exception exception) {
+            final String message = "Unable to invoke get current Operation status";
+            LOGGER.error(message);
+            exceptionUtil.buildAndThrowWorkflowException(execution, 1209, message);
+
+        }
     }
 
     /**
index e91f362..34e3efa 100644 (file)
@@ -56,10 +56,18 @@ public class MonitorVnfmDeleteJobTask extends MonitorVnfmJobTask {
      * @param execution {@link org.onap.so.bpmn.common.DelegateExecutionImpl}
      */
     public void getCurrentOperationStatus(final BuildingBlockExecution execution) {
-        LOGGER.debug("Executing getCurrentOperationStatus  ...");
-        final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
-        execution.setVariable(OPERATION_STATUS_PARAM_NAME, getOperationStatus(execution, deleteVnfResponse.getJobId()));
-        LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        try {
+            LOGGER.debug("Executing getCurrentOperationStatus  ...");
+            final DeleteVnfResponse deleteVnfResponse = execution.getVariable(Constants.DELETE_VNF_RESPONSE_PARAM_NAME);
+            execution.setVariable(OPERATION_STATUS_PARAM_NAME,
+                    getOperationStatus(execution, deleteVnfResponse.getJobId()));
+            LOGGER.debug("Finished executing getCurrentOperationStatus ...");
+        } catch (final Exception exception) {
+            final String message = "Unable to invoke get current Operation status";
+            LOGGER.error(message);
+            exceptionUtil.buildAndThrowWorkflowException(execution, 1216, message);
+
+        }
     }
 
     /**
index f193967..4a51891 100644 (file)
@@ -145,7 +145,7 @@ public class VnfmAdapterServiceProviderImpl implements VnfmAdapterServiceProvide
             return Optional.of(response.getBody());
         } catch (final RestProcessingException | InvalidRestRequestException httpInvocationException) {
             LOGGER.error("Unexpected error while processing job request", httpInvocationException);
-            return Optional.absent();
+            throw httpInvocationException;
         }
     }
 }
index 94e9568..b0ba059 100644 (file)
@@ -205,14 +205,22 @@ public class VnfAdapterVfModuleObjectMapper {
     private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive,
             Map<String, Object> srcMap) {
         StringBuilder directives = new StringBuilder();
-        if (srcMap.size() > 0) {
+        int no_directives_size = 0;
+        if (directives.equals(MsoMulticloudUtils.USER_DIRECTIVES)
+                && srcMap.containsKey(MsoMulticloudUtils.OOF_DIRECTIVES)) {
+            no_directives_size = 1;
+        }
+        if (srcMap.size() > no_directives_size) {
             directives.append("{ \"attributes\": [ ");
             int i = 0;
             for (String attributeName : srcMap.keySet()) {
-                directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString()));
-                if (i < (srcMap.size() - 1))
-                    directives.append(", ");
-                i++;
+                if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directives)
+                        && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) {
+                    directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString()));
+                    if (i < (srcMap.size() - 1 + no_directives_size))
+                        directives.append(", ");
+                    i++;
+                }
             }
             directives.append("] }");
         } else {
index 7bd6435..e94d7c2 100644 (file)
@@ -228,7 +228,7 @@ public class VnfmAdapterServiceProviderImplTest {
         assertFalse(actual.isPresent());
     }
 
-    @Test
+    @Test(expected = RestProcessingException.class)
     public void testGetInstantiateOperationJobStatus_Exception() {
 
         when(mockedHttpServiceProvider.getHttpResponse(eq(TestConstants.JOB_STATUS_EXPECTED_URL),
@@ -237,8 +237,7 @@ public class VnfmAdapterServiceProviderImplTest {
         final VnfmAdapterServiceProvider objUnderTest =
                 new VnfmAdapterServiceProviderImpl(getVnfmAdapterUrlProvider(), mockedHttpServiceProvider);
 
-        final Optional<QueryJobResponse> actual = objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
-        assertFalse(actual.isPresent());
+        objUnderTest.getInstantiateOperationJobStatus(DUMMY_JOB_ID);
     }
 
     private QueryJobResponse getQueryJobResponse() {