summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql22
-rw-r--r--adapters/mso-ve-vnfm-adapter/pom.xml22
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java4
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java82
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java67
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java36
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java35
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java48
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/exception/VeVnfmException.java28
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java53
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java67
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSender.java58
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties1
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml20
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java55
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java80
-rw-r--r--adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java97
-rw-r--r--adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java11
18 files changed, 768 insertions, 18 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
index f5c7cd65c2..ede499f9ee 100644
--- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql
@@ -873,3 +873,25 @@ VALUES
UPDATE vnf_recipe
SET ORCHESTRATION_URI = '/mso/async/services/WorkflowActionBB'
WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate';
+
+INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY, SECONDARY_POLICY, REG_EX_ERROR_MESSAGE, SERVICE_ROLE)
+VALUES
+('VNFCheckPserversLockedFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFCheckInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFSetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFCheckClosedLoopDisabledFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFSetClosedLoopDisabledFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFLockActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUpgradePreCheckActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFQuiesceTrafficActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFStopActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFSnapShotActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFStartActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUpgradeBackupActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUpgradeSoftwareActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUpgradePostCheckActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFResumeTrafficActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUnlockActivity','*','*','*','*','Manual','Abort','*', '*'),
+('SDNOVnfHealthCheckBB','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'),
+('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*');
diff --git a/adapters/mso-ve-vnfm-adapter/pom.xml b/adapters/mso-ve-vnfm-adapter/pom.xml
index 02abd600f8..3518445b45 100644
--- a/adapters/mso-ve-vnfm-adapter/pom.xml
+++ b/adapters/mso-ve-vnfm-adapter/pom.xml
@@ -30,15 +30,27 @@
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-actuator</artifactId>
- </dependency>
- <dependency>
<groupId>org.onap.so.adapters</groupId>
<artifactId>mso-vnfm-adapter-ext-clients</artifactId>
<version>${project.version}</version>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.so</groupId>
+ <artifactId>common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.core</groupId>
+ <artifactId>jersey-client</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.glassfish.jersey.inject</groupId>
+ <artifactId>jersey-hk2</artifactId>
+ </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
index c4ca5f1fe1..e4a6bed300 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/Application.java
@@ -23,10 +23,10 @@ package org.onap.so.adapters.vevnfm;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-@SpringBootApplication
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
public class Application {
- public static void main(String... args) {
+ public static void main(final String... args) {
SpringApplication.run(Application.class, args);
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java
new file mode 100644
index 0000000000..91a79b29bf
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiConnection.java
@@ -0,0 +1,82 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.aai;
+
+import java.util.List;
+import java.util.Optional;
+import org.onap.aai.domain.yang.EsrSystemInfo;
+import org.onap.aai.domain.yang.EsrVnfm;
+import org.onap.aai.domain.yang.EsrVnfmList;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIUriFactory;
+import org.onap.so.client.graphinventory.entities.uri.Depth;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AaiConnection {
+
+ private static final Logger logger = LoggerFactory.getLogger(AaiConnection.class);
+
+ private static final int FIRST_INDEX = 0;
+
+ public String receiveVnfm() {
+ final AAIResourcesClient resourcesClient = new AAIResourcesClient();
+ final Optional<EsrVnfmList> response =
+ resourcesClient.get(EsrVnfmList.class, AAIUriFactory.createResourceUri(AAIObjectType.VNFM_LIST));
+
+ if (response.isPresent()) {
+ final EsrVnfmList esrVnfmList = response.get();
+ logger.info("The VNFM replied with: {}", esrVnfmList);
+ final List<EsrVnfm> esrVnfm = esrVnfmList.getEsrVnfm();
+
+ if (esrVnfm.isEmpty()) {
+ return null;
+ }
+
+ final String vnfmId = esrVnfm.get(FIRST_INDEX).getVnfmId();
+ return receiveVnfmServiceUrl(resourcesClient, vnfmId);
+ }
+
+ return null;
+ }
+
+ private String receiveVnfmServiceUrl(final AAIResourcesClient resourcesClient, final String vnfmId) {
+ final Optional<EsrVnfm> response = resourcesClient.get(EsrVnfm.class,
+ AAIUriFactory.createResourceUri(AAIObjectType.VNFM, vnfmId).depth(Depth.ONE));
+
+ if (response.isPresent()) {
+ final EsrVnfm esrVnfm = response.get();
+ logger.info("The VNFM replied with: {}", esrVnfm);
+ final List<EsrSystemInfo> esrSystemInfo = esrVnfm.getEsrSystemInfoList().getEsrSystemInfo();
+
+ if (esrSystemInfo.isEmpty()) {
+ return null;
+ }
+
+ return esrSystemInfo.get(FIRST_INDEX).getServiceUrl();
+ }
+
+ return null;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java
new file mode 100644
index 0000000000..aa8c7f68c9
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/aai/AaiPropertiesExt.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.aai;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import org.onap.so.client.aai.AAIProperties;
+import org.onap.so.client.aai.AAIVersion;
+import org.onap.so.spring.SpringContextHelper;
+import org.springframework.context.ApplicationContext;
+
+public class AaiPropertiesExt implements AAIProperties {
+
+ private final String endpoint;
+ private final String encryptedBasicAuth;
+ private final String encryptionKey;
+
+ public AaiPropertiesExt() {
+ final ApplicationContext context = SpringContextHelper.getAppContext();
+ this.endpoint = context.getEnvironment().getProperty("aai.endpoint");
+ this.encryptedBasicAuth = context.getEnvironment().getProperty("aai.auth");
+ this.encryptionKey = context.getEnvironment().getProperty("mso.key");
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ return new URL(endpoint);
+ }
+
+ @Override
+ public String getSystemName() {
+ return "MSO";
+ }
+
+ @Override
+ public AAIVersion getDefaultVersion() {
+ return AAIVersion.V15;
+ }
+
+ @Override
+ public String getAuth() {
+ return encryptedBasicAuth;
+ }
+
+ @Override
+ public String getKey() {
+ return encryptionKey;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java
new file mode 100644
index 0000000000..108b2ee896
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.configuration;
+
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.onap.so.rest.service.HttpRestServiceProviderImpl;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.client.RestTemplate;
+
+@Configuration
+public class ApplicationConfiguration {
+
+ @Bean
+ public HttpRestServiceProvider restProvider(final RestTemplate restTemplate) {
+ return new HttpRestServiceProviderImpl(restTemplate);
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
new file mode 100644
index 0000000000..32c2559d7b
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/SecurityConfiguration.java
@@ -0,0 +1,35 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.configuration;
+
+import org.onap.so.security.SoBasicWebSecurityConfigurerAdapter;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+
+@Configuration
+public class SecurityConfiguration extends SoBasicWebSecurityConfigurerAdapter {
+
+ @Override
+ protected void configure(final HttpSecurity http) throws Exception {
+ http.authorizeRequests().antMatchers().permitAll().and().requestMatchers().antMatchers("/").and()
+ .authorizeRequests().anyRequest().authenticated();
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java
new file mode 100644
index 0000000000..f7b7283c59
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/StartupConfiguration.java
@@ -0,0 +1,48 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.configuration;
+
+import org.onap.so.adapters.vevnfm.service.StartupService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.context.event.ApplicationReadyEvent;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.event.EventListener;
+import org.springframework.core.env.Environment;
+import org.springframework.core.env.Profiles;
+
+@Configuration
+public class StartupConfiguration {
+
+ public static final String TEST_PROFILE = "test";
+
+ @Autowired
+ private Environment environment;
+
+ @Autowired
+ private StartupService startupService;
+
+ @EventListener(ApplicationReadyEvent.class)
+ public void onApplicationReadyEvent() throws Exception {
+ if (!environment.acceptsProfiles(Profiles.of(TEST_PROFILE))) {
+ startupService.run();
+ }
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/exception/VeVnfmException.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/exception/VeVnfmException.java
new file mode 100644
index 0000000000..abd9ff9d33
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/exception/VeVnfmException.java
@@ -0,0 +1,28 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.exception;
+
+public class VeVnfmException extends Exception {
+
+ public VeVnfmException(final String message) {
+ super(message);
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java
new file mode 100644
index 0000000000..7a9ec9659e
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java
@@ -0,0 +1,53 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.service;
+
+import org.apache.logging.log4j.util.Strings;
+import org.onap.so.adapters.vevnfm.aai.AaiConnection;
+import org.onap.so.adapters.vevnfm.exception.VeVnfmException;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class StartupService {
+
+ @Autowired
+ private AaiConnection aaiConnection;
+
+ @Autowired
+ private SubscriberService subscriberService;
+
+ private static void isValid(final String endpoint) throws VeVnfmException {
+ if (Strings.isBlank(endpoint)) {
+ throw new VeVnfmException("No 'url' field in VNFM info");
+ }
+ }
+
+ public void run() throws Exception {
+ final String endpoint = aaiConnection.receiveVnfm();
+ isValid(endpoint);
+ final boolean done = subscriberService.subscribe(endpoint);
+
+ if (!done) {
+ throw new VeVnfmException("Could not subscribe to VNFM");
+ }
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
new file mode 100644
index 0000000000..e413124b4b
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.service;
+
+import org.onap.so.adapters.vevnfm.subscription.SubscribeSender;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SubscriberService {
+
+ private static final char COLON = ':';
+
+ @Value("${notification.url}")
+ private String notificationUrl;
+
+ @Value("${server.port}")
+ private String serverPort;
+
+ @Value("${system.url}")
+ private String systemUrl;
+
+ @Autowired
+ private SubscribeSender sender;
+
+ public boolean subscribe(final String endpoint) {
+ final LccnSubscriptionRequest request = createRequest();
+ return sender.send(endpoint, request);
+ }
+
+ private LccnSubscriptionRequest createRequest() {
+ final LccnSubscriptionRequest request = new LccnSubscriptionRequest();
+ request.callbackUri(getCallbackUri());
+ final SubscriptionsAuthenticationParamsBasic paramsBasic = new SubscriptionsAuthenticationParamsBasic();
+ final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
+ authentication.setParamsBasic(paramsBasic);
+ request.authentication(authentication);
+
+ return request;
+ }
+
+ private String getCallbackUri() {
+ return systemUrl + COLON + serverPort + notificationUrl;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSender.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSender.java
new file mode 100644
index 0000000000..1b3a049bcf
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSender.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.subscription;
+
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.onap.so.rest.service.HttpRestServiceProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.stereotype.Component;
+
+@Component
+public class SubscribeSender {
+
+ private static final Logger logger = LoggerFactory.getLogger(SubscribeSender.class);
+
+ @Value("${vnfm.subscription}")
+ private String vnfmSubscription;
+
+ @Autowired
+ private HttpRestServiceProvider restProvider;
+
+ public boolean send(final String endpoint, final LccnSubscriptionRequest request) {
+ final ResponseEntity<String> response = restProvider.postHttpRequest(request, getUrl(endpoint), String.class);
+
+ final HttpStatus statusCode = response.getStatusCode();
+ final String body = response.getBody();
+
+ logger.info("The VNFM replied with the code {} and the body {}", statusCode, body);
+
+ return HttpStatus.CREATED == statusCode;
+ }
+
+ private String getUrl(final String endpoint) {
+ return endpoint + vnfmSubscription;
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-ve-vnfm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
new file mode 100644
index 0000000000..9fc8e62cf5
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties
@@ -0,0 +1 @@
+org.onap.so.adapters.vevnfm.aai.AaiPropertiesExt
diff --git a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
index 30b3955821..12197d737d 100644
--- a/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-ve-vnfm-adapter/src/main/resources/application.yaml
@@ -1,5 +1,5 @@
#
-# Copyright © 2019 Samsung.
+# Copyright © 2019, 2020 Samsung.
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,8 +14,24 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+server:
+ port: 8080
+
+system:
+ url: http://localhost
+
notification:
- url: /lcm/v1/vnf/instances/notifications
+ url: /lcm/v1/vnf/instances/notifications
+
+mso:
+ key: 07a7159d3bf51a0e53be7a8f89699be7
+
+aai:
+ endpoint: https://aai.onap:30233
+ auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE
+
+vnfm:
+ subscription: /vnflcm/v1/subscriptions
spring:
http:
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java
index c8d2a6bf90..418c2e2201 100644
--- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/controller/NotificationControllerTest.java
@@ -20,20 +20,59 @@
package org.onap.so.adapters.vevnfm.controller;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
import org.junit.Test;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpStatus;
-import org.springframework.http.ResponseEntity;
-import static org.junit.Assert.assertEquals;
+import org.springframework.http.MediaType;
+import org.springframework.mock.web.MockHttpServletResponse;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.servlet.MockMvc;
+import org.springframework.test.web.servlet.MvcResult;
+import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
+import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
+import org.springframework.test.web.servlet.setup.MockMvcBuilders;
+import org.springframework.web.context.WebApplicationContext;
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@ActiveProfiles(StartupConfiguration.TEST_PROFILE)
public class NotificationControllerTest {
- private final NotificationController controller = new NotificationController();
+ private static final String MINIMAL_JSON_CONTENT = "{}";
+ private static final int ZERO = 0;
+
+ @Value("${notification.url}")
+ private String notificationUrl;
+
+ @Autowired
+ private WebApplicationContext webApplicationContext;
+
+ private MockMvc mvc;
+
+ @Before
+ public void init() {
+ mvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
+ }
@Test
- public void testReceiveNotification() {
- final VnfLcmOperationOccurrenceNotification notification = new VnfLcmOperationOccurrenceNotification();
- final ResponseEntity response = controller.receiveNotification(notification);
- assertEquals(HttpStatus.OK, response.getStatusCode());
+ public void testReceiveNotification() throws Exception {
+ // given
+ final MockHttpServletRequestBuilder request = MockMvcRequestBuilders.post(notificationUrl)
+ .contentType(MediaType.APPLICATION_JSON).content(MINIMAL_JSON_CONTENT);
+
+ // when
+ final MvcResult mvcResult = mvc.perform(request).andReturn();
+
+ // then
+ final MockHttpServletResponse response = mvcResult.getResponse();
+ assertEquals(HttpStatus.OK.value(), response.getStatus());
+ assertEquals(ZERO, response.getContentLength());
}
}
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
new file mode 100644
index 0000000000..8c480d0415
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/StartupServiceTest.java
@@ -0,0 +1,80 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.service;
+
+import static org.mockito.Mockito.*;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.adapters.vevnfm.aai.AaiConnection;
+import org.onap.so.adapters.vevnfm.exception.VeVnfmException;
+
+@RunWith(MockitoJUnitRunner.class)
+public class StartupServiceTest {
+
+ @Mock
+ private AaiConnection aaiConnection;
+
+ @Mock
+ private SubscriberService subscriberService;
+
+ @InjectMocks
+ private StartupService startupService;
+
+ @Test
+ public void testSuccess() throws Exception {
+ // given
+ final String endpoint = "lh";
+
+ when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
+ when(subscriberService.subscribe(endpoint)).thenReturn(true);
+
+ // when
+ startupService.run();
+
+ // then
+ verify(aaiConnection, times(1)).receiveVnfm();
+ verify(subscriberService, times(1)).subscribe(endpoint);
+ }
+
+ @Test(expected = VeVnfmException.class)
+ public void testFailureAai() throws Exception {
+ // given
+ when(aaiConnection.receiveVnfm()).thenReturn(null);
+
+ // when
+ startupService.run();
+ }
+
+ @Test(expected = VeVnfmException.class)
+ public void testFailureSubscriber() throws Exception {
+ // given
+ final String endpoint = "lh";
+
+ when(aaiConnection.receiveVnfm()).thenReturn(endpoint);
+ when(subscriberService.subscribe(endpoint)).thenReturn(false);
+
+ // when
+ startupService.run();
+ }
+}
diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java
new file mode 100644
index 0000000000..62a624a983
--- /dev/null
+++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/subscription/SubscribeSenderTest.java
@@ -0,0 +1,97 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SO
+ * ================================================================================
+ * Copyright (C) 2020 Samsung. 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.so.adapters.vevnfm.subscription;
+
+import static org.junit.Assert.assertTrue;
+import static org.springframework.http.HttpHeaders.CONTENT_TYPE;
+import static org.springframework.test.web.client.ExpectedCount.once;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.*;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import org.hamcrest.CoreMatchers;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.http.HttpMethod;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.MediaType;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.test.web.client.MockRestServiceServer;
+import org.springframework.web.client.RestTemplate;
+
+@SpringBootTest
+@RunWith(SpringRunner.class)
+@ActiveProfiles(StartupConfiguration.TEST_PROFILE)
+public class SubscribeSenderTest {
+
+ private static final String SLASH = "/";
+ private static final String MINIMAL_JSON_CONTENT = "{}";
+
+ private static final Gson GSON;
+
+ static {
+ final GsonBuilder builder = new GsonBuilder();
+ builder.serializeNulls();
+ GSON = builder.create();
+ }
+
+ @Value("${vnfm.subscription}")
+ private String vnfmSubscription;
+
+ @Autowired
+ private SubscribeSender sender;
+
+ @Autowired
+ private RestTemplate restTemplate;
+
+ private MockRestServiceServer mockRestServer;
+
+ @Before
+ public void init() {
+ mockRestServer = MockRestServiceServer.bindTo(restTemplate).build();
+ }
+
+ @Test
+ public void testSuccess() {
+ // given
+ final String endpoint = "lh";
+ final LccnSubscriptionRequest request = new LccnSubscriptionRequest();
+
+ mockRestServer.expect(once(), requestTo(SLASH + endpoint + vnfmSubscription))
+ .andExpect(header(CONTENT_TYPE, CoreMatchers.containsString(MediaType.APPLICATION_JSON_VALUE)))
+ .andExpect(method(HttpMethod.POST)).andExpect(content().json(GSON.toJson(request)))
+ .andRespond(withStatus(HttpStatus.CREATED).body(MINIMAL_JSON_CONTENT));
+
+ // when
+ final boolean done = sender.send(endpoint, request);
+
+ // then
+ assertTrue(done);
+ mockRestServer.verify();
+ }
+}
diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java
index 181d114cc0..db70a6b5cb 100644
--- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java
+++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTask.java
@@ -4,6 +4,7 @@ import org.camunda.bpm.client.task.ExternalTask;
import org.camunda.bpm.client.task.ExternalTaskService;
import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerCallback;
import org.onap.so.adapters.appc.orchestrator.client.ApplicationControllerSupport;
+import org.onap.so.adapters.appc.orchestrator.client.StatusCategory;
import org.onap.so.appc.orchestrator.service.beans.ApplicationControllerTaskRequest;
import org.onap.so.externaltasks.logging.AuditMDCSetup;
import org.onap.so.utils.ExternalTaskUtils;
@@ -42,8 +43,16 @@ public class ApplicationControllerTask extends ExternalTaskUtils {
try {
status = applicationControllerTaskImpl.execute(msoRequestId, request, listener);
+ if (status != null && status.getCode() != 0
+ && !applicationControllerSupport.getCategoryOf(status).equals(StatusCategory.NORMAL)) {
+ logger.error("The External Task Id: {} Failed locally with status {}", externalTask.getId(),
+ status.getMessage());
+ externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", status.getMessage());
+ }
} catch (Exception e) {
- logger.error("Error while calling appc", e.getMessage());
+ logger.error("The External Task Id: {} Failed while calling appc with exception", externalTask.getId(),
+ e.getMessage());
+ externalTaskService.handleBpmnError(externalTask, "MSOWorkflowException", e.getMessage());
}
}