diff options
Diffstat (limited to 'adapters')
72 files changed, 1002 insertions, 477 deletions
diff --git a/adapters/etsi-sol002-adapter/pom.xml b/adapters/etsi-sol002-adapter/pom.xml index b419d8806b..5dee8fe8e6 100644 --- a/adapters/etsi-sol002-adapter/pom.xml +++ b/adapters/etsi-sol002-adapter/pom.xml @@ -17,12 +17,6 @@ <name>ETSI SOL002 Application Jar</name> - <properties> - <java.version>1.8</java.version> - <maven.compiler.source>${java.version}</maven.compiler.source> - <maven.compiler.target>${java.version}</maven.compiler.target> - </properties> - <dependencies> <dependency> <groupId>org.springframework.boot</groupId> @@ -88,6 +82,18 @@ </executions> </plugin> </plugins> + <resources> + <resource> + <directory>${basedir}/src/main/resources</directory> + <excludes> + <exclude>certs/*</exclude> + </excludes> + </resource> + <resource> + <directory>${basedir}/src/main/resources/certs</directory> + <filtering>false</filtering> + </resource> + </resources> </build> </project> diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java index 411572ff5b..38f7a0cd3f 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ApplicationConfiguration.java @@ -20,17 +20,44 @@ package org.onap.so.adapters.vevnfm.configuration; +import java.io.IOException; +import java.security.*; +import java.security.cert.CertificateException; +import javax.net.ssl.SSLContext; +import org.apache.http.client.HttpClient; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.ssl.SSLContextBuilder; import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; +import org.springframework.http.client.BufferingClientHttpRequestFactory; +import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.web.client.RestTemplate; @Configuration public class ApplicationConfiguration { + private static final Logger logger = LoggerFactory.getLogger(ApplicationConfiguration.class); + + private final Resource clientKeyStore; + private final String clientKeyStorePassword; + private final Resource clientTrustStore; + private final String clientTrustStorePassword; + + public ApplicationConfiguration(final ConfigProperties configProperties) { + clientKeyStore = configProperties.getClientKeyStore(); + clientKeyStorePassword = configProperties.getClientKeyStorePassword(); + clientTrustStore = configProperties.getClientTrustStore(); + clientTrustStorePassword = configProperties.getClientTrustStorePassword(); + } + @Bean public AuthorizationHeadersProvider headersProvider() { return new AuthorizationHeadersProvider(); @@ -39,6 +66,35 @@ public class ApplicationConfiguration { @Bean public HttpRestServiceProvider restProvider(final RestTemplate restTemplate, final HttpHeadersProvider headersProvider) { + modify(restTemplate); return new HttpRestServiceProviderImpl(restTemplate, headersProvider); } + + private void modify(final RestTemplate restTemplate) { + + if (clientKeyStore == null || clientTrustStore == null) { + return; + } + + try { + final KeyStore keystore = KeyStore.getInstance("PKCS12"); + keystore.load(clientKeyStore.getInputStream(), clientKeyStorePassword.toCharArray()); + + final SSLContext sslContext = new SSLContextBuilder() + .loadTrustMaterial(clientTrustStore.getURL(), clientTrustStorePassword.toCharArray()) + .loadKeyMaterial(keystore, clientKeyStorePassword.toCharArray()).build(); + + logger.info("Setting truststore: {}", clientTrustStore.getURL()); + + final SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(sslContext); + final HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build(); + final HttpComponentsClientHttpRequestFactory factory = + new HttpComponentsClientHttpRequestFactory(httpClient); + + restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(factory)); + } catch (KeyManagementException | NoSuchAlgorithmException | KeyStoreException | CertificateException + | IOException | UnrecoverableKeyException e) { + logger.error("Error reading truststore, TLS connection to VNFM will fail.", e); + } + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java index d4ca5af0f2..a8a436ddc6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/configuration/ConfigProperties.java @@ -23,6 +23,7 @@ package org.onap.so.adapters.vevnfm.configuration; import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Configuration; +import org.springframework.core.io.Resource; @Configuration public class ConfigProperties { @@ -72,6 +73,18 @@ public class ConfigProperties { @Value("${spring.security.usercredentials[0].openpass}") private String springSecurityOpenpass; + @Value("${client.key-store:#{null}}") + private Resource clientKeyStore; + + @Value("${client.key-store-password:#{null}}") + private String clientKeyStorePassword; + + @Value("${client.trust-store:#{null}}") + private Resource clientTrustStore; + + @Value("${client.trust-store-password:#{null}}") + private String clientTrustStorePassword; + public String getVevnfmadapterVnfFilterJson() { return vevnfmadapterVnfFilterJson; } @@ -131,4 +144,20 @@ public class ConfigProperties { public String getSpringSecurityOpenpass() { return springSecurityOpenpass; } + + public Resource getClientKeyStore() { + return clientKeyStore; + } + + public String getClientKeyStorePassword() { + return clientKeyStorePassword; + } + + public Resource getClientTrustStore() { + return clientTrustStore; + } + + public String getClientTrustStorePassword() { + return clientTrustStorePassword; + } } diff --git a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java index c128275e43..eba1d087c6 100644 --- a/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java +++ b/adapters/etsi-sol002-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/StartupService.java @@ -28,7 +28,6 @@ import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.retry.annotation.Backoff; import org.springframework.retry.annotation.EnableRetry; import org.springframework.retry.annotation.Recover; @@ -44,7 +43,6 @@ public class StartupService { private final String vnfmDefaultEndpoint; private final AaiConnection aaiConnection; - @Autowired public StartupService(final ConfigProperties configProperties, final AaiConnection aaiConnection) { this.vnfmDefaultEndpoint = configProperties.getVnfmDefaultEndpoint(); this.aaiConnection = aaiConnection; diff --git a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml index c69c95187a..f5b6bc3158 100644 --- a/adapters/etsi-sol002-adapter/src/main/resources/application.yaml +++ b/adapters/etsi-sol002-adapter/src/main/resources/application.yaml @@ -19,17 +19,23 @@ server: vevnfmadapter: vnf-filter-json: '{notificationTypes:[VnfLcmOperationOccurrenceNotification],operationStates:[COMPLETED]}' - endpoint: http://so-ve-vnfm-adapter.onap:9098 + endpoint: http://so-ve-vnfm-adapter:9098 + +client: + key-store: classpath:ve-vnfm-adapter.p12 + key-store-password: 'ywsqCy:EEo#j}HJHM7z^Rk[L' + trust-store: classpath:org.onap.so.trust.jks + trust-store-password: ',sx#.C*W)]wVgJC6ccFHI#:H' mso: key: 07a7159d3bf51a0e53be7a8f89699be7 aai: - endpoint: https://aai.onap:30233 + endpoint: https://aai:30233 auth: 75C4483F9C05E2C33A8602635FA532397EC44AB667A2B64DED4FEE08DD932F2E3C1FEE vnfm: - default-endpoint: https://so-vnfm-simulator.onap:9093 + default-endpoint: https://so-vnfm-simulator:9093 subscription: /vnflcm/v1/subscriptions notification: /lcm/v1/vnf/instances/notifications @@ -37,7 +43,7 @@ notification: vnf-filter-type: NONE dmaap: - endpoint: http://message-router.onap:30227 + endpoint: http://message-router:30227 topic: /events/unauthenticated.DCAE_CL_OUTPUT closed-loop: control: diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks Binary files differnew file mode 100644 index 0000000000..1f0d8a550a --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/org.onap.so.trust.jks diff --git a/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 Binary files differnew file mode 100644 index 0000000000..ae4fddc684 --- /dev/null +++ b/adapters/etsi-sol002-adapter/src/main/resources/certs/ve-vnfm-adapter.p12 diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml index f1f8bb5a70..e8b1fd08e6 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-adapter-application</artifactId> <name>ETSI SOL003 Application Jar</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml index 9c88f6a546..391a5c622d 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-adapter-common</artifactId> <name>ETSI SOL003 Adapter Common</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java index b9ce641096..6161fa60f9 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/AbstractServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/AbstractServiceProviderConfiguration.java @@ -1,27 +1,25 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2020 Ericsson. 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. - * + * * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ - -package org.onap.so.adapters.etsisol003adapter.lcm.extclients; +package org.onap.so.adapters.etsi.sol003.adapter.common.configuration; import java.util.Iterator; -import org.onap.so.adapters.etsisol003adapter.lcm.v1.JSON; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; @@ -33,6 +31,7 @@ import com.google.gson.Gson; * that will be useful to some such classes. * * @author gareth.roper@est.tech + * @author Waqas Ikram (waqas.ikram@est.tech) */ public abstract class AbstractServiceProviderConfiguration { @@ -43,7 +42,9 @@ public abstract class AbstractServiceProviderConfiguration { iterator.remove(); } } - final Gson gson = new JSON().getGson(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(getGson())); } + + protected abstract Gson getGson(); + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml index 560cd87bee..8359fd3829 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-adapter</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter</name> @@ -106,4 +106,4 @@ <scope>test</scope> </dependency> </dependencies> -</project>
\ No newline at end of file +</project> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java index e35dafb4ea..da727b395a 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -39,7 +39,8 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.ssl.SSLContextBuilder; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.so.adapters.etsisol003adapter.lcm.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsisol003adapter.lcm.v1.JSON; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; @@ -55,6 +56,7 @@ import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; import org.springframework.security.oauth2.client.OAuth2RestTemplate; import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; /** * Configures the HttpRestServiceProvider for REST call to a VNFM. @@ -151,4 +153,9 @@ public class VnfmServiceProviderConfiguration extends AbstractServiceProviderCon } } + @Override + protected Gson getGson() { + return new JSON().getGson(); + } + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml index f6789575c6..01ba94ddd4 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-api</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter API</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml index 5452b578a7..14e8a600b5 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-lcm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm-ext-clients</artifactId> <name>ETSI SOL003 Life Cycle Management Adapter Ext Clients</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml index e3f87680d8..5bcc43f2bd 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-lcm</artifactId> <name>ETSI SOL003 Life Cycle Management</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml index 250ac504c7..fd4dc0d972 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-adapter</artifactId> <name>ETSI SOL003 VNF Package Management Adapter</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java deleted file mode 100644 index f9da6981c8..0000000000 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/AbstractServiceProviderConfiguration.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. - * ================================================================================ - * 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. - * - * SPDX-License-Identifier: Apache-2.0 - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.etsisol003adapter.pkgm.extclients; - -import java.time.LocalDateTime; -import java.util.Iterator; -import org.onap.so.adapters.etsisol003adapter.pkgm.JSON; -import org.onap.so.adapters.etsisol003adapter.pkgm.rest.EtsiSubscriptionNotificationController; -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 org.threeten.bp.OffsetDateTime; -import com.google.gson.Gson; - -/** - * A base class that can be extended by classes for configuring HttpRestServiceProvider classes. Provides common methods - * that will be useful to some such classes. - * - * @author gareth.roper@est.tech - */ -public abstract class AbstractServiceProviderConfiguration { - private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); - - public void setGsonMessageConverter(final RestTemplate restTemplate) { - final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); - while (iterator.hasNext()) { - if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { - iterator.remove(); - } - } - final Gson gson = JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) - .registerTypeAdapter(LocalDateTime.class, - new EtsiSubscriptionNotificationController.LocalDateTimeTypeAdapter()) - .create(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); - } -} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 5caeebe53d..1ff3672df9 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -25,7 +25,6 @@ import java.security.KeyManagementException; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; import java.security.cert.CertificateException; -import java.util.Iterator; import java.util.concurrent.TimeUnit; import javax.net.ssl.HostnameVerifier; import javax.net.ssl.SSLContext; @@ -40,7 +39,7 @@ import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContextBuilder; import org.onap.logging.filter.spring.SpringClientPayloadFilter; -import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpClientConnectionConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; @@ -56,12 +55,8 @@ import org.springframework.context.annotation.Configuration; import org.springframework.core.io.Resource; import org.springframework.http.client.BufferingClientHttpRequestFactory; import org.springframework.http.client.HttpComponentsClientHttpRequestFactory; -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 com.google.gson.Gson; -import com.google.gson.GsonBuilder; /** * Configures the HttpRestServiceProvider to make REST calls to the ETSI Catalog Manager @@ -173,15 +168,9 @@ public class EtsiCatalogServiceProviderConfiguration extends AbstractServiceProv } - public void setGsonMessageConverter(final RestTemplate restTemplate) { - final Iterator<HttpMessageConverter<?>> iterator = restTemplate.getMessageConverters().iterator(); - while (iterator.hasNext()) { - if (iterator.next() instanceof MappingJackson2HttpMessageConverter) { - iterator.remove(); - } - } - final Gson gson = new GsonBuilder().create(); - restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + @Override + protected Gson getGson() { + return new JSON().getGson(); } } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java index 568c3df48b..22bbef9c01 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-adapter/src/main/java/org/onap/so/adapters/etsisol003adapter/pkgm/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java @@ -20,7 +20,11 @@ package org.onap.so.adapters.etsisol003adapter.pkgm.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import org.onap.so.adapters.etsisol003adapter.pkgm.extclients.AbstractServiceProviderConfiguration; +import java.time.LocalDateTime; +import java.time.OffsetDateTime; +import org.onap.so.adapters.etsi.sol003.adapter.common.configuration.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsisol003adapter.pkgm.JSON; +import org.onap.so.adapters.etsisol003adapter.pkgm.rest.EtsiSubscriptionNotificationController; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; @@ -29,6 +33,7 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; /** * @author Waqas Ikram (waqas.ikram@est.tech) @@ -36,6 +41,8 @@ import org.springframework.web.client.RestTemplate; */ @Configuration public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProviderConfiguration { + private final JSON.OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new JSON.OffsetDateTimeTypeAdapter(); + public static final String VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN = "vnfmAdapterHttpServiceProvider"; @Bean @@ -46,4 +53,12 @@ public class VnfmHttpServiceProviderConfiguration extends AbstractServiceProvide return new HttpRestServiceProviderImpl(restTemplate, new BasicHttpHeadersProvider().getHttpHeaders()); } + @Override + protected Gson getGson() { + return JSON.createGson().registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDateTime.class, + new EtsiSubscriptionNotificationController.LocalDateTimeTypeAdapter()) + .create(); + } + } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml index 884419c550..8d79aff29d 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-api/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-api</artifactId> <name>ETSI SOL003 VNF Package Management Adapter API</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml index 6e6de84b5f..f34fb61802 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/etsi-sol003-pkgm-ext-clients/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-pkgm</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm-ext-clients</artifactId> <name>ETSI SOL003 VNF Package Management Adapter Ext Clients</name> diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml index fb5b636ee4..37f9e2efee 100644 --- a/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-pkgm/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>etsi-sol003-pkgm</artifactId> <name>ETSI SOL003 VNF Package Management</name> diff --git a/adapters/etsi-sol003-adapter/pom.xml b/adapters/etsi-sol003-adapter/pom.xml index 6c3a1f5b1c..ceaaab42d0 100644 --- a/adapters/etsi-sol003-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>etsi-sol003-adapter</artifactId> @@ -16,10 +16,10 @@ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <version-swagger-codegen>2.3.1</version-swagger-codegen> <gson-fire-version>1.8.2</gson-fire-version> - <retrofit-version>2.3.0</retrofit-version> + <retrofit-version>2.7.2</retrofit-version> <threetenbp-version>1.3.5</threetenbp-version> <oltu-version>1.0.1</oltu-version> - <swagger-core-version>1.5.15</swagger-core-version> + <swagger-core-version>1.5.21</swagger-core-version> <okhttp3-version>3.14.0</okhttp3-version> <okhttp-version>2.7.5</okhttp-version> <okio-version>1.13.0</okio-version> @@ -32,4 +32,4 @@ <module>etsi-sol003-lcm</module> <module>etsi-sol003-adapter-application</module> </modules> -</project>
\ No newline at end of file +</project> diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index a121d2d89b..6346983f96 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapter-utils</artifactId> @@ -113,12 +113,6 @@ <scope>provided</scope> </dependency> <dependency> - <groupId>org.jmockit</groupId> - <artifactId>jmockit</artifactId> - <version>1.8</version> - <scope>test</scope> - </dependency> - <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> </dependency> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java index 2f7d19ff1d..cc79e615f1 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java @@ -24,12 +24,14 @@ import org.springframework.cache.CacheManager; import org.springframework.cache.caffeine.CaffeineCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; import com.github.benmanes.caffeine.cache.Caffeine; @Configuration public class NovaCacheConfig { @Bean + @Primary public CacheManager cacheManager() { CaffeineCacheManager cacheManager = new CaffeineCacheManager("novaClient"); cacheManager.setCaffeine(caffeineCacheBuilder()); diff --git a/adapters/mso-adapters-rest-interface/pom.xml b/adapters/mso-adapters-rest-interface/pom.xml index 584c47fea6..9e86f41af3 100644 --- a/adapters/mso-adapters-rest-interface/pom.xml +++ b/adapters/mso-adapters-rest-interface/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-adapters-rest-interface</artifactId> @@ -18,7 +18,8 @@ <plugins> <plugin> <artifactId>maven-jar-plugin</artifactId> - <version>2.6</version> + <!--<version>2.6</version>--> + <version>3.0.2</version> <configuration> <classesDirectory>target/classes</classesDirectory> </configuration> diff --git a/adapters/mso-catalog-db-adapter/pom.xml b/adapters/mso-catalog-db-adapter/pom.xml index 8735f98804..9b51e35c57 100644 --- a/adapters/mso-catalog-db-adapter/pom.xml +++ b/adapters/mso-catalog-db-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -13,7 +13,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <java.version>1.8</java.version> <swagger.version>2.0.8</swagger.version> </properties> <build> @@ -39,6 +38,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -53,19 +55,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <fork>true</fork> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> @@ -84,14 +73,14 @@ </plugin> </plugins> <pluginManagement> - <plugins> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> @@ -186,7 +175,12 @@ <dependency> <groupId>uk.co.blackpepper.bowman</groupId> <artifactId>bowman-client</artifactId> - <version>0.3.0</version> + <version>${bowman.client.version}</version> + </dependency> + <dependency> + <groupId>org.javassist</groupId> + <artifactId>javassist</artifactId> + <version>3.25.0-GA</version> </dependency> <dependency> <groupId>ch.vorburger.mariaDB4j</groupId> diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java index fdec7cf5d6..4d8f55e220 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/CatalogDbRepositoryConfiguration.java @@ -20,8 +20,8 @@ package org.onap.so.adapters.catalogdb; -import java.util.stream.Collectors; import javax.persistence.EntityManager; +import javax.persistence.metamodel.Type; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Configuration; import org.springframework.data.rest.core.config.RepositoryRestConfiguration; @@ -35,8 +35,8 @@ public class CatalogDbRepositoryConfiguration extends RepositoryRestConfigurerAd @Override public void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) { - config.exposeIdsFor(entityManager.getMetamodel().getEntities().stream().map(e -> e.getJavaType()) - .collect(Collectors.toList()).toArray(new Class[0])); + config.exposeIdsFor( + entityManager.getMetamodel().getEntities().stream().map(Type::getJavaType).toArray(Class[]::new)); } } diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java index f283af1ba6..aa039c6ac4 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/CatalogDbAdapterRest.java @@ -655,4 +655,36 @@ public class CatalogDbAdapterRest { return Response.status(HttpStatus.SC_NOT_FOUND).header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON) .build(); } + + @GET + @Path("processingFlags") + @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) + @Transactional(readOnly = true) + public Response getAllProcessingFlags() { + return getAllProcessingFlagsImpl(); + } + + public Response getAllProcessingFlagsImpl() { + List<ProcessingFlags> processingFlags = null; + + int respStatus = HttpStatus.SC_OK; + try { + processingFlags = processingFlagsRepo.findAll(); + if (processingFlags == null) { + logger.debug("ProcessingFlags not found"); + respStatus = HttpStatus.SC_NOT_FOUND; + } else { + + logger.debug("ProcessingFlags processingFlags = {}", processingFlags.toString()); + } + return Response.status(respStatus).entity(processingFlags) + .header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON).build(); + } catch (Exception e) { + logger.error("Exception - queryProcesssingFlags", e); + CatalogQueryException excResp = new CatalogQueryException(e.getMessage(), + CatalogQueryExceptionCategory.INTERNAL, Boolean.FALSE, null); + return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .entity(new GenericEntity<CatalogQueryException>(excResp) {}).build(); + } + } } 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 a5e546e093..ea371f54f7 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 @@ -68,32 +68,33 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('Service-Macro-Create', '7', 'ConfigAssignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Create', '8', 'AssignPnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Create', '9', 'WaitForPnfReadyBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '10', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '11', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '12', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '13', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '14', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '15', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '16', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '17', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '18', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '19', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Create', '20', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '11', 'ActivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '12', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '13', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '14', 'CreateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '15', 'ActivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '16', 'CreateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '17', 'ActivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '18', 'ConfigDeployVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '19', 'ActivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '20', 'ActivateNetworkCollectionBB',1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Create', '21', 'ActivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '1', 'DeactivateVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '2', 'DeleteVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '3', 'DeactivateVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '4', 'DeleteVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Service-Macro-Delete', '5', 'DeactivateVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '6', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '7', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '8', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '9', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '10', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '11', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '12', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '13', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '14', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), -('Service-Macro-Delete', '15', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '6', 'DeactivatePnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '7', 'DeactivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '8', 'DeleteNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '9', 'DeactivateNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '10', 'DeleteNetworkCollectionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '11', 'DeactivateServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '12', 'UnassignVfModuleBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '13', 'UnassignVolumeGroupBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '14', 'UnassignVnfBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '15', 'UnassignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), +('Service-Macro-Delete', '16', 'UnassignServiceInstanceBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Delete' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '1', 'AssignNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '2', 'CreateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), ('Network-Create', '3', 'ActivateNetworkBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Network-Create' and CLOUD_OWNER = 'DEFAULT')), @@ -210,6 +211,9 @@ INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FL ('VNF-Config-Update', '8', 'VNFUnsetInMaintFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')), ('VNF-Config-Update', '9', 'VNFUnsetClosedLoopDisabledFlagActivity', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VNF-Config-Update' and CLOUD_OWNER = 'DEFAULT')); +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES +('Service-Macro-Create', '10', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'Service-Macro-Create' and CLOUD_OWNER = 'DEFAULT'), 'pnf', 'config-assign'); + INSERT INTO rainy_day_handler_macro (FLOW_NAME, SERVICE_TYPE, VNF_TYPE, ERROR_CODE, WORK_STEP, POLICY) VALUES ('ActivateNetworkBB', '*', '*', '*', '*' , 'Rollback'), @@ -280,6 +284,7 @@ VALUES ('DeactivateVolumeGroupBB', 'VOLUME_GROUP', 'DEACTIVATE'), ('DeactivateVfModuleBB', 'VF_MODULE', 'DEACTIVATE'), ('DeactivateNetworkBB', 'NETWORK', 'DEACTIVATE'), +('DeactivatePnfBB', 'NO_VALIDATE', 'DEACTIVATE'), ('ChangeModelServiceInstanceBB', 'SERVICE', 'CHANGEMODEL'), @@ -929,3 +934,13 @@ VALUES ('VNFConfigModifyActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'); + +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-assign' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigAssignVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='config-deploy' WHERE COMPOSITE_ACTION = 'Service-Macro-Create' and FLOW_NAME = 'ConfigDeployVnfBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vnf', ACTION='HealthCheck' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; +UPDATE orchestration_flow_reference set FLOW_NAME='ControllerExecutionBB', SCOPE='vfmodule', ACTION='ScaleOutReconfiguration' WHERE COMPOSITE_ACTION = 'VFModule-ScaleOut' and FLOW_NAME = 'GenericVnfHealthCheckBB'; + +INSERT INTO orchestration_flow_reference(COMPOSITE_ACTION, SEQ_NO, FLOW_NAME, FLOW_VERSION, NB_REQ_REF_LOOKUP_ID, SCOPE, ACTION) VALUES +('VFModule-Delete', '1', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck"), +('VFModule-Delete', '2', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vfmodule", "ScaleInReconfiguration"), +('VFModule-Delete', '6', 'ControllerExecutionBB', 1.0,(SELECT id from northbound_request_ref_lookup WHERE MACRO_ACTION = 'VFModule-Delete' and CLOUD_OWNER = 'DEFAULT'), "vnf", "HealthCheck");
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java index 04161e9df9..3906229c2c 100644 --- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java +++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/CatalogDBRestTest.java @@ -21,7 +21,9 @@ package org.onap.so.adapters.catalogdb.catalogrest; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.io.IOException; +import java.util.List; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.json.JSONException; @@ -37,6 +39,7 @@ import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.web.util.UriComponentsBuilder; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; @@ -831,6 +834,34 @@ public class CatalogDBRestTest extends CatalogDbAdapterBaseTest { } @Test + public void testGetAllProcessingFlags() throws Exception { + HttpEntity<String> entity = new HttpEntity<String>(null, headers); + headers.set("Accept", MediaType.APPLICATION_JSON); + + UriComponentsBuilder builder = + UriComponentsBuilder.fromHttpUrl(createURLWithPort(ECOMP_MSO_CATALOG_PROCESSING_FLAGS)); + + ResponseEntity<String> response = + restTemplate.exchange(builder.toUriString(), HttpMethod.GET, entity, String.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + ObjectMapper mapper = new ObjectMapper(); + + List<ProcessingFlags> processingFlagsResponse = + mapper.readValue(response.getBody(), new TypeReference<List<ProcessingFlags>>() {}); + + boolean testFlagFound = false; + for (int i = 0; i < processingFlagsResponse.size(); i++) { + if (processingFlagsResponse.get(i).getFlag().equals("TESTFLAG")) { + assertEquals(processingFlagsResponse.get(i).getEndpoint(), "TESTENDPOINT"); + assertEquals(processingFlagsResponse.get(i).getDescription(), "TEST FLAG"); + testFlagFound = true; + } + } + assertTrue(testFlagFound); + } + + @Test public void testSetProcessingFlagsFlagValue() throws JSONException { ProcessingFlags updatedProcessingFlag = new ProcessingFlags(); updatedProcessingFlag.setFlag("TESTFLAG"); diff --git a/adapters/mso-nssmf-adapter/pom.xml b/adapters/mso-nssmf-adapter/pom.xml index b257adaa96..db791826c3 100644 --- a/adapters/mso-nssmf-adapter/pom.xml +++ b/adapters/mso-nssmf-adapter/pom.xml @@ -26,7 +26,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-nssmf-adapter</artifactId> diff --git a/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters b/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters index 4d3e36ed9c..8bc2ea6f83 100644 --- a/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters +++ b/adapters/mso-openstack-adapters/Deployment/Dockerfile.adapters @@ -1,4 +1,4 @@ -FROM openjdk:8-jdk-alpine +FROM onap/integration-java11:7.0.0 MAINTAINER mc4615@att.com EXPOSE 8080 ENV APP_HOME /home/$USER_NAME/app @@ -37,4 +37,4 @@ ENTRYPOINT ["java","-jar","-Dspring.profiles.active=dev","mso-openstack-adapters # OR for interactive mode (-it), run the following command # docker run -it --net=mso_network -p 8080:8080 --name mchan mercechan/msoadapters # COMMANDS ######## -######### README #########
\ No newline at end of file +######### README ######### diff --git a/adapters/mso-openstack-adapters/pom.xml b/adapters/mso-openstack-adapters/pom.xml index 53af40ca4b..ad41b0f050 100644 --- a/adapters/mso-openstack-adapters/pom.xml +++ b/adapters/mso-openstack-adapters/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-openstack-adapters</artifactId> <packaging>jar</packaging> @@ -18,10 +18,6 @@ <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-dependency-plugin</artifactId> - </plugin> - <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> @@ -135,6 +131,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -153,9 +152,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -263,10 +260,24 @@ </dependency> <dependency> <groupId>org.pacesys.openstack4j.connectors</groupId> - <artifactId>openstack4j-httpclient</artifactId> + <artifactId>openstack4j-jersey2</artifactId> <version>3.2.0</version> </dependency> - + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + <version>2.22.1</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + <version>2.22.1</version> + </dependency> <dependency> <groupId>commons-collections</groupId> <artifactId>commons-collections</artifactId> @@ -342,5 +353,10 @@ <artifactId>camunda-external-task-client</artifactId> <version>1.1.1</version> </dependency> + <dependency> + <groupId>com.github.seancfoley</groupId> + <artifactId>ipaddress</artifactId> + <version>2.0.0</version> + </dependency> </dependencies> </project> diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java index 15c5eda054..1f0422b0b2 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java @@ -47,20 +47,19 @@ public class DeleteAAIInventory { @Autowired protected Environment env; - public void heatbridge(CloudInformation cloudInformation, boolean dryrun) { + public void heatbridge(CloudInformation cloudInformation) { try { - if (!dryrun) { - logger.debug("Heatbridge delete executing"); + logger.debug("Heatbridge delete executing"); + + CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) + .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); + CloudIdentity cloudIdentity = cloudSite.getIdentityService(); + HeatBridgeApi heatBridgeClient = + new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(), + cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId()); + heatBridgeClient.authenticate(); + heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) - .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); - CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, - cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), - cloudInformation.getTenantId()); - heatBridgeClient.authenticate(); - heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); - } } catch (Exception ex) { logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java index b104c3310c..4e5e880f80 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryService.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.inventory.delete; import javax.annotation.PostConstruct; -import org.camunda.bpm.client.ExternalTaskClient; import org.onap.so.utils.ExternalTaskServiceUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Profile; @@ -43,10 +42,11 @@ public class DeleteInventoryService { @PostConstruct public void auditAAIInventory() throws Exception { - ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDelete") - .lockDuration(Long.parseLong(env.getProperty("mso.audit.lock-time", "60000"))) - .handler(deleteInventory::executeExternalTask).open(); + for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { + externalTaskServiceUtils.createExternalTaskClient().subscribe("InventoryDelete") + .lockDuration(externalTaskServiceUtils.getLockDurationMedium()) + .handler(deleteInventory::executeExternalTask).open(); + } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java index c5feee2089..10faa2b08f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteInventoryTask.java @@ -60,14 +60,13 @@ public class DeleteInventoryTask extends ExternalTaskUtils { protected void executeExternalTask(ExternalTask externalTask, ExternalTaskService externalTaskService) { mdcSetup.setupMDC(externalTask); - boolean inventoryException = false; String externalTaskId = externalTask.getId(); CloudInformation cloudInformation = externalTask.getVariable("cloudInformation"); boolean success = true; if (cloudInformation != null) { Integer retryCount = externalTask.getRetries(); try { - deleteInventory.heatbridge(cloudInformation, env.getProperty("heatBridgeDryrun", Boolean.class, true)); + deleteInventory.heatbridge(cloudInformation); } catch (Exception e) { logger.error("Error during inventory of stack", e); success = false; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java index d282046b3f..d4a4bb792f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/TaskServices.java @@ -22,7 +22,6 @@ package org.onap.so.adapters.tasks; import javax.annotation.PostConstruct; import org.camunda.bpm.client.ExternalTaskClient; -import org.onap.so.utils.ExternalTaskServiceUtils; import org.onap.so.adapters.tasks.audit.AuditCreateStackService; import org.onap.so.adapters.tasks.audit.AuditDeleteStackService; import org.onap.so.adapters.tasks.audit.AuditQueryStackService; @@ -30,6 +29,7 @@ import org.onap.so.adapters.tasks.inventory.CreateInventoryTask; import org.onap.so.adapters.tasks.orchestration.PollService; import org.onap.so.adapters.tasks.orchestration.RollbackService; import org.onap.so.adapters.tasks.orchestration.StackService; +import org.onap.so.utils.ExternalTaskServiceUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -70,7 +70,7 @@ public class TaskServices { public void auditAddAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryAddAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditCreateStack::executeExternalTask).open(); } } @@ -79,7 +79,7 @@ public class TaskServices { public void auditDeleteAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryDeleteAudit").lockDuration(externalTaskServiceUtils.getLockDurationLong()) .handler(auditDeleteStack::executeExternalTask).open(); } } @@ -94,10 +94,10 @@ public class TaskServices { } @PostConstruct - public void auditAAIInventory() throws Exception { + public void createtAAIInventory() throws Exception { for (int i = 0; i < externalTaskServiceUtils.getMaxClients(); i++) { ExternalTaskClient client = externalTaskServiceUtils.createExternalTaskClient(); - client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLockDuration()) + client.subscribe("InventoryCreate").lockDuration(externalTaskServiceUtils.getLongLockDuration()) .handler(createInventory::executeExternalTask).open(); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java index 2f7155bffc..8cdd37d43f 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AbstractAuditService.java @@ -21,7 +21,6 @@ package org.onap.so.adapters.tasks.audit; -import java.util.Optional; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.utils.ExternalTaskUtils; @@ -37,8 +36,6 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { private static final Logger logger = LoggerFactory.getLogger(AbstractAuditService.class); - - protected static final String UNABLE_TO_FIND_ALL_V_SERVERS_AND_L_INTERACES_IN_A_AI = "Unable to find all VServers and L-Interaces in A&AI"; @@ -52,29 +49,27 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { } /** - * @param auditHeatStackFailed * @param auditList * @return */ - protected boolean didCreateAuditFail(Optional<AAIObjectAuditList> auditList) { - if (auditList.get().getAuditList() != null && !auditList.get().getAuditList().isEmpty()) { + protected boolean didCreateAuditFail(AAIObjectAuditList auditList) { + if (isAuditListNotNullAndNotEmpty(auditList)) { if (logger.isInfoEnabled()) { - logger.info("Audit Results: {}", auditList.get().toString()); + logger.info("Audit Results: {}", auditList.toString()); } - return auditList.get().getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()) - .findFirst().map(v -> true).orElse(false); + return auditList.getAuditList().stream().filter(auditObject -> !auditObject.isDoesObjectExist()).findFirst() + .map(v -> true).orElse(false); } else { return false; } } /** - * @param auditHeatStackFailed * @param auditList * @return */ protected boolean didDeleteAuditFail(AAIObjectAuditList auditList) { - if (auditList.getAuditList() != null && !auditList.getAuditList().isEmpty()) { + if (isAuditListNotNullAndNotEmpty(auditList)) { if (logger.isInfoEnabled()) { logger.info("Audit Results: {}", auditList.toString()); } @@ -84,4 +79,9 @@ public abstract class AbstractAuditService extends ExternalTaskUtils { return false; } } + + private boolean isAuditListNotNullAndNotEmpty(AAIObjectAuditList auditList) { + return auditList != null && auditList.getAuditList() != null && !auditList.getAuditList().isEmpty(); + } + } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java index 010475c87a..a4afcf1378 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditCreateStackService.java @@ -59,7 +59,7 @@ public class AuditCreateStackService extends AbstractAuditService { boolean success = false; try { Integer retryCount = externalTask.getRetries(); - logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", auditInventory, retryCount); + logger.info("Executing External Task Audit Inventory, Retry Number: {} \n {}", retryCount, auditInventory); Optional<AAIObjectAuditList> auditListOpt = heatStackAudit.auditHeatStack(auditInventory.getCloudRegion(), auditInventory.getCloudOwner(), auditInventory.getTenantId(), auditInventory.getHeatStackName()); if (auditListOpt.isPresent()) { @@ -67,7 +67,7 @@ public class AuditCreateStackService extends AbstractAuditService { auditListOpt.get().setHeatStackName(auditInventory.getHeatStackName()); GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); variables.put("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditListOpt.get())); - success = !didCreateAuditFail(auditListOpt); + success = !didCreateAuditFail(auditListOpt.get()); } } catch (Exception e) { logger.error("Error during audit of stack", e); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java index 4e8443bf45..200f6375ea 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditDataService.java @@ -17,6 +17,8 @@ import com.fasterxml.jackson.databind.JsonMappingException; @Component public class AuditDataService { + private static final String AUDIT_STACK_DATA = "AuditStackData"; + @Autowired private RequestsDbClient requestsDbClient; @@ -30,7 +32,7 @@ public class AuditDataService { throws JsonProcessingException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (requestProcessingDataList.isEmpty()) { GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; @@ -39,7 +41,7 @@ public class AuditDataService { requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); requestProcessingData.setGroupingId(auditInventory.getVfModuleId()); requestProcessingData.setName(auditInventory.getHeatStackName()); - requestProcessingData.setTag("AuditStackData"); + requestProcessingData.setTag(AUDIT_STACK_DATA); requestProcessingData.setValue(auditListString); requestsDbClient.saveRequestProcessingData(requestProcessingData); @@ -53,12 +55,11 @@ public class AuditDataService { * @throws JsonMappingException * @throws JsonParseException */ - public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) - throws JsonParseException, JsonMappingException, IOException { + public Optional<AAIObjectAuditList> getStackDataFromRequestDb(AuditInventory auditInventory) throws IOException { List<RequestProcessingData> requestProcessingDataList = requestsDbClient.getRequestProcessingDataByGroupingIdAndNameAndTag(auditInventory.getVfModuleId(), - auditInventory.getHeatStackName(), "AuditStackData"); + auditInventory.getHeatStackName(), AUDIT_STACK_DATA); if (!requestProcessingDataList.isEmpty()) { RequestProcessingData requestProcessingData = requestProcessingDataList.get(0); String auditListString = requestProcessingData.getValue(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index eab0451aa6..12751f8c27 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -35,6 +35,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -72,6 +73,10 @@ public class CreateAAIInventory { List<Resource> stackResources = heatBridgeClient.queryNestedHeatStackResources(cloudInformation.getTemplateInstanceId()); + List<Network> osNetworks = heatBridgeClient.getAllOpenstackProviderNetworks(stackResources); + heatBridgeClient.buildAddNetworksToAaiAction(cloudInformation.getVnfId(), cloudInformation.getVfModuleId(), + osNetworks); + List<Server> osServers = heatBridgeClient.getAllOpenstackServers(stackResources); heatBridgeClient.createPserversAndPinterfacesIfNotPresentInAai(stackResources); @@ -108,7 +113,8 @@ public class CreateAAIInventory { if (!CollectionUtils.isEmpty(oobMgtNetNames)) { oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); } - heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds); + heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, + cloudInformation.getOwner()); logger.debug( "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java index 317dae61b9..2202e97e71 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateInventoryTask.java @@ -64,8 +64,8 @@ public class CreateInventoryTask extends ExternalTaskUtils { if (cloudInformation != null) { Integer retryCount = externalTask.getRetries(); try { - logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", cloudInformation, - retryCount); + logger.info("Executing External Task Create Inventory, Retry Number: {} \n {}", retryCount, + cloudInformation.toString()); createInventory.heatbridge(cloudInformation); } catch (Exception e) { logger.error("Error during inventory of stack", e); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index d0ca87df95..a4e6cccc06 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -38,6 +38,7 @@ import org.openstack4j.model.compute.Flavor; import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.Network; /** * Defines the contract to extract Heat Stack Resources from Openstack and inventory it to AAI. This API is used only to @@ -88,6 +89,14 @@ public interface HeatBridgeApi { List<Server> getAllOpenstackServers(List<Resource> stackResources); /** + * Query the Openstack provider network objects from the list of stack resources + * + * @param stackResources A list of stack based resources + * @return A list of Openstack Network objects + */ + List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources); + + /** * Extract Openstack Image objects from a a list of Server objects * * @param servers A list of Openstack Server objects @@ -104,6 +113,15 @@ public interface HeatBridgeApi { List<Flavor> extractOpenstackFlavorsFromServers(List<Server> servers); /** + * Query and build AAI actions for Openstack Compute resources to AAI's l3-network objects with its subnets + * + * @param genericVnfId AAI generic-vnf-id + * @param vfModuleId AAI vf-module-id + * @param networks Openstack Network list + */ + void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, List<Network> networks); + + /** * Query and build AAI actions for Openstack Image resources to AAI's image objects * * @param images List of Openstack Image objects @@ -134,8 +152,10 @@ public interface HeatBridgeApi { * * @param stackResources Openstack Heat stack resource list * @param oobMgtNetIds List of OOB network IDs list + * @param cloudOwner */ - void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds); + void buildAddVserverLInterfacesToAaiAction(List<Resource> stackResources, List<String> oobMgtNetIds, + String cloudOwner); /** * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index bbabd7fab8..ef2577d6fe 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -42,24 +42,28 @@ import java.util.function.Function; import java.util.function.Predicate; import java.util.stream.Collectors; import javax.annotation.Nonnull; +import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.L3InterfaceIpv4AddressList; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovPf; import org.onap.aai.domain.yang.SriovPfs; +import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.SriovVfs; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.Vlan; import org.onap.aai.domain.yang.Vlans; import org.onap.aai.domain.yang.Vserver; -import org.onap.logging.filter.base.ErrorCode; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -67,8 +71,10 @@ import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; +import org.onap.logging.filter.base.ErrorCode; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.heatbridge.constants.HeatBridgeConstants; @@ -79,17 +85,21 @@ import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.onap.so.spring.SpringContextHelper; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.IP; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; +import inet.ipaddr.IPAddressString; /** * This class provides an implementation of {@link HeatBridgeApi} @@ -109,6 +119,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { private String tenantId; private AaiHelper aaiHelper = new AaiHelper(); private CloudIdentity cloudIdentity; + private Environment env; + public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity, @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId, @@ -124,7 +136,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; - this.transaction = resourcesClient.beginSingleTransaction(); + if (resourcesClient != null) + this.transaction = resourcesClient.beginSingleTransaction(); + if (SpringContextHelper.getAppContext() != null) + this.env = SpringContextHelper.getAppContext().getEnvironment(); } public HeatBridgeImpl() { @@ -145,7 +160,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { logger.trace("Keystone Version: {} ", keystoneVersion); this.osClient = new MsoCloudClientFactoryImpl(new OpenstackClientFactoryImpl()).getOpenstackClient( cloudIdentity.getIdentityUrl(), cloudIdentity.getMsoId(), cloudIdentity.getMsoPass(), regionId, - tenantId, keystoneVersion); + tenantId, keystoneVersion, cloudIdentity.getUserDomainName(), cloudIdentity.getProjectDomainName()); logger.trace("Successfully authenticated with keystone for tenant: {} and region: {}", tenantId, regionId); return osClient; } @@ -187,6 +202,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } @Override + public List<Network> getAllOpenstackProviderNetworks(final List<Resource> stackResources) { + Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); + // Filter Openstack Compute resources + List<String> providerNetworkIds = + extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_NEUTRON_PROVIDERNET); + return providerNetworkIds.stream().map(providerNetworkId -> osClient.getNetworkById(providerNetworkId)) + .collect(Collectors.toList()); + } + + @Override public List<org.openstack4j.model.compute.Image> extractOpenstackImagesFromServers(final List<Server> servers) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); return servers.stream().map(Server::getImage) @@ -200,6 +225,27 @@ public class HeatBridgeImpl implements HeatBridgeApi { .filter(distinctByProperty(org.openstack4j.model.compute.Flavor::getId)).collect(Collectors.toList()); } + public void buildAddNetworksToAaiAction(final String genericVnfId, final String vfModuleId, + List<Network> networks) { + networks.forEach(network -> { + L3Network l3Network = aaiHelper.buildNetwork(network); + if (l3Network != null) { + l3Network.setSubnets(buildSunets(network)); + + RelationshipList relationshipList = new RelationshipList(); + List<Relationship> relationships = relationshipList.getRelationship(); + + relationships.add(aaiHelper.getRelationshipToVfModule(genericVnfId, vfModuleId)); + relationships.add(aaiHelper.getRelationshipToTenant(cloudOwner, cloudRegionId, tenantId)); + + l3Network.setRelationshipList(relationshipList); + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3Network.getNetworkId()), + Optional.of(l3Network)); + } + }); + } + @Override public void buildAddImagesToAaiAction(final List<org.openstack4j.model.compute.Image> images) throws HeatBridgeException { @@ -246,24 +292,25 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Build vserver relationships to: image, flavor, pserver, vf-module vserver.setRelationshipList( aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server)); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegionId, - tenantId, vserver.getVserverId()), vserver); + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, + cloudRegionId, tenantId, vserver.getVserverId()), Optional.of(vserver)); }); } @Override public void buildAddVserverLInterfacesToAaiAction(final List<Resource> stackResources, - final List<String> oobMgtNetIds) { + final List<String> oobMgtNetIds, String cloudOwner) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List<String> portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); for (String portId : portIds) { Port port = osClient.getPortById(portId); + Network network = osClient.getNetworkById(port.getNetworkId()); LInterface lIf = new LInterface(); lIf.setInterfaceId(port.getId()); lIf.setInterfaceName(port.getName()); lIf.setMacaddr(port.getMacAddress()); - lIf.setNetworkName((String) port.getProfile().get("physical_network")); + lIf.setNetworkName(network.getName()); lIf.setIsPortMirrored(false); lIf.setIsIpUnnumbered(false); lIf.setInMaint(false); @@ -280,12 +327,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } lIf.setL2Multicasting(isL2Multicast); + + transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, + cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName()), Optional.of(lIf)); + updateLInterfaceIps(port, lIf); - updateLInterfaceVlan(port, lIf); + if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { + updateLInterfaceVlan(port, lIf); + } - // Update l-interface to the vserver - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, cloudRegionId, - tenantId, port.getDeviceId(), lIf.getInterfaceName()), lIf); + updateSriovPfToPserver(port, lIf); } } @@ -322,6 +373,20 @@ public class HeatBridgeImpl implements HeatBridgeApi { return pserverMap; } + private Subnets buildSunets(Network network) { + Subnets aaiSubnets = new Subnets(); + List<String> subnetIds = network.getSubnets(); + + subnetIds.forEach(subnetId -> { + Subnet subnet = osClient.getSubnetById(subnetId); + org.onap.aai.domain.yang.Subnet aaiSubnet = aaiHelper.buildSubnet(subnet); + if (aaiSubnet != null) { + aaiSubnets.getSubnet().add(aaiSubnet); + } + }); + return aaiSubnets; + } + private void createPServerIfNotExists(Map<String, Pserver> serverHostnames) { for (Pserver pserver : serverHostnames.values()) { AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserver.getHostname()); @@ -339,38 +404,35 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vlan vlan = new Vlan(); Network network = osClient.getNetworkById(port.getNetworkId()); if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) { - vlan.setVlanInterface(network.getName() + network.getProviderSegID()); - + vlan.setVlanInterface(port.getName() + network.getProviderSegID()); vlan.setVlanIdOuter(Long.parseLong(network.getProviderSegID())); vlan.setVlanIdInner(0L); vlan.setInMaint(false); vlan.setIsIpUnnumbered(false); vlan.setIsPrivate(false); - Vlans vlans = new Vlans(); - List<Vlan> vlanList = vlans.getVlan(); - vlanList.add(vlan); - lIf.setVlans(vlans); + + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).vlan(vlan.getVlanInterface())), + Optional.of(vlan)); } - // Build sriov-vf to the l-interface + if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { - SriovVfs sriovVfs = new SriovVfs(); - // JAXB does not generate setters for list, however getter ensures its creation. - // Thus, all list manipulations must be made on live list. - List<SriovVf> sriovVfList = sriovVfs.getSriovVf(); SriovVf sriovVf = new SriovVf(); sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); sriovVf.setNeutronNetworkId(port.getNetworkId()); - if (port.getVifDetails() != null) { - sriovVf.setVfVlanFilter((String) port.getVifDetails().get(HeatBridgeConstants.OS_VLAN_NETWORK_KEY)); - } + sriovVf.setVfVlanFilter("0"); sriovVf.setVfVlanAntiSpoofCheck(false); sriovVf.setVfMacAntiSpoofCheck(false); - sriovVfList.add(sriovVf); - - lIf.setSriovVfs(sriovVfs); - // For the given port create sriov-pf for host pserver/p-interface if absent - updateSriovPfToPserver(port, lIf); + transaction + .createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).sriovVf(sriovVf.getPciId())), + Optional.of(sriovVf)); } } @@ -384,63 +446,82 @@ public class HeatBridgeImpl implements HeatBridgeApi { * @param lIf AAI l-interface object */ private void updateSriovPfToPserver(final Port port, final LInterface lIf) { - if (port.getProfile() == null || Strings - .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { - logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " - + "sriov-pf object for host pserver: " + port.getHostId()); - return; - } - Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( - port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); - if (matchingPifName.isPresent()) { - // Update l-interface description - String pserverHostName = port.getHostId(); - lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); - try { - Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, - AAIUriFactory - .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) - .depth(Depth.ONE)); - if (matchingPIf.isPresent()) { - SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); - if (pIfSriovPfs == null) { - pIfSriovPfs = new SriovPfs(); - } - // Extract PCI-ID from OS port object - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); - if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - // Add sriov-pf object with PCI-ID to AAI - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName - + "/" + matchingPifName.get()); - transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverHostName, - matchingPifName.get(), sriovPf.getPfPciId()), sriovPf); + if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { + if (port.getProfile() == null || Strings + .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { + logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " + + "sriov-pf object for host pserver: " + port.getHostId()); + return; + } + Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( + port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); + if (matchingPifName.isPresent()) { + // Update l-interface description + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription( + "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); + try { + Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class, AAIUriFactory + .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) + .depth(Depth.ONE)); + if (matchingPIf.isPresent()) { + SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); + if (pIfSriovPfs == null) { + pIfSriovPfs = new SriovPfs(); + } + // Extract PCI-ID from OS port object + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); + + List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf(); + if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream() + .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { + // Add sriov-pf object with PCI-ID to AAI + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName + + "/" + matchingPifName.get()); + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverHostName, matchingPifName.get(), sriovPf.getPfPciId()); + + if (!resourcesClient.exists(sriovPfUri)) { + transaction.create(sriovPfUri, sriovPf); + + AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_VF, + cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName(), + port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); + + transaction.connect(sriovPfUri, sriovVfUri); + } + } } + } catch (WebApplicationException e) { + // Silently log that we failed to update the Pserver p-interface with PCI-ID + logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, + matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge", + ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e); } - } catch (WebApplicationException e) { - // Silently log that we failed to update the Pserver p-interface with PCI-ID - logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, matchingPifName.get(), - cloudOwner, tenantId, "OpenStack", "Heatbridge", ErrorCode.DataError.getValue(), - "Exception - Failed to add sriov-pf object to pserver", e); } } } private void updateLInterfaceIps(final Port port, final LInterface lIf) { - List<L3InterfaceIpv4AddressList> lInterfaceIps = lIf.getL3InterfaceIpv4AddressList(); for (IP ip : port.getFixedIps()) { String ipAddress = ip.getIpAddress(); if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) { + Subnet subnet = osClient.getSubnetById(ip.getSubnetId()); + IPAddressString cidr = new IPAddressString(subnet.getCidr()); L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList(); lInterfaceIp.setL3InterfaceIpv4Address(ipAddress); lInterfaceIp.setNeutronNetworkId(port.getNetworkId()); lInterfaceIp.setNeutronSubnetId(ip.getSubnetId()); - lInterfaceIp.setL3InterfaceIpv4PrefixLength(32L); - lInterfaceIps.add(lInterfaceIp); + lInterfaceIp.setL3InterfaceIpv4PrefixLength(Long.parseLong(cidr.getNetworkPrefixLength().toString())); + + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(port.getDeviceId()) + .lInterface(lIf.getInterfaceName()).l3InterfaceIpv4AddressList(ipAddress)), + Optional.of(lInterfaceIp)); } } } @@ -462,27 +543,48 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(vnfId, "Null vnf-id!"); Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); try { - Optional<VfModule> vfModule = resourcesClient.get(VfModule.class, - AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE)); - logger.debug("vfModule is present: {}", vfModule.isPresent()); - if (vfModule.isPresent()) { - - AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); - Optional<Relationships> relationships = resultWrapper.getRelationships(); - logger.debug("relationships is present: {}", relationships.isPresent()); - if (relationships.isPresent()) { - List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); - logger.debug("vserverList isEmpty: {}", vserverUris.isEmpty()); - createTransactionToDeleteSriovPfFromPserver(vserverUris); - - if (!vserverUris.isEmpty()) { - for (AAIResourceUri vserverUri : vserverUris) { - logger.debug("Deleting Vservers: {}", vserverUri.toString()); + Optional<VfModule> vfModule = resourcesClient + .get(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE), + NotFoundException.class) + .asBean(VfModule.class); + + AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); + Optional<Relationships> relationships = resultWrapper.getRelationships(); + logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent()); + if (relationships.isPresent()) { + + List<AAIResourceUri> l3NetworkUris = relationships.get().getRelatedUris(AAIObjectType.L3_NETWORK); + logger.debug("L3Network contains {} relationships in AAI", l3NetworkUris.size()); + + if (!l3NetworkUris.isEmpty()) { + for (AAIResourceUri l3NetworkUri : l3NetworkUris) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete L3Network: {}", l3NetworkUri.build().toString()); + } else { + resourcesClient.delete(l3NetworkUri); + } + } + } + + List<AAIResourceUri> vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); + logger.debug("VServer contains {} relationships in AAI", vserverUris.size()); + createTransactionToDeleteSriovPfFromPserver(vserverUris); + + if (!vserverUris.isEmpty()) { + for (AAIResourceUri vserverUri : vserverUris) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Vserver: {}", vserverUri.build().toString()); + } else { resourcesClient.delete(vserverUri); } } } } + + } catch (NotFoundException e) { + String msg = "Failed to commit delete heatbridge data transaction"; + logger.debug(msg + " with error: " + e); + throw new HeatBridgeException(msg, e); } catch (Exception e) { String msg = "Failed to commit delete heatbridge data transaction"; logger.debug(msg + " with error: " + e); @@ -505,8 +607,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { if (pciIds.contains(sriovPf.getPfPciId())) { logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName); - resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, - pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + logger.debug("Would delete Sriov Pf: {}", + AAIUriFactory + .createResourceUri(AAIObjectType.SRIOV_PF, pserverName, + pIf.getInterfaceName(), sriovPf.getPfPciId()) + .build().toString()); + } else { + resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, + pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + } } })); } @@ -523,9 +633,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { Vserver vserver = vserverWrapper.asBean(Vserver.class).get(); List<String> pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver); if (CollectionUtils.isNotEmpty(pciIds)) { - List<String> matchingPservers = vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER); + List<AAIResourceUri> matchingPservers = + vserverRelationships.get().getRelatedUris(AAIObjectType.PSERVER); if (matchingPservers != null && matchingPservers.size() == 1) { - pserverToPciIdMap.put(matchingPservers.get(0), pciIds); + pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds); } } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index fdf7ce38f1..71c6a96cd6 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java @@ -40,6 +40,7 @@ public class HeatBridgeConstants { public static final Integer OS_DEFAULT_HEAT_NESTING = 5; public static final String OS_SERVER_RESOURCE_TYPE = "OS::Nova::Server"; public static final String OS_PORT_RESOURCE_TYPE = "OS::Neutron::Port"; + public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet"; public static final String OS_SRIOV_PORT_TYPE = "direct"; public static final String OS_PCI_SLOT_KEY = "pci_slot"; public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network"; @@ -64,6 +65,8 @@ public class HeatBridgeConstants { public static final String AAI_VF_MODULE_ID = "vf-module.vf-module-id"; public static final String AAI_IMAGE = "image"; public static final String AAI_IMAGE_ID = "image.image-id"; + public static final String AAI_TENANT = "tenant"; + public static final String AAI_TENANT_ID = "tenant.tenant-id"; public static final String AAI_CLOUD_OWNER = "cloud-region.cloud-owner"; public static final String AAI_CLOUD_REGION_ID = "cloud-region.cloud-region-id"; public static final String AAI_FLAVOR = "flavor"; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java index a9a63b312d..3c209314f3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactory.java @@ -55,5 +55,5 @@ public interface MsoCloudClientFactory { OpenstackClient getOpenstackClient(String url, String msoId, String msoPass, String regionId, String tenantId, - String keystoneVersion) throws HeatBridgeException; + String keystoneVersion, String userDomainName, String projectDomainName) throws HeatBridgeException; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java index 88a7d3dbbc..e299f6ffb8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImpl.java @@ -64,21 +64,26 @@ public class MsoCloudClientFactoryImpl implements MsoCloudClientFactory { @Override public OpenstackClient getOpenstackClient(@Nonnull String url, @Nonnull String msoId, @Nonnull String msoPass, - @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion) - throws HeatBridgeException { + @Nonnull String regionId, @Nonnull String tenantId, @Nonnull String keystoneVersion, String userDomainName, + String projectDomainName) throws HeatBridgeException { Objects.requireNonNull(url, "Null openstack url!"); Objects.requireNonNull(msoId, "Null openstack user id!"); Objects.requireNonNull(msoPass, "Null openstack password!"); Objects.requireNonNull(regionId, "Null regionId ID!"); Objects.requireNonNull(tenantId, "Null tenant ID!"); - Objects.requireNonNull(tenantId, "Null keystone version"); + Objects.requireNonNull(keystoneVersion, "Null keystone version"); + if (userDomainName == null) { + userDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } + if (projectDomainName == null) { + projectDomainName = HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME; + } try { final OpenstackAccess osAccess = new OpenstackAccessBuilder().setBaseUrl(url) // keystone URL .setUser(msoId) // keystone username .setPassword(CryptoUtils.decryptCloudConfigPassword(msoPass)) // keystone decrypted password .setRegion(regionId) // openstack region - .setDomainName(HeatBridgeConstants.OS_DEFAULT_DOMAIN_NAME) // hardcode to "default" - .setTenantId(tenantId) // tenantId + .setDomainName(userDomainName).setProjectName(projectDomainName).setTenantId(tenantId) // tenantId .build(); // Identify the Keystone version diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 6817be8c49..7d4e92d9ad 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -42,6 +42,7 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; +import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Relationship; @@ -54,7 +55,9 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.openstack4j.model.compute.Server; +import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import com.google.common.base.Preconditions; /** @@ -131,6 +134,49 @@ public class AaiHelper { return relationshipList; } + public Relationship getRelationshipToVfModule(String vnfId, String vfModuleId) { + return buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)); + } + + public Relationship getRelationshipToTenant(String cloudOwner, String cloudRegionId, String tenantId) { + return buildRelationship( + AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegionId, tenantId)); + } + + public org.onap.aai.domain.yang.Subnet buildSubnet(Subnet subnet) { + org.onap.aai.domain.yang.Subnet aaiSubnet = new org.onap.aai.domain.yang.Subnet(); + aaiSubnet.setSubnetId(subnet.getId()); + aaiSubnet.setDhcpEnabled(subnet.isDHCPEnabled()); + + aaiSubnet.setSubnetName(subnet.getName()); + aaiSubnet.setGatewayAddress(subnet.getGateway()); + aaiSubnet.setCidrMask(subnet.getCidr()); + aaiSubnet.setIpVersion(subnet.getIpVersion().name()); + return aaiSubnet; + } + + public L3Network buildNetwork(Network network) { + if (network.getId() == null) { + return null; + } + L3Network l3Network = new L3Network(); + l3Network.setNetworkId(network.getId()); + l3Network.setIsBoundToVpn(true); + l3Network.setIsProviderNetwork(true); + + // optional fields + l3Network.setIsSharedNetwork(network.isShared()); + l3Network.setIsExternalNetwork(network.isRouterExternal()); + l3Network.setOperationalStatus(String.valueOf(network.isAdminStateUp())); + if (network.getName() != null) { + l3Network.setNetworkName(network.getName()); + } + if (network.getProviderPhyNet() != null) { + l3Network.setPhysicalNetworkName(network.getProviderPhyNet()); + } + return l3Network; + } + /** * Transform Openstack Server object to AAI Vserver object * @@ -145,7 +191,6 @@ public class AaiHelper { vserver.setVserverId(serverId); vserver.setVserverName(server.getName()); vserver.setVserverName2(server.getName()); - vserver.setProvStatus(server.getStatus().value()); server.getLinks().stream().filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)) .findFirst().ifPresent(link -> vserver.setVserverSelflink(link.getHref())); return vserver; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java index 69c76fad84..d8f2ee7273 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackAccess.java @@ -88,6 +88,10 @@ public class OpenstackAccess { return projectName; } + public Identifier getProjectNameIdentifier() { + return Identifier.byName(projectName); + } + public static class OpenstackAccessBuilder { private String baseUrl; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java index 7184ec1e93..8d47ff4ceb 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClient.java @@ -42,6 +42,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; public interface OpenstackClient { @@ -92,4 +93,12 @@ public interface OpenstackClient { * @return List of filtered Network objects */ List<Network> listNetworksByFilter(Map<String, String> filterParams); + + /** + * Get a subnet object by subnet ID + * + * @param subnetId Unique UUID of the subnet. + * @return Subnet object. + */ + Subnet getSubnetById(String subnetId); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java index 5a2b0732dc..1505203d7c 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/api/OpenstackClientImpl.java @@ -45,6 +45,7 @@ import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; abstract class OpenstackClientImpl implements OpenstackClient { @Override @@ -78,6 +79,11 @@ abstract class OpenstackClientImpl implements OpenstackClient { return (List<Network>) getClient().networking().network().list(filterParams); } + @Override + public Subnet getSubnetById(String subnetId) { + return getClient().networking().subnet().get(subnetId); + } + /** * Retrieves the specific client to utilize. * diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java index bbcd54e6f8..e2fa89bf39 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/openstack/factory/OpenstackClientFactoryImpl.java @@ -60,10 +60,11 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV3 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV3().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword(), osAccess.getDomainNameIdentifier()) - .scopeToProject(Identifier.byId(osAccess.getTenantId())).authenticate() - .useRegion(osAccess.getRegion()); + .scopeToProject(Identifier.byId(osAccess.getTenantId()), osAccess.getProjectNameIdentifier()) + .authenticate().useRegion(osAccess.getRegion()); return new OpenstackV3ClientImpl(client); } catch (AuthenticationException exception) { throw new OpenstackClientException("Failed to authenticate with Keystone-v3: " + osAccess.getUrl(), @@ -81,6 +82,7 @@ public class OpenstackClientFactoryImpl implements OpenstackClientFactory { OSClientV2 client; try { + OSFactory.enableHttpLoggingFilter(true); client = OSFactory.builderV2().endpoint(osAccess.getUrl()) .credentials(osAccess.getUser(), osAccess.getPassword()).tenantId(osAccess.getTenantId()) .authenticate().useRegion(osAccess.getRegion()); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java new file mode 100644 index 0000000000..c70e60e9d3 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AbstractAuditServiceTest.java @@ -0,0 +1,51 @@ +package org.onap.so.adapters.tasks.audit; + +import org.junit.Test; +import org.onap.so.objects.audit.AAIObjectAudit; +import org.onap.so.objects.audit.AAIObjectAuditList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +public class AbstractAuditServiceTest extends AbstractAuditService { + + private AAIObjectAuditList getAuditListWithObjectWithExistenceStateOf(boolean existenceState) { + AAIObjectAudit auditObject = new AAIObjectAudit(); + AAIObjectAuditList auditList = new AAIObjectAuditList(); + + auditObject.setDoesObjectExist(existenceState); + auditList.getAuditList().add(auditObject); + + return auditList; + } + + @Test + public void didCreateAuditFail_shouldReturnFalse_whenGivenNull() { + assertFalse(didCreateAuditFail(null)); + } + + @Test + public void didCreateAuditFail_shouldReturnTrue_whenGivenNotExistingObject() { + assertTrue(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); + } + + @Test + public void didCreateAuditFail_shouldReturnFalse_whenGivenExistingObject() { + assertFalse(didCreateAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); + } + + @Test + public void didDeleteAuditFail_shouldReturnFalse_whenGivenNull() { + assertFalse(didDeleteAuditFail(null)); + } + + @Test + public void didDeleteAuditFail_shouldReturnTrue_whenGivenExistingObject() { + assertTrue(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(true))); + } + + @Test + public void didDeleteAuditFail_shouldReturnFalse_whenGivenNotExistingObject() { + assertFalse(didDeleteAuditFail(getAuditListWithObjectWithExistenceStateOf(false))); + } + +} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java index fd36995f3d..76e5bbc47f 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditDataServiceTest.java @@ -1,10 +1,9 @@ package org.onap.so.adapters.tasks.audit; -import static org.junit.Assert.assertEquals; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; +import static org.assertj.core.api.Assertions.assertThat; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -13,7 +12,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.tasks.audit.AuditDataService; import org.onap.so.audit.beans.AuditInventory; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.db.request.beans.RequestProcessingData; @@ -22,6 +20,7 @@ import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import com.fasterxml.jackson.core.JsonProcessingException; + @RunWith(MockitoJUnitRunner.Silent.class) public class AuditDataServiceTest { @@ -56,9 +55,8 @@ public class AuditDataServiceTest { vserver.setVserverId("testVserverId"); audit.setAaiObject(vserver); auditList.getAuditList().add(audit); - GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider(); - String auditListString = objectMapper.getMapper().writeValueAsString(auditList);; + String auditListString = objectMapper.getMapper().writeValueAsString(auditList); RequestProcessingData requestProcessingData = new RequestProcessingData(); requestProcessingData.setSoRequestId(auditInventory.getMsoRequestId()); @@ -99,4 +97,17 @@ public class AuditDataServiceTest { "testVnfModuleId", "testVfModuleName1", "AuditStackData"); } + @Test + public void testGetStackDataToRequestDbWhenRequestProcessingDataListIsEmpty() throws Exception { + + Mockito.doReturn(new ArrayList<RequestProcessingData>()).when(requestsDbClient) + .getRequestProcessingDataByGroupingIdAndNameAndTag(Mockito.any(), Mockito.any(), Mockito.any()); + Optional<AAIObjectAuditList> result = auditDataService.getStackDataFromRequestDb(auditInventory); + Mockito.verify(requestsDbClient, Mockito.times(1)).getRequestProcessingDataByGroupingIdAndNameAndTag( + "testVnfModuleId", "testVfModuleName1", "AuditStackData"); + assertThat(result).isEmpty(); + + } + + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java index a10ab4b7df..78dbcd94c2 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/tasks/audit/AuditStackServiceDataTest.java @@ -179,13 +179,13 @@ public class AuditStackServiceDataTest extends AuditCreateStackService { @Test public void determineAuditResult_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess); + boolean actual = auditStackService.didCreateAuditFail(auditListOptSuccess.get()); assertEquals(false, actual); } @Test public void determineAuditResult_Failure_Test() throws Exception { - boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure); + boolean actual = auditStackService.didCreateAuditFail(auditListOptFailure.get()); assertEquals(true, actual); } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 464a17d2a5..8c21e3f7f7 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -42,15 +42,18 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import static org.mockito.Mockito.doReturn; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.List; import java.util.Objects; import java.util.Optional; +import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; @@ -58,12 +61,13 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; +import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.Vserver; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -80,11 +84,15 @@ import org.openstack4j.model.compute.Image; import org.openstack4j.model.compute.Server; import org.openstack4j.model.compute.Server.Status; import org.openstack4j.model.heat.Resource; +import org.openstack4j.model.network.IP; +import org.openstack4j.model.network.IPVersionType; import org.openstack4j.model.network.Network; import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; +import org.openstack4j.model.network.Subnet; import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; +import org.springframework.core.env.Environment; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -104,16 +112,20 @@ public class HeatBridgeImplTest { @Mock private AAIResourcesClient resourcesClient; + @Mock private AAISingleTransactionClient transaction; - private HeatBridgeImpl heatbridge; + @Mock + private Environment env; + + @InjectMocks + private HeatBridgeImpl heatbridge = + new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); @Before public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed { - when(resourcesClient.beginSingleTransaction()).thenReturn(transaction); - heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); } @Ignore @@ -252,7 +264,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -296,7 +308,7 @@ public class HeatBridgeImplTest { // Assert ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); - verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + verify(transaction, times(2)).createIfNotExists(captor.capture(), any(Optional.class)); List<AAIResourceUri> uris = captor.getAllValues(); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, @@ -396,7 +408,6 @@ public class HeatBridgeImplTest { verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); } - @Ignore @Test public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException { // Arrange @@ -408,7 +419,113 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); - when(port.getVifDetails()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_VLAN_NETWORK_KEY, "2345")); + String pfPciId = "0000:08:00.0"; + when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, + HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); + + Network network = mock(Network.class); + when(network.getId()).thenReturn("test-network-id"); + when(network.getNetworkType()).thenReturn(NetworkType.VLAN); + when(network.getProviderSegID()).thenReturn("2345"); + + when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port); + when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port); + when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port); + when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port); + when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port); + when(osClient.getNetworkById(anyString())).thenReturn(network); + + SriovPf sriovPf = new SriovPf(); + sriovPf.setPfPciId(pfPciId); + PInterface pIf = mock(PInterface.class); + when(pIf.getInterfaceName()).thenReturn("test-port-id"); + when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner"); + + // Act + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); + + // Assert + verify(transaction, times(15)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + verify(osClient, times(5)).getPortById(anyString()); + verify(osClient, times(10)).getNetworkById(anyString()); + } + + @Test + public void testUpdateNetworksToAai() throws HeatBridgeException { + + Subnet subnet1 = mock(Subnet.class); + when(subnet1.getId()).thenReturn("test-subnet1-id"); + when(subnet1.getName()).thenReturn("test-subnet1-name"); + when(subnet1.isDHCPEnabled()).thenReturn(true); + when(subnet1.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet1.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet1.getIpVersion()).thenReturn(IPVersionType.V4); + + Subnet subnet2 = mock(Subnet.class); + when(subnet2.getId()).thenReturn("test-subnet2-id"); + when(subnet2.getName()).thenReturn("test-subnet2-name"); + when(subnet2.isDHCPEnabled()).thenReturn(true); + when(subnet2.getGateway()).thenReturn("test-subnet1-gateway"); + when(subnet2.getCidr()).thenReturn("test-subnet1-gateway"); + when(subnet2.getIpVersion()).thenReturn(IPVersionType.V6); + + when(osClient.getSubnetById(subnet1.getId())).thenReturn(subnet1); + when(osClient.getSubnetById(subnet2.getId())).thenReturn(subnet2); + + List<String> subnetIds = Arrays.asList(subnet1.getId(), subnet2.getId()); + + // Arrange + Network network1 = mock(Network.class); + when(network1.getId()).thenReturn("test-network1-id"); + when(network1.isShared()).thenReturn(true); + when(network1.isRouterExternal()).thenReturn(true); + when(network1.isAdminStateUp()).thenReturn(true); + when(network1.getProviderPhyNet()).thenReturn("sriov-network1"); + when(network1.getName()).thenReturn("network1"); + when(network1.getSubnets()).thenReturn(subnetIds); + + Network network2 = mock(Network.class); + when(network2.getId()).thenReturn("test-network2-id"); + when(network2.isShared()).thenReturn(true); + when(network2.isRouterExternal()).thenReturn(true); + when(network2.isAdminStateUp()).thenReturn(true); + when(network2.getProviderPhyNet()).thenReturn("sriov-network2"); + when(network2.getName()).thenReturn("network2"); + when(network2.getSubnets()).thenReturn(subnetIds); + + String vnfId = "some-uuiid-of-the-vnf"; + String vfModuleId = "some-uuiid-of-the-vf-module"; + + Subnet subnet = mock(Subnet.class); + + List<Network> networks = Arrays.asList(network1, network2); + + // Act #1 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #1 + verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + // Act #2 + heatbridge.buildAddNetworksToAaiAction(vnfId, vfModuleId, networks); + + // Assert #2 + verify(transaction, times(4)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); + + } + + @Test + public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { + // Arrange + List<Resource> stackResources = (List<Resource>) extractTestStackResources(); + Port port = mock(Port.class); + when(port.getId()).thenReturn("test-port-id"); + when(port.getName()).thenReturn("test-port-name"); + when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE); + when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); + when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); + when(port.getDeviceId()).thenReturn("test-device-id"); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -432,10 +549,10 @@ public class HeatBridgeImplTest { when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); // Act - heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2")); + heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); // Assert - verify(transaction, times(5)).create(any(AAIResourceUri.class), any(LInterface.class)); + verify(transaction, times(5)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class)); verify(osClient, times(5)).getPortById(anyString()); verify(osClient, times(5)).getNetworkById(anyString()); } @@ -463,4 +580,6 @@ public class HeatBridgeImplTest { } return content; } + + } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java index 86400c2190..9b5e1e85cd 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/factory/MsoCloudClientFactoryImplTest.java @@ -40,6 +40,8 @@ public class MsoCloudClientFactoryImplTest { private static final String ENCRYPTED_PASSWORD = CryptoUtils.encryptCloudConfigPassword("testPassword"); private static final String REGION_ID = "testCloudRegionId"; private static final String TENANT_ID = "testTenantId"; + private static final String USER_DOMAIN_NAME = "userDomainName"; + private static final String PROJECT_DOMAIN_NAME = "projectDomainName"; private MsoCloudClientFactoryImpl testedObject; private OpenstackClientFactory openstackClientFactoryMock; @@ -52,20 +54,21 @@ public class MsoCloudClientFactoryImplTest { @Test public void getOpenstackClientWithVersion2() throws Exception { - testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0"); + testedObject.getOpenstackClient(URL_V2, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v2.0", null, null); verify(openstackClientFactoryMock).createOpenstackV2Client(any(OpenstackAccess.class)); } @Test public void getOpenstackClientWithVersion3() throws Exception { - testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3"); + testedObject.getOpenstackClient(URL_V3, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, "v3", + USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); verify(openstackClientFactoryMock).createOpenstackV3Client(any(OpenstackAccess.class)); } @Test(expected = HeatBridgeException.class) public void getOpenstackClient_unsupportedVersion() throws Exception { testedObject.getOpenstackClient(URL_WITH_UNSUPPORTED_VERSION, MSO_ID, ENCRYPTED_PASSWORD, REGION_ID, TENANT_ID, - "UNKNOWN"); + "UNKNOWN", USER_DOMAIN_NAME, PROJECT_DOMAIN_NAME); } } diff --git a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml index 42955c35c9..ac45f85711 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml +++ b/adapters/mso-openstack-adapters/src/test/resources/application-test.yaml @@ -64,8 +64,6 @@ mso: adapters: requestDb: endpoint: http://localhost:${wiremock.server.port} - audit: - lock-time: 240000 logPath: logs msb-ip: localhost msb-port: ${wiremock.server.port} diff --git a/adapters/mso-requests-db-adapter/.gitignore b/adapters/mso-requests-db-adapter/.gitignore index ae3c172604..9920c72893 100644 --- a/adapters/mso-requests-db-adapter/.gitignore +++ b/adapters/mso-requests-db-adapter/.gitignore @@ -1 +1,2 @@ /bin/ +/.apt_generated_tests/ diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index f9026d82c8..ca13895848 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -108,25 +108,58 @@ <artifactId>cxf-logging</artifactId> <version>${project.version}</version> </dependency> - </dependencies> + + </dependencies> + <pluginRepositories> + <pluginRepository> + <id>apache.snapshots</id> + <name>Maven Plugin Snapshots</name> + <url>http://repository.apache.org/snapshots/</url> + <snapshots> + <enabled>true</enabled> + </snapshots> + </pluginRepository> + </pluginRepositories> <build> <finalName>${project.artifactId}-${project.version}</finalName> <plugins> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-java2ws-plugin</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> <dependencies> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-jaxws</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> </dependency> <dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-frontend-simple</artifactId> - <version>${cxf.version}</version> + <version>3.3.3</version> + </dependency> + + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-ri</artifactId> + <version>2.3.0</version> + <type>pom</type> + </dependency> + <dependency> + <groupId>javax.annotation</groupId> + <artifactId>javax.annotation-api</artifactId> + <version>1.3.2</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.4.0-b180725.0427</version> + </dependency> + <dependency> + <groupId>org.glassfish.jaxb</groupId> + <artifactId>jaxb-runtime</artifactId> + <version>2.4.0-b180725.0644</version> </dependency> </dependencies> <executions> @@ -137,6 +170,9 @@ <className>org.onap.so.adapters.requestsdb.MsoRequestsDbAdapter</className> <genWsdl>true</genWsdl> <verbose>true</verbose> + <ignoredDependencies> + <ignoredDependency>com.sun.xml.bind:jaxb-impl</ignoredDependency> + </ignoredDependencies> </configuration> <goals> <goal>java2ws</goal> @@ -169,9 +205,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -181,6 +215,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -243,7 +280,7 @@ </ignore> </action> </pluginExecution> - <pluginExecution> + <pluginExecution> <pluginExecutionFilter> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> diff --git a/adapters/mso-sdnc-adapter/.gitignore b/adapters/mso-sdnc-adapter/.gitignore new file mode 100644 index 0000000000..da7560e07f --- /dev/null +++ b/adapters/mso-sdnc-adapter/.gitignore @@ -0,0 +1 @@ +/.apt_generated_tests/ diff --git a/adapters/mso-sdnc-adapter/pom.xml b/adapters/mso-sdnc-adapter/pom.xml index f54c2ec568..808210389a 100644 --- a/adapters/mso-sdnc-adapter/pom.xml +++ b/adapters/mso-sdnc-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>mso-sdnc-adapter</artifactId> <properties> @@ -16,7 +16,7 @@ <build> <finalName>${project.artifactId}-${project.version}</finalName> - <pluginManagement> + <pluginManagement> <plugins> <plugin> <groupId>org.eclipse.m2e</groupId> @@ -70,9 +70,7 @@ <executions> <execution> <id>original</id> - <configuration> - <skip>false</skip> - </configuration> + <phase>package</phase> </execution> </executions> </plugin> @@ -86,6 +84,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -133,6 +134,26 @@ <dependencies> <dependency> + <groupId>com.sun.activation</groupId> + <artifactId>javax.activation</artifactId> + <version>1.2.0</version> + </dependency> + <dependency> + <groupId>javax.xml.bind</groupId> + <artifactId>jaxb-api</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-core</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> + <groupId>com.sun.xml.bind</groupId> + <artifactId>jaxb-impl</artifactId> + <version>2.3.0</version> + </dependency> + <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> diff --git a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java index b8977f05d8..4ad32909b0 100644 --- a/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java +++ b/adapters/mso-sdnc-adapter/src/main/java/org/onap/so/adapters/sdnc/impl/SDNCRestClient.java @@ -24,7 +24,6 @@ package org.onap.so.adapters.sdnc.impl; - import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStream; @@ -65,7 +64,6 @@ import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; - @Component public class SDNCRestClient { @@ -153,10 +151,15 @@ public class SDNCRestClient { String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(userCredentials.getBytes()); con.setRequestProperty("Authorization", basicAuth); con.setRequestMethod(rt.getReqMethod()); + String msoAction = rt.getMsoAction(); // Add request headers if ("POST".equals(rt.getReqMethod()) || "PUT".equals(rt.getReqMethod())) { - con.setRequestProperty("Content-type", "application/xml"); + if (Constants.MSO_ACTION_MDONS.equals(msoAction)) { + con.setRequestProperty("Content-type", "application/json"); + } else { + con.setRequestProperty("Content-type", "application/xml"); + } con.setRequestProperty("Content-length", String.valueOf(sdncReqBody.length())); con.setDoOutput(true); out = new DataOutputStream(con.getOutputStream()); diff --git a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java b/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java deleted file mode 100644 index 4a3db26443..0000000000 --- a/adapters/mso-sdnc-adapter/src/test/java/org/onap/so/adapters/sdnc/impl/UtilsTest.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2018 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.so.adapters.sdnc.impl; - -import static org.junit.Assert.assertEquals; -import java.io.File; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; -import org.junit.Test; -import org.onap.so.adapters.sdnc.SDNCAdapterRequest; -import org.w3c.dom.Document; -import org.w3c.dom.Node; - -public class UtilsTest { - - @Test - public final void testUnmarshal() { - - String expectedXml = - "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><feature-list xmlns=\"com:att:sdnctl:l3api\"><feature-type>FIREWALL-LITE</feature-type><feature-instance-id>mtjnj40evbc0eceb</feature-instance-id><feature-sub-type>SHARED</feature-sub-type><feature-instance-xpath>/restconf/config/Firewall-API:feature-model/feature-list/FIREWALL-LITE/mtjnj40evbc0eceb/</feature-instance-xpath> </feature-list>"; - - try { - - File file = new File("src/test/resources/sdncBpmnAdiodFirewallRequest.xml"); - JAXBContext jaxbContext = JAXBContext.newInstance(SDNCAdapterRequest.class); - - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - SDNCAdapterRequest request = (SDNCAdapterRequest) jaxbUnmarshaller.unmarshal(file); - - RequestTunables rt = new RequestTunables("0460ba40-60c8-4b07-8878-c8e8d87cde04-1527983610512", "", - "/L3SDN-API:services/layer3-service-list/MIS%2F1806%2F25057%2FSW_INTERNET/service-data/feature-list/FIREWALL-LITE/", - "put"); - - Node node = (Node) request.getRequestData(); - Document reqDoc = node.getOwnerDocument(); - String sdncReqBody = Utils.genSdncPutReq(reqDoc, rt); - assertEquals(sdncReqBody.replaceAll("[\\t\\n\\r]+", ""), expectedXml); - - } catch (JAXBException e) { - e.printStackTrace(); - } - - } - -} diff --git a/adapters/mso-vfc-adapter/pom.xml b/adapters/mso-vfc-adapter/pom.xml index 451831f966..a86dc94cf2 100644 --- a/adapters/mso-vfc-adapter/pom.xml +++ b/adapters/mso-vfc-adapter/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> <artifactId>mso-vfc-adapter</artifactId> diff --git a/adapters/pom.xml b/adapters/pom.xml index 76b4a58af6..05d8b38dac 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -5,7 +5,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>so</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <artifactId>adapters</artifactId> @@ -22,7 +22,6 @@ <module>mso-vfc-adapter</module> <module>mso-openstack-adapters</module> <module>etsi-sol003-adapter</module> - <module>etsi-sol002-adapter</module> <module>mso-nssmf-adapter</module> <module>so-appc-orchestrator</module> </modules> @@ -46,5 +45,11 @@ <artifactId>aai-client</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>com.sun.xml.ws</groupId> + <artifactId>jaxws-ri</artifactId> + <version>2.3.0</version> + <type>pom</type> + </dependency> </dependencies> </project> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml index f8d8fabcf7..2229c1a60b 100644 --- a/adapters/so-appc-orchestrator/pom.xml +++ b/adapters/so-appc-orchestrator/pom.xml @@ -4,7 +4,7 @@ <parent> <groupId>org.onap.so</groupId> <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> + <version>1.7.1-SNAPSHOT</version> </parent> <groupId>org.onap.so.adapters</groupId> @@ -13,7 +13,6 @@ <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <java.version>1.8</java.version> </properties> <name>so-appc-orchestrator</name> <description>MSO APPC-C Orchestrator</description> @@ -40,6 +39,9 @@ <executions> <execution> <id>extract-docker-file</id> + <configuration> + <skip>false</skip> + </configuration> </execution> </executions> </plugin> @@ -54,19 +56,6 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - <version>3.3</version> - <configuration> - <source>1.8</source> - <target>1.8</target> - <fork>true</fork> - <compilerArgs> - <arg>-parameters</arg> - </compilerArgs> - </configuration> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <executions> <execution> diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 20093be6a4..1da6fc096f 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -52,7 +52,6 @@ import org.onap.appc.client.lcm.model.ZULU; @Component public class ApplicationControllerClient { - @Autowired public Environment env; @@ -117,6 +116,7 @@ public class ApplicationControllerClient { controllerType = DEFAULT_CONTROLLER_TYPE; } controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); } catch (AppcClientException e) { @@ -128,7 +128,7 @@ public class ApplicationControllerClient { } public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, - Optional<String> request, String controllerType, ApplicationControllerCallback listener) + Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException { this.setControllerType(controllerType); Status status; @@ -142,7 +142,7 @@ public class ApplicationControllerClient { payload = new Payload(request.get()); } - status = runCommand(action, actionIdentifiers, payload, requestId, listener); + status = runCommand(action, actionIdentifiers, payload, requestId, listener, requestorId); if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); } else { @@ -152,11 +152,11 @@ public class ApplicationControllerClient { public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, - org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) - throws ApplicationControllerOrchestratorException { + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener, + String requestorId) throws ApplicationControllerOrchestratorException { Status status; Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); + requestObject = createRequest(action, actionIdentifiers, payload, requestID, requestorId); appCSupport.logLCMMessage(requestObject); LifeCycleManagerStateful client = getAppCClient(); Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); @@ -194,12 +194,13 @@ public class ApplicationControllerClient { return properties; } - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, + String requestorId) { Object requestObject = appCSupport.getInput(action.name()); try { - CommonHeader commonHeader = buildCommonHeader(requestId); + CommonHeader commonHeader = buildCommonHeader(requestId, requestorId); requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader); requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); @@ -215,12 +216,13 @@ public class ApplicationControllerClient { return requestObject; } - private CommonHeader buildCommonHeader(String requestId) { + private CommonHeader buildCommonHeader(String requestId, String requestorId) { CommonHeader commonHeader = new CommonHeader(); commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(UUID.randomUUID().toString()); + commonHeader.setXOnapRequestorid(requestorId); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java index 8e38935441..e61053d043 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -111,7 +111,7 @@ public class ApplicationControllerTaskImpl { status = appcClient.vnfCommand(request.getAction(), msoRequestId, request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), - listener); + listener, request.getRequestorId()); return status; } diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java index 82b0695ed9..cac8e9e16a 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -63,6 +63,7 @@ public class ApplicationControllerTaskImplITTest { @Before public void setup() { request = new ApplicationControllerTaskRequest(); + request.setRequestorId("testRequestorId"); request.setBookName("testBookName"); request.setControllerType("testControllerType"); request.setFileParameters("testFileParams"); diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java index ff979acf7b..fe2b4f84b5 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -52,6 +52,7 @@ public class ApplicationControllerTaskImplTest { request.setNewSoftwareVersion("2.0"); request.setExistingSoftwareVersion("1.0"); request.setOperationsTimeout("30"); + request.setRequestorId("testRequestorId"); Map<String, String> reqConfigParams = new HashMap<>(); reqConfigParams.put("name1", "value1"); reqConfigParams.put("name2", "value2"); @@ -77,13 +78,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @@ -99,13 +100,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -118,13 +119,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -133,13 +134,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener)).thenReturn(new Status()); + "testControllerType", listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener); + "testControllerType", listener, "testRequestorId"); } @Test @@ -154,13 +155,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -179,13 +180,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -204,13 +205,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -224,13 +225,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -251,13 +252,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test |