diff options
187 files changed, 2093 insertions, 10263 deletions
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/Readme.txt index aaad60320d..aaad60320d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/Readme.txt +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/Readme.txt diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml new file mode 100644 index 0000000000..85024edee0 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/pom.xml @@ -0,0 +1,86 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-adapter-application</artifactId> + <name>ETSI SOL003 Application Jar</name> + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <configuration> + <mainClass>org.onap.so.adapters.etsi.sol003.adapter.VnfmAdapterApplication</mainClass> + </configuration> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>original</id> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <so.log.level>DEBUG</so.log.level> + </systemPropertyVariables> + <rerunFailingTestsCount>2</rerunFailingTestsCount> + <parallel>suites</parallel> + <useUnlimitedThreads>false</useUnlimitedThreads> + <threadCount>1</threadCount> + </configuration> + </plugin> + </plugins> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <excludes> + <exclude>**/*.p12</exclude> + <exclude>**/*.jks</exclude> + </excludes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <includes> + <include>**/*.p12</include> + <include>**/*.jks</include> + </includes> + </resource> + </resources> + </build> + <dependencies> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-lcm-adapter</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management-adapter</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java index 405bf896ef..6fe76db5e4 100755 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmAdapterApplication.java @@ -18,10 +18,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.VnfmAdapterController; import org.slf4j.Logger; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java index f1815054e3..cfc4ef02d7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmBasicHttpSecurityConfigurer.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/VnfmBasicHttpSecurityConfigurer.java @@ -20,8 +20,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter; +import org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants; import org.onap.so.security.HttpSecurityConfigurer; import org.onap.so.security.SoUserCredentialConfiguration; import org.springframework.beans.factory.annotation.Autowired; @@ -52,7 +53,7 @@ public class VnfmBasicHttpSecurityConfigurer implements HttpSecurityConfigurer { http.csrf().disable().authorizeRequests().anyRequest().permitAll(); } else { http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll() - .antMatchers(HttpMethod.GET, Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll() + .antMatchers(HttpMethod.GET, CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL).permitAll() .antMatchers("/**") .hasAnyRole(StringUtils.collectionToDelimitedString(soUserCredentialConfiguration.getRoles(), ",")) .and().httpBasic(); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application-aaf.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application-aaf.yaml index e69de29bb2..e69de29bb2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application-aaf.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application-aaf.yaml diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application-basic.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application-basic.yaml index e69de29bb2..e69de29bb2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application-basic.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application-basic.yaml diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application.yaml index 57dc08f3b5..57dc08f3b5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/application.yaml diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/org.onap.so.trust.jks b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/org.onap.so.trust.jks Binary files differindex 1f0d8a550a..1f0d8a550a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/org.onap.so.trust.jks +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/org.onap.so.trust.jks diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/so-vnfm-adapter.p12 b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/so-vnfm-adapter.p12 Binary files differindex ae4fddc684..ae4fddc684 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/so-vnfm-adapter.p12 +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-application/src/main/resources/so-vnfm-adapter.p12 diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml new file mode 100644 index 0000000000..9c88f6a546 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/pom.xml @@ -0,0 +1,24 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-adapter-common</artifactId> + <name>ETSI SOL003 Adapter Common</name> + + <dependencies> + <dependency> + <groupId>org.springframework.security.oauth</groupId> + <artifactId>spring-security-oauth2</artifactId> + <version>${spring-security-oauth2-version}</version> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/CommonConstants.java index d798267918..dbe4dac321 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/Constants.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/CommonConstants.java @@ -18,33 +18,30 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter.common; /** - * VNFM Adapter constants + * VNFM Adapter Common constants * - * @author Ronan Kenny (ronan.kenny@est.tech) + * @author Waqas Ikram (waqas.ikram@est.tech) * @author Gareth Roper (gareth.roper@est.tech) */ -public class Constants { +public class CommonConstants { public static final String SERVICE_NAME = "vnfm-adapter"; public static final String SERVICE_VERSION = "v1"; public static final String BASE_URL = "/so/" + SERVICE_NAME + "/" + SERVICE_VERSION; + public static final String PACKAGE_MANAGEMENT_BASE_URL = BASE_URL + "/vnfpkgm/v1"; + public static final String ETSI_CATALOG_MANAGER_BASE_ENDPOINT = "/etsicatalogmanager"; public static final String ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT = "/notification"; public static final String ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL = BASE_URL + ETSI_CATALOG_MANAGER_BASE_ENDPOINT; public static final String ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL = ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL + ETSI_SUBSCRIPTION_NOTIFICATION_ENDPOINT; - public static final String APPLICATION_ZIP = "application/zip"; - public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification"; - /** - * Name of the subscription cache - */ - public static final String PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE = "PackageManagementSubscriptionCache"; + public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification"; - private Constants() {} + private CommonConstants() {} } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/VnfmAdapterUrlProvider.java index 411a57069f..855b5a454f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterUrlProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/VnfmAdapterUrlProvider.java @@ -17,12 +17,12 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter.common; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL; -import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; -import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.OPERATION_NOTIFICATION_ENDPOINT; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.PACKAGE_MANAGEMENT_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; import java.net.URI; import java.security.GeneralSecurityException; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/MessageConverterConfiguration.java index bb2730bd2b..25c37b9016 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/MessageConverterConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/common/configuration/MessageConverterConfiguration.java @@ -17,26 +17,19 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter.common.configuration; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; import java.util.ArrayList; import java.util.Collection; -import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.PkgChangeNotificationConverter; -import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.PkgOnboardingNotificationConverter; -import org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003.VnfPkgInfoConverter; -import org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog.PkgmSubscriptionRequestConverter; -import org.onap.so.adapters.vnfmadapter.oauth.OAuth2AccessTokenAdapter; -import org.springframework.beans.factory.annotation.Autowired; +import org.onap.so.adapters.etsi.sol003.adapter.oauth.configuration.OAuth2AccessTokenAdapter; import org.springframework.boot.autoconfigure.http.HttpMessageConverters; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import org.springframework.core.convert.ConversionService; -import org.springframework.core.convert.support.DefaultConversionService; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.GsonHttpMessageConverter; import org.springframework.security.oauth2.common.OAuth2AccessToken; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; /** * Configures message converter @@ -44,23 +37,6 @@ import org.springframework.security.oauth2.common.OAuth2AccessToken; @Configuration public class MessageConverterConfiguration { - private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider; - - @Autowired - public MessageConverterConfiguration(final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) { - this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider; - } - - @Bean - public ConversionService conversionService() { - final DefaultConversionService service = new DefaultConversionService(); - service.addConverter(new VnfPkgInfoConverter(vnfmAdapterUrlProvider)); - service.addConverter(new PkgmSubscriptionRequestConverter()); - service.addConverter(new PkgChangeNotificationConverter()); - service.addConverter(new PkgOnboardingNotificationConverter()); - return service; - } - @Bean public HttpMessageConverters customConverters() { final Collection<HttpMessageConverter<?>> messageConverters = new ArrayList<>(); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/AuthorizationServerConfig.java index 7f71b2e9d6..3a3287535e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/AuthorizationServerConfig.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/AuthorizationServerConfig.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.oauth; +package org.onap.so.adapters.etsi.sol003.adapter.oauth.configuration; import org.onap.so.utils.CryptoUtils; import org.springframework.beans.factory.annotation.Value; @@ -46,7 +46,7 @@ public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdap @Override public void configure(final ClientDetailsServiceConfigurer clients) throws Exception { final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":"); - BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); + final BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder(); clients.inMemory().withClient(decrypedAuth[0]).secret(passwordEncoder.encode(decrypedAuth[1])) .authorizedGrantTypes("client_credentials").scopes("write").accessTokenValiditySeconds(ONE_DAY) .refreshTokenValiditySeconds(ONE_DAY); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/OAuth2AccessTokenAdapter.java index 2f51406e23..4be5b8a86a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2AccessTokenAdapter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/OAuth2AccessTokenAdapter.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.oauth; +package org.onap.so.adapters.etsi.sol003.adapter.oauth.configuration; import com.google.gson.JsonArray; import com.google.gson.JsonElement; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/OAuth2ResourceServer.java index 1f0594e811..2dcfea4045 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/oauth/OAuth2ResourceServer.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-adapter-common/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/oauth/configuration/OAuth2ResourceServer.java @@ -18,10 +18,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.oauth; +package org.onap.so.adapters.etsi.sol003.adapter.oauth.configuration; import javax.servlet.http.HttpServletRequest; -import org.onap.so.adapters.vnfmadapter.Constants; +import org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; @@ -38,7 +38,8 @@ public class OAuth2ResourceServer extends ResourceServerConfigurerAdapter { @Override public void configure(final HttpSecurity http) throws Exception { http.requestMatcher(new OAuth2ResourceServerRequestMatcher()).authorizeRequests() - .antMatchers(Constants.BASE_URL + "/grants/**", Constants.BASE_URL + "/lcn/**").authenticated(); + .antMatchers(CommonConstants.BASE_URL + "/grants/**", CommonConstants.BASE_URL + "/lcn/**") + .authenticated(); } private static class OAuth2ResourceServerRequestMatcher implements RequestMatcher { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml index 66b1d2e12e..560cd87bee 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/pom.xml @@ -3,44 +3,15 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter</artifactId> + <artifactId>etsi-sol003-lcm</artifactId> <version>1.6.0-SNAPSHOT</version> </parent> - <artifactId>mso-vnfm-etsi-adapter</artifactId> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - </properties> - <name>mso-vnfm-etsi-adapter</name> - <description>MSO ETSI compliant VNFM Adapter</description> + <artifactId>etsi-sol003-lcm-adapter</artifactId> + <name>ETSI SOL003 Life Cycle Management Adapter</name> <build> - <finalName>${project.artifactId}-${project.version}</finalName> <plugins> <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - <configuration> - <mainClass>org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication</mainClass> - </configuration> - <executions> - <execution> - <goals> - <goal>repackage</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <id>original</id> - </execution> - </executions> - </plugin> - <plugin> <groupId>org.jacoco</groupId> <artifactId>jacoco-maven-plugin</artifactId> </plugin> @@ -58,24 +29,6 @@ </configuration> </plugin> </plugins> - <resources> - <resource> - <directory>src/main/resources</directory> - <filtering>true</filtering> - <excludes> - <exclude>**/*.p12</exclude> - <exclude>**/*.jks</exclude> - </excludes> - </resource> - <resource> - <directory>src/main/resources</directory> - <filtering>false</filtering> - <includes> - <include>**/*.p12</include> - <include>**/*.jks</include> - </includes> - </resource> - </resources> </build> <dependencies> <dependency> @@ -108,23 +61,23 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.springframework.security.oauth</groupId> - <artifactId>spring-security-oauth2</artifactId> - <version>2.3.6.RELEASE</version> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-adapters-rest-interface</artifactId> + <artifactId>etsi-sol003-adapter-common</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter-api</artifactId> + <artifactId>etsi-sol003-lcm-api</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter-ext-clients</artifactId> + <artifactId>etsi-sol003-lcm-ext-clients</artifactId> <version>${project.version}</version> </dependency> <dependency> @@ -136,13 +89,8 @@ <artifactId>jersey-common</artifactId> </dependency> <dependency> - <groupId>org.glassfish.jersey.core</groupId> - <artifactId>jersey-client</artifactId> - </dependency> - <dependency> <groupId>org.glassfish.jersey.inject</groupId> <artifactId>jersey-hk2</artifactId> - <version>2.26</version> </dependency> <dependency> <groupId>org.glassfish.jersey.media</groupId> @@ -151,7 +99,11 @@ <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> - <version>1.23</version> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> </dependency> </dependencies> -</project> +</project>
\ No newline at end of file diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/LifeCycleManagementConstants.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/LifeCycleManagementConstants.java new file mode 100644 index 0000000000..ec82c17971 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/LifeCycleManagementConstants.java @@ -0,0 +1,33 @@ +/*- + * ============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.etsi.sol003.adapter.lcm; + +/** + * ETSI SOL003 Life Cycle Management Adapter constants + * + * @author Waqas Ikram (waqas.ikram@est.tech) + */ +public class LifeCycleManagementConstants { + + public static final String OPERATION_NOTIFICATION_ENDPOINT = "/lcn/VnfLcmOperationOccurrenceNotification"; + + private LifeCycleManagementConstants() {} +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/NvfmAdapterUtils.java index db34cbf3f2..2132108ca2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/NvfmAdapterUtils.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/NvfmAdapterUtils.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter; +package org.onap.so.adapters.etsi.sol003.adapter.lcm; import com.google.gson.JsonElement; import com.google.gson.JsonObject; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/AbstractServiceProviderConfiguration.java index 8f6d853997..84dd549d61 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/AbstractServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/AbstractServiceProviderConfiguration.java @@ -18,15 +18,15 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients; -import com.google.gson.Gson; import java.util.Iterator; -import org.onap.vnfmadapter.v1.JSON; +import org.onap.etsi.sol003.adapter.lcm.v1.JSON; 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; /** * A base class that can be extended by classes for configuring HttpRestServiceProvider classes. Provides common methods diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/SdcPackageProvider.java index 735e1f9d42..907a15d3bc 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/SdcPackageProvider.java @@ -20,7 +20,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients; import static com.google.common.base.Splitter.on; import static com.google.common.collect.Iterables.filter; @@ -28,10 +28,10 @@ import static com.google.common.io.ByteStreams.toByteArray; import static java.lang.String.format; import static org.apache.http.HttpHeaders.ACCEPT; import static org.apache.http.HttpHeaders.AUTHORIZATION; -import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation; -import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child; -import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement; -import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children; +import static org.onap.so.adapters.etsi.sol003.adapter.lcm.NvfmAdapterUtils.abortOperation; +import static org.onap.so.adapters.etsi.sol003.adapter.lcm.NvfmAdapterUtils.child; +import static org.onap.so.adapters.etsi.sol003.adapter.lcm.NvfmAdapterUtils.childElement; +import static org.onap.so.adapters.etsi.sol003.adapter.lcm.NvfmAdapterUtils.children; import static org.slf4j.LoggerFactory.getLogger; import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE; import com.google.common.io.ByteStreams; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiClientProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiClientProvider.java index 674314d9da..f12ff4c89b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiClientProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiClientProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; import org.onap.so.client.aai.AAIResourcesClient; import org.springframework.context.annotation.Bean; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiHelper.java index fc9efef947..806193fc5f 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiHelper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; import java.util.Collections; import java.util.HashMap; @@ -32,10 +32,10 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.TenantNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; -import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.TenantNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmNotFoundException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiPropertiesImpl.java index cfaad3fd04..cc1af3d215 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiPropertiesImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiPropertiesImpl.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; import org.onap.so.client.aai.AAIProperties; import org.onap.so.client.aai.AAIVersion; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiServiceProvider.java index d19190d88e..68a8405c0a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiServiceProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.aai.domain.yang.EsrVnfm; @@ -26,7 +26,7 @@ import org.onap.aai.domain.yang.EsrVnfmList; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Vserver; -import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; /** * Provides methods for invoking REST calls to AAI. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiServiceProviderImpl.java index 6dc6020834..140d0370e0 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/AaiServiceProviderImpl.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; import org.onap.aai.domain.yang.EsrSystemInfoList; import org.onap.aai.domain.yang.EsrVnfm; @@ -26,10 +26,10 @@ import org.onap.aai.domain.yang.EsrVnfmList; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Vserver; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; -import org.onap.vnfmadapter.v1.model.Tenant; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/OamIpAddressSource.java index 311c4de8bd..25bacce705 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/OamIpAddressSource.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/aai/OamIpAddressSource.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.aai; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai; /** * Represents the source of the value to use as the AAI OAM IP address of a VNF diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/AccessInfo.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/AccessInfo.java index 9ab7618ee3..b557acd892 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/AccessInfo.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/AccessInfo.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vim.model; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model; import java.util.Objects; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/InterfaceInfo.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/InterfaceInfo.java index ae28ea589c..af11e35e80 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/InterfaceInfo.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/InterfaceInfo.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vim.model; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model; import java.util.Objects; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/VimCredentials.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/VimCredentials.java index 63b00b4ef2..6927d38757 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vim/model/VimCredentials.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vim/model/VimCredentials.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vim.model; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model; import java.util.Objects; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmHelper.java index fabf8839a6..e2f673b6c4 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmHelper.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm; import java.security.GeneralSecurityException; import java.util.ArrayList; @@ -26,26 +26,26 @@ import java.util.List; import java.util.Map; import org.apache.commons.lang3.tuple.ImmutablePair; import org.onap.aai.domain.yang.EsrSystemInfo; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vim.model.InterfaceInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vim.model.VimCredentials; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo; -import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.ExternalVirtualLink; -import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.etsi.sol003.adapter.lcm.v1.model.ExternalVirtualLink; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; +import org.onap.so.adapters.etsi.sol003.adapter.common.VnfmAdapterUrlProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model.AccessInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model.InterfaceInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model.VimCredentials; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InstantiateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsFilter; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsFilter.NotificationTypesEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201VimConnections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProvider.java index cb8c7c4e56..d4ce8c8484 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProvider.java @@ -18,17 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm; -import com.google.common.base.Optional; import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.CreateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InstantiateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.TerminateVnfRequest; +import com.google.common.base.Optional; /** * Provides methods for invoking REST calls to a VNFM. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java index eaaa8d8544..231d19a6aa 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProviderConfiguration.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; import java.io.IOException; @@ -39,7 +39,7 @@ 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.vnfmadapter.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java index d898de3ad0..6adbde2eae 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmServiceProviderImpl.java @@ -18,20 +18,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm; -import com.google.common.base.Optional; import org.onap.aai.domain.yang.EsrVnfm; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest; -import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.CreateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InstantiateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.TerminateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmRequestFailureException; import org.onap.so.rest.exceptions.RestProcessingException; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; @@ -40,6 +39,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Service; +import com.google.common.base.Optional; @Service public class VnfmServiceProviderImpl implements VnfmServiceProvider { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmUrlProvider.java index 9c760b44b1..a88086ff00 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/extclients/vnfm/VnfmUrlProvider.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm; import static org.slf4j.LoggerFactory.getLogger; import java.net.URI; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.aai.domain.yang.EsrSystemInfoList; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmNotFoundException; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/jobmanagement/JobManager.java index 3de94ebe05..84d1022424 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/JobManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/jobmanagement/JobManager.java @@ -18,25 +18,25 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.jobmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement; import static org.slf4j.LoggerFactory.getLogger; -import com.google.common.base.Optional; -import com.google.common.collect.Maps; import java.util.Map; import java.util.UUID; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.JobNotFoundException; +import org.onap.etsi.sol003.adapter.lcm.v1.model.OperationEnum; +import org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStateEnum; +import org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStatusRetrievalStatusEnum; +import org.onap.etsi.sol003.adapter.lcm.v1.model.QueryJobResponse; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.JobNotFoundException; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; -import org.onap.vnfmadapter.v1.model.OperationEnum; -import org.onap.vnfmadapter.v1.model.OperationStateEnum; -import org.onap.vnfmadapter.v1.model.OperationStatusRetrievalStatusEnum; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Optional; +import com.google.common.collect.Maps; /** * Manages jobs enabling the status of jobs to be queried. A job is associated with an operation on a VNFM. @@ -134,11 +134,11 @@ public class JobManager { final InlineResponse200 operationResponse) { switch (vnfmOperation.getNotificationStatus()) { case NOTIFICATION_PROCESSING_PENDING: - return org.onap.vnfmadapter.v1.model.OperationStateEnum.PROCESSING; + return org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStateEnum.PROCESSING; case NOTIFICATION_PROCEESING_SUCCESSFUL: - return org.onap.vnfmadapter.v1.model.OperationStateEnum.COMPLETED; + return org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStateEnum.COMPLETED; case NOTIFICATION_PROCESSING_FAILED: - return org.onap.vnfmadapter.v1.model.OperationStateEnum.FAILED; + return org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStateEnum.FAILED; default: if (operationResponse == null || operationResponse.getOperationState() == null) return null; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/jobmanagement/VnfmOperation.java index 3bfe48af12..f28eeb9ebc 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/jobmanagement/VnfmOperation.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/jobmanagement/VnfmOperation.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.jobmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement; /** * Represents an operation on a VNFM. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/lifecycle/LifecycleManager.java index a885721b76..74c6571c3d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/lifecycle/LifecycleManager.java @@ -18,36 +18,36 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.lifecycle; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.lifecycle; -import com.google.common.base.Optional; import java.util.Map; import org.onap.aai.domain.yang.EsrVnfm; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; -import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InstantiateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.TerminateVnfRequest.TerminationTypeEnum; -import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmRequestFailureException; -import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.DeleteVnfResponse; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.SdcPackageProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource.OamIpAddressType; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InstantiateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.TerminateVnfRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.TerminateVnfRequest.TerminationTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmRequestFailureException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import com.google.common.base.Optional; /** * Manages lifecycle operations towards the VNFMs. @@ -155,8 +155,8 @@ public class LifecycleManager { private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf, final String vnfIdInAai, final EsrVnfm vnfm) { logger.debug("Sending a create request to SVNFM " + aaiRequest); - final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest = - new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest(); + final org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.CreateVnfRequest vnfmRequest = + new org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.CreateVnfRequest(); final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId()); vnfmRequest.setVnfdId(vnfdId); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/notificationhandling/NotificationHandler.java index 63ec4ccc57..43a8c352ff 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/notificationhandling/NotificationHandler.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.notificationhandling; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.notificationhandling; import static org.slf4j.LoggerFactory.getLogger; import java.util.HashMap; @@ -29,18 +29,18 @@ import org.json.JSONObject; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo; -import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource.OamIpAddressType; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201VimConnectionInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; import org.slf4j.Logger; /** diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003GrantController.java index 21b20b0134..a9682964d8 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003GrantController.java @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.BASE_URL; import java.util.ArrayList; import java.util.List; import java.util.UUID; import javax.ws.rs.core.MediaType; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201AddResources; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections; -import org.onap.vnfmadapter.v1.model.Tenant; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantsAddResources; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201AddResources; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201VimConnections; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003LcnContoller.java index f97822a0cd..26ba1fffcf 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnContoller.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003LcnContoller.java @@ -18,27 +18,27 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; -import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.lcm.LifeCycleManagementConstants.OPERATION_NOTIFICATION_ENDPOINT; import static org.slf4j.LoggerFactory.getLogger; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import javax.ws.rs.core.MediaType; import org.onap.aai.domain.yang.EsrVnfm; import org.onap.aai.domain.yang.GenericVnf; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierCreationNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierDeletionNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; -import org.onap.so.adapters.vnfmadapter.notificationhandling.NotificationHandler; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.VnfmServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfIdentifierCreationNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfIdentifierDeletionNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.notificationhandling.NotificationHandler; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/VnfmAdapterController.java index 8eccc476d2..9b571af81e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterController.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/VnfmAdapterController.java @@ -18,16 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; -import io.swagger.annotations.ApiParam; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.BASE_URL; +import javax.validation.Valid; +import javax.ws.rs.core.MediaType; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.DeleteVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.QueryJobResponse; import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager; -import org.onap.so.adapters.vnfmadapter.lifecycle.LifecycleManager; -import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.jobmanagement.JobManager; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lifecycle.LifecycleManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.MDC; @@ -42,9 +44,7 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; -import javax.validation.Valid; -import javax.ws.rs.core.MediaType; -import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL; +import io.swagger.annotations.ApiParam; /** * Controller for handling requests to the VNFM (Virtual Network Function Manager) adapter REST API. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/JobNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/JobNotFoundException.java index bc7c569231..a5fac29ec7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/JobNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/JobNotFoundException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/TenantNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/TenantNotFoundException.java index 215e68adcf..d120f7e81a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/TenantNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/TenantNotFoundException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions; /** * Exception for Tenant not found. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfNotFoundException.java index 9b73293020..31ea91ae72 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfNotFoundException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfmNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfmNotFoundException.java index 4e494c14c6..d4107616c3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfmNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfmNotFoundException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfmRequestFailureException.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfmRequestFailureException.java index 9f50a2cee1..c2add907fe 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfmRequestFailureException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/exceptions/VnfmRequestFailureException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions; /** * Exception indicating a request to a VNFM failed. diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties new file mode 100644 index 0000000000..1d13643147 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties @@ -0,0 +1 @@ +org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiPropertiesImpl
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/HealthCheckTest.java index 07c471ec87..8b3c7f3ce7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/HealthCheckTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/HealthCheckTest.java @@ -18,11 +18,12 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; +import static org.junit.Assert.assertEquals; +import java.net.URI; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -31,11 +32,9 @@ import org.springframework.http.RequestEntity; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import java.net.URI; -import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class HealthCheckTest { diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003GrantControllerTest.java index 69223d7922..d15693ddfc 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003GrantControllerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -42,15 +42,14 @@ import org.onap.aai.domain.yang.GenericVnfs; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantRequest.OperationEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantsAddResources; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantsAddResources.TypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantsLinks; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.GrantsLinksVnfLcmOpOcc; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model.InlineResponse201VimConnections; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.springframework.beans.factory.annotation.Autowired; @@ -63,11 +62,10 @@ import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class Sol003GrantControllerTest { @@ -82,7 +80,6 @@ public class Sol003GrantControllerTest { @Autowired @Qualifier(CONFIGURABLE_REST_TEMPLATE) private RestTemplate testRestTemplate; - private MockRestServiceServer mockRestServer; @MockBean private AAIResourcesClient aaiResourcesClient; @@ -92,7 +89,6 @@ public class Sol003GrantControllerTest { @Before public void setUp() throws Exception { - mockRestServer = MockRestServiceServer.bindTo(testRestTemplate).build(); setUpVimInMockAai(); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003LcnControllerTest.java index cd92d987d7..ec35099469 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/Sol003LcnControllerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; import static org.junit.Assert.assertEquals; import static org.mockito.ArgumentMatchers.eq; @@ -30,7 +30,6 @@ import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; -import com.google.gson.Gson; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -54,26 +53,24 @@ import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.Vserver; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource; -import org.onap.so.adapters.vnfmadapter.extclients.aai.OamIpAddressSource.OamIpAddressType; -import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationComputeResource; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfIdentifierCreationNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201Links; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.AaiHelper; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.aai.OamIpAddressSource.OamIpAddressType; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vim.model.AccessInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201Links; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201LinksSelf; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201VimConnectionInfo; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationAffectedVnfcs.ChangeTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationComputeResource; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinks; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.LcnVnfLcmOperationOccurrenceNotificationLinksVnfInstance; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfIdentifierCreationNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification.OperationStateEnum; import org.onap.so.client.aai.AAIResourcesClient; -import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -88,9 +85,10 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.client.MockRestServiceServer; import org.springframework.web.client.RestTemplate; +import com.google.gson.Gson; @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class Sol003LcnControllerTest { diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/TestApplication.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/TestApplication.java new file mode 100755 index 0000000000..9c2453db85 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/TestApplication.java @@ -0,0 +1,38 @@ +/*- + * ============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.etsi.sol003.adapter.lcm.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.cache.annotation.EnableCaching; + +@EnableCaching +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) +public class TestApplication { + + public static void main(final String[] args) { + new SpringApplication(TestApplication.class).run(args); + } + +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/VnfmAdapterControllerTest.java index fca50ea6f2..4280e579be 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/lcm/rest/VnfmAdapterControllerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.lcm.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -33,7 +33,6 @@ import static org.springframework.test.web.client.match.MockRestRequestMatchers. import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; -import com.google.gson.Gson; import java.net.URI; import java.util.Optional; import org.hamcrest.BaseMatcher; @@ -52,26 +51,25 @@ import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.JSON; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201Links; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfRequest; +import org.onap.etsi.sol003.adapter.lcm.v1.model.CreateVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.DeleteVnfResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.OperationEnum; +import org.onap.etsi.sol003.adapter.lcm.v1.model.OperationStateEnum; +import org.onap.etsi.sol003.adapter.lcm.v1.model.QueryJobResponse; +import org.onap.etsi.sol003.adapter.lcm.v1.model.Tenant; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.SdcPackageProvider; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201.InstantiationStateEnum; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201Links; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse201LinksSelf; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.JSON; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.rest.exceptions.VnfmNotFoundException; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.AAIVersion; import org.onap.so.client.aai.entities.uri.AAIResourceUri; -import org.onap.vnfmadapter.v1.model.CreateVnfRequest; -import org.onap.vnfmadapter.v1.model.CreateVnfResponse; -import org.onap.vnfmadapter.v1.model.DeleteVnfResponse; -import org.onap.vnfmadapter.v1.model.OperationEnum; -import org.onap.vnfmadapter.v1.model.OperationStateEnum; -import org.onap.vnfmadapter.v1.model.QueryJobResponse; -import org.onap.vnfmadapter.v1.model.Tenant; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -90,11 +88,11 @@ import org.springframework.web.client.RestTemplate; import org.threeten.bp.LocalDateTime; import org.threeten.bp.OffsetDateTime; import org.threeten.bp.ZoneOffset; +import com.google.gson.Gson; @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") - public class VnfmAdapterControllerTest { private static final OffsetDateTime JAN_1_2019_12_00 = @@ -153,14 +151,14 @@ public class VnfmAdapterControllerTest { .location(new URI("http://vnfm2:8080/vnf_lcm_op_occs/123456"))); final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse( - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.INSTANTIATE, - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING); + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationEnum.INSTANTIATE, + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING); mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_lcm_op_occs/123456")) .andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON)); final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse( - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.INSTANTIATE, - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED); + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationEnum.INSTANTIATE, + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED); mockRestServer.expect(requestTo("http://vnfm2:8080/vnf_lcm_op_occs/123456")) .andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON)); @@ -290,14 +288,14 @@ public class VnfmAdapterControllerTest { .location(new URI("http://vnfm1:8080/vnf_lcm_op_occs/1234567"))); final InlineResponse200 firstOperationQueryResponse = createOperationQueryResponse( - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING); + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationStateEnum.PROCESSING); mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567")) .andRespond(withSuccess(gson.toJson(firstOperationQueryResponse), MediaType.APPLICATION_JSON)); final InlineResponse200 secondOperationQueryReponse = createOperationQueryResponse( - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, - org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED); + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationEnum.TERMINATE, + org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationStateEnum.COMPLETED); mockRestServer.expect(requestTo("http://vnfm1:8080/vnf_lcm_op_occs/1234567")) .andRespond(withSuccess(gson.toJson(secondOperationQueryReponse), MediaType.APPLICATION_JSON)); @@ -413,8 +411,8 @@ public class VnfmAdapterControllerTest { } private InlineResponse200 createOperationQueryResponse( - final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationEnum operation, - final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200.OperationStateEnum operationState) { + final org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationEnum operation, + final org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.InlineResponse200.OperationStateEnum operationState) { final InlineResponse200 response = new InlineResponse200(); response.setId("9876"); response.setOperation(operation); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/resources/application.yaml index cdb6662191..cdb6662191 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/application.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-adapter/src/test/resources/application.yaml diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml index 54f05859d9..06251a2593 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/pom.xml @@ -3,30 +3,17 @@ <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter</artifactId> + <artifactId>etsi-sol003-lcm</artifactId> <version>1.6.0-SNAPSHOT</version> </parent> - <artifactId>mso-vnfm-adapter-api</artifactId> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <gson-fire-version>1.8.2</gson-fire-version> - <retrofit-version>2.3.0</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> - <okhttp3-version>3.14.0</okhttp3-version> - <okhttp-version>2.7.5</okhttp-version> - </properties> - <name>mso-vnfm-adapter-api</name> - <description>MSO VNFM adapter API</description> - + <artifactId>etsi-sol003-lcm-api</artifactId> + <name>ETSI SOL003 Life Cycle Management Adapter API</name> <build> <plugins> <plugin> <groupId>io.swagger</groupId> <artifactId>swagger-codegen-maven-plugin</artifactId> - <version>2.3.1</version> + <version>${version-swagger-codegen}</version> <executions> <execution> <id>vnfmadapter</id> @@ -38,8 +25,10 @@ <language>java</language> <library>retrofit2</library> <output>${project.build.directory}/generated-sources/vnfmadapter</output> - <apiPackage>org.onap.vnfmadapter.v1.api</apiPackage> - <modelPackage>org.onap.vnfmadapter.v1.model</modelPackage> + <apiPackage>org.onap.etsi.sol003.adapter.lcm.v1.api</apiPackage> + <modelPackage>org.onap.etsi.sol003.adapter.lcm.v1.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> <configOptions> <jackson>true</jackson> <sourceFolder>src/gen/java/main</sourceFolder> @@ -50,17 +39,19 @@ </configuration> </execution> <execution> - <id>sol003-packagemanagement-notification-api</id> + <id>sol003-vnf-lcn-api</id> <goals> <goal>generate</goal> </goals> <configuration> - <inputSpec>${basedir}/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json</inputSpec> + <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json</inputSpec> <language>java</language> <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/sol003-vnf-packagemanagement/notification</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model</modelPackage> + <output>${project.build.directory}/generated-sources/sol003-vnf-lcn</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> <configOptions> <sourceFolder>src/gen/java/main</sourceFolder> <withXml>true</withXml> @@ -70,18 +61,21 @@ </configuration> </execution> <execution> - <id>etsicatalog-notification-api</id> + <id>sol003-vnf-grant-api</id> <goals> <goal>generate</goal> </goals> <configuration> - <inputSpec>${basedir}/src/main/resources/ETSI-Catalog-Notification-API.json</inputSpec> + <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json</inputSpec> <language>java</language> <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/etsicatalog/notification</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model</modelPackage> + <output>${project.build.directory}/generated-sources/sol003-vnf-grant</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.grant.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> <configOptions> + <generateSupportingFiles>false</generateSupportingFiles> <sourceFolder>src/gen/java/main</sourceFolder> <withXml>true</withXml> <useRxJava2>true</useRxJava2> @@ -103,9 +97,9 @@ </goals> <configuration> <sources> - <source>${project.basedir}/target/generated-sources/etsicatalog/notification/src/gen/java/main</source> - <source>${project.basedir}/target/generated-sources/sol003-vnf-packagemanagement/notification/src/gen/java/main</source> <source>${project.basedir}/target/generated-sources/vnfmadapter/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-lcn/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-grant/src/gen/java/main</source> </sources> </configuration> </execution> @@ -195,7 +189,7 @@ <dependency> <groupId>com.squareup.okio</groupId> <artifactId>okio</artifactId> - <version>1.13.0</version> + <version>${okio-version}</version> </dependency> <dependency> <groupId>com.squareup.okhttp3</groupId> @@ -222,9 +216,5 @@ <artifactId>logging-interceptor</artifactId> <version>${okhttp-version}</version> </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - </dependency> </dependencies> -</project> +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json index d3b6ebaa7e..d3b6ebaa7e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json index aab56ee2af..aab56ee2af 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/vnfmadapter.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/vnfmadapter.yaml index 9d0a5283af..9d0a5283af 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/vnfmadapter.yaml +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-api/src/main/resources/vnfmadapter.yaml 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 new file mode 100644 index 0000000000..97c261971f --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/pom.xml @@ -0,0 +1,173 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-lcm</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-lcm-ext-clients</artifactId> + <name>ETSI SOL003 Life Cycle Management Adapter Ext Clients</name> + <build> + <plugins> + <plugin> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <version>${version-swagger-codegen}</version> + <executions> + <execution> + <id>sol003-vnf-lcm-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleManagement-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/sol003-vnf-lcm</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> + <configOptions> + <jackson>true</jackson> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/sol003-vnf-lcm/src/gen/java/main</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <goals> + <goal>generate</goal> + </goals> + <versionRange>[2.2.0,)</versionRange> + </pluginExecutionFilter> + <action> + <execute> + <runOnIncremental>false</runOnIncremental> + </execute> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>${swagger-core-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-gson</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>retrofit</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-scalars</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>org.apache.oltu.oauth2</groupId> + <artifactId>org.apache.oltu.oauth2.client</artifactId> + <version>${oltu-version}</version> + </dependency> + <dependency> + <groupId>io.gsonfire</groupId> + <artifactId>gson-fire</artifactId> + <version>${gson-fire-version}</version> + </dependency> + <dependency> + <groupId>org.threeten</groupId> + <artifactId>threetenbp</artifactId> + <version>${threetenbp-version}</version> + </dependency> + <dependency> + <groupId>io.reactivex.rxjava2</groupId> + <artifactId>rxjava</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>adapter-rxjava2</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.okio</groupId> + <artifactId>okio</artifactId> + <version>${okio-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleManagement-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/src/main/resources/SOL003-VNFLifecycleManagement-API.json index 2bc25a2d5b..2bc25a2d5b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFLifecycleManagement-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/etsi-sol003-lcm-ext-clients/src/main/resources/SOL003-VNFLifecycleManagement-API.json diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml new file mode 100644 index 0000000000..e3f87680d8 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-lcm/pom.xml @@ -0,0 +1,17 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-lcm</artifactId> + <name>ETSI SOL003 Life Cycle Management</name> + <packaging>pom</packaging> + <modules> + <module>etsi-sol003-lcm-api</module> + <module>etsi-sol003-lcm-ext-clients</module> + <module>etsi-sol003-lcm-adapter</module> + </modules> +</project>
\ No newline at end of file diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/pom.xml new file mode 100644 index 0000000000..f24ad64db4 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/pom.xml @@ -0,0 +1,109 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-package-management-adapter</artifactId> + <name>ETSI SOL003 VNF Package Management Adapter</name> + + <build> + <plugins> + <plugin> + <groupId>org.jacoco</groupId> + <artifactId>jacoco-maven-plugin</artifactId> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <so.log.level>DEBUG</so.log.level> + </systemPropertyVariables> + <rerunFailingTestsCount>2</rerunFailingTestsCount> + <parallel>suites</parallel> + <useUnlimitedThreads>false</useUnlimitedThreads> + <threadCount>1</threadCount> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-web</artifactId> + <exclusions> + <exclusion> + <groupId>com.fasterxml.jackson.core</groupId> + <artifactId>jackson-databind</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-actuator</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.onap.so</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter-common</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management-ext-clients</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-client</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.core</groupId> + <artifactId>jersey-common</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.inject</groupId> + <artifactId>jersey-hk2</artifactId> + </dependency> + <dependency> + <groupId>org.glassfish.jersey.media</groupId> + <artifactId>jersey-media-json-jackson</artifactId> + </dependency> + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/ConversionServiceConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/ConversionServiceConfiguration.java new file mode 100644 index 0000000000..ecb8bbbc2e --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/ConversionServiceConfiguration.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * 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.etsi.sol003.adapter.packagemanagement; + +import org.onap.so.adapters.etsi.sol003.adapter.common.VnfmAdapterUrlProvider; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003.PkgChangeNotificationConverter; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003.PkgOnboardingNotificationConverter; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003.VnfPkgInfoConverter; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.sol003.etsicatalog.PkgmSubscriptionRequestConverter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.core.convert.ConversionService; +import org.springframework.core.convert.support.DefaultConversionService; + +/** + * @author Waqas Ikram (waqas.ikram@est.tech) + * + */ +public class ConversionServiceConfiguration { + + private final VnfmAdapterUrlProvider vnfmAdapterUrlProvider; + + @Autowired + public ConversionServiceConfiguration(final VnfmAdapterUrlProvider vnfmAdapterUrlProvider) { + this.vnfmAdapterUrlProvider = vnfmAdapterUrlProvider; + } + + @Bean + public ConversionService conversionService() { + final DefaultConversionService service = new DefaultConversionService(); + service.addConverter(new VnfPkgInfoConverter(vnfmAdapterUrlProvider)); + service.addConverter(new PkgmSubscriptionRequestConverter()); + service.addConverter(new PkgChangeNotificationConverter()); + service.addConverter(new PkgOnboardingNotificationConverter()); + return service; + } + +} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/PackageManagementConstants.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/PackageManagementConstants.java new file mode 100644 index 0000000000..9f39b092eb --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/PackageManagementConstants.java @@ -0,0 +1,39 @@ +/*- + * ============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.etsi.sol003.adapter.packagemanagement; + +/** + * ETSI SOL003 VNF Package Management Adapter constants + * + * @author Ronan Kenny (ronan.kenny@est.tech) + * @author Gareth Roper (gareth.roper@est.tech) + */ +public class PackageManagementConstants { + + public static final String APPLICATION_ZIP = "application/zip"; + + /** + * Name of the subscription cache + */ + public static final String PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE = "PackageManagementSubscriptionCache"; + + private PackageManagementConstants() {} +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java index e1c43098f8..5aba579115 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/AbstractPkgNotificationConverter.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgmLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgmLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.URIisprovidedbytheclientwhencreatingthesubscriptionVnfPackageOnboardingNotificationLinksVnfPackage; /** * A base class that can be extended by classes for converting Etsi Catalog Manager Pkg Notification classes. Provides diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java index 8c4168632b..164f6d05b4 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/PkgChangeNotificationConverter.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageChangeNotification; import org.slf4j.Logger; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Service; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java index 836acb6d36..aeaef94304 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/PkgOnboardingNotificationConverter.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageOnboardingNotification; import org.slf4j.Logger; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Service; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/VnfPkgInfoConverter.java index ee941f6951..b6a955bc23 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/etsicatalog/sol003/VnfPkgInfoConverter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/etsicatalog/sol003/VnfPkgInfoConverter.java @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.converters.etsicatalog.sol003; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.etsicatalog.sol003; import java.util.ArrayList; import java.util.List; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesAdditionalArtifacts; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesChecksum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesSoftwareImages; +import org.onap.so.adapters.etsi.sol003.adapter.common.VnfmAdapterUrlProvider; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.Checksum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VNFPKGMLinkSerializer; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPackageArtifactInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesAdditionalArtifacts; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesChecksum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesLinksSelf; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesSoftwareImages; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.convert.converter.Converter; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java index caefe71993..1fb5d8ad5c 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/converters/sol003/etsicatalog/PkgmSubscriptionRequestConverter.java @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.converters.sol003.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.converters.sol003.etsicatalog; import java.util.ArrayList; import java.util.Collections; import java.util.List; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVersions; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProducts; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.Version; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfProducts; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfProductsProviders; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilter1.NotificationTypesEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilter1.OperationalStateEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilter1.UsageStateEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilterVersions; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilterVnfProducts; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; import org.springframework.core.convert.converter.Converter; import org.springframework.stereotype.Service; @@ -46,13 +46,13 @@ import org.springframework.stereotype.Service; */ @Service public class PkgmSubscriptionRequestConverter implements - Converter<PkgmSubscriptionRequest, org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest> { + Converter<PkgmSubscriptionRequest, org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest> { @Override - public org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest convert( + public org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest convert( final PkgmSubscriptionRequest pkgmSubscriptionRequest) { - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = - new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest(); + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = + new org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest(); etsiCatalogManagerSubscriptionRequest .setFilter(getPkgmNotificationsFilter(pkgmSubscriptionRequest.getFilter())); @@ -61,10 +61,10 @@ public class PkgmSubscriptionRequestConverter implements } - private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( + private org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter getPkgmNotificationsFilter( final SubscriptionsFilter1 sol003SubscriptionsFilter) { - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = - new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter(); + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter etsiCatalogManagerFilters = + new org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter(); if (sol003SubscriptionsFilter.getNotificationTypes() != null) { etsiCatalogManagerFilters.setNotificationTypes( @@ -87,14 +87,14 @@ public class PkgmSubscriptionRequestConverter implements } - private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( + private List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> getUsageState( final List<UsageStateEnum> usageStates) { if (usageStates != null) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = + final List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum> etsiCatalogUsageStates = new ArrayList<>(); usageStates.stream().forEach(state -> { etsiCatalogUsageStates.add( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum + org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.UsageStateEnum .fromValue(state.getValue())); }); return etsiCatalogUsageStates; @@ -103,14 +103,14 @@ public class PkgmSubscriptionRequestConverter implements } - private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( + private List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> getOperationalState( final List<OperationalStateEnum> operationalStates) { if (operationalStates != null) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = + final List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum> etsiCatalogOperationalStates = new ArrayList<>(); operationalStates.forEach(state -> { etsiCatalogOperationalStates.add( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum + org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.OperationalStateEnum .fromValue(state.getValue())); }); @@ -180,14 +180,14 @@ public class PkgmSubscriptionRequestConverter implements return Collections.emptyList(); } - private List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> getPkgmNotificationsFilterNotificationTypes( + private List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> getPkgmNotificationsFilterNotificationTypes( final List<NotificationTypesEnum> notificationTypes) { if (notificationTypes != null && !notificationTypes.isEmpty()) { - final List<org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = + final List<org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum> etsiCatalogNotificationTypes = new ArrayList<>(); notificationTypes.forEach(type -> etsiCatalogNotificationTypes.add( - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum + org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter.NotificationTypesEnum .fromValue(type.getValue()))); return etsiCatalogNotificationTypes; } diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/AbstractServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/AbstractServiceProviderConfiguration.java new file mode 100644 index 0000000000..5ac9fe6a0d --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/AbstractServiceProviderConfiguration.java @@ -0,0 +1,49 @@ +/*- + * ============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.etsi.sol003.adapter.packagemanagement.extclients; + +import java.util.Iterator; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.JSON; +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; + +/** + * 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 { + + 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 JSON().getGson(); + restTemplate.getMessageConverters().add(new GsonHttpMessageConverter(gson)); + } +} diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java index 95252218c8..dfa0ab73bd 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogPackageManagementServiceProvider.java @@ -17,10 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; import java.util.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2001; /** * @author Waqas Ikram (waqas.ikram@est.tech) diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProvider.java index 61db82f38c..7a99c344ef 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; /** * Provides methods for invoking REST calls to the ETSI Catalog Manager. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java index 860dfbbe9c..f99bdfe3b7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProviderConfiguration.java @@ -18,13 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; import java.io.IOException; 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; @@ -39,7 +40,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.vnfmadapter.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpClientConnectionConfiguration; import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; @@ -55,7 +56,12 @@ 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 @@ -167,4 +173,15 @@ 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)); + } + } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java index cae413ce10..a27a22d674 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogServiceProviderImpl.java @@ -18,20 +18,20 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; -import static org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_SERVICE_PROVIDER_BEAN; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_SERVICE_PROVIDER_BEAN; import java.util.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerBadRequestException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.EtsiCatalogManagerRequestFailureException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgBadRequestException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgConflictException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfPkgNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.NsdmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.EtsiCatalogManagerBadRequestException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.EtsiCatalogManagerRequestFailureException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.SubscriptionNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.VnfPkgBadRequestException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.VnfPkgConflictException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.VnfPkgNotFoundException; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.InvalidRestRequestException; import org.onap.so.rest.exceptions.RestProcessingException; @@ -183,7 +183,7 @@ public class EtsiCatalogServiceProviderImpl implements EtsiCatalogServiceProvide @Override public Optional<PkgmSubscription> postSubscription( - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest) { + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest) { try { final ResponseEntity<PkgmSubscription> responseEntity = httpServiceProvider.postHttpRequest(etsiCatalogManagerSubscriptionRequest, diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java index ed04ad7746..74e9915819 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogSubscriptionServiceProvider.java @@ -17,11 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; import java.util.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.NsdmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscription; /** * @author Waqas Ikram (waqas.ikram@est.tech) @@ -35,7 +35,7 @@ public interface EtsiCatalogSubscriptionServiceProvider { * @return The ETSI Catalog Manager's PkgmSubscription object. */ Optional<PkgmSubscription> postSubscription( - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest); + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest); /** * Get the Subscription from ETSI Catalog. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogUrlProvider.java index 3b4c4c3066..63564600ca 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/etsicatalog/EtsiCatalogUrlProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/etsicatalog/EtsiCatalogUrlProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.etsicatalog; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog; import static org.slf4j.LoggerFactory.getLogger; import org.slf4j.Logger; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java index 9ed17e4379..57ed2c381a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/extclients/vnfm/VnfmHttpServiceProviderConfiguration.java @@ -17,10 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.extclients.vnfm; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; -import org.onap.so.adapters.vnfmadapter.extclients.AbstractServiceProviderConfiguration; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.AbstractServiceProviderConfiguration; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.onap.so.rest.service.HttpRestServiceProviderImpl; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/EtsiSubscriptionNotificationController.java index a97f04bcc8..0d821fcd69 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationController.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/EtsiSubscriptionNotificationController.java @@ -18,18 +18,18 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; import java.util.AbstractMap; import java.util.Map.Entry; import javax.ws.rs.core.MediaType; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification; -import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.NotificationManager; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.NotificationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.InternalServerErrorException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.NotificationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.NotificationManager; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementController.java index 6d067902c5..275ffa21e5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementController.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementController.java @@ -18,16 +18,16 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.APPLICATION_ZIP; -import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.PackageManagementConstants.APPLICATION_ZIP; import static org.slf4j.LoggerFactory.getLogger; import java.util.Optional; import javax.ws.rs.core.MediaType; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.EtsiCatalogServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2001; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementSubscriptionController.java index 515e317496..73c62afac5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionController.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementSubscriptionController.java @@ -18,19 +18,19 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; -import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.PACKAGE_MANAGEMENT_BASE_URL; import static org.slf4j.LoggerFactory.getLogger; import java.net.URI; import java.security.GeneralSecurityException; import java.util.List; import java.util.Optional; import javax.ws.rs.core.MediaType; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.SubscriptionManager; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.SubscriptionManager; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpHeaders; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/AuthenticationTypeNotSupportedException.java index 303420f1e8..b886f348fe 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/AuthenticationTypeNotSupportedException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/AuthenticationTypeNotSupportedException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/ConversionFailedException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/ConversionFailedException.java index e19a53d1dc..ebb2aeb2c3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/ConversionFailedException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/ConversionFailedException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiCatalogManagerBadRequestException.java index dbd098f7cd..fec2045253 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerBadRequestException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiCatalogManagerBadRequestException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerRequestFailureException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiCatalogManagerRequestFailureException.java index dbdc354f4e..8c20ec1565 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiCatalogManagerRequestFailureException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiCatalogManagerRequestFailureException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java index e8e1ce35b9..434560aa57 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/EtsiSubscriptionNotificationControllerExceptionHandler.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.rest.EtsiSubscriptionNotificationController; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.EtsiSubscriptionNotificationController; import org.onap.so.rest.exceptions.HttpResouceNotFoundException; import org.onap.so.rest.exceptions.InvalidRestRequestException; import org.onap.so.rest.exceptions.RestProcessingException; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/InternalServerErrorException.java index 9b547d3c5a..e3a7207dcb 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/InternalServerErrorException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/InternalServerErrorException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/NotificationTypeNotSupportedException.java index dcc98864aa..42b75d51b2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/NotificationTypeNotSupportedException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/NotificationTypeNotSupportedException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java index 8091f35da6..bfcf451f13 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/Sol003PackageManagementControllerExceptionHandler.java @@ -18,10 +18,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.rest.Sol003PackageManagementController; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.Sol003PackageManagementController; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/SubscriptionNotFoundException.java index 58c2ef050d..65f7245b09 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/SubscriptionNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/SubscriptionNotFoundException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgBadRequestException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgBadRequestException.java index 211131c2a4..bbf80928cb 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgBadRequestException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgBadRequestException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgConflictException.java index f9aa2a0e21..a5ec31318e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgConflictException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgConflictException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgNotFoundException.java index c15e7052ab..0d3cdd27a8 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/exceptions/VnfPkgNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/exceptions/VnfPkgNotFoundException.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest.exceptions; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java index d6b7ae7201..666067b714 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/AbstractNotificationServiceProvider.java @@ -17,9 +17,9 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; -import static org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHttpServiceProviderConfiguration.VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.VnfmHttpServiceProviderConfiguration.VNFM_ADAPTER_HTTP_SERVICE_PROVIDER_BEAN; import java.nio.charset.StandardCharsets; import org.apache.commons.codec.binary.Base64; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java index cf0cdb085a..616493ccf3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/BasicAuthNotificationServiceProvider.java @@ -17,11 +17,11 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationManager.java index c1051d1c9d..aaf824630d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationManager.java @@ -18,22 +18,22 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import static org.slf4j.LoggerFactory.getLogger; import java.util.List; import java.util.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.NotificationTypeNotSupportedException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.AuthenticationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.ConversionFailedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.NotificationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.SubscriptionNotFoundException; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.convert.ConversionService; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java index 2be80eec75..bdba77efcb 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationServiceProvider.java @@ -17,10 +17,10 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; /** * Interface which lays out requirements for a Notification Service Provider diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java index ab67afed82..05795750c3 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/NotificationServiceProviderFactory.java @@ -17,14 +17,14 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import static org.slf4j.LoggerFactory.getLogger; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.AuthenticationTypeNotSupportedException; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java index c065203cd8..e5bc5bdbed 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/OAuthNotificationServiceProvider.java @@ -17,12 +17,12 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.InternalServerErrorException; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.onap.so.configuration.rest.HttpHeadersProvider; import org.onap.so.rest.service.HttpRestServiceProvider; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java index 146641cc7c..b7e288a4be 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/OAuthTokenResponse.java @@ -17,7 +17,7 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import java.io.Serializable; import javax.xml.bind.annotation.XmlElement; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java index a63e14c899..adf0fda1ab 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/SubscriptionManager.java @@ -18,9 +18,9 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; -import static org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication.AuthTypeEnum.BASIC; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.SubscriptionAuthentication.AuthTypeEnum.BASIC; import static org.slf4j.LoggerFactory.getLogger; import java.net.URI; import java.security.GeneralSecurityException; @@ -30,19 +30,19 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterUrlProvider; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProvider; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; -import org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.ConversionFailedException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.InternalServerErrorException; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.SubscriptionNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.common.VnfmAdapterUrlProvider; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.EtsiCatalogServiceProvider; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.BasicAuth; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.NsdmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesLinksSelf; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.ConversionFailedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.InternalServerErrorException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.SubscriptionNotFoundException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache.PackageManagementCacheServiceProvider; import org.slf4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.convert.ConversionService; @@ -76,7 +76,7 @@ public class SubscriptionManager { public Optional<InlineResponse201> createSubscription(final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest = buildEtsiCatalogManagerPkgmSubscriptionRequest(pkgmSubscriptionRequest); final Optional<PkgmSubscription> optionalEtsiCatalogManagerSubscription = @@ -172,13 +172,13 @@ public class SubscriptionManager { .callbackUri(subscription.getCallbackUri()); } - private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest buildEtsiCatalogManagerPkgmSubscriptionRequest( + private org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest buildEtsiCatalogManagerPkgmSubscriptionRequest( final PkgmSubscriptionRequest pkgmSubscriptionRequest) throws GeneralSecurityException { - final org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest; + final org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest etsiCatalogManagerSubscriptionRequest; try { etsiCatalogManagerSubscriptionRequest = conversionService.convert(pkgmSubscriptionRequest, - org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest.class); + org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest.class); } catch (final org.springframework.core.convert.ConversionException conversionException) { logger.error(conversionException.getMessage()); throw new ConversionFailedException( @@ -196,7 +196,7 @@ public class SubscriptionManager { final ImmutablePair<String, String> immutablePair = vnfmAdapterUrlProvider.getDecryptAuth(); if (!immutablePair.equals(ImmutablePair.nullPair())) { etsiCatalogManagerSubscriptionRequest.setAuthentication( - new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication() + new org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.SubscriptionAuthentication() .addAuthTypeItem(BASIC).paramsBasic(new BasicAuth().userName(immutablePair.getLeft()) .password(immutablePair.getRight()))); } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java index c9babbd345..3db2cca75a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/TlsNotificationServiceProvider.java @@ -17,16 +17,17 @@ * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement; import static org.slf4j.LoggerFactory.getLogger; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; -import org.onap.so.adapters.vnfmadapter.rest.exceptions.AuthenticationTypeNotSupportedException; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication.AuthTypeEnum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest.exceptions.AuthenticationTypeNotSupportedException; import org.slf4j.Logger; import org.springframework.stereotype.Service; /** + * * @author Waqas Ikram (waqas.ikram@est.tech) * @author Andrew Lamb (andrew.a.lamb@est.tech) */ diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java index e1e9b2307e..6d92a9f688 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/AbstractCacheServiceProvider.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java index 830db39888..89b1164c1e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/CacheManagerConfiguration.java @@ -18,10 +18,10 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache; import java.util.Arrays; -import org.onap.so.adapters.vnfmadapter.Constants; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.PackageManagementConstants; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; import org.springframework.cache.concurrent.ConcurrentMapCache; @@ -39,7 +39,7 @@ public class CacheManagerConfiguration { @Bean public CacheManager cacheManager() { final SimpleCacheManager manager = new SimpleCacheManager(); - manager.setCaches(Arrays.asList(getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE))); + manager.setCaches(Arrays.asList(getCache(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE))); return manager; } diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java index edd5982ab1..1c9448b50c 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/CacheNotFoundException.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache; /** * Exception for failure to find the cache. diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java index 437d20e593..531beec83a 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProvider.java @@ -18,11 +18,11 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache; import java.util.Map; import java.util.Optional; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; /** * Interface which provides methods for communicating with the cache diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java index ba57eb5e05..8280a4614b 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/main/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/subscriptionmanagement/cache/PackageManagementCacheServiceProviderImpl.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.packagemanagement.subscriptionmanagement.cache; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.subscriptionmanagement.cache; import java.util.Collections; import java.util.HashMap; @@ -26,8 +26,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; -import org.onap.so.adapters.vnfmadapter.Constants; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.PackageManagementConstants; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,7 +49,7 @@ public class PackageManagementCacheServiceProviderImpl extends AbstractCacheServ @Autowired public PackageManagementCacheServiceProviderImpl(final CacheManager cacheManager) { - super(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE, cacheManager); + super(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE, cacheManager); } @Override diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/EtsiSubscriptionNotificationControllerTest.java index 29afa8c549..5f2f8f5c39 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/EtsiSubscriptionNotificationControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/EtsiSubscriptionNotificationControllerTest.java @@ -18,14 +18,17 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.onap.so.adapters.vnfmadapter.Constants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_CONTROLLER_BASE_URL; import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE; import static org.springframework.test.annotation.DirtiesContext.ClassMode.BEFORE_CLASS; -import static org.springframework.test.web.client.match.MockRestRequestMatchers.*; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.header; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.jsonPath; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; +import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess; import java.net.URI; @@ -36,19 +39,18 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.adapters.vnfmadapter.Constants; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.NOTIFICATIONLINKSERIALIZER; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgOnboardingNotification; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.notification.model.PkgmLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsBasic; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageChangeNotification; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.notification.model.VnfPackageOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.NOTIFICATIONLINKSERIALIZER; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model.PkgmLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageChangeNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model.VnfPackageOnboardingNotification; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.PackageManagementConstants; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthenticationParamsBasic; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthenticationParamsOauth2ClientCredentials; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -57,7 +59,11 @@ import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.boot.web.server.LocalServerPort; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; -import org.springframework.http.*; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.test.annotation.DirtiesContext; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.junit4.SpringRunner; @@ -74,7 +80,7 @@ import com.google.gson.GsonBuilder; * */ @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") @DirtiesContext(classMode = BEFORE_CLASS) public class EtsiSubscriptionNotificationControllerTest { @@ -106,7 +112,7 @@ public class EtsiSubscriptionNotificationControllerTest { @Autowired @Qualifier(CONFIGURABLE_REST_TEMPLATE) private RestTemplate restTemplate; - private MockRestServiceServer mockRestServer; + private MockRestServiceServer mockRestServiceServer; @Autowired private TestRestTemplate testRestTemplate; @@ -117,14 +123,15 @@ public class EtsiSubscriptionNotificationControllerTest { @Before public void setUp() { - mockRestServer = MockRestServiceServer.bindTo(restTemplate).build(); + mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build(); basicHttpHeadersProvider = new BasicHttpHeadersProvider(); - cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); + cache = cacheServiceProvider.getCache(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); cache.clear(); } @After public void tearDown() { + mockRestServiceServer.reset(); cache.clear(); } @@ -142,7 +149,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andExpect(jsonPath("$.id").value(NOTIFICATION_ID)) .andExpect(jsonPath("$.notificationType") .value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION @@ -183,7 +190,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -206,7 +213,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.MOVED_PERMANENTLY)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -228,7 +235,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -251,7 +258,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -275,7 +282,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andExpect(jsonPath("$.id").value(NOTIFICATION_ID)) .andExpect(jsonPath("$.notificationType").value( VnfPackageChangeNotification.NotificationTypeEnum.VNFPACKAGECHANGENOTIFICATION.getValue())) @@ -319,7 +326,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -342,7 +349,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -365,7 +372,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<?> response = sendHttpPost(notificationString); @@ -389,7 +396,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgOnboardingNotification notification = buildPkgOnboardingNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andExpect(jsonPath("$.id").value(NOTIFICATION_ID)) .andExpect(jsonPath("$.notificationType") .value(VnfPackageOnboardingNotification.NotificationTypeEnum.VNFPACKAGEONBOARDINGNOTIFICATION @@ -414,7 +421,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)) .andRespond(withStatus(HttpStatus.UNAUTHORIZED)); @@ -438,11 +445,11 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST)) .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)) .andRespond(withSuccess(JSON_TOKEN, MediaType.APPLICATION_JSON)); - mockRestServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(CALLBACK_URI)).andExpect(method(HttpMethod.POST)) .andExpect(header("Authorization", EXPECTED_OAUTH_AUTHORIZATION)) .andExpect(jsonPath("$.id").value(NOTIFICATION_ID)) .andExpect(jsonPath("$.notificationType").value( @@ -470,7 +477,7 @@ public class EtsiSubscriptionNotificationControllerTest { final PkgChangeNotification notification = buildPkgChangeNotification(); final String notificationString = gson.toJson(notification); - mockRestServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST)) + mockRestServiceServer.expect(requestTo(TOKEN_ENDPOINT)).andExpect(method(HttpMethod.POST)) .andExpect(header("Authorization", EXPECTED_BASIC_AUTHORIZATION)).andRespond(withSuccess()); final ResponseEntity<?> response = sendHttpPost(notificationString); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementControllerTest.java index be8b0c2e0b..b473248da1 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementControllerTest.java @@ -18,14 +18,14 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; -import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; -import static org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; @@ -33,19 +33,19 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat import java.util.ArrayList; import java.util.List; import java.util.Random; +import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Checksum; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.UriLink; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VNFPKGMLinkSerializer; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageArtifactInfo; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfPkgInfo; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2001; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.Checksum; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.UriLink; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VNFPKGMLinkSerializer; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPackageArtifactInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPackageSoftwareImageInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfPkgInfo; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2001; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesLinks; import org.onap.so.configuration.rest.BasicHttpHeadersProvider; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; @@ -67,7 +67,7 @@ import com.google.gson.Gson; * @author gareth.roper@est.tech */ @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class Sol003PackageManagementControllerTest { @@ -101,7 +101,7 @@ public class Sol003PackageManagementControllerTest { private static final String EXPECTED_VNFD_HREF = EXPECTED_BASE_URL + VNF_PACKAGE_ID + "/vnfd"; private static final String EXPECTED_PACKAGE_CONTENT_HREF = EXPECTED_BASE_URL + VNF_PACKAGE_ID + "/package_content"; - private MockRestServiceServer mockRestServer; + private MockRestServiceServer mockRestServiceServer; private BasicHttpHeadersProvider basicHttpHeadersProvider; private final Gson gson = new Gson(); @@ -111,15 +111,20 @@ public class Sol003PackageManagementControllerTest { public void setUp() { final MockRestServiceServer.MockRestServiceServerBuilder builder = MockRestServiceServer.bindTo(restTemplate); builder.ignoreExpectOrder(true); - mockRestServer = builder.build(); + mockRestServiceServer = builder.build(); basicHttpHeadersProvider = new BasicHttpHeadersProvider(); } + @After + public void after() { + mockRestServiceServer.reset(); + } + @Test public void testGetPackageContent_ValidArray_Success() { final byte[] responseArray = buildByteArrayWithRandomData(10); - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseArray, MediaType.APPLICATION_OCTET_STREAM)); @@ -136,7 +141,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageContent_Conflict_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -147,7 +152,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageContent_NotFound_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -161,7 +166,7 @@ public class Sol003PackageManagementControllerTest { final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + VNF_PACKAGE_ID + "/package_content"; - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); @@ -176,7 +181,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageContent_InternalServerError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -187,7 +192,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageContent_BadRequest_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -198,7 +203,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageContent_UnauthorizedServer_InternalError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -209,7 +214,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testGetPackageContent_SuccessResponseFromServerWithNullPackage_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/package_content")) .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/package_content"); @@ -222,7 +227,7 @@ public class Sol003PackageManagementControllerTest { public void testGetPackageArtifact_ValidArray_Success() { final byte[] responseArray = buildByteArrayWithRandomData(10); - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseArray, MediaType.APPLICATION_OCTET_STREAM)); @@ -239,7 +244,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageArtifact_Conflict_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); final ResponseEntity<ProblemDetails> responseEntity = @@ -251,7 +256,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageArtifact_NotFound_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<ProblemDetails> responseEntity = @@ -266,7 +271,7 @@ public class Sol003PackageManagementControllerTest { final String testURL = "http://localhost:" + port + PACKAGE_MANAGEMENT_BASE_URL + "/vnf_packages/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH; - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final HttpEntity<?> request = new HttpEntity<>(basicHttpHeadersProvider.getHttpHeaders()); @@ -279,7 +284,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageArtifact_InternalServerError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<ProblemDetails> responseEntity = @@ -291,7 +296,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageArtifact_BadRequest_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<ProblemDetails> responseEntity = @@ -303,7 +308,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageArtifact_UnauthorizedServer_InternalError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final ResponseEntity<ProblemDetails> responseEntity = @@ -315,7 +320,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testGetPackageArtifact_SuccessResponseFromServerWithNullPackage_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/artifacts/" + ARTIFACT_PATH)) .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); final ResponseEntity<ProblemDetails> responseEntity = @@ -329,7 +334,7 @@ public class Sol003PackageManagementControllerTest { public void testVnfPackagesReceivedAsInlineResponse2001ListIfGetVnfPackagesSuccessful() { final VnfPkgInfo[] responses = createVnfPkgArray(); - mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(gson.toJson(responses), MediaType.APPLICATION_JSON)); final String testURL = localhostUrl + port + VNFPKGM_BASE_URL; @@ -360,7 +365,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test400BadRequestInfoReceivedAsProblemDetailsIfGetVnfPackagesIs400BadRequest() { - mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); @@ -373,7 +378,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test404NotFoundInfoReceivedAsProblemDetailsIfGetVnfPackagesIs404NotFound() { - mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); @@ -386,7 +391,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackagesReturns500InternalServerError() { - mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); @@ -399,7 +404,8 @@ public class Sol003PackageManagementControllerTest { @Test public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackagesReturnsANullPackage() { - mockRestServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); + mockRestServiceServer.expect(requestTo(MSB_BASE_URL)).andExpect(method(HttpMethod.GET)) + .andRespond(withSuccess()); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGES_URL); assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode()); @@ -415,7 +421,7 @@ public class Sol003PackageManagementControllerTest { public void testVnfPackageReceivedAsInlineResponse2001IfGetVnfPackageByIdSuccessful() { final VnfPkgInfo response = createVnfPkgInfo(VNF_PACKAGE_ID); - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(gson.toJson(response), MediaType.APPLICATION_JSON)); final String testURL = localhostUrl + port + VNFPKGM_BASE_URL + "/" + VNF_PACKAGE_ID; @@ -445,7 +451,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test400BadRequestInfoReceivedAsProblemDetailsIfGetVnfPackageByIdIs400BadRequest() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); @@ -458,7 +464,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test404NotFoundInfoReceivedAsProblemDetailsIfGetVnfPackageByIdIs404NotFound() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); @@ -471,7 +477,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackageByIdReturns500InternalServerError() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) .andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); @@ -484,7 +490,7 @@ public class Sol003PackageManagementControllerTest { @Test public void test500InternalServerErrorProblemDetailsReceivedIfGetVnfPackageByIdReturnsANullPackage() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID)).andExpect(method(HttpMethod.GET)) .andRespond(withSuccess()); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(GET_VNF_PACKAGE_BY_ID_URL); @@ -503,7 +509,7 @@ public class Sol003PackageManagementControllerTest { public void testGetPackageVnfd_ValidArray_Success() { final byte[] responseArray = buildByteArrayWithRandomData(10); - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)) .andRespond(withSuccess(responseArray, MediaType.APPLICATION_OCTET_STREAM)); @@ -520,7 +526,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_Conflict_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.CONFLICT)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -531,7 +537,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_NotFound_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.NOT_FOUND)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -542,7 +548,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_UnauthorizedClient_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -553,7 +559,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_InternalServerError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.INTERNAL_SERVER_ERROR)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -564,7 +570,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_BadRequest_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.BAD_REQUEST)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -575,7 +581,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testOnGetPackageVnfd_UnauthorizedServer_InternalError_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withStatus(HttpStatus.UNAUTHORIZED)); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); @@ -586,7 +592,7 @@ public class Sol003PackageManagementControllerTest { @Test public void testGetPackageVnfd_SuccessResponseFromServerWithNullPackage_Fail() { - mockRestServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) + mockRestServiceServer.expect(requestTo(MSB_BASE_URL + "/" + VNF_PACKAGE_ID + "/vnfd")) .andExpect(method(HttpMethod.GET)).andRespond(withSuccess()); final ResponseEntity<ProblemDetails> responseEntity = sendHttpRequest(VNF_PACKAGE_ID + "/vnfd"); diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementSubscriptionControllerTest.java index c269af8e68..a2a7c4510e 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003PackageManagementSubscriptionControllerTest.java +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/Sol003PackageManagementSubscriptionControllerTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.adapters.vnfmadapter.rest; +package org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.rest; import static org.hamcrest.Matchers.is; import static org.junit.Assert.assertEquals; @@ -27,8 +27,9 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.onap.so.adapters.vnfmadapter.Constants.PACKAGE_MANAGEMENT_BASE_URL; -import static org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.common.CommonConstants.PACKAGE_MANAGEMENT_BASE_URL; +import static org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.EtsiCatalogServiceProviderConfiguration.ETSI_CATALOG_REST_TEMPLATE_BEAN; import static org.springframework.test.web.client.match.MockRestRequestMatchers.method; import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo; import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus; @@ -47,26 +48,25 @@ import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.so.adapters.vnfmadapter.Constants; -import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.BasicAuth; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.LinkSelf; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.NsdmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmNotificationsFilter; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscription; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.ProblemDetails; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.SubscriptionAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.Version; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProducts; -import org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.VnfProductsProviders; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse2002; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.InlineResponse201; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.PkgmSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilter1; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.SubscriptionsLinks; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model.VnfPackagesLinksSelf; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.PackageManagementConstants; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.BasicAuth; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.LinkSelf; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.NsdmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmNotificationsFilter; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscription; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.ProblemDetails; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.SubscriptionAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.Version; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfProducts; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.VnfProductsProviders; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse2002; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.InlineResponse201; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.PkgmSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilter1; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsFilterVnfProductsFromProviders; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.SubscriptionsLinks; +import org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model.VnfPackagesLinksSelf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.boot.test.context.SpringBootTest; @@ -91,14 +91,14 @@ import com.google.gson.Gson; * @author Gareth Roper (gareth.roper@est.tech) */ @RunWith(SpringRunner.class) -@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ActiveProfiles("test") public class Sol003PackageManagementSubscriptionControllerTest { private final Gson gson = new Gson(); private final URI msbEndpoint = URI.create("http://msb-iag.onap:80/api/vnfpkgm/v1/subscriptions"); private static final String _NOTIFICATION_CALLBACK_URI = - "https://so-vnfm-adapter.onap:30406" + Constants.ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL; + "https://so-vnfm-adapter.onap:30406" + ETSI_SUBSCRIPTION_NOTIFICATION_BASE_URL; private static final String LOCALHOST_URL = "http://localhost:"; @Autowired @@ -121,7 +121,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { @Before public void setUp() { mockRestServiceServer = MockRestServiceServer.bindTo(restTemplate).build(); - final Cache cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); + final Cache cache = + cacheServiceProvider.getCache(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); cache.clear(); } @@ -280,7 +281,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { (ResponseEntity<InlineResponse2002>) sol003PackageManagementSubscriptionController .postSubscriptionRequest(pkgmSubscriptionRequest); - final Cache cache = cacheServiceProvider.getCache(Constants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); + final Cache cache = + cacheServiceProvider.getCache(PackageManagementConstants.PACKAGE_MANAGEMENT_SUBSCRIPTION_CACHE); assertNotNull(cache.get(ID)); final ResponseEntity responseDelete = sol003PackageManagementSubscriptionController.deleteSubscription(ID); @@ -310,9 +312,9 @@ public class Sol003PackageManagementSubscriptionControllerTest { .andRespond(withSuccess(gson.toJson(buildPkgmSubscription()), MediaType.APPLICATION_JSON)); - final ResponseEntity<InlineResponse201> responseEntity = testRestTemplate.postForEntity( - LOCALHOST_URL + port + Constants.PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", request, - InlineResponse201.class); + final ResponseEntity<InlineResponse201> responseEntity = + testRestTemplate.postForEntity(LOCALHOST_URL + port + PACKAGE_MANAGEMENT_BASE_URL + "/subscriptions", + request, InlineResponse201.class); assertEquals(HttpStatus.CREATED, responseEntity.getStatusCode()); assertTrue(responseEntity.hasBody()); @@ -322,8 +324,8 @@ public class Sol003PackageManagementSubscriptionControllerTest { } - private org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest getEtsiCatalogPkgmSubscriptionRequest() { - return new org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model.PkgmSubscriptionRequest() + private org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest getEtsiCatalogPkgmSubscriptionRequest() { + return new org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model.PkgmSubscriptionRequest() .filter(new PkgmNotificationsFilter() .addNotificationTypesItem( PkgmNotificationsFilter.NotificationTypesEnum.VNFPACKAGEONBOARDINGNOTIFICATION) diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/TestApplication.java b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/TestApplication.java new file mode 100755 index 0000000000..7e3f925a58 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/java/org/onap/so/adapters/etsi/sol003/adapter/packagemanagement/rest/TestApplication.java @@ -0,0 +1,38 @@ +/*- + * ============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.etsi.sol003.adapter.packagemanagement.rest; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; +import org.springframework.cache.annotation.EnableCaching; + +@EnableCaching +@SpringBootApplication(scanBasePackages = {"org.onap.so"}) +@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class}) +public class TestApplication { + + public static void main(final String[] args) { + new SpringApplication(TestApplication.class).run(args); + } + +} diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/resources/application.yaml b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/resources/application.yaml new file mode 100644 index 0000000000..cdb6662191 --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/resources/application.yaml @@ -0,0 +1,61 @@ +# Copyright © 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. +spring: + security: + usercredentials: + - username: test + password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu' + role: BPEL-Client + - username: vnfm + password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke' + role: BPEL-Client + main: + allow-bean-definition-overriding: true + +mso: + key: 07a7159d3bf51a0e53be7a8f89699be7 + +aai: + auth: 2A11B07DB6214A839394AA1EC5844695F5114FC407FF5422625FB00175A3DCB8A1FF745F22867EFA72D5369D599BBD88DA8BED4233CF5586 + endpoint: https://aai.onap:8443 + version: v15 + +sdc: + username: sdcUser + password: sdcPassword + key: adadadadad + endpoint: http://sdc.onap/1234A + + +vnfmadapter: + endpoint: https://so-vnfm-adapter.onap:30406 + + +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" + metrics: + se-global-registry: false + export: + prometheus: + enabled: true # Whether exporting of metrics to Prometheus is enabled. + step: 1m # Step size (i.e. reporting frequency) to use. + +etsi-catalog-manager: + vnfpkgm: + endpoint: http://msb-iag.onap:80/api/vnfpkgm/v1 diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/resources/requests/SubscriptionRequest.json index c38466f8e5..c38466f8e5 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/resources/requests/SubscriptionRequest.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-adapter/src/test/resources/requests/SubscriptionRequest.json diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/pom.xml new file mode 100644 index 0000000000..ba7fb65add --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/pom.xml @@ -0,0 +1,195 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-package-management-api</artifactId> + <name>ETSI SOL003 VNF Package Management Adapter API</name> + <build> + <plugins> + <plugin> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <version>${version-swagger-codegen}</version> + <executions> + <execution> + <id>etsicatalog-notification-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/ETSI-Catalog-Notification-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/etsicatalog/notification</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.etsicatalog.notification.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> + <configOptions> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> + <execution> + <id>sol003-vnf-packagemanagement-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/SOL003-VNFPackageManagement-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/sol003-vnf-packagemanagement</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> + <configOptions> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/etsicatalog/notification/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/sol003-vnf-packagemanagement/src/gen/java/main</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <goals> + <goal>generate</goal> + </goals> + <versionRange>[2.2.0,)</versionRange> + </pluginExecutionFilter> + <action> + <execute> + <runOnIncremental>false</runOnIncremental> + </execute> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>${swagger-core-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-gson</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>retrofit</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-scalars</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>org.apache.oltu.oauth2</groupId> + <artifactId>org.apache.oltu.oauth2.client</artifactId> + <version>${oltu-version}</version> + </dependency> + <dependency> + <groupId>io.gsonfire</groupId> + <artifactId>gson-fire</artifactId> + <version>${gson-fire-version}</version> + </dependency> + <dependency> + <groupId>org.threeten</groupId> + <artifactId>threetenbp</artifactId> + <version>${threetenbp-version}</version> + </dependency> + <dependency> + <groupId>io.reactivex.rxjava2</groupId> + <artifactId>rxjava</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>adapter-rxjava2</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.okio</groupId> + <artifactId>okio</artifactId> + <version>${okio-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + </dependencies> +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/src/main/resources/ETSI-Catalog-Notification-API.json index 6db54435d2..6db54435d2 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/ETSI-Catalog-Notification-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/src/main/resources/ETSI-Catalog-Notification-API.json diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/src/main/resources/SOL003-VNFPackageManagement-API.json index 17d81f44c1..17d81f44c1 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/SOL003-VNFPackageManagement-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-api/src/main/resources/SOL003-VNFPackageManagement-API.json diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/pom.xml new file mode 100644 index 0000000000..5c0963f68d --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/pom.xml @@ -0,0 +1,196 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-package-management</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-package-management-ext-clients</artifactId> + <name>ETSI SOL003 VNF Package Management Adapter Ext Clients</name> + <build> + <plugins> + <plugin> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <version>${version-swagger-codegen}</version> + <executions> + <execution> + <id>etsicatalog-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/ETSI-Catalog-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/etsicatalog</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.etsicatalog.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> + <configOptions> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> + <execution> + <id>sol003-packagemanagement-notification-api</id> + <goals> + <goal>generate</goal> + </goals> + <configuration> + <inputSpec>${basedir}/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json</inputSpec> + <language>java</language> + <library>okhttp-gson</library> + <output>${project.build.directory}/generated-sources/sol003-vnf-packagemanagement/notification</output> + <apiPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.api</apiPackage> + <modelPackage>org.onap.so.adapters.etsi.sol003.adapter.packagemanagement.extclients.vnfm.notification.model</modelPackage> + <generateApiTests>false</generateApiTests> + <generateModelTests>false</generateModelTests> + <configOptions> + <sourceFolder>src/gen/java/main</sourceFolder> + <withXml>true</withXml> + <useRxJava2>true</useRxJava2> + <serializableModel>true</serializableModel> + </configOptions> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>add-source</id> + <phase>generate-sources</phase> + <goals> + <goal>add-source</goal> + </goals> + <configuration> + <sources> + <source>${project.basedir}/target/generated-sources/sol003-vnf-packagemanagement/notification/src/gen/java/main</source> + <source>${project.basedir}/target/generated-sources/etsicatalog/src/gen/java/main</source> + </sources> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>io.swagger</groupId> + <artifactId>swagger-codegen-maven-plugin</artifactId> + <goals> + <goal>generate</goal> + </goals> + <versionRange>[2.2.0,)</versionRange> + </pluginExecutionFilter> + <action> + <execute> + <runOnIncremental>false</runOnIncremental> + </execute> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> + </build> + <dependencies> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>${swagger-core-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-gson</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>retrofit</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>converter-scalars</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>org.apache.oltu.oauth2</groupId> + <artifactId>org.apache.oltu.oauth2.client</artifactId> + <version>${oltu-version}</version> + </dependency> + <dependency> + <groupId>io.gsonfire</groupId> + <artifactId>gson-fire</artifactId> + <version>${gson-fire-version}</version> + </dependency> + <dependency> + <groupId>org.threeten</groupId> + <artifactId>threetenbp</artifactId> + <version>${threetenbp-version}</version> + </dependency> + <dependency> + <groupId>io.reactivex.rxjava2</groupId> + <artifactId>rxjava</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.retrofit2</groupId> + <artifactId>adapter-rxjava2</artifactId> + <version>${retrofit-version}</version> + </dependency> + <dependency> + <groupId>com.google.code.gson</groupId> + <artifactId>gson</artifactId> + </dependency> + <dependency> + <groupId>com.squareup.okio</groupId> + <artifactId>okio</artifactId> + <version>${okio-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp3</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp3-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>okhttp</artifactId> + <version>${okhttp-version}</version> + </dependency> + <dependency> + <groupId>com.squareup.okhttp</groupId> + <artifactId>logging-interceptor</artifactId> + <version>${okhttp-version}</version> + </dependency> + </dependencies> + +</project>
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/src/main/resources/ETSI-Catalog-API.json index 35a8c2bd3d..35a8c2bd3d 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/src/main/resources/ETSI-Catalog-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/src/main/resources/ETSI-Catalog-API.json diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json index 32e002f0e7..32e002f0e7 100644 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/etsi-sol003-package-management-ext-clients/src/main/resources/SOL003-VNFPackageManagement-Notification-API.json diff --git a/adapters/etsi-sol003-adapter/etsi-sol003-package-management/pom.xml b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/pom.xml new file mode 100644 index 0000000000..6983f2ffed --- /dev/null +++ b/adapters/etsi-sol003-adapter/etsi-sol003-package-management/pom.xml @@ -0,0 +1,17 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <artifactId>etsi-sol003-package-management</artifactId> + <name>ETSI SOL003 VNF Package Management</name> + <packaging>pom</packaging> + <modules> + <module>etsi-sol003-package-management-api</module> + <module>etsi-sol003-package-management-ext-clients</module> + <module>etsi-sol003-package-management-adapter</module> + </modules> +</project>
\ No newline at end of file diff --git a/adapters/etsi-sol003-adapter/pom.xml b/adapters/etsi-sol003-adapter/pom.xml new file mode 100644 index 0000000000..7179fb7492 --- /dev/null +++ b/adapters/etsi-sol003-adapter/pom.xml @@ -0,0 +1,35 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so</groupId> + <artifactId>adapters</artifactId> + <version>1.6.0-SNAPSHOT</version> + </parent> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-adapter</artifactId> + <name>ETSI SOL003 Adapter</name> + <packaging>pom</packaging> + + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <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> + <threetenbp-version>1.3.5</threetenbp-version> + <oltu-version>1.0.1</oltu-version> + <swagger-core-version>1.5.15</swagger-core-version> + <okhttp3-version>3.14.0</okhttp3-version> + <okhttp-version>2.7.5</okhttp-version> + <okio-version>1.13.0</okio-version> + <spring-security-oauth2-version>2.3.6.RELEASE</spring-security-oauth2-version> + </properties> + + <modules> + <module>etsi-sol003-adapter-common</module> + <module>etsi-sol003-package-management</module> + <module>etsi-sol003-lcm</module> + <module>etsi-sol003-adapter-application</module> + </modules> +</project>
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java index 3e28e5c45a..9a9bccfb5d 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java @@ -24,7 +24,6 @@ package org.onap.so.openstack.utils; import java.util.ArrayList; -import java.util.Calendar; import java.util.List; import java.util.Optional; import org.onap.so.cloud.CloudConfig; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java index 4dc139f37d..5d28eaaf71 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java @@ -20,6 +20,7 @@ package org.onap.so.openstack.utils; +import java.io.IOException; import org.onap.so.cloud.authentication.KeystoneAuthHolder; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; @@ -224,20 +225,15 @@ public class NovaClientImpl extends MsoCommonUtils { } public void postActionToServer(String cloudSiteId, String tenantId, String id, String request) - throws NovaClientException { - try { - ObjectMapper mapper = new ObjectMapper(); - JsonNode actualObj = mapper.readTree(request); - Entity<JsonNode> openstackEntity = new Entity<>(actualObj, "application/json"); - CharSequence actionPath = "/servers/" + id + "/action"; - Nova novaClient = getNovaClient(cloudSiteId, tenantId); - OpenStackRequest<Void> OSRequest = - new OpenStackRequest<>(novaClient, HttpMethod.POST, actionPath, openstackEntity, Void.class); - executeAndRecordOpenstackRequest(OSRequest, false); - } catch (Exception e) { - logger.error("Error building Nova Client", e); - throw new NovaClientException("Error building Nova Client", e); - } + throws IOException, MsoException { + ObjectMapper mapper = new ObjectMapper(); + JsonNode actualObj = mapper.readTree(request); + Entity<JsonNode> openstackEntity = new Entity<>(actualObj, "application/json"); + CharSequence actionPath = "/servers/" + id + "/action"; + Nova novaClient = getNovaClient(cloudSiteId, tenantId); + OpenStackRequest<Void> OSRequest = + new OpenStackRequest<>(novaClient, HttpMethod.POST, actionPath, openstackEntity, Void.class); + executeAndRecordOpenstackRequest(OSRequest, false); } public void attachVolume(String cloudSiteId, String tenantId, String serverId, VolumeAttachment volumeAttachment) diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/QueryVolumeGroupResponse.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/QueryVolumeGroupResponse.java deleted file mode 100644 index a95df93a27..0000000000 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vnfrest/QueryVolumeGroupResponse.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnfrest; - - -import java.util.Map; -import javax.xml.bind.annotation.XmlRootElement; -import org.onap.so.openstack.beans.VnfStatus; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.SerializationFeature; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@XmlRootElement(name = "queryVolumeGroupResponse") -public class QueryVolumeGroupResponse { - private static final Logger logger = LoggerFactory.getLogger(QueryVolumeGroupResponse.class); - private String volumeGroupId; - private String volumeGroupStackId; - private VnfStatus volumeGroupStatus; - private Map<String, String> volumeGroupOutputs; - - public QueryVolumeGroupResponse() {} - - public QueryVolumeGroupResponse(String volumeGroupId, String volumeGroupStackId, VnfStatus volumeGroupStatus, - Map<String, String> volumeGroupOutputs) { - super(); - this.volumeGroupId = volumeGroupId; - this.volumeGroupStackId = volumeGroupStackId; - this.volumeGroupStatus = volumeGroupStatus; - this.volumeGroupOutputs = volumeGroupOutputs; - } - - public String getVolumeGroupId() { - return volumeGroupId; - } - - public void setVolumeGroupId(String volumeGroupId) { - this.volumeGroupId = volumeGroupId; - } - - public String getVolumeGroupStackId() { - return volumeGroupStackId; - } - - public void setVolumeGroupStackId(String volumeGroupStackId) { - this.volumeGroupStackId = volumeGroupStackId; - } - - public VnfStatus getVolumeGroupStatus() { - return volumeGroupStatus; - } - - public void setVolumeGroupStatus(VnfStatus volumeGroupStatus) { - this.volumeGroupStatus = volumeGroupStatus; - } - - public Map<String, String> getVolumeGroupOutputs() { - return volumeGroupOutputs; - } - - public void setVolumeGroupOutputs(Map<String, String> volumeGroupOutputs) { - this.volumeGroupOutputs = volumeGroupOutputs; - } - - public String toJsonString() { - String jsonString = null; - try { - ObjectMapper mapper = new ObjectMapper(); - mapper.enable(SerializationFeature.WRAP_ROOT_VALUE); - jsonString = mapper.writeValueAsString(this); - } catch (Exception e) { - logger.debug("Exception :", e); - } - return jsonString; - } -} diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java index 195ada37f7..d08c2e1444 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceInfo.java @@ -26,7 +26,6 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; import javax.xml.bind.annotation.XmlRootElement; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java index d6e7415a77..f945208854 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java @@ -23,7 +23,6 @@ package org.onap.so.adapters.catalogdb.catalogrest; /* should be called QueryVnfResource.java */ -import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -33,7 +32,6 @@ import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.databind.ObjectMapper; @XmlRootElement(name = "serviceVnfs") public class QueryServiceVnfs extends CatalogQuery { diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java index 9202fd21d4..87526f7009 100644 --- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java +++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/rest/VnfRestImpl.java @@ -34,7 +34,6 @@ import javax.ws.rs.core.Response; import org.onap.so.db.catalog.beans.VnfResourceCustomization; import org.onap.so.db.catalog.data.repository.ServiceRepository; import org.onap.so.db.catalog.data.repository.VnfCustomizationRepository; -import org.onap.so.rest.catalog.beans.Service; import org.onap.so.rest.catalog.beans.Vnf; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; 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 b70d409cd8..33293afa10 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 @@ -632,7 +632,17 @@ VALUES ('VOLUME_GROUP', 'PENDING', 'DELETE', 'SILENT_SUCCESS'), ('VF_MODULE', 'PENDING', 'DELETE', 'FAIL'), -('NETWORK', 'PENDING', 'DELETE', 'FAIL'); +('NETWORK', 'PENDING', 'DELETE', 'FAIL'), + +('VNF', 'CONFIGURED', 'ACTIVATE', 'CONTINUE'), +('VNF', 'CONFIGURED', 'UNASSIGN', 'CONTINUE'), +('VNF', 'CONFIGURED', 'DESACTIVATE', 'SILENT_SUCCESS'), + +('VNF', 'CONFIGURE', 'UNASSIGN', 'CONTINUE'), +('VNF', 'CONFIGURE', 'DESACTIVATE', 'SILENT_SUCCESS'), + +('VNF', 'CONFIGASSIGNED', 'UNASSIGN', 'CONTINUE'), +('VNF', 'CONFIGASSIGNED', 'DESACTIVATE', 'SILENT_SUCCESS'); UPDATE orchestration_flow_reference SET FLOW_NAME = 'HomingBB' WHERE FLOW_NAME = 'SniroHoming'; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql deleted file mode 100644 index c0cec5da31..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0.1__AddMissingTransitionStates.sql +++ /dev/null @@ -1,17 +0,0 @@ -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGASSIGNED', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; - -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGASSIGNED', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; - -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGURE', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; - -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGURE', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; - -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGURED', 'UNASSIGN', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'CONTINUE'; - -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) VALUES -('VNF', 'CONFIGURED', 'DEACTIVATE', 'SILENT_SUCCESS') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE = 'SILENT_SUCCES'; diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql deleted file mode 100644 index 1d26c4c8d9..0000000000 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V9.0__AddConfiguredForVnfOrchestrationStatus.sql +++ /dev/null @@ -1,2 +0,0 @@ -INSERT INTO orchestration_status_state_transition_directive(RESOURCE_TYPE, ORCHESTRATION_STATUS, TARGET_ACTION, FLOW_DIRECTIVE) -VALUES ('VNF', 'CONFIGURED', 'ACTIVATE', 'CONTINUE') ON DUPLICATE KEY UPDATE FLOW_DIRECTIVE='CONTINUE'; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 4728effdca..860c747f15 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -81,8 +81,8 @@ import com.fasterxml.jackson.databind.ObjectMapper; targetNamespace = "http://org.onap.so/network") public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { - private static final String AIC3_NW_PROPERTY = "org.onap.so.adapters.network.aic3nw"; - private static final String AIC3_NW = "OS::ContrailV2::VirtualNetwork"; + private static final String OS3_NW_PROPERTY = "org.onap.so.adapters.network.aic3nw"; + private static final String OS3_NW = "OS::ContrailV2::VirtualNetwork"; private static final String VLANS = "vlans"; private static final String PHYSICAL_NETWORK = "physical_network"; private static final String UPDATE_NETWORK_CONTEXT = "UpdateNetwork"; @@ -223,272 +223,203 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { NetworkResource networkResource = networkCheck(startTime, networkType, modelCustomizationUuid, networkName, physicalNetworkName, vlans, routeTargets, cloudSiteId, cloudSiteOpt.get()); - String mode = networkResource.getOrchestrationMode(); NetworkType neutronNetworkType = NetworkType.valueOf(networkResource.getNeutronNetworkType()); - if (NEUTRON_MODE.equals(mode)) { - - // Use an MsoNeutronUtils for all neutron commands - - // See if the Network already exists (by name) - NetworkInfo netInfo = null; - try { - netInfo = neutron.queryNetwork(networkName, tenantId, cloudSiteId); - } catch (MsoException me) { - logger.error( - "{} {} Exception while querying network {} for CloudSite {} from Tenant {} from OpenStack ", - MessageEnum.RA_QUERY_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkName, - cloudSiteId, tenantId, me); - me.addContext(CREATE_NETWORK_CONTEXT); - throw new NetworkException(me); - } - - if (netInfo != null) { - // Exists. If that's OK, return success with the network ID. - // Otherwise, return an exception. - if (failIfExists != null && failIfExists) { - String error = String.format("Create Nework: Network %s already exists in %s/%s with ID %s", - networkName, cloudSiteId, tenantId, netInfo.getId()); - logger.error(LoggingAnchor.THREE, MessageEnum.RA_NETWORK_ALREADY_EXIST, - ErrorCode.DataError.getValue(), error); - throw new NetworkException(error, MsoExceptionCategory.USERDATA); - } else { - // Populate the outputs from the existing network. - networkId.value = netInfo.getId(); - neutronNetworkId.value = netInfo.getId(); - rollback.value = networkRollback; // Default rollback - no updates performed - logger.warn("{} {} Found Existing network, status={} for Neutron mode ", - MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), netInfo.getStatus()); - } - heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); - return; - } + HeatTemplate heatTemplate = networkResource.getHeatTemplate(); + if (heatTemplate == null) { + String error = String.format("Network error - undefined Heat Template. Network Type = %s", networkType); + logger.error(LoggingAnchor.THREE, MessageEnum.RA_PARAM_NOT_FOUND, ErrorCode.DataError.getValue(), error); + throw new NetworkException(error, MsoExceptionCategory.INTERNAL); + } - try { - netInfo = neutron.createNetwork(cloudSiteId, tenantId, neutronNetworkType, networkName, - physicalNetworkName, vlans); - } catch (MsoException me) { - me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Create Network: type {} in {}/{}: ", MessageEnum.RA_CREATE_NETWORK_EXC, - ErrorCode.DataError.getValue(), neutronNetworkType, cloudSiteId, tenantId, me); + logger.debug("Got HEAT Template from DB: {}", heatTemplate); - throw new NetworkException(me); - } + // "Fix" the template if it has CR/LF (getting this from Oracle) + String template = heatTemplate.getHeatTemplate(); + template = template.replaceAll("\r\n", "\n"); - // Note: ignoring MsoNetworkAlreadyExists because we already checked. + boolean os3template = false; + String os3nw = OS3_NW; - // If reach this point, network creation is successful. - // Since directly created via Neutron, networkId tracked by MSO is the same - // as the neutron network ID. - networkId.value = netInfo.getId(); - neutronNetworkId.value = netInfo.getId(); + os3nw = environment.getProperty(OS3_NW_PROPERTY, OS3_NW); - networkRollback.setNetworkCreated(true); - networkRollback.setNetworkId(netInfo.getId()); - networkRollback.setNeutronNetworkId(netInfo.getId()); - networkRollback.setNetworkType(networkType); + if (template.contains(os3nw)) + os3template = true; - logger.debug("Network {} created, id = {}", networkName, netInfo.getId()); - } else if ("HEAT".equals(mode)) { + // First, look up to see if the Network already exists (by name). + // For HEAT orchestration of networks, the stack name will always match the network name + StackInfo heatStack = null; + try { + heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName); + } catch (MsoException me) { + me.addContext(CREATE_NETWORK_CONTEXT); + logger.error("{} {} Create Network (heat): query network {} in {}/{}: ", MessageEnum.RA_QUERY_NETWORK_EXC, + ErrorCode.DataError.getValue(), networkName, cloudSiteId, tenantId, me); + throw new NetworkException(me); + } - HeatTemplate heatTemplate = networkResource.getHeatTemplate(); - if (heatTemplate == null) { - String error = String.format("Network error - undefined Heat Template. Network Type = %s", networkType); - logger.error(LoggingAnchor.THREE, MessageEnum.RA_PARAM_NOT_FOUND, ErrorCode.DataError.getValue(), + if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) { + // Stack exists. Return success or error depending on input directive + if (failIfExists != null && failIfExists) { + String error = String.format("CreateNetwork: Stack %s already exists in %s/%s as %s", networkName, + cloudSiteId, tenantId, heatStack.getCanonicalName()); + logger.error(LoggingAnchor.THREE, MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), error); - throw new NetworkException(error, MsoExceptionCategory.INTERNAL); - } - - logger.debug("Got HEAT Template from DB: {}", heatTemplate); - - // "Fix" the template if it has CR/LF (getting this from Oracle) - String template = heatTemplate.getHeatTemplate(); - template = template.replaceAll("\r\n", "\n"); - - boolean aic3template = false; - String aic3nw = AIC3_NW; - - aic3nw = environment.getProperty(AIC3_NW_PROPERTY, AIC3_NW); - - if (template.contains(aic3nw)) - aic3template = true; - - // First, look up to see if the Network already exists (by name). - // For HEAT orchestration of networks, the stack name will always match the network name - StackInfo heatStack = null; - try { - heatStack = heat.queryStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName); - } catch (MsoException me) { - me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Create Network (heat): query network {} in {}/{}: ", - MessageEnum.RA_QUERY_NETWORK_EXC, ErrorCode.DataError.getValue(), networkName, cloudSiteId, - tenantId, me); - throw new NetworkException(me); - } - - if (heatStack != null && (heatStack.getStatus() != HeatStatus.NOTFOUND)) { - // Stack exists. Return success or error depending on input directive - if (failIfExists != null && failIfExists) { - String error = String.format("CreateNetwork: Stack %s already exists in %s/%s as %s", networkName, - cloudSiteId, tenantId, heatStack.getCanonicalName()); - logger.error(LoggingAnchor.THREE, MessageEnum.RA_NETWORK_ALREADY_EXIST, - ErrorCode.DataError.getValue(), error); - throw new NetworkException(error, MsoExceptionCategory.USERDATA); - } else { - // Populate the outputs from the existing stack. - networkId.value = heatStack.getCanonicalName(); - Map<String, String> sMap = new HashMap<>(); - if (heatStack.getOutputs() != null) { - neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); - rollback.value = networkRollback; // Default rollback - no updates performed - if (aic3template) { - networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); - } - Map<String, Object> outputs = heatStack.getOutputs(); - - for (Map.Entry<String, Object> entry : outputs.entrySet()) { - String key = entry.getKey(); - if (key != null && key.startsWith("subnet")) { - if (aic3template) // one subnet_id output - { - Map<String, String> map = getSubnetUUId(key, outputs, subnets); - sMap.putAll(map); - } else // multiples subnet_%aaid% outputs - { - String subnetUUId = (String) outputs.get(key); - sMap.put(key.substring("subnet_id_".length()), subnetUUId); - } + throw new NetworkException(error, MsoExceptionCategory.USERDATA); + } else { + // Populate the outputs from the existing stack. + networkId.value = heatStack.getCanonicalName(); + Map<String, String> sMap = new HashMap<>(); + if (heatStack.getOutputs() != null) { + neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); + rollback.value = networkRollback; // Default rollback - no updates performed + if (os3template) { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); + } + Map<String, Object> outputs = heatStack.getOutputs(); + + for (Map.Entry<String, Object> entry : outputs.entrySet()) { + String key = entry.getKey(); + if (key != null && key.startsWith("subnet")) { + if (os3template) // one subnet_id output + { + Map<String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } else // multiples subnet_%aaid% outputs + { + String subnetUUId = (String) outputs.get(key); + sMap.put(key.substring("subnet_id_".length()), subnetUUId); } } } - subnetIdMap.value = sMap; - logger.warn("{} {} Found Existing network stack, status={} networkName={} for {}/{}", - MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(), - networkName, cloudSiteId, tenantId); } - heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); - return; + subnetIdMap.value = sMap; + logger.warn("{} {} Found Existing network stack, status={} networkName={} for {}/{}", + MessageEnum.RA_NETWORK_ALREADY_EXIST, ErrorCode.DataError.getValue(), heatStack.getStatus(), + networkName, cloudSiteId, tenantId); } + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_EXIST_STATUS_MESSAGE); + return; + } - // Ready to deploy the new Network - // Build the common set of HEAT template parameters - Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType, networkName, - physicalNetworkName, vlans, routeTargets, shared, external, aic3template); - - // Validate (and update) the input parameters against the DB definition - // Shouldn't happen unless DB config is wrong, since all networks use same inputs - // and inputs were already validated. - try { - stackParams = heat.validateStackParams(stackParams, heatTemplate); - } catch (IllegalArgumentException e) { - String error = "Create Network: Configuration Error: " + e.getMessage(); - logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error, e); - // Input parameters were not valid - throw new NetworkException(error, MsoExceptionCategory.INTERNAL); - } + // Ready to deploy the new Network + // Build the common set of HEAT template parameters + Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType, networkName, physicalNetworkName, + vlans, routeTargets, shared, external, os3template); - if (subnets != null) { - try { - if (aic3template) { - template = mergeSubnetsAIC3(template, subnets, stackParams); - } else { - template = mergeSubnets(template, subnets); - } - } catch (MsoException me) { - me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Exception Create Network, merging subnets for network (heat) type {} in {}/{} ", - MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), - neutronNetworkType.toString(), cloudSiteId, tenantId, me); - throw new NetworkException(me); - } - } + // Validate (and update) the input parameters against the DB definition + // Shouldn't happen unless DB config is wrong, since all networks use same inputs + // and inputs were already validated. + try { + stackParams = heat.validateStackParams(stackParams, heatTemplate); + } catch (IllegalArgumentException e) { + String error = "Create Network: Configuration Error: " + e.getMessage(); + logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error, e); + // Input parameters were not valid + throw new NetworkException(error, MsoExceptionCategory.INTERNAL); + } - if (policyFqdns != null && !policyFqdns.isEmpty() && aic3template) { - try { - mergePolicyRefs(policyFqdns, stackParams); - } catch (MsoException me) { - me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Exception Create Network, merging policyRefs type {} in {}/{} ", - MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), - neutronNetworkType.toString(), cloudSiteId, tenantId, me); - throw new NetworkException(me); + if (subnets != null) { + try { + if (os3template) { + template = mergeSubnetsAIC3(template, subnets, stackParams); + } else { + template = mergeSubnets(template, subnets); } + } catch (MsoException me) { + me.addContext(CREATE_NETWORK_CONTEXT); + logger.error("{} {} Exception Create Network, merging subnets for network (heat) type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); + throw new NetworkException(me); } + } - if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { - try { - mergeRouteTableRefs(routeTableFqdns, stackParams); - } catch (MsoException me) { - me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Exception Create Network, merging routeTableRefs type {} in {}/{} ", - MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), - neutronNetworkType.toString(), cloudSiteId, tenantId, me); - throw new NetworkException(me); - } + if (policyFqdns != null && !policyFqdns.isEmpty() && os3template) { + try { + mergePolicyRefs(policyFqdns, stackParams); + } catch (MsoException me) { + me.addContext(CREATE_NETWORK_CONTEXT); + logger.error("{} {} Exception Create Network, merging policyRefs type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); + throw new NetworkException(me); } + } - // Deploy the network stack - // Ignore MsoStackAlreadyExists exception because we already checked. + if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && os3template) { try { - if (backout == null) - backout = true; - heatStack = heat.createStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName, null, template, - stackParams, true, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(), - failIfExists); + mergeRouteTableRefs(routeTableFqdns, stackParams); } catch (MsoException me) { me.addContext(CREATE_NETWORK_CONTEXT); - logger.error("{} {} Exception creating network type {} in {}/{} ", MessageEnum.RA_CREATE_NETWORK_EXC, - ErrorCode.DataError.getValue(), networkName, cloudSiteId, tenantId, me); + logger.error("{} {} Exception Create Network, merging routeTableRefs type {} in {}/{} ", + MessageEnum.RA_CREATE_NETWORK_EXC, ErrorCode.DataError.getValue(), + neutronNetworkType.toString(), cloudSiteId, tenantId, me); throw new NetworkException(me); } + } - // Reach this point if createStack is successful. + // Deploy the network stack + // Ignore MsoStackAlreadyExists exception because we already checked. + try { + if (backout == null) + backout = true; + heatStack = heat.createStack(cloudSiteId, CLOUD_OWNER, tenantId, networkName, null, template, stackParams, + true, heatTemplate.getTimeoutMinutes(), null, null, null, backout.booleanValue(), failIfExists); + } catch (MsoException me) { + me.addContext(CREATE_NETWORK_CONTEXT); + logger.error("{} {} Exception creating network type {} in {}/{} ", MessageEnum.RA_CREATE_NETWORK_EXC, + ErrorCode.DataError.getValue(), networkName, cloudSiteId, tenantId, me); + throw new NetworkException(me); + } - // For Heat-based orchestration, the MSO-tracked network ID is the heat stack, - // and the neutronNetworkId is the network UUID returned in stack outputs. - networkId.value = heatStack.getCanonicalName(); - if (heatStack.getOutputs() != null) { - neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); - if (aic3template) { - networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); - } + // Reach this point if createStack is successful. + + // For Heat-based orchestration, the MSO-tracked network ID is the heat stack, + // and the neutronNetworkId is the network UUID returned in stack outputs. + networkId.value = heatStack.getCanonicalName(); + if (heatStack.getOutputs() != null) { + neutronNetworkId.value = (String) heatStack.getOutputs().get(NETWORK_ID); + if (os3template) { + networkFqdn.value = (String) heatStack.getOutputs().get(NETWORK_FQDN); } - Map<String, Object> outputs = heatStack.getOutputs(); - Map<String, String> sMap = new HashMap<>(); - if (outputs != null) { - for (Map.Entry<String, Object> entry : outputs.entrySet()) { - String key = entry.getKey(); - if (key != null && key.startsWith("subnet")) { - if (aic3template) // one subnet output expected - { - Map<String, String> map = getSubnetUUId(key, outputs, subnets); - sMap.putAll(map); - } else // multiples subnet_%aaid% outputs allowed - { - String subnetUUId = (String) outputs.get(key); - sMap.put(key.substring("subnet_id_".length()), subnetUUId); - } + } + Map<String, Object> outputs = heatStack.getOutputs(); + Map<String, String> sMap = new HashMap<>(); + if (outputs != null) { + for (Map.Entry<String, Object> entry : outputs.entrySet()) { + String key = entry.getKey(); + if (key != null && key.startsWith("subnet")) { + if (os3template) // one subnet output expected + { + Map<String, String> map = getSubnetUUId(key, outputs, subnets); + sMap.putAll(map); + } else // multiples subnet_%aaid% outputs allowed + { + String subnetUUId = (String) outputs.get(key); + sMap.put(key.substring("subnet_id_".length()), subnetUUId); } } - networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); } - subnetIdMap.value = sMap; - - rollback.value = networkRollback; - // Populate remaining rollback info and response parameters. - networkRollback.setNetworkStackId(heatStack.getCanonicalName()); - networkRollback.setNetworkCreated(true); - networkRollback.setNetworkType(networkType); + networkRollback.setNeutronNetworkId((String) outputs.get(NETWORK_ID)); + } + subnetIdMap.value = sMap; - try { - heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE); - } catch (Exception e) { - logger.warn("Exception while updating infra active request", e); - } + rollback.value = networkRollback; + // Populate remaining rollback info and response parameters. + networkRollback.setNetworkStackId(heatStack.getCanonicalName()); + networkRollback.setNetworkCreated(true); + networkRollback.setNetworkType(networkType); - logger.debug("Network {} successfully created via HEAT", networkName); + try { + heat.updateResourceStatus(msoRequest.getRequestId(), NETWORK_CREATED_STATUS_MESSAGE); + } catch (Exception e) { + logger.warn("Exception while updating infra active request", e); } + logger.debug("Network {} successfully created via HEAT", networkName); + + return; } @@ -674,17 +605,17 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String template = heatTemplate.getHeatTemplate(); template = template.replaceAll("\r\n", "\n"); - boolean aic3template = false; - String aic3nw = AIC3_NW; + boolean os3template = false; + String os3nw = OS3_NW; - aic3nw = environment.getProperty(AIC3_NW_PROPERTY, AIC3_NW); + os3nw = environment.getProperty(OS3_NW_PROPERTY, OS3_NW); - if (template.contains(aic3nw)) - aic3template = true; + if (template.contains(os3nw)) + os3template = true; // Build the common set of HEAT template parameters Map<String, Object> stackParams = populateNetworkParams(neutronNetworkType, networkName, - physicalNetworkName, vlans, routeTargets, shared, external, aic3template); + physicalNetworkName, vlans, routeTargets, shared, external, os3template); // Validate (and update) the input parameters against the DB definition // Shouldn't happen unless DB config is wrong, since all networks use same inputs @@ -698,7 +629,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (subnets != null) { try { - if (aic3template) { + if (os3template) { template = mergeSubnetsAIC3(template, subnets, stackParams); } else { template = mergeSubnets(template, subnets); @@ -712,7 +643,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } - if (policyFqdns != null && aic3template) { + if (policyFqdns != null && os3template) { try { mergePolicyRefs(policyFqdns, stackParams); } catch (MsoException me) { @@ -724,7 +655,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } - if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && aic3template) { + if (routeTableFqdns != null && !routeTableFqdns.isEmpty() && os3template) { try { mergeRouteTableRefs(routeTableFqdns, stackParams); } catch (MsoException me) { @@ -754,7 +685,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { for (Map.Entry<String, Object> entry : outputs.entrySet()) { String key = entry.getKey(); if (key != null && key.startsWith("subnet")) { - if (aic3template) // one subnet output expected + if (os3template) // one subnet output expected { Map<String, String> map = getSubnetUUId(key, outputs, subnets); sMap.putAll(map); @@ -837,14 +768,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { throw new NetworkException(error, MsoExceptionCategory.INTERNAL); } - MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getCloudVersion()); - if ((aicV.isMoreRecentThan(networkResource.getAicVersionMin()) - || aicV.isTheSameVersion(networkResource.getAicVersionMin())) // aic + MavenLikeVersioning osV = new MavenLikeVersioning(); + osV.setVersion(cloudSite.getCloudVersion()); + if ((osV.isMoreRecentThan(networkResource.getAicVersionMin()) + || osV.isTheSameVersion(networkResource.getAicVersionMin())) // os // >= // min - && (aicV.isTheSameVersion(networkResource.getAicVersionMax()) - || !(aicV.isMoreRecentThan(networkResource.getAicVersionMax())))) // aic <= max + && (osV.isTheSameVersion(networkResource.getAicVersionMax()) + || !(osV.isMoreRecentThan(networkResource.getAicVersionMax())))) // os <= max { logger.debug("Network Type:{} VersionMin:{} VersionMax:{} supported on Cloud:{} with AIC_Version:{}", networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, @@ -921,7 +852,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Use MsoNeutronUtils for all NEUTRON commands - String mode; String neutronId = null; // Try Heat first, since networks may be named the same as the Heat stack StackInfo heatStack = null; @@ -939,7 +869,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Found it. Get the neutronNetworkId for further query Map<String, String> sMap = new HashMap<>(); Map<String, Object> outputs = heatStack.getOutputs(); - mode = "HEAT"; if (outputs != null) { neutronId = (String) outputs.get(NETWORK_ID); @@ -957,10 +886,6 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } subnetIdMap.value = sMap; - } else { - // Input ID was not a Heat stack ID. Try it directly in Neutron - neutronId = networkNameOrId; - mode = NEUTRON_MODE; } // Query directly against the Neutron Network for the details @@ -971,7 +896,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (netInfo != null) { // Found. Populate the output elements networkExists.value = Boolean.TRUE; - if ("HEAT".equals(mode) && heatStack != null) { + if (heatStack != null) { networkId.value = heatStack.getCanonicalName(); } else { networkId.value = netInfo.getId(); @@ -981,8 +906,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if (vlans != null) vlans.value = netInfo.getVlans(); - logger.debug("Network {} found({}), ID = {}{}", networkNameOrId, mode, networkId.value, - ("HEAT".equals(mode) ? ",NeutronId = " + neutronNetworkId.value : "")); + logger.debug("Network {}, ID = {}{}", networkNameOrId, networkId.value, + (",NeutronId = " + neutronNetworkId.value)); } else { // Not found. Populate the status fields, leave the rest null networkExists.value = Boolean.FALSE; @@ -1043,10 +968,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } int timeoutMinutes = 118; - String mode = ""; if (networkResource != null) { logger.debug(LOG_DEBUG_MSG, networkResource.toString()); - mode = networkResource.getOrchestrationMode(); networkResource.getHeatTemplate().getTimeoutMinutes(); HeatTemplate heat = networkResource.getHeatTemplate(); if (heat != null && heat.getTimeoutMinutes() != null) { @@ -1056,27 +979,16 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } } - if (NEUTRON_MODE.equals(mode)) { - try { - boolean deleted = neutron.deleteNetwork(networkId, tenantId, cloudSiteId); - networkDeleted.value = deleted; - } catch (MsoException me) { - me.addContext("DeleteNetwork"); - logger.error("{} {} Delete Network (neutron): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, - ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); - throw new NetworkException(me); - } - } else { - try { - StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); - networkDeleted.value = stack.isOperationPerformed(); - } catch (MsoException me) { - me.addContext("DeleteNetwork"); - logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, - ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); - throw new NetworkException(me); - } + try { + StackInfo stack = heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, timeoutMinutes); + networkDeleted.value = stack.isOperationPerformed(); + } catch (MsoException me) { + me.addContext("DeleteNetwork"); + logger.error("{} {} Delete Network (heat): {} in {}/{} ", MessageEnum.RA_DELETE_NETWORK_EXC, + ErrorCode.DataError.getValue(), networkId, cloudSiteId, tenantId, me); + throw new NetworkException(me); } + try { heat.updateResourceStatus(msoRequest.getRequestId(), networkDeleted.value ? NETWORK_DELETED_STATUS_MESSAGE : NETWORK_NOT_EXIST_STATUS_MESSAGE); @@ -1104,48 +1016,20 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String cloudSiteId = rollback.getCloudId(); String tenantId = rollback.getTenantId(); String networkId = rollback.getNetworkStackId(); - String networkType = rollback.getNetworkType(); - String modelCustomizationUuid = rollback.getModelCustomizationUuid(); logger.debug("*** ROLLBACK Network {} in {}/{}", networkId, cloudSiteId, tenantId); - // Retrieve the Network Resource definition - NetworkResource networkResource = null; - if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) { - networkResource = networkCustomRepo.findOneByNetworkType(networkType).getNetworkResource(); - } else { - networkResource = - networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid).getNetworkResource(); - } - String mode = ""; - if (networkResource != null) { - - logger.debug(LOG_DEBUG_MSG, networkResource); - - mode = networkResource.getOrchestrationMode(); - } if (rollback.getNetworkCreated()) { - if (NEUTRON_MODE.equals(mode)) { - try { - neutron.deleteNetwork(networkId, tenantId, cloudSiteId); - } catch (MsoException me) { - me.addContext("RollbackNetwork"); - logger.error("{} {} Exception - Rollback Network (neutron): {} in {}/{} ", - MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkId, - cloudSiteId, tenantId, me); - throw new NetworkException(me); - } - } else { - try { - heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120); - } catch (MsoException me) { - me.addContext("RollbackNetwork"); - logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ", - MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkId, - cloudSiteId, tenantId, me); - throw new NetworkException(me); - } + try { + heat.deleteStack(tenantId, CLOUD_OWNER, cloudSiteId, networkId, true, 120); + } catch (MsoException me) { + me.addContext("RollbackNetwork"); + logger.error("{} {} Exception - Rollback Network (heat): {} in {}/{} ", + MessageEnum.RA_DELETE_NETWORK_EXC, ErrorCode.BusinessProcessError.getValue(), networkId, + cloudSiteId, tenantId, me); + throw new NetworkException(me); } + } } @@ -1173,7 +1057,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private Map<String, Object> populateNetworkParams(NetworkType neutronNetworkType, String networkName, String physicalNetwork, List<Integer> vlans, List<RouteTarget> routeTargets, String shared, String external, - boolean aic3template) { + boolean os3template) { // Build the common set of HEAT template parameters Map<String, Object> stackParams = new HashMap<>(); stackParams.put("network_name", networkName); @@ -1227,14 +1111,14 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { if ("IMPORT".equalsIgnoreCase(role)) { sep = rtImport.isEmpty() ? "" : ","; - rtImport = aic3template ? rtImport + sep + "target:" + rtValue : rtImport + sep + rtValue; + rtImport = os3template ? rtImport + sep + "target:" + rtValue : rtImport + sep + rtValue; } else if ("EXPORT".equalsIgnoreCase(role)) { sep = rtExport.isEmpty() ? "" : ","; - rtExport = aic3template ? rtExport + sep + "target:" + rtValue : rtExport + sep + rtValue; + rtExport = os3template ? rtExport + sep + "target:" + rtValue : rtExport + sep + rtValue; } else // covers BOTH, empty etc { sep = rtGlobal.isEmpty() ? "" : ","; - rtGlobal = aic3template ? rtGlobal + sep + "target:" + rtValue : rtGlobal + sep + rtValue; + rtGlobal = os3template ? rtGlobal + sep + "target:" + rtValue : rtGlobal + sep + rtValue; } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java index 9badd795eb..8f815f1827 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java @@ -40,11 +40,6 @@ import org.onap.so.adapters.tenant.MsoTenantAdapterImpl; import org.onap.so.adapters.tenant.TenantAdapterRest; import org.onap.so.adapters.vnf.MsoVnfAdapterAsyncImpl; import org.onap.so.adapters.vnf.MsoVnfAdapterImpl; -import org.onap.so.adapters.vnf.MsoVnfCloudifyAdapterImpl; -import org.onap.so.adapters.vnf.VnfAdapterRest; -import org.onap.so.adapters.vnf.VnfAdapterRestV2; -import org.onap.so.adapters.vnf.VolumeAdapterRest; -import org.onap.so.adapters.vnf.VolumeAdapterRestV2; import org.onap.so.client.policy.JettisonStyleMapperProvider; import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor; import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor; @@ -64,14 +59,6 @@ public class CXFConfiguration { @Autowired private TenantAdapterRest tenantAdapterRest; @Autowired - private VnfAdapterRest vnfAdapterRest; - @Autowired - private VnfAdapterRestV2 vnfAdapterRestV2; - @Autowired - private VolumeAdapterRest volumeAdapterRest; - @Autowired - private VolumeAdapterRestV2 volumeAdapterRestV2; - @Autowired private MsoNetworkAdapterImpl networkAdapterImpl; @Autowired private MsoNetworkAdapterAsyncImpl networkAdapterAsyncImpl; @@ -82,8 +69,6 @@ public class CXFConfiguration { @Autowired private MsoVnfAdapterAsyncImpl vnfAdapterAsyncImpl; @Autowired - private MsoVnfCloudifyAdapterImpl vnfCloudifyAdapterImpl; - @Autowired private CloudRegionRestV1 cloudRegionRestV1; @Autowired private JettisonStyleMapperProvider jettisonStyleObjectMapper; @@ -169,24 +154,12 @@ public class CXFConfiguration { return endpoint; } - @Bean - public Endpoint vnfCloudAdapterEndpoint() { - EndpointImpl endpoint = new EndpointImpl(springBus(), vnfCloudifyAdapterImpl); - endpoint.publish("/VnfCloudifyAdapterImpl"); - endpoint.setWsdlLocation("VnfCloudifyAdapterImpl.wsdl"); - endpoint.getInInterceptors().add(new SOAPLoggingInInterceptor()); - endpoint.getOutInterceptors().add(new SOAPLoggingOutInterceptor()); - endpoint.getOutFaultInterceptors().add(new SOAPLoggingOutInterceptor()); - return endpoint; - } - // Uses Jettson Style marshalling semantics @Bean public Server rsServer() { JAXRSServerFactoryBean endpoint = new JAXRSServerFactoryBean(); endpoint.setBus(springBus()); - endpoint.setServiceBeans(Arrays.<Object>asList(networkAdapterRest, tenantAdapterRest, vnfAdapterRest, - vnfAdapterRestV2, volumeAdapterRest, volumeAdapterRestV2)); + endpoint.setServiceBeans(Arrays.<Object>asList(networkAdapterRest, tenantAdapterRest)); endpoint.setAddress("/rest"); endpoint.setFeatures(Arrays.asList(createSwaggerFeature(), new LoggingFeature())); endpoint.setProviders(Arrays.asList(new JacksonJsonProvider(jettisonStyleObjectMapper.getMapper()), 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 874823a7cd..182ae11166 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 @@ -32,7 +32,6 @@ import org.onap.so.audit.beans.AuditInventory; import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.logging.tasks.AuditMDCSetup; import org.onap.so.objects.audit.AAIObjectAuditList; -import org.onap.so.utils.RetrySequenceLevel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java deleted file mode 100644 index 0074dca03c..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapter.java +++ /dev/null @@ -1,150 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.vnf; - - -import java.util.Map; -import javax.jws.WebMethod; -import javax.jws.WebParam; -import javax.jws.WebParam.Mode; -import javax.jws.WebService; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import javax.xml.ws.Holder; -import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.mappers.MapAdapter; - -@WebService(name = "VnfAdapter", targetNamespace = "http://org.onap.so/vnf") -public interface MsoVnfAdapter { - /** - * This is the "Create VNF" Web Service Endpoint definition. - */ - @WebMethod - public void createVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType, - @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "requestType") @XmlElement(required = false) String requestType, - @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId, - @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs, - @WebParam(name = "failIfExists") Boolean failIfExists, @WebParam(name = "backout") Boolean backout, - @WebParam(name = "enableBridge") Boolean enableBridge, @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId, - @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs, - @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) - throws VnfException, VnfAlreadyExists; - - @WebMethod - public void updateVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType, - @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "requestType") @XmlElement(required = false) String requestType, - @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId, - @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs, - @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) throws VnfException; - - @WebMethod - public void queryVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "vnfExists", mode = Mode.OUT) Holder<Boolean> vnfExists, - @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId, - @WebParam(name = "status", mode = Mode.OUT) Holder<VnfStatus> status, - @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs) throws VnfException; - - @WebMethod - public void deleteVnf(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "request") MsoRequest msoRequest) throws VnfException; - - - @WebMethod - public void rollbackVnf(@WebParam(name = "rollback") @XmlElement(required = true) VnfRollback rollback) - throws VnfException; - - @WebMethod - public void createVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType, - @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion, - @WebParam(name = "genericVnfId") @XmlElement(required = true) String genericVnfId, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId, - @WebParam(name = "requestType") @XmlElement(required = false) String requestType, - @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId, - @WebParam(name = "baseVfHeatStackId") @XmlElement(required = false) String baseVfHeatStackId, - @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, - @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs, - @WebParam(name = "failIfExists") Boolean failIfExists, @WebParam(name = "backout") Boolean backout, - @WebParam(name = "enableBridge") Boolean enableBridge, @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "vnfId", mode = Mode.OUT) Holder<String> vnfId, - @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs, - @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) - throws VnfException, VnfAlreadyExists; - - @WebMethod - public void deleteVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vfName") @XmlElement(required = true) String vfName, - @WebParam(name = "vnfId") @XmlElement(required = true) String vnfId, - @WebParam(name = "vfModuleId") @XmlElement(required = true) String vfModuleId, - @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "vfModuleOutputs", mode = Mode.OUT) Holder<Map<String, String>> vfModuleOutputs) - throws VnfException; - - @WebMethod - public void updateVfModule(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType, - @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "requestType") @XmlElement(required = false) String requestType, - @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId, - @WebParam(name = "baseVfHeatStackId") @XmlElement(required = false) String baseVfHeatStackId, - @WebParam(name = "vfModuleStackId") @XmlElement(required = false) String vfModuleStackId, - @WebParam(name = "modelCustomizationUuid") @XmlElement(required = false) String modelCustomizationUuid, - @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "outputs", mode = Mode.OUT) Holder<Map<String, String>> outputs, - @WebParam(name = "rollback", mode = Mode.OUT) Holder<VnfRollback> rollback) throws VnfException; - - @WebMethod - public void healthCheck(); -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java index 13ca78a1f5..4b9c36b7b7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsync.java @@ -29,7 +29,6 @@ import javax.jws.WebService; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.VnfRollback; import org.onap.so.openstack.mappers.MapAdapter; /** @@ -37,6 +36,7 @@ import org.onap.so.openstack.mappers.MapAdapter; * are documented elsewhere (by the client service WSDL). * */ +@Deprecated @WebService(name = "VnfAdapterAsync", targetNamespace = "http://org.onap.so/vnfA") public interface MsoVnfAdapterAsync { /** @@ -61,31 +61,6 @@ public interface MsoVnfAdapterAsync { @WebMethod @Oneway - public void updateVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfType") @XmlElement(required = true) String vnfType, - @WebParam(name = "vnfVersion") @XmlElement(required = false) String vnfVersion, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "requestType") @XmlElement(required = false) String requestType, - @WebParam(name = "volumeGroupHeatStackId") @XmlElement(required = false) String volumeGroupHeatStackId, - @WebParam(name = "inputs") @XmlJavaTypeAdapter(MapAdapter.class) Map<String, Object> inputs, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway - public void queryVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, - @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, - @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, - @WebParam(name = "vnfName") @XmlElement(required = true) String vnfName, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "request") MsoRequest msoRequest, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - - @WebMethod - @Oneway public void deleteVnfA(@WebParam(name = "cloudSiteId") @XmlElement(required = true) String cloudSiteId, @WebParam(name = "cloudOwner") @XmlElement(required = false) String cloudOwner, @WebParam(name = "tenantId") @XmlElement(required = true) String tenantId, @@ -94,12 +69,6 @@ public interface MsoVnfAdapterAsync { @WebParam(name = "request") MsoRequest msoRequest, @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - @WebMethod - @Oneway - public void rollbackVnfA(@WebParam(name = "rollback") @XmlElement(required = true) VnfRollback rollback, - @WebParam(name = "messageId") @XmlElement(required = true) String messageId, - @WebParam(name = "notificationUrl") @XmlElement(required = true) String notificationUrl); - @WebMethod public void healthCheckA(); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java index 68d1bebc51..3bea44b884 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImpl.java @@ -38,8 +38,6 @@ import javax.xml.ws.BindingProvider; import javax.xml.ws.Holder; import javax.xml.ws.handler.MessageContext; import org.onap.so.adapters.vnf.async.client.CreateVnfNotification; -import org.onap.so.adapters.vnf.async.client.QueryVnfNotification; -import org.onap.so.adapters.vnf.async.client.UpdateVnfNotification; import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify; import org.onap.so.adapters.vnf.async.client.VnfAdapterNotify_Service; import org.onap.so.adapters.vnf.exceptions.VnfException; @@ -48,7 +46,6 @@ import org.onap.logging.filter.base.ErrorCode; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.utils.CryptoUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -64,9 +61,7 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterAsyncImpl.class); private static final String BPEL_AUTH_PROP = "org.onap.so.adapters.vnf.bpelauth"; - private static final String ENCRYPTION_KEY_PROP = "org.onap.so.adapters.network.encryptionKey"; - private static final String UPDATE_VNFA = "{} UpdateVnfA"; - private static final String EXCEPTION_UPDATEVNF_NOTIFICATION = "{} {} Exception sending updateVnf notification "; + private static final String ENCRYPTION_KEY_PROP = "mso.msoKey"; @Autowired private Environment environment; @@ -122,15 +117,13 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { String notificationUrl) { logger.info("{} createVnfA", MessageEnum.RA_ASYNC_CREATE_VNF); - // Use the synchronous method to perform the actual Create - MsoVnfAdapter vnfAdapter = vnfImpl; // Synchronous Web Service Outputs Holder<String> vnfId = new Holder<>(); Holder<Map<String, String>> outputs = new Holder<>(); Holder<VnfRollback> vnfRollback = new Holder<>(); try { - vnfAdapter.createVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType, + vnfImpl.createVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType, volumeGroupHeatStackId, inputs, failIfExists, backout, enableBridge, msoRequest, vnfId, outputs, vnfRollback); } catch (VnfException e) { @@ -171,140 +164,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { return; } - @Override - public void updateVnfA(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - String messageId, MsoRequest msoRequest, String notificationUrl) { - - logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF); - - // Use the synchronous method to perform the actual Create - MsoVnfAdapter vnfAdapter = vnfImpl; - - // Synchronous Web Service Outputs - Holder<String> vnfId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - - try { - vnfAdapter.updateVnf(cloudSiteId, cloudOwner, tenantId, vnfType, vnfVersion, vnfName, requestType, - volumeGroupHeatStackId, inputs, msoRequest, outputs, vnfRollback); - } catch (VnfException e) { - logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory - .fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcessError.getValue(), e1); - } - // Build and send Asynchronous error response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.updateVnfNotification(messageId, false, exCat, eMsg, null, null); - } catch (Exception e1) { - logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e1); - } - logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); - return; - } - logger.debug("Async Update VNF: {} VnfId:{}", vnfName, vnfId.value); - // Build and send Asynchronous response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.updateVnfNotification(messageId, true, null, null, copyUpdateOutputs(outputs), - copyVrb(vnfRollback)); - } catch (Exception e) { - logger.error(EXCEPTION_UPDATEVNF_NOTIFICATION, MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - } - logger.info(UPDATE_VNFA, MessageEnum.RA_ASYNC_UPDATE_VNF_COMPLETE); - return; - } - - /** - * This is the "Query VNF" web service implementation. It will look up a VNF by name or ID in the specified cloud - * and tenant. - * - * The method returns an indicator that the VNF exists, its Openstack internal ID, its status, and the set of - * outputs (from when the stack was created). - * - * @param cloudSiteId CLLI code of the cloud site in which to query - * @param cloudOwner cloud owner of cloud site in which to query - * @param tenantId Openstack tenant identifier - * @param vnfName VNF Name or Openstack ID - * @param msoRequest Request tracking information for logs - * @param notificationURL the target URL for asynchronous response - */ - @Override - public void queryVnfA(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String messageId, - MsoRequest msoRequest, String notificationUrl) { - - logger.info(LoggingAnchor.ONE, MessageEnum.RA_ASYNC_QUERY_VNF); - - // Use the synchronous method to perform the actual query - MsoVnfAdapter vnfAdapter = vnfImpl; - - // Synchronous Web Service Outputs - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vnfId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - - try { - vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest, vnfExists, vnfId, status, - outputs); - } catch (VnfException e) { - logger.error("{} {} Exception sending queryVnfA notification ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory - .fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcessError.getValue(), e1); - } - // Build and send Asynchronous error response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.queryVnfNotification(messageId, false, exCat, eMsg, null, null, null, null); - } catch (Exception e1) { - logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e1); - } - logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); - return; - } - - if (!vnfExists.value) { - logger.debug("Async Query, VNF not found"); - } else { - logger.debug("Async Query, VNF={}, status={}", vnfId.value, status.value); - } - // Build and send Asynchronous response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - org.onap.so.adapters.vnf.async.client.VnfStatus vnfS = - org.onap.so.adapters.vnf.async.client.VnfStatus.fromValue(status.value.name()); - notifyPort.queryVnfNotification(messageId, true, null, null, vnfExists.value, vnfId.value, vnfS, - copyQueryOutputs(outputs)); - } catch (Exception e) { - logger.error("{} {} Exception sending queryVnf notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - } - - logger.info("{} queryVnfA", MessageEnum.RA_ASYNC_QUERY_VNF_COMPLETE); - return; - } - /** * This is the Asynchronous "Delete VNF" web service implementation. It will delete a VNF by name or ID in the * specified cloud and tenant. @@ -324,11 +183,8 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { logger.info(LoggingAnchor.ONE, MessageEnum.RA_ASYNC_DELETE_VNF); - // Use the synchronous method to perform the actual delete - MsoVnfAdapter vnfAdapter = vnfImpl; - try { - vnfAdapter.deleteVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest); + vnfImpl.deleteVnf(cloudSiteId, cloudOwner, tenantId, vnfName, msoRequest); } catch (VnfException e) { logger.error("{} {} Exception sending deleteVnfA notification ", MessageEnum.RA_DELETE_VNF_ERR, ErrorCode.BusinessProcessError.getValue(), e); @@ -369,65 +225,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { return; } - /** - * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the - * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation - * to undo the creation. - */ - @Override - public void rollbackVnfA(VnfRollback rollback, String messageId, String notificationUrl) { - // rollback may be null (e.g. if stack already existed when Create was called) - if (rollback == null) { - logger.info("{} rollbackVnfA: Empty Rollback: No action to perform", MessageEnum.RA_ROLLBACK_NULL); - return; - } - - logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF); - - // Use the synchronous method to perform the actual rollback - MsoVnfAdapter vnfAdapter = vnfImpl; - - try { - vnfAdapter.rollbackVnf(rollback); - } catch (VnfException e) { - logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - org.onap.so.adapters.vnf.async.client.MsoExceptionCategory exCat = null; - String eMsg = null; - try { - eMsg = e.getFaultInfo().getMessage(); - exCat = org.onap.so.adapters.vnf.async.client.MsoExceptionCategory - .fromValue(e.getFaultInfo().getCategory().name()); - } catch (Exception e1) { - logger.error("{} {} Exception - fault info ", MessageEnum.RA_FAULT_INFO_EXC, - ErrorCode.BusinessProcessError.getValue(), e1); - } - // Build and send Asynchronous error response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.rollbackVnfNotification(messageId, false, exCat, eMsg); - } catch (Exception e1) { - logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e1); - } - logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); - return; - } - - logger.debug("Async Rollback VNF:" + rollback.getVnfId()); - // Build and send Asynchronous response - try { - VnfAdapterNotify notifyPort = getNotifyEP(notificationUrl); - notifyPort.rollbackVnfNotification(messageId, true, null, null); - } catch (Exception e) { - logger.error("{} {} Exception sending rollbackVnfA notification ", MessageEnum.RA_SEND_VNF_NOTIF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - } - - logger.info("{} rollbackVnfA", MessageEnum.RA_ASYNC_ROLLBACK_VNF_COMPLETE); - return; - } - private org.onap.so.adapters.vnf.async.client.VnfRollback copyVrb(Holder<VnfRollback> hVrb) { org.onap.so.adapters.vnf.async.client.VnfRollback cvrb = new org.onap.so.adapters.vnf.async.client.VnfRollback(); @@ -471,47 +268,6 @@ public class MsoVnfAdapterAsyncImpl implements MsoVnfAdapterAsync { return outputs; } - private UpdateVnfNotification.Outputs copyUpdateOutputs(Holder<Map<String, String>> hMap) { - - UpdateVnfNotification.Outputs outputs = new UpdateVnfNotification.Outputs(); - - if (hMap != null && hMap.value != null) { - Map<String, String> sMap; - sMap = hMap.value; - UpdateVnfNotification.Outputs.Entry entry = new UpdateVnfNotification.Outputs.Entry(); - - for (Map.Entry<String, String> mapEntry : sMap.entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - entry.setKey(key); - entry.setValue(value); - outputs.getEntry().add(entry); - } - } - return outputs; - } - - private QueryVnfNotification.Outputs copyQueryOutputs(Holder<Map<String, String>> hMap) { - - QueryVnfNotification.Outputs outputs = new QueryVnfNotification.Outputs(); - - if (hMap != null && hMap.value != null) { - Map<String, String> sMap; - sMap = hMap.value; - - QueryVnfNotification.Outputs.Entry entry = new QueryVnfNotification.Outputs.Entry(); - - for (Map.Entry<String, String> mapEntry : sMap.entrySet()) { - String key = mapEntry.getKey(); - String value = mapEntry.getValue(); - entry.setKey(key); - entry.setValue(value); - outputs.getEntry().add(entry); - } - } - return outputs; - } - private VnfAdapterNotify getNotifyEP(String notificationUrl) { URL warWsdlLoc = null; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 4617299f48..a58c0c10c5 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -30,7 +30,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; -import javax.jws.WebService; import javax.xml.ws.Holder; import org.apache.commons.collections.CollectionUtils; import org.onap.logging.filter.base.ErrorCode; @@ -59,7 +58,6 @@ import org.onap.so.logger.MessageEnum; import org.onap.so.openstack.beans.HeatStatus; import org.onap.so.openstack.beans.StackInfo; import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.onap.so.openstack.exceptions.MsoExceptionCategory; @@ -81,11 +79,9 @@ import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter", - targetNamespace = "http://org.onap.so/vnf") @Component @Transactional -public class MsoVnfAdapterImpl implements MsoVnfAdapter { +public class MsoVnfAdapterImpl { @Autowired private CloudConfig cloudConfig; @@ -96,7 +92,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { private static final Logger logger = LoggerFactory.getLogger(MsoVnfAdapterImpl.class); - private static final String VNF_ADAPTER_SERVICE_NAME = "MSO-BPMN:MSO-VnfAdapter."; private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; private static final String ADD_GET_FILES_ON_VOLUME_REQ = "org.onap.so.adapters.vnf.addGetFilesOnVolumeReq"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -139,7 +134,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { /** * Health Check web method. Does nothing but return to show the adapter is deployed. */ - @Override public void healthCheck() { logger.debug("Health check call in VNF Adapter"); } @@ -175,7 +169,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc) * @param rollback Holder for returning VnfRollback object */ - @Override public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, @@ -218,75 +211,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // End createVf shortcut } - @Override - public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) - throws VnfException { - // As of 1707 - this method should no longer be called - logger.debug("UpdateVnf called?? This should not be called any longer - update vfModule"); - } - - /** - * This is the "Query VNF" web service implementation. It will look up a VNF by name or ID in the specified cloud - * and tenant. - * - * The method returns an indicator that the VNF exists, its Openstack internal ID, its status, and the set of - * outputs (from when the stack was created). - * - * @param cloudSiteId CLLI code of the cloud site in which to query - * @param tenantId Openstack tenant identifier - * @param vnfName VNF Name or Openstack ID - * @param msoRequest Request tracking information for logs - * @param vnfExists Flag reporting the result of the query - * @param vnfId Holder for output VNF Openstack ID - * @param outputs Holder for Map of VNF outputs from heat (assigned IPs, etc) - */ - @Override - public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest, - Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status, - Holder<Map<String, String>> outputs) throws VnfException { - - logger.debug("Querying VNF {} in {}/{}", vnfName, cloudSiteId, tenantId); - - // Will capture execution time for metrics - - StackInfo heatStack; - try { - heatStack = msoHeatUtils.queryStack(cloudSiteId, cloudOwner, tenantId, vnfName); - } catch (MsoException me) { - me.addContext("QueryVNF"); - // Failed to query the Stack due to an openstack exception. - // Convert to a generic VnfException - String error = - "Query VNF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudSiteId, tenantId, - OPENSTACK, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - " + QUERY_STACK, me); - logger.debug(error); - throw new VnfException(me); - } - - // Populate the outputs based on the returned Stack information - // - if (heatStack == null || heatStack.getStatus() == HeatStatus.NOTFOUND) { - // Not Found - vnfExists.value = Boolean.FALSE; - status.value = VnfStatus.NOTFOUND; - vnfId.value = null; - outputs.value = new HashMap<>(); // Return as an empty map - - logger.debug("VNF {} not found", vnfName); - } else { - vnfExists.value = Boolean.TRUE; - status.value = stackStatusToVnfStatus(heatStack.getStatus()); - vnfId.value = heatStack.getCanonicalName(); - outputs.value = copyStringOutputs(heatStack.getOutputs()); - - logger.debug("VNF {} found, ID = {}", vnfName, vnfId.value); - } - return; - } - /** * This is the "Delete VNF" web service implementation. It will delete a VNF by name or ID in the specified cloud * and tenant. @@ -299,7 +223,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { * @param vnfName VNF Name or Openstack ID * @param msoRequest Request tracking information for logs */ - @Override public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest) throws VnfException { @@ -368,7 +291,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation * to undo the creation. */ - @Override public void rollbackVnf(VnfRollback rollback) throws VnfException { // rollback may be null (e.g. if stack already existed when Create was called) if (rollback == null) { @@ -404,19 +326,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return; } - private VnfStatus stackStatusToVnfStatus(HeatStatus stackStatus) { - switch (stackStatus) { - case CREATED: - return VnfStatus.ACTIVE; - case UPDATED: - return VnfStatus.ACTIVE; - case FAILED: - return VnfStatus.FAILED; - default: - return VnfStatus.UNKNOWN; - } - } - private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) { Map<String, String> stringOutputs = new HashMap<>(); for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) { @@ -570,7 +479,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return stringMap; } - @Override public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, String genericVnfName, String vnfName, String vfModuleId, String requestType, String volumeGroupHeatStackId, String baseVfHeatStackId, String modelCustomizationUuid, @@ -1138,7 +1046,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } - @Override public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, Holder<Map<String, String>> outputs) throws VnfException { @@ -1212,7 +1119,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { } } - @Override public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId, String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs, @@ -1220,8 +1126,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throws VnfException { String vfModuleName = vnfName; String vfModuleType = vnfType; - String methodName = "updateVfModule"; - String serviceName = VNF_ADAPTER_SERVICE_NAME + methodName; StringBuilder sbInit = new StringBuilder(); sbInit.append("updateVfModule: \n"); @@ -1334,7 +1238,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { // 1604 Cinder Volume support - handle a nestedStackId if sent (volumeGroupHeatStackId): StackInfo nestedHeatStack = null; - Map<String, Object> nestedVolumeOutputs = null; if (nestedStackId != null) { try { logger.debug("Querying for nestedStackId = {}", nestedStackId); @@ -1360,13 +1263,11 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { logger.debug("Found nested heat stack - copying values to inputs *later*"); - nestedVolumeOutputs = nestedHeatStack.getOutputs(); msoHeatUtils.copyStringOutputsToInputs(inputs, nestedHeatStack.getOutputs(), false); } } // handle a nestedBaseStackId if sent - this is the stack ID of the base. StackInfo nestedBaseHeatStack = null; - Map<String, Object> baseStackOutputs = null; if (nestedBaseStackId != null) { try { logger.debug("Querying for nestedBaseStackId = {}", nestedBaseStackId); @@ -1392,7 +1293,6 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { throw new VnfException(error, MsoExceptionCategory.USERDATA); } else { logger.debug("Found nested base heat stack - copying values to inputs *later*"); - baseStackOutputs = nestedBaseHeatStack.getOutputs(); msoHeatUtils.copyStringOutputsToInputs(inputs, nestedBaseHeatStack.getOutputs(), false); } } @@ -1832,56 +1732,4 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { return vfModuleName; } - /* - * Helper method to check a boolean property value - on error return provided default - */ - private boolean checkBooleanProperty(String propertyName, boolean defaultValue) { - boolean property = defaultValue; - try { - String propertyString = this.environment.getProperty(propertyName); - if ("true".equalsIgnoreCase(propertyString) || "y".equalsIgnoreCase(propertyString)) { - property = true; - } else if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { - property = false; - } - } catch (Exception e) { - logger.debug("An exception occured trying to get property {} - defaulting to ", propertyName, defaultValue, - e); - property = defaultValue; - } - return property; - } - - /* - * Helper method to combine getFiles and nestedTemplates in to a single Map - */ - private Map<String, Object> combineGetFilesAndNestedTemplates(Map<String, Object> getFiles, - Map<String, Object> nestedTemplates) { - boolean haveGetFiles = true; - boolean haveNestedTemplates = true; - Map<String, Object> files = new HashMap<>(); - if (getFiles == null || getFiles.isEmpty()) { - haveGetFiles = false; - } - if (nestedTemplates == null || nestedTemplates.isEmpty()) { - haveNestedTemplates = false; - } - if (haveGetFiles && haveNestedTemplates) { - for (String keyString : getFiles.keySet()) { - files.put(keyString, getFiles.get(keyString)); - } - for (String keyString : nestedTemplates.keySet()) { - files.put(keyString, nestedTemplates.get(keyString)); - } - } else { - // Handle if we only have one or neither: - if (haveGetFiles) { - files = getFiles; - } - if (haveNestedTemplates) { - files = nestedTemplates; - } - } - return files; - } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java deleted file mode 100644 index ba837a9718..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImpl.java +++ /dev/null @@ -1,1142 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - MSO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import javax.jws.WebService; -import javax.xml.ws.Holder; -import org.onap.so.logger.LoggingAnchor; -import com.woorea.openstack.heat.Heat; -import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.cloudify.beans.DeploymentInfo; -import org.onap.so.cloudify.beans.DeploymentStatus; -import org.onap.so.cloudify.exceptions.MsoCloudifyManagerNotFound; -import org.onap.so.cloudify.utils.MsoCloudifyUtils; -import org.onap.so.db.catalog.beans.HeatEnvironment; -import org.onap.so.db.catalog.beans.HeatFiles; -import org.onap.so.db.catalog.beans.HeatTemplate; -import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.so.db.catalog.beans.VfModule; -import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.onap.so.db.catalog.beans.VnfResource; -import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; -import org.onap.so.db.catalog.utils.MavenLikeVersioning; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.MsoTenant; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry; -import org.onap.so.openstack.utils.MsoHeatEnvironmentParameter; -import org.onap.so.openstack.utils.MsoKeystoneUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.springframework.transaction.annotation.Transactional; - -@Component -@Transactional -@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter", - targetNamespace = "http://org.onap.so/vnf") -public class MsoVnfCloudifyAdapterImpl implements MsoVnfAdapter { - - private static Logger logger = LoggerFactory.getLogger(MsoVnfCloudifyAdapterImpl.class); - - private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; - private static final String CLOUDIFY = "Cloudify"; - - private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - private static final String BRACKETS = LoggingAnchor.NINE; - private static final String OPENSTACK = "OpenStack"; - - @Autowired - protected CloudConfig cloudConfig; - - @Autowired - private VFModuleCustomizationRepository vfModuleCustomRepo; - - @Autowired - private Environment environment; - - @Autowired - protected MsoKeystoneUtils keystoneUtils; - - @Autowired - protected MsoCloudifyUtils cloudifyUtils; - - /** - * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL. - * - * @see MsoVnfCloudifyAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory) - */ - public MsoVnfCloudifyAdapterImpl() { - - } - - /** - * Health Check web method. Does nothing but return to show the adapter is deployed. - */ - @Override - public void healthCheck() { - logger.debug("Health check call in VNF Cloudify Adapter"); - } - - /** - * This is the "Create VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, - Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("CreateVNF command attempted but not supported"); - throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This is the "Update VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) - throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("UpdateVNF command attempted but not supported"); - throw new VnfException("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This is the "Query VNF" web service implementation. - * - * This really should be QueryVfModule, but nobody ever changed it. - * - * For Cloudify, this will look up a deployment by its deployment ID, which is really the same as deployment name, - * since it assigned by the client when a deployment is created. Also, the input cloudSiteId is used only to - * identify which Cloudify instance to query, and the tenantId is ignored (since that really only applies for - * Openstack/Heat). - * - * The method returns an indicator that the VNF exists, along with its status and outputs. The input "vnfName" will - * also be reflected back as its ID. - * - * @param cloudSiteId CLLI code of the cloud site in which to query - * @param cloudOwner cloud owner of the cloud site in which to query - * @param tenantId Openstack tenant identifier - ignored for Cloudify - * @param vnfName VNF Name (should match a deployment ID) - * @param msoRequest Request tracking information for logs - * @param vnfExists Flag reporting the result of the query - * @param vnfId Holder for output VNF ID - * @param outputs Holder for Map of VNF outputs from Cloudify deployment (assigned IPs, etc) - */ - @Override - public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest, - Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status, - Holder<Map<String, String>> outputs) throws VnfException { - logger.debug("Querying VNF {} in {}", vnfName, cloudSiteId + "/" + tenantId); - - DeploymentInfo deployment = null; - - try { - deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName); - } catch (MsoCloudifyManagerNotFound e) { - // This site does not have a Cloudify Manager. - // This isn't an error, just means we won't find the VNF here. - deployment = null; - } catch (MsoException me) { - // Failed to query the Deployment due to a cloudify exception. - logger.debug("Failed to query the Deployment due to a cloudify exception"); - // Convert to a generic VnfException - me.addContext("QueryVNF"); - String error = "Query VNF (Cloudify): " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId, - CLOUDIFY, "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryDeployment", me); - logger.debug(error); - throw new VnfException(me); - } - - if (deployment != null && deployment.getStatus() != DeploymentStatus.NOTFOUND) { - vnfExists.value = Boolean.TRUE; - status.value = deploymentStatusToVnfStatus(deployment); - vnfId.value = deployment.getId(); - outputs.value = copyStringOutputs(deployment.getOutputs()); - - logger.debug("VNF {} found in Cloudify, ID = {}", vnfName, vnfId.value); - } else { - vnfExists.value = Boolean.FALSE; - status.value = VnfStatus.NOTFOUND; - vnfId.value = null; - outputs.value = new HashMap<String, String>(); // Return as an empty map - - logger.debug("VNF {} not found", vnfName); - } - } - - - /** - * This is the "Delete VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest) - throws VnfException { - - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("DeleteVNF command attempted but not supported"); - throw new VnfException("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the - * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation - * to undo the creation. - * - * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup, but APIs were apparently never updated. - */ - @Override - public void rollbackVnf(VnfRollback rollback) throws VnfException { - // rollback may be null (e.g. if stack already existed when Create was called) - if (rollback == null) { - logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), OPENSTACK, "rollbackVnf"); - return; - } - - // Don't rollback if nothing was done originally - if (!rollback.getVnfCreated()) { - return; - } - - // Get the elements of the VnfRollback object for easier access - String cloudSiteId = rollback.getCloudSiteId(); - String cloudOwner = rollback.getCloudOwner(); - String tenantId = rollback.getTenantId(); - String vfModuleId = rollback.getVfModuleStackId(); - - logger.debug("Rolling Back VF Module {} in {}", vfModuleId, cloudOwner + "/" + cloudSiteId + "/" + tenantId); - - DeploymentInfo deployment = null; - - // Use the MsoCloudifyUtils to delete the deployment. Set the polling flag to true. - // The possible outcomes of deleteStack are a StackInfo object with status - // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException - // could be thrown. - try { - // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID. - // Go directly to Keystone until APIs could be updated to supply the name. - MsoTenant msoTenant = keystoneUtils.queryTenant(tenantId, cloudSiteId); - String tenantName = (msoTenant != null ? msoTenant.getTenantName() : tenantId); - - // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object - // and use that. - deployment = cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantName, vfModuleId, 5); - logger.debug("Rolled back deployment: {}", deployment.getId()); - } catch (MsoException me) { - // Failed to rollback the VNF due to a cloudify exception. - // Convert to a generic VnfException - me.addContext("RollbackVNF"); - String error = "Rollback VF Module: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner, cloudSiteId, - tenantId, CLOUDIFY, "DeleteDeployment", ErrorCode.DataError.getValue(), - "Exception - DeleteDeployment", me); - logger.debug(error); - throw new VnfException(me); - } - } - - - private VnfStatus deploymentStatusToVnfStatus(DeploymentInfo deployment) { - // Determine the status based on last action & status - // DeploymentInfo object should be enhanced to report a better status internally. - DeploymentStatus status = deployment.getStatus(); - String lastAction = deployment.getLastAction(); - - if (status == null || lastAction == null) { - return VnfStatus.UNKNOWN; - } else if (status == DeploymentStatus.NOTFOUND) { - return VnfStatus.NOTFOUND; - } else if (status == DeploymentStatus.INSTALLED) { - return VnfStatus.ACTIVE; - } else if (status == DeploymentStatus.CREATED) { - // Should have an INACTIVE status for this case. Shouldn't really happen, but - // Install was never run, or Uninstall was done but deployment didn't get deleted. - return VnfStatus.UNKNOWN; - } else if (status == DeploymentStatus.FAILED) { - return VnfStatus.FAILED; - } - - return VnfStatus.UNKNOWN; - } - - private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) { - Map<String, String> stringOutputs = new HashMap<>(); - for (Map.Entry<String, Object> entry : stackOutputs.entrySet()) { - if (entry.getValue() instanceof String) { - stringOutputs.put(entry.getKey(), (String) entry.getValue()); - } else if (entry.getValue() instanceof Integer) { - try { - String str = "" + entry.getValue(); - stringOutputs.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("Unable to add " + entry.getKey() + " to outputs", e); - } - } else if (entry.getValue() instanceof JsonNode) { - try { - String str = this.convertNode((JsonNode) entry.getValue()); - stringOutputs.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting JsonNode", e); - } - } else if (entry.getValue() instanceof java.util.LinkedHashMap) { - try { - String str = JSON_MAPPER.writeValueAsString(entry.getValue()); - stringOutputs.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("Unable to add " + entry.getKey() + " to outputs - exception converting LinkedHashMap", - e); - } - } else { - try { - String str = entry.getValue().toString(); - stringOutputs.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("Unable to add " + entry.getKey() + " to outputs - unable to call .toString() ", e); - } - } - } - return stringOutputs; - } - - - private void sendMapToDebug(Map<String, Object> inputs, String optionalName) { - int i = 0; - StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName); - if (inputs == null) { - sb.append("\tNULL"); - } else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (Map.Entry<String, Object> entry : inputs.entrySet()) { - String outputString; - try { - outputString = entry.getValue().toString(); - } catch (Exception e) { - outputString = "Unable to call toString() on the value for " + entry.getKey(); - } - sb.append("\t\nitem " + i++ + ": '" + entry.getKey() + "'='" + outputString + "'"); - } - } - logger.debug(sb.toString()); - } - - private void sendMapToDebug(Map<String, Object> inputs) { - int i = 0; - StringBuilder sb = new StringBuilder("inputs:"); - if (inputs == null) { - sb.append("\tNULL"); - } else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (Map.Entry<String, Object> entry : inputs.entrySet()) { - sb.append("\titem " + i++ + ": " + entry.getKey() + "=" + entry.getValue()); - } - } - logger.debug(sb.toString()); - } - - private String convertNode(final JsonNode node) { - try { - final Object obj = JSON_MAPPER.treeToValue(node, Object.class); - final String json = JSON_MAPPER.writeValueAsString(obj); - return json; - } catch (JsonParseException jpe) { - logger.error("Error converting json to string ", jpe); - } catch (Exception e) { - logger.error("Error converting json to string ", e); - } - return "[Error converting json to string]"; - } - - private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) { - if (objectMap == null) { - return null; - } - Map<String, String> stringMap = new HashMap<>(); - for (Map.Entry<String, Object> entry : objectMap.entrySet()) { - if (!stringMap.containsKey(entry.getKey())) { - Object obj = entry.getValue(); - if (obj instanceof String) { - stringMap.put(entry.getKey(), (String) entry.getValue()); - } else if (obj instanceof JsonNode) { - // This is a bit of mess - but I think it's the least impacting - // let's convert it BACK to a string - then it will get converted back later - try { - String str = this.convertNode((JsonNode) obj); - stringMap.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("DANGER WILL ROBINSON: unable to convert value for JsonNode " + entry.getKey(), e); - // okay in this instance - only string values (fqdn) are expected to be needed - } - } else if (obj instanceof java.util.LinkedHashMap) { - logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); - try { - String str = JSON_MAPPER.writeValueAsString(obj); - stringMap.put(entry.getKey(), str); - } catch (Exception e) { - logger.error( - "DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + entry.getKey(), e); - } - } else if (obj instanceof Integer) { - try { - String str = "" + obj; - stringMap.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("DANGER WILL ROBINSON: unable to convert value for Integer " + entry.getKey(), e); - } - } else { - try { - String str = obj.toString(); - stringMap.put(entry.getKey(), str); - } catch (Exception e) { - logger.error("DANGER WILL ROBINSON: unable to convert value " + entry.getKey(), e); - } - } - } - } - - return stringMap; - } - - /** - * This is the "Create VF Module" web service implementation. It will instantiate a new VF Module of the requested - * type in the specified cloud and tenant. The tenant must exist before this service is called. - * - * If a VF Module with the same name already exists, this can be considered a success or failure, depending on the - * value of the 'failIfExists' parameter. - * - * All VF Modules are defined in the MSO catalog. The caller must request one of the pre-defined module types or an - * error will be returned. Within the catalog, each VF Module references (among other things) a cloud template which - * is used to deploy the required artifacts (VMs, networks, etc.) to the cloud. In this adapter implementation, that - * artifact is expected to be a Cloudify blueprint. - * - * Depending on the blueprint, a variable set of input parameters will be defined, some of which are required. The - * caller is responsible to pass the necessary input data for the module or an error will be thrown. - * - * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback object. This last object can be - * passed as-is to the rollbackVnf operation to undo everything that was created for the Module. This is useful if a - * VF module is successfully created but the orchestration fails on a subsequent step. - * - * @param cloudSiteId CLLI code of the cloud site in which to create the VNF - * @param cloudOwner cloud owner of the cloud site in which to create the VNF - * @param tenantId Openstack tenant identifier - * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB. Deprecated - should use - * modelCustomizationUuid - * @param vnfVersion VNF version key, should match a VNF definition in catalog DB Deprecated - VF Module versions - * also captured by modelCustomizationUuid - * @param genericVnfId Generic VNF ID - * @param vfModuleName Name to be assigned to the new VF Module - * @param vfModuleId Id of the new VF Module - * @param requestType Indicates if this is a Volume Group or Module request - * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group to attach to a VF Module - * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if this is an Add-on module - * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces the use of vfModuleType. - * @param inputs Map of key=value inputs for VNF stack creation - * @param failIfExists Flag whether already existing VNF should be considered - * @param backout Flag whether to suppress automatic backout (for testing) - * @param msoRequest Request tracking information for logs - * @param vnfId Holder for output VNF Cloudify Deployment ID - * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc) - * @param rollback Holder for returning VnfRollback object - */ - @Override - public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleType, - String vnfVersion, String genericVnfId, String vfModuleName, String vfModuleId, String requestType, - String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs, - Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, - Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException { - - // Require a model customization ID. Every VF Module definition must have one. - if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { - logger.debug("Missing required input: modelCustomizationUuid"); - String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), - "VF Module ModelCustomizationUuid", CLOUDIFY, ErrorCode.DataError.getValue(), - "Create VF Module: Missing required input: modelCustomizationUuid"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - - // Clean up some inputs to make comparisons easier - if (requestType == null) - requestType = ""; - - if ("".equals(volumeGroupId) || "null".equals(volumeGroupId)) - volumeGroupId = null; - - if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId)) - baseVfModuleId = null; - - if (inputs == null) { - // Create an empty set of inputs - inputs = new HashMap<>(); - logger.debug("inputs == null - setting to empty"); - } else { - this.sendMapToDebug(inputs); - } - - // Check if this is for a "Volume" module - boolean isVolumeRequest = false; - if (requestType.startsWith("VOLUME")) { - isVolumeRequest = true; - } - - logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " - + baseVfModuleId); - - // Build a default rollback object (no actions performed) - VnfRollback vfRollback = new VnfRollback(); - vfRollback.setCloudSiteId(cloudSiteId); - vfRollback.setCloudOwner(cloudOwner); - vfRollback.setTenantId(tenantId); - vfRollback.setMsoRequest(msoRequest); - vfRollback.setRequestType(requestType); - vfRollback.setIsBase(false); // Until we know better - vfRollback.setVolumeGroupHeatStackId(volumeGroupId); - vfRollback.setBaseGroupHeatStackId(baseVfModuleId); - vfRollback.setModelCustomizationUuid(modelCustomizationUuid); - vfRollback.setMode("CFY"); - - rollback.value = vfRollback; // Default rollback - no updates performed - - // Get the VNF/VF Module definition from the Catalog DB first. - // There are three relevant records: VfModule, VfModuleCustomization, VnfResource - - VfModule vf = null; - VnfResource vnfResource = null; - VfModuleCustomization vfmc = null; - - try { - vfmc = vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid); - - if (vfmc == null) { - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" - + modelCustomizationUuid; - logger.debug(error); - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), - "VF Module " + "ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", - ErrorCode.DataError.getValue(), error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found vfModuleCust entry " + vfmc.toString()); - } - - // Get the vfModule and vnfResource records - vf = vfmc.getVfModule(); - vnfResource = vfmc.getVfModule().getVnfResources(); - } catch (Exception e) { - - logger.error("unhandled exception in create VF - [Query]", e); - throw new VnfException("Exception during create VF " + e.getMessage()); - } - - // Perform a version check against cloudSite - // Obtain the cloud site information where we will create the VF Module - Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSiteOp.isPresent()) { - throw new VnfException(new MsoCloudSiteNotFound(cloudSiteId)); - } - CloudSite cloudSite = cloudSiteOp.get(); - MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getCloudVersion()); - - String vnfMin = vnfResource.getAicVersionMin(); - String vnfMax = vnfResource.getAicVersionMax(); - - if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) - || (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) { - // ERROR - String error = "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" - + vnfResource.getModelUUID() + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax - + " NOT supported on Cloud: " + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, OPENSTACK, - ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - // End Version check - - - DeploymentInfo cloudifyDeployment = null; - - // First, look up to see if the VF already exists. - - try { - cloudifyDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vfModuleName); - } catch (MsoException me) { - // Failed to query the Deployment due to a cloudify exception. - String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + me; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudSiteId, - tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Exception - queryDeployment", me); - logger.debug(error); - - // Convert to a generic VnfException - me.addContext("CreateVFModule"); - throw new VnfException(me); - } - - // More precise handling/messaging if the Module already exists - if (cloudifyDeployment != null && !(cloudifyDeployment.getStatus() == DeploymentStatus.NOTFOUND)) { - // CREATED, INSTALLED, INSTALLING, FAILED, UNINSTALLING, UNKNOWN - DeploymentStatus status = cloudifyDeployment.getStatus(); - logger.debug("Found Existing Deployment, status=" + status); - - if (status == DeploymentStatus.INSTALLED) { - // fail - it exists - if (failIfExists != null && failIfExists) { - String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId; - logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Deployment " + vfModuleName + " already exists"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - cloudifyDeployment.getId()); - } else { - // Found existing deployment and client has not requested "failIfExists". - // Populate the outputs from the existing deployment. - - vnfId.value = cloudifyDeployment.getId(); - outputs.value = copyStringOutputs(cloudifyDeployment.getOutputs()); - return; - } - } - // Check through various detailed error cases - if (status == DeploymentStatus.INSTALLING || status == DeploymentStatus.UNINSTALLING) { - // fail - it's in progress - return meaningful error - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; please wait for it to complete, or fix manually."; - logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Deployment " + vfModuleName + " already exists"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId()); - } else if (status == DeploymentStatus.FAILED) { - // fail - it exists and is in a FAILED state - String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " - + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Deployment " + vfModuleName + " already " + "exists and is in FAILED state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId()); - } else if (status == DeploymentStatus.UNKNOWN || status == DeploymentStatus.CREATED) { - // fail - it exists and is in a UNKNOWN state - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; requires manual intervention."; - logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Deployment " + vfModuleName + " already " + "exists and is in " + status.toString() - + " state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId()); - } else { - // Unexpected, since all known status values have been tested for - String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; requires manual intervention."; - logger.error(BRACKETS, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment", ErrorCode.DataError.getValue(), - "Deployment " + vfModuleName + " already " + "exists and is in an unknown state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, cloudifyDeployment.getId()); - } - } - - - // Collect outputs from Base Modules and Volume Modules - Map<String, Object> baseModuleOutputs = null; - Map<String, Object> volumeGroupOutputs = null; - - // If a Volume Group was provided, query its outputs for inclusion in Module input parameters - if (volumeGroupId != null) { - DeploymentInfo volumeDeployment = null; - try { - volumeDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, volumeGroupId); - } catch (MsoException me) { - // Failed to query the Volume GroupDeployment due to a cloudify exception. - String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner, cloudSiteId, - tenantId, CLOUDIFY, "queryDeployment(volume)", ErrorCode.DataError.getValue(), - "Exception - queryDeployment(volume)", me); - logger.debug(error); - // Convert to a generic VnfException - me.addContext("CreateVFModule(QueryVolume)"); - throw new VnfException(me); - } - - if (volumeDeployment == null || volumeDeployment.getStatus() == DeploymentStatus.NOTFOUND) { - String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " - + cloudSiteId + "/" + tenantId + " USER ERROR"; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudSiteId, tenantId, - error, CLOUDIFY, "queryDeployment(volume)", ErrorCode.BusinessProcessError.getValue(), - "Create VFModule: Attached Volume Group DOES NOT EXIST"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found nested volume group"); - volumeGroupOutputs = volumeDeployment.getOutputs(); - this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs"); - } - } - - // If this is an Add-On Module, query the Base Module outputs - // Note: This will be performed whether or not the current request is for an - // Add-On Volume Group or Add-On VF Module - - if (vf.getIsBase()) { - logger.debug("This is a BASE Module request"); - vfRollback.setIsBase(true); - } else { - logger.debug("This is an Add-On Module request"); - - // Add-On Modules should always have a Base, but just treat as a warning if not provided. - // Add-on Volume requests may or may not specify a base. - if (!isVolumeRequest && baseVfModuleId == null) { - logger.debug("WARNING: Add-on Module request - no Base Module ID provided"); - } - - if (baseVfModuleId != null) { - DeploymentInfo baseDeployment = null; - try { - baseDeployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, baseVfModuleId); - } catch (MsoException me) { - // Failed to query the Volume GroupDeployment due to a cloudify exception. - String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, "queryDeployment(Base)", ErrorCode.DataError.getValue(), - "Exception - queryDeployment(Base)", me); - logger.debug(error); - // Convert to a generic VnfException - me.addContext("CreateVFModule(QueryBase)"); - throw new VnfException(me); - } - - if (baseDeployment == null || baseDeployment.getStatus() == DeploymentStatus.NOTFOUND) { - String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " - + cloudSiteId + "/" + tenantId + " USER ERROR"; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudSiteId, - tenantId, error, CLOUDIFY, "queryDeployment(Base)", - ErrorCode.BusinessProcessError.getValue(), - "Create VFModule: Base " + "Module DOES NOT EXIST"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found base module"); - baseModuleOutputs = baseDeployment.getOutputs(); - this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); - } - } - } - - - // Ready to deploy the new VNF - - // NOTE: For this section, heatTemplate is used for both HEAT templates and Cloudify blueprints. - // In final implementation (post-POC), the template object would either be generic or there would - // be a separate DB Table/Object for Blueprints. - - - // NOTE: The template is fixed for the VF Module. The environment is part of the customization. - HeatTemplate heatTemplate = null; - HeatEnvironment heatEnvironment = null; - if (isVolumeRequest) { - heatTemplate = vf.getVolumeHeatTemplate(); - heatEnvironment = vfmc.getVolumeHeatEnv(); - } else { - heatTemplate = vf.getModuleHeatTemplate(); - heatEnvironment = vfmc.getHeatEnvironment(); - } - - if (heatTemplate == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType - + ", modelCustomizationUuid=" + modelCustomizationUuid + ", vfModuleUuid=" + vf.getModelUUID() - + ", reqType=" + requestType; - logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", - vfModuleType, OPENSTACK, ErrorCode.DataError.getValue(), error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - logger.debug("Got HEAT Template from DB: {}", heatTemplate.getHeatTemplate()); - } - - if (heatEnvironment == null) { - String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType + ", modelCustomizationUuid=" - + modelCustomizationUuid + ", vfModuleUuid=" + vf.getModelUUID() + ", reqType=" + requestType; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", - OPENSTACK, ErrorCode.DataError.getValue(), error); - // Alarm on this error, configuration must be fixed - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - logger.debug("Got Heat Environment from DB: {}", heatEnvironment.getEnvironment()); - } - - - try { - // All variables converted to their native object types - HashMap<String, Object> goldenInputs = new HashMap<>(); - List<String> extraInputs = new ArrayList<>(); - - // NOTE: SKIP THIS FOR CLOUDIFY for now. Just use what was passed in. - // This whole section needs to be rewritten. - Boolean skipInputChecks = false; - - if (skipInputChecks) { - goldenInputs = new HashMap<>(); - for (Map.Entry<String, Object> entry : inputs.entrySet()) { - goldenInputs.put(entry.getKey(), entry.getValue()); - } - } else { - // Build maps for the parameters (including aliases) to simplify checks - HashMap<String, HeatTemplateParam> params = new HashMap<>(); - - Set<HeatTemplateParam> paramSet = heatTemplate.getParameters(); - logger.debug("paramSet has {} entries", paramSet.size()); - - for (HeatTemplateParam htp : paramSet) { - params.put(htp.getParamName(), htp); - - // Include aliases. - String alias = htp.getParamAlias(); - if (alias != null && !"".equals(alias) && !params.containsKey(alias)) { - params.put(alias, htp); - } - } - - // First, convert all inputs to their "template" type - for (String key : inputs.keySet()) { - if (params.containsKey(key)) { - Object value = cloudifyUtils.convertInputValue(inputs.get(key), params.get(key)); - if (value != null) { - goldenInputs.put(key, value); - } else { - logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " - + params.get(key).getParamType()); - } - } else { - extraInputs.add(key); - } - } - - if (!extraInputs.isEmpty()) { - logger.debug("Ignoring extra inputs: " + extraInputs); - } - - // Next add in Volume Group Outputs if there are any. Copy directly without conversions. - if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) { - for (Map.Entry<String, Object> entry : volumeGroupOutputs.entrySet()) { - if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) { - goldenInputs.put(entry.getKey(), entry.getValue()); - } - } - } - - // Next add in Base Module Outputs if there are any. Copy directly without conversions. - if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) { - for (Map.Entry<String, Object> entry : baseModuleOutputs.entrySet()) { - if (params.containsKey(entry.getKey()) && !goldenInputs.containsKey(entry.getKey())) { - goldenInputs.put(entry.getKey(), entry.getValue()); - } - } - } - - // Last, add in values from the "environment" file. - // These are added to the inputs, since Cloudify doesn't pass an environment file like Heat. - - // TODO: This may take a different form for Cloudify, but for now process it - // with Heat environment file syntax - StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment()); - MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry(sb); - - if (mhee.getParameters() != null) { - for (MsoHeatEnvironmentParameter envParam : mhee.getParameters()) { - // If this is a template input, copy to golden inputs - String envKey = envParam.getName(); - if (params.containsKey(envKey) && !goldenInputs.containsKey(envKey)) { - Object value = cloudifyUtils.convertInputValue(envParam.getValue(), params.get(envKey)); - if (value != null) { - goldenInputs.put(envKey, value); - } else { - logger.debug("Failed to convert environment parameter " + envKey + "='" - + envParam.getValue() + "' to " + params.get(envKey).getParamType()); - } - } - } - } - - this.sendMapToDebug(goldenInputs, "Final inputs sent to Cloudify"); - - - // Check that required parameters have been supplied from any of the sources - String missingParams = null; - boolean checkRequiredParameters = true; - try { - String propertyString = this.environment.getProperty(MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS); - if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { - checkRequiredParameters = false; - logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking... {}", - MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS); - } - } catch (Exception e) { - // No problem - default is true - logger.error("An exception occured trying to get property {}", - MsoVnfCloudifyAdapterImpl.CHECK_REQD_PARAMS, e); - } - - - for (HeatTemplateParam parm : heatTemplate.getParameters()) { - if (parm.isRequired() && (!goldenInputs.containsKey(parm.getParamName()))) { - logger.debug("adding to missing parameters list: {}", parm.getParamName()); - if (missingParams == null) { - missingParams = parm.getParamName(); - } else { - missingParams += "," + parm.getParamName(); - } - } - } - - if (missingParams != null) { - if (checkRequiredParameters) { - // Problem - missing one or more required parameters - String error = "Create VFModule: Missing Required inputs: " + missingParams; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_MISSING_PARAM.toString(), missingParams, - CLOUDIFY, ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("found missing parameters [" + missingParams - + "] - but checkRequiredParameters is false -" + " will not block"); - } - } else { - logger.debug("No missing parameters found - ok to proceed"); - } - - } // NOTE: END PARAMETER CHECKING - - // Ready to deploy the VF Module. - // *First step - make sure the blueprint is loaded into Cloudify. - String blueprintName = heatTemplate.getTemplateName(); - String blueprint = heatTemplate.getTemplateBody(); - String blueprintId = blueprintName; - - // Use the main blueprint name as the blueprint ID (strip yaml extensions). - if (blueprintId.endsWith(".yaml")) - blueprintId = blueprintId.substring(0, blueprintId.lastIndexOf(".yaml")); - - try { - if (!cloudifyUtils.isBlueprintLoaded(cloudSiteId, blueprintId)) { - logger.debug("Blueprint " + blueprintId + " is not loaded. Will upload it now."); - - Map<String, byte[]> blueprintFiles = new HashMap<>(); - - blueprintFiles.put(blueprintName, blueprint.getBytes()); - - // TODO: Implement nested blueprint logic based on Cloudify structures. - // For now, just use the Heat structures. - // The query returns a map of String->Object, where the map keys provide one layer of - // indirection from the Heat template names. For this case, assume the map key matches - // the nested blueprint name. - List<HeatTemplate> nestedBlueprints = heatTemplate.getChildTemplates(); - if (nestedBlueprints != null) { - for (HeatTemplate nestedBlueprint : nestedBlueprints) { - blueprintFiles.put(nestedBlueprint.getTemplateName(), - nestedBlueprint.getTemplateBody().getBytes()); - } - } - - // TODO: Implement file artifact logic based on Cloudify structures. - // For now, just use the Heat structures. - List<HeatFiles> heatFiles = vf.getHeatFiles(); - if (heatFiles != null) { - for (HeatFiles heatFile : heatFiles) { - blueprintFiles.put(heatFile.getFileName(), heatFile.getFileBody().getBytes()); - } - } - - // Upload the blueprint package - cloudifyUtils.uploadBlueprint(cloudSiteId, blueprintId, blueprintName, blueprintFiles, false); - - } - } - - catch (MsoException me) { - me.addContext("CreateVFModule"); - String error = "Create VF Module: Upload blueprint failed. Blueprint=" + blueprintName + ": " + me; - logger.error(LoggingAnchor.SEVEN, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudSiteId, - tenantId, CLOUDIFY, ErrorCode.DataError.getValue(), "MsoException - uploadBlueprint", me); - logger.debug(error); - throw new VnfException(me); - } - - // Ignore MsoTenantNotFound and MsoStackAlreadyExists exceptions - // because we already checked for those. - try { - // KLUDGE - Cloudify requires Tenant Name for Openstack. We have the ID. - // Go directly to Keystone until APIs could be updated to supply the name. - MsoTenant msoTenant = keystoneUtils.queryTenant(tenantId, cloudSiteId); - String tenantName = (msoTenant != null ? msoTenant.getTenantName() : tenantId); - - if (backout == null) { - backout = true; - } - - cloudifyDeployment = cloudifyUtils.createAndInstallDeployment(cloudSiteId, tenantName, vfModuleName, - blueprintId, goldenInputs, true, heatTemplate.getTimeoutMinutes(), backout.booleanValue()); - - } catch (MsoException me) { - me.addContext("CreateVFModule"); - String error = "Create VF Module " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + me; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, ErrorCode.DataError.getValue(), - "MsoException - createDeployment", me); - logger.debug(error); - throw new VnfException(me); - } catch (NullPointerException npe) { - String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + npe; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner, - cloudSiteId, tenantId, CLOUDIFY, ErrorCode.DataError.getValue(), - "NullPointerException - createDeployment", npe); - logger.debug(error); - logger.debug("NULL POINTER EXCEPTION at cloudify.createAndInstallDeployment"); - // npe.addContext ("CreateVNF"); - throw new VnfException("NullPointerException during cloudify.createAndInstallDeployment"); - } catch (Exception e) { - logger.error("unhandled exception at cloudify.createAndInstallDeployment", e); - throw new VnfException("Exception during cloudify.createAndInstallDeployment! " + e.getMessage()); - } - } catch (Exception e) { - logger.error("unhandled exception in create VF", e); - throw new VnfException("Exception during create VF " + e.getMessage()); - - } - - // Reach this point if create is successful. - // Populate remaining rollback info and response parameters. - vfRollback.setVnfCreated(true); - vfRollback.setVnfId(cloudifyDeployment.getId()); - vnfId.value = cloudifyDeployment.getId(); - outputs.value = copyStringOutputs(cloudifyDeployment.getOutputs()); - - rollback.value = vfRollback; - - logger.debug("VF Module successfully created {}", vfModuleName); - - } - - public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, String vnfId, - String vfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, - Holder<Map<String, String>> outputs) throws VnfException { - logger.debug("Deleting VF " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); - - // 1702 capture the output parameters on a delete - // so we'll need to query first - DeploymentInfo deployment = null; - try { - deployment = cloudifyUtils.queryDeployment(cloudSiteId, tenantId, vnfName); - } catch (MsoException me) { - // Failed to query the deployment. Convert to a generic VnfException - me.addContext("DeleteVFModule"); - String error = "Delete VFModule: Query to get outputs: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId - + "/" + tenantId + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId, - CLOUDIFY, "QueryDeployment", ErrorCode.DataError.getValue(), "Exception - QueryDeployment", me); - logger.debug(error); - throw new VnfException(me); - } - // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected - // Object types - outputs.value = convertMapStringObjectToStringString(deployment.getOutputs()); - - // Use the MsoHeatUtils to delete the stack. Set the polling flag to true. - // The possible outcomes of deleteStack are a StackInfo object with status - // of NOTFOUND (on success) or FAILED (on error). Also, MsoOpenstackException - // could be thrown. - try { - cloudifyUtils.uninstallAndDeleteDeployment(cloudSiteId, tenantId, vnfName, 5); - } catch (MsoException me) { - me.addContext("DeleteVfModule"); - // Convert to a generic VnfException - String error = - "Delete VF: " + vnfName + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), vnfName, cloudOwner, cloudSiteId, tenantId, - "DeleteDeployment", "DeleteDeployment", ErrorCode.DataError.getValue(), - "Exception - DeleteDeployment: " + me.getMessage()); - logger.debug(error); - throw new VnfException(me); - } - - // On success, nothing is returned. - return; - } - - // TODO: Should Update be supported for Cloudify? What would this look like? - @Override - public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, - String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId, - String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs, - MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) - throws VnfException { - // This operation is not currently supported for Cloudify-orchestrated VF Modules. - logger.debug("Update VF Module command attempted but not supported"); - throw new VnfException("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA); - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java deleted file mode 100644 index 0ecfd15dde..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImpl.java +++ /dev/null @@ -1,1169 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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========================================================= - */ - -/** - * This VNF Adapter implementation is based on the VDU Plugin model. It assumes that each VF Module definition in the - * MSO catalog is expressed via a set of template and/or file artifacts that are appropriate for some specific - * sub-orchestrator that provides an implementation of the VduPlugin interface. This adapter handles all of the common - * VF Module logic, including: - catalog lookups for artifact retrieval - parameter filtering and validation - base and - * volume module queries - rollback logic - logging and error handling - * - * Then based on the orchestration mode of the VNF, it will invoke different VDU plug-ins to perform the low level - * instantiations, deletions, and queries. At this time, the set of available plug-ins is hard-coded, though in the - * future a dynamic selection is expected (e.g. via a service-provider interface). - */ -package org.onap.so.adapters.vnf; - - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Set; -import javax.jws.WebService; -import javax.xml.ws.Holder; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.adapters.vdu.CloudInfo; -import org.onap.so.adapters.vdu.VduException; -import org.onap.so.adapters.vdu.VduInstance; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vdu.VduPlugin; -import org.onap.so.adapters.vdu.VduStateType; -import org.onap.so.adapters.vdu.VduStatus; -import org.onap.so.adapters.vdu.mapper.VfModuleCustomizationToVduMapper; -import org.onap.so.adapters.vnf.exceptions.VnfAlreadyExists; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.db.catalog.beans.CloudSite; -import org.onap.so.cloudify.utils.MsoCloudifyUtils; -import org.onap.so.db.catalog.beans.HeatEnvironment; -import org.onap.so.db.catalog.beans.HeatTemplate; -import org.onap.so.db.catalog.beans.HeatTemplateParam; -import org.onap.so.db.catalog.beans.VfModule; -import org.onap.so.db.catalog.beans.VfModuleCustomization; -import org.onap.so.db.catalog.beans.VnfResource; -import org.onap.so.db.catalog.data.repository.VFModuleCustomizationRepository; -import org.onap.so.db.catalog.utils.MavenLikeVersioning; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.onap.so.openstack.utils.MsoHeatEnvironmentEntry; -import org.onap.so.openstack.utils.MsoHeatUtils; -import org.onap.so.openstack.utils.MsoKeystoneUtils; -import org.onap.so.openstack.utils.MsoMulticloudUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -@WebService(serviceName = "VnfAdapter", endpointInterface = "org.onap.so.adapters.vnf.MsoVnfAdapter", - targetNamespace = "http://org.onap.so/vnf") -@Component -@Transactional -public class MsoVnfPluginAdapterImpl implements MsoVnfAdapter { - - private static Logger logger = LoggerFactory.getLogger(MsoVnfPluginAdapterImpl.class); - - private static final String CHECK_REQD_PARAMS = "org.onap.so.adapters.vnf.checkRequiredParameters"; - private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - - @Autowired - protected CloudConfig cloudConfig; - - @Autowired - private VFModuleCustomizationRepository vfModuleCustomRepo; - - @Autowired - private Environment environment; - - @Autowired - protected MsoKeystoneUtils keystoneUtils; - - @Autowired - protected MsoCloudifyUtils cloudifyUtils; - - @Autowired - protected MsoHeatUtils heatUtils; - - @Autowired - protected MsoMulticloudUtils multicloudUtils; - - @Autowired - protected VfModuleCustomizationToVduMapper vduMapper; - - /** - * DO NOT use that constructor to instantiate this class, the msoPropertiesfactory will be NULL. - * - * @see MsoVnfPluginAdapterImpl#MsoVnfAdapterImpl(MsoPropertiesFactory, CloudConfigFactory) - */ - public MsoVnfPluginAdapterImpl() { - - } - - /** - * Health Check web method. Does nothing but return to show the adapter is deployed. - */ - @Override - public void healthCheck() { - logger.debug("Health check call in VNF Plugin Adapter"); - } - - /** - * This is the "Create VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void createVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, - Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("CreateVNF command attempted but not supported"); - throw new VnfException("CreateVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This is the "Update VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void updateVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, String vnfVersion, - String vnfName, String requestType, String volumeGroupHeatStackId, Map<String, Object> inputs, - MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) - throws VnfException { - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("UpdateVNF command attempted but not supported"); - throw new VnfException("UpdateVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This is the "Query VNF" web service implementation. - * - * This really should be QueryVfModule, but nobody ever changed it. - * - * The method returns an indicator that the VNF exists, along with its status and outputs. The input "vnfName" will - * also be reflected back as its ID. - * - * @param cloudSiteId CLLI code of the cloud site in which to query - * @param tenantId Openstack tenant identifier - * @param vnfNameOrId VNF Name or ID to query - * @param msoRequest Request tracking information for logs - * @param vnfExists Flag reporting the result of the query - * @param vnfId Holder for output VNF ID - * @param outputs Holder for Map of outputs from the deployed VF Module (assigned IPs, etc) - */ - @Override - public void queryVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfNameOrId, - MsoRequest msoRequest, Holder<Boolean> vnfExists, Holder<String> vnfId, Holder<VnfStatus> status, - Holder<Map<String, String>> outputs) throws VnfException { - logger.debug("Querying VNF " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); - - VduInstance vduInstance; - CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null); - - VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner); - - try { - vduInstance = vduPlugin.queryVdu(cloudInfo, vnfNameOrId); - } catch (VduException e) { - // Failed to query the VDU due to a plugin exception. - // Convert to a generic VnfException - e.addContext("QueryVNF"); - String error = "Query VNF (VDU): " + vnfNameOrId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + ": " + e; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vnfNameOrId, cloudOwner, - cloudSiteId, tenantId, "VDU", "QueryVNF", ErrorCode.DataError.getValue(), "Exception - queryVDU", - e); - logger.debug(error); - throw new VnfException(e); - } - - if (vduInstance != null && vduInstance.getStatus().getState() != VduStateType.NOTFOUND) { - vnfExists.value = Boolean.TRUE; - status.value = vduStatusToVnfStatus(vduInstance); - vnfId.value = vduInstance.getVduInstanceId(); - outputs.value = copyStringOutputs(vduInstance.getOutputs()); - - logger.debug("VNF {} found, ID = {}", vnfNameOrId, vnfId.value); - } else { - vnfExists.value = Boolean.FALSE; - status.value = VnfStatus.NOTFOUND; - vnfId.value = null; - outputs.value = new HashMap<String, String>(); // Return as an empty map - - logger.debug("VNF {} not found", vnfNameOrId); - } - return; - } - - - /** - * This is the "Delete VNF" web service implementation. This function is now unsupported and will return an error. - * - */ - @Override - public void deleteVnf(String cloudSiteId, String cloudOwner, String tenantId, String vnfName, MsoRequest msoRequest) - throws VnfException { - - // This operation is no longer supported at the VNF level. The adapter is only called to deploy modules. - logger.debug("DeleteVNF command attempted but not supported"); - throw new VnfException("DeleteVNF: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /** - * This web service endpoint will rollback a previous Create VNF operation. A rollback object is returned to the - * client in a successful creation response. The client can pass that object as-is back to the rollbackVnf operation - * to undo the creation. - * - * TODO: This should be rollbackVfModule and/or rollbackVolumeGroup, but APIs were apparently never updated. - */ - @Override - public void rollbackVnf(VnfRollback rollback) throws VnfException { - // rollback may be null (e.g. if stack already existed when Create was called) - if (rollback == null) { - logger.info(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_NULL.toString(), "OpenStack", "rollbackVnf"); - return; - } - - // Don't rollback if nothing was done originally - if (!rollback.getVnfCreated()) { - return; - } - - // Get the elements of the VnfRollback object for easier access - String cloudSiteId = rollback.getCloudSiteId(); - String cloudOwner = rollback.getCloudOwner(); - String tenantId = rollback.getTenantId(); - CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null); - - String vfModuleId = rollback.getVfModuleStackId(); - - logger.debug("Rolling Back VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); - - VduInstance vduInstance = null; - - // Use the VduPlugin to delete the VF Module. - VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner); - - try { - // TODO: Get a reasonable timeout. Use a global property, or store the creation timeout in rollback object - // and use that. - vduInstance = vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5); - - logger.debug("Rolled back VDU instantiation: {}", vduInstance.getVduInstanceId()); - } catch (VduException ve) { - // Failed to rollback the VF Module due to a plugin exception. - // Convert to a generic VnfException - ve.addContext("RollbackVFModule"); - String error = "Rollback VF Module: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + ve; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner, - cloudSiteId, tenantId, "VDU", "DeleteVdu", ErrorCode.DataError.getValue(), "Exception - DeleteVdu", - ve); - logger.debug(error); - throw new VnfException(ve); - } - return; - } - - - private VnfStatus vduStatusToVnfStatus(VduInstance vdu) { - // Determine the status based on last action & status - // DeploymentInfo object should be enhanced to report a better status internally. - VduStatus vduStatus = vdu.getStatus(); - VduStateType status = vduStatus.getState(); - - if (status == null) { - return VnfStatus.UNKNOWN; - } else if (status == VduStateType.NOTFOUND) { - return VnfStatus.NOTFOUND; - } else if (status == VduStateType.INSTANTIATED) { - return VnfStatus.ACTIVE; - } else if (status == VduStateType.FAILED) { - return VnfStatus.FAILED; - } - - return VnfStatus.UNKNOWN; - } - - /* - * Normalize an input value to an Object, based on the target parameter type. If the type is not recognized, it will - * just be returned unchanged (as a string). - */ - private Object convertInputValue(Object inputValue, HeatTemplateParam templateParam) { - String type = templateParam.getParamType(); - logger.debug("Parameter: {} is of type ", templateParam.getParamName(), type); - - if ("number".equalsIgnoreCase(type)) { - try { - return Integer.valueOf(inputValue.toString()); - } catch (Exception e) { - logger.debug("Unable to convert " + inputValue + " to an integer!", e); - return null; - } - } else if ("json".equalsIgnoreCase(type)) { - try { - JsonNode jsonNode = JSON_MAPPER.readTree(JSON_MAPPER.writeValueAsString(inputValue)); - return jsonNode; - } catch (Exception e) { - logger.debug("Unable to convert " + inputValue + " to a JsonNode!", e); - return null; - } - } else if ("boolean".equalsIgnoreCase(type)) { - return Boolean.valueOf(inputValue.toString()); - } - - // Nothing else matched. Return the original string - return inputValue; - } - - private Map<String, String> copyStringOutputs(Map<String, Object> stackOutputs) { - Map<String, String> stringOutputs = new HashMap<>(); - for (String key : stackOutputs.keySet()) { - if (stackOutputs.get(key) instanceof String) { - stringOutputs.put(key, (String) stackOutputs.get(key)); - } else if (stackOutputs.get(key) instanceof Integer) { - try { - String str = "" + stackOutputs.get(key); - stringOutputs.put(key, str); - } catch (Exception e) { - logger.debug("Unable to add {} to outputs", key, e); - } - } else if (stackOutputs.get(key) instanceof JsonNode) { - try { - String str = this.convertNode((JsonNode) stackOutputs.get(key)); - stringOutputs.put(key, str); - } catch (Exception e) { - logger.debug("Unable to add {} to outputs - exception converting JsonNode", key, e); - } - } else if (stackOutputs.get(key) instanceof java.util.LinkedHashMap) { - try { - String str = JSON_MAPPER.writeValueAsString(stackOutputs.get(key)); - stringOutputs.put(key, str); - } catch (Exception e) { - logger.debug("Unable to add {} to outputs - exception converting LinkedHashMap", key, e); - } - } else { - try { - String str = stackOutputs.get(key).toString(); - stringOutputs.put(key, str); - } catch (Exception e) { - logger.debug("Unable to add " + key + " to outputs - unable to call .toString() " + e.getMessage(), - e); - } - } - } - return stringOutputs; - } - - - private void sendMapToDebug(Map<String, Object> inputs, String optionalName) { - int i = 0; - StringBuilder sb = new StringBuilder(optionalName == null ? "\ninputs" : "\n" + optionalName); - if (inputs == null) { - sb.append("\tNULL"); - } else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (String str : inputs.keySet()) { - String outputString; - try { - outputString = inputs.get(str).toString(); - } catch (Exception e) { - outputString = "Unable to call toString() on the value for " + str; - } - sb.append("\t\nitem " + i++ + ": '" + str + "'='" + outputString + "'"); - } - } - logger.debug(sb.toString()); - return; - } - - private void sendMapToDebug(Map<String, Object> inputs) { - int i = 0; - StringBuilder sb = new StringBuilder("inputs:"); - if (inputs == null) { - sb.append("\tNULL"); - } else if (inputs.size() < 1) { - sb.append("\tEMPTY"); - } else { - for (String str : inputs.keySet()) { - sb.append("\titem " + i++ + ": " + str + "=" + inputs.get(str)); - } - } - logger.debug(sb.toString()); - return; - } - - private String convertNode(final JsonNode node) { - try { - final Object obj = JSON_MAPPER.treeToValue(node, Object.class); - final String json = JSON_MAPPER.writeValueAsString(obj); - return json; - } catch (JsonParseException jpe) { - logger.debug("Error converting json to string " + jpe.getMessage()); - } catch (Exception e) { - logger.debug("Error converting json to string " + e.getMessage()); - } - return "[Error converting json to string]"; - } - - private Map<String, String> convertMapStringObjectToStringString(Map<String, Object> objectMap) { - if (objectMap == null) { - return null; - } - Map<String, String> stringMap = new HashMap<>(); - for (String key : objectMap.keySet()) { - if (!stringMap.containsKey(key)) { - Object obj = objectMap.get(key); - if (obj instanceof String) { - stringMap.put(key, (String) objectMap.get(key)); - } else if (obj instanceof JsonNode) { - // This is a bit of mess - but I think it's the least impacting - // let's convert it BACK to a string - then it will get converted back later - try { - String str = this.convertNode((JsonNode) obj); - stringMap.put(key, str); - } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for JsonNode " + key, e); - // okay in this instance - only string values (fqdn) are expected to be needed - } - } else if (obj instanceof java.util.LinkedHashMap) { - logger.debug("LinkedHashMap - this is showing up as a LinkedHashMap instead of JsonNode"); - try { - String str = JSON_MAPPER.writeValueAsString(obj); - stringMap.put(key, str); - } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for LinkedHashMap " + key, e); - } - } else if (obj instanceof Integer) { - try { - String str = "" + obj; - stringMap.put(key, str); - } catch (Exception e) { - logger.debug("DANGER WILL ROBINSON: unable to convert value for Integer " + key, e); - } - } else { - try { - String str = obj.toString(); - stringMap.put(key, str); - } catch (Exception e) { - logger.debug( - "DANGER WILL ROBINSON: unable to convert value " + key + " (" + e.getMessage() + ")", - e); - } - } - } - } - - return stringMap; - } - - /** - * This is the "Create VF Module" web service implementation. It will instantiate a new VF Module of the requested - * type in the specified cloud and tenant. The tenant must exist before this service is called. - * - * If a VF Module with the same name already exists, this can be considered a success or failure, depending on the - * value of the 'failIfExists' parameter. - * - * All VF Modules are defined in the MSO catalog. The caller must request one of the pre-defined module types or an - * error will be returned. Within the catalog, each VF Module references (among other things) a collection of - * artifacts that are used to deploy the required cloud resources (VMs, networks, etc.). - * - * Depending on the module templates, a variable set of input parameters will be defined, some of which are - * required. The caller is responsible to pass the necessary input data for the module or an error will be thrown. - * - * The method returns the vfModuleId, a Map of output attributes, and a VnfRollback object. This last object can be - * passed as-is to the rollbackVnf operation to undo everything that was created for the Module. This is useful if a - * VF module is successfully created but the orchestration fails on a subsequent step. - * - * @param cloudSiteId CLLI code of the cloud site in which to create the VNF - * @param cloudOwner cloud owner of the cloud site in which to create the VNF - * @param tenantId Openstack tenant identifier - * @param vfModuleType VF Module type key, should match a VNF definition in catalog DB. Deprecated - should use - * modelCustomizationUuid - * @param vnfVersion VNF version key, should match a VNF definition in catalog DB Deprecated - VF Module versions - * also captured by modelCustomizationUuid - * @param vnfId - VNF ID - * @param vfModuleName Name to be assigned to the new VF Module - * @param vfModuleId Id fo the new VF Module - * @param requestType Indicates if this is a Volume Group or Module request - * @param volumeGroupId Identifier (i.e. deployment ID) for a Volume Group to attach to a VF Module - * @param baseVfModuleId Identifier (i.e. deployment ID) of the Base Module if this is an Add-on module - * @param modelCustomizationUuid Unique ID for the VF Module's model. Replaces the use of vfModuleType. - * @param inputs Map of key=value inputs for VNF stack creation - * @param failIfExists Flag whether already existing VNF should be considered - * @param backout Flag whether to suppress automatic backout (for testing) - * @param msoRequest Request tracking information for logs - * @param vnfId Holder for output VF Module instance ID in the cloud - * @param outputs Holder for Map of VNF outputs from Deployment (assigned IPs, etc) - * @param rollback Holder for returning VnfRollback object - */ - @Override - public void createVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleType, - String vnfVersion, String genericVnfId, String vfModuleName, String vfModuleId, String requestType, - String volumeGroupId, String baseVfModuleId, String modelCustomizationUuid, Map<String, Object> inputs, - Boolean failIfExists, Boolean backout, Boolean enableBridge, MsoRequest msoRequest, Holder<String> vnfId, - Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) throws VnfException { - - // Require a model customization ID. Every VF Module definition must have one. - if (modelCustomizationUuid == null || modelCustomizationUuid.isEmpty()) { - logger.debug("Missing required input: modelCustomizationUuid"); - String error = "Create vfModule error: Missing required input: modelCustomizationUuid"; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), - "VF Module ModelCustomizationUuid", "VDU", ErrorCode.DataError, - "Create VF Module: " + "Missing required input: modelCustomizationUuid"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - - // Clean up some inputs to make comparisons easier - if (requestType == null) - requestType = ""; - - if ("".equals(volumeGroupId) || "null".equals(volumeGroupId)) - volumeGroupId = null; - - if ("".equals(baseVfModuleId) || "null".equals(baseVfModuleId)) - baseVfModuleId = null; - - if (inputs == null) { - // Create an empty set of inputs - inputs = new HashMap<>(); - logger.debug("inputs == null - setting to empty"); - } else { - this.sendMapToDebug(inputs); - } - - // Check if this is for a "Volume" module - boolean isVolumeRequest = false; - if (requestType.startsWith("VOLUME")) { - isVolumeRequest = true; - } - - logger.debug("requestType = " + requestType + ", volumeGroupStackId = " + volumeGroupId + ", baseStackId = " - + baseVfModuleId); - - // Build a default rollback object (no actions performed) - VnfRollback vfRollback = new VnfRollback(); - vfRollback.setCloudSiteId(cloudSiteId); - vfRollback.setCloudOwner(cloudOwner); - vfRollback.setTenantId(tenantId); - vfRollback.setMsoRequest(msoRequest); - vfRollback.setRequestType(requestType); - vfRollback.setIsBase(false); // Until we know better - vfRollback.setVolumeGroupHeatStackId(volumeGroupId); - vfRollback.setBaseGroupHeatStackId(baseVfModuleId); - vfRollback.setModelCustomizationUuid(modelCustomizationUuid); - vfRollback.setMode("CFY"); - - rollback.value = vfRollback; // Default rollback - no updates performed - - // Get the VNF/VF Module definition from the Catalog DB first. - // There are three relevant records: VfModule, VfModuleCustomization, VnfResource - - VfModule vfModule = null; - VnfResource vnfResource = null; - VfModuleCustomization vfModuleCust = null; - - try { - vfModuleCust = - vfModuleCustomRepo.findFirstByModelCustomizationUUIDOrderByCreatedDesc(modelCustomizationUuid); - - if (vfModuleCust == null) { - String error = "Create vfModule error: Unable to find vfModuleCust with modelCustomizationUuid=" - + modelCustomizationUuid; - logger.debug(error); - logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), - "VF Module ModelCustomizationUuid", modelCustomizationUuid, "CatalogDb", ErrorCode.DataError, - error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found vfModuleCust entry {}", vfModuleCust.toString()); - } - - // Get the vfModule and vnfResource records - vfModule = vfModuleCust.getVfModule(); - vnfResource = vfModuleCust.getVfModule().getVnfResources(); - } catch (Exception e) { - - logger.debug("unhandled exception in create VF - [Query] {}", e.getMessage()); - throw new VnfException("Exception during create VF " + e.getMessage()); - } - - // Perform a version check against cloudSite - // Obtain the cloud site information where we will create the VF Module - Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId); - if (!cloudSiteOp.isPresent()) { - // If cloudSiteId is not present in the catalog DB, then default to multicloud - logger.debug("{} is not present in cloud_site catalog DB, defaulting to Multicloud plugin adapter", - cloudSiteId); - } else { - CloudSite cloudSite = cloudSiteOp.get(); - MavenLikeVersioning aicV = new MavenLikeVersioning(); - aicV.setVersion(cloudSite.getCloudVersion()); - - String vnfMin = vnfResource.getAicVersionMin(); - String vnfMax = vnfResource.getAicVersionMax(); - - if ((vnfMin != null && !(aicV.isMoreRecentThan(vnfMin) || aicV.isTheSameVersion(vnfMin))) - || (vnfMax != null && aicV.isMoreRecentThan(vnfMax))) { - // ERROR - String error = - "VNF Resource type: " + vnfResource.getModelName() + ", ModelUuid=" + vnfResource.getModelUUID() - + " VersionMin=" + vnfMin + " VersionMax:" + vnfMax + " NOT supported on Cloud: " - + cloudSiteId + " with AIC_Version:" + cloudSite.getCloudVersion(); - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_CONFIG_EXC.toString(), error, "OpenStack", - ErrorCode.BusinessProcessError.getValue(), "Exception - setVersion"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } - } - // End Version check - - - VduInstance vduInstance = null; - CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null); - - // Use the VduPlugin. - VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner); - - try { - vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleName); - } catch (VduException me) { - // Failed to query the VDU due to a plugin exception. - String error = "Create VF Module: Query " + vfModuleName + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + me; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), "Exception - queryVdu", - me); - logger.debug(error); - // Convert to a generic VnfException - me.addContext("CreateVFModule"); - throw new VnfException(me); - } - - // More precise handling/messaging if the Module already exists - if (vduInstance != null && !(vduInstance.getStatus().getState() == VduStateType.NOTFOUND)) { - VduStateType status = vduInstance.getStatus().getState(); - logger.debug("Found Existing VDU, status=" + status); - - if (status == VduStateType.INSTANTIATED) { - if (failIfExists != null && failIfExists) { - // fail - it exists - String error = "Create VF: Deployment " + vfModuleName + " already exists in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, - cloudOwner, cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), - "VF Module " + vfModuleName + " already exists"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - vduInstance.getVduInstanceId()); - } else { - // Found existing deployment and client has not requested "failIfExists". - // Populate the outputs from the existing deployment. - - vnfId.value = vduInstance.getVduInstanceId(); - outputs.value = copyStringOutputs(vduInstance.getOutputs()); - return; - } - } - // Check through various detailed error cases - else if (status == VduStateType.INSTANTIATING || status == VduStateType.DELETING - || status == VduStateType.UPDATING) { - // fail - it's in progress - return meaningful error - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; please wait for it to complete, or fix manually."; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), - "VF Module " + vfModuleName + " already exists"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - vduInstance.getVduInstanceId()); - } else if (status == VduStateType.FAILED) { - // fail - it exists and is in a FAILED state - String error = "Create VF: Deployment " + vfModuleName + " already exists and is in FAILED state in " - + cloudOwner + "/" + cloudSiteId + "/" + tenantId + "; requires manual intervention."; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), - "VF Module " + vfModuleName + " already exists and is in FAILED state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - vduInstance.getVduInstanceId()); - } else if (status == VduStateType.UNKNOWN) { - // fail - it exists and is in a UNKNOWN state - String error = "Create VF: Deployment " + vfModuleName + " already exists and has status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; requires manual intervention."; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), - "VF Module " + vfModuleName + " already exists and is in " + status.toString() + " state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - vduInstance.getVduInstanceId()); - } else { - // Unexpected, since all known status values have been tested for - String error = "Create VF: Deployment " + vfModuleName + " already exists with unexpected status " - + status.toString() + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + "; requires manual intervention."; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_VNF_ALREADY_EXIST.toString(), vfModuleName, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu", ErrorCode.DataError.getValue(), - "VF Module " + vfModuleName + " already exists and is in an unknown state"); - logger.debug(error); - throw new VnfAlreadyExists(vfModuleName, cloudSiteId, cloudOwner, tenantId, - vduInstance.getVduInstanceId()); - } - } - - - // Collect outputs from Base Modules and Volume Modules - Map<String, Object> baseModuleOutputs = null; - Map<String, Object> volumeGroupOutputs = null; - - // If a Volume Group was provided, query its outputs for inclusion in Module input parameters - if (volumeGroupId != null) { - VduInstance volumeVdu; - try { - volumeVdu = vduPlugin.queryVdu(cloudInfo, volumeGroupId); - } catch (VduException me) { - // Failed to query the Volume Group VDU due to a plugin exception. - String error = "Create VF Module: Query Volume Group " + volumeGroupId + " in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner, - cloudSiteId, tenantId, "VDU", "queryVdu(volume)", ErrorCode.DataError.getValue(), - "Exception - queryVdu(volume)", me); - logger.debug(error); - // Convert to a generic VnfException - me.addContext("CreateVFModule(QueryVolume)"); - throw new VnfException(me); - } - - if (volumeVdu == null || volumeVdu.getStatus().getState() == VduStateType.NOTFOUND) { - String error = "Create VFModule: Attached Volume Group DOES NOT EXIST " + volumeGroupId + " in " - + cloudOwner + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; - logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), volumeGroupId, cloudOwner, - cloudSiteId, tenantId, error, "VDU", "queryVdu(volume)", - ErrorCode.BusinessProcessError.getValue(), - "Create VFModule: Attached Volume Group " + "DOES NOT EXIST"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found nested volume group"); - volumeGroupOutputs = volumeVdu.getOutputs(); - this.sendMapToDebug(volumeGroupOutputs, "volumeGroupOutputs"); - } - } - - // If this is an Add-On Module, query the Base Module outputs - // Note: This will be performed whether or not the current request is for an - // Add-On Volume Group or Add-On VF Module - - if (vfModule.getIsBase()) { - logger.debug("This is a BASE Module request"); - vfRollback.setIsBase(true); - } else { - logger.debug("This is an Add-On Module request"); - - // Add-On Modules should always have a Base, but just treat as a warning if not provided. - // Add-on Volume requests may or may not specify a base. - if (!isVolumeRequest && baseVfModuleId == null) { - logger.debug("WARNING: Add-on Module request - no Base Module ID provided"); - } - - if (baseVfModuleId != null) { - VduInstance baseVdu; - try { - baseVdu = vduPlugin.queryVdu(cloudInfo, baseVfModuleId); - } catch (MsoException me) { - // Failed to query the Base VF Module due to a Vdu Plugin exception. - String error = "Create VF Module: Query Base " + baseVfModuleId + " in " + cloudOwner + "/" - + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, - cloudOwner, cloudSiteId, tenantId, "VDU", "queryVdu(Base)", ErrorCode.DataError.getValue(), - "Exception - queryVdu(Base)", me); - logger.debug(error); - // Convert to a generic VnfException - me.addContext("CreateVFModule(QueryBase)"); - throw new VnfException(me); - } - - if (baseVdu == null || baseVdu.getStatus().getState() == VduStateType.NOTFOUND) { - String error = "Create VFModule: Base Module DOES NOT EXIST " + baseVfModuleId + " in " + cloudOwner - + "/" + cloudSiteId + "/" + tenantId + " USER ERROR"; - logger.error(LoggingAnchor.TEN, MessageEnum.RA_QUERY_VNF_ERR.toString(), baseVfModuleId, cloudOwner, - cloudSiteId, tenantId, error, "VDU", "queryVdu(Base)", - ErrorCode.BusinessProcessError.getValue(), "Create VFModule: Base Module DOES NOT EXIST"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("Found base module"); - baseModuleOutputs = baseVdu.getOutputs(); - this.sendMapToDebug(baseModuleOutputs, "baseModuleOutputs"); - } - } - } - - - // NOTE: For this section, heatTemplate is used for all template artifacts. - // In final implementation (post-POC), the template object would either be generic or there would - // be a separate DB Table/Object for different sub-orchestrators. - - // NOTE: The template is fixed for the VF Module. The environment is part of the customization. - - HeatTemplate heatTemplate = null; - HeatEnvironment heatEnvironment = null; - if (isVolumeRequest) { - heatTemplate = vfModule.getVolumeHeatTemplate(); - heatEnvironment = vfModuleCust.getVolumeHeatEnv(); - } else { - heatTemplate = vfModule.getModuleHeatTemplate(); - heatEnvironment = vfModuleCust.getHeatEnvironment(); - } - - if (heatTemplate == null) { - String error = "UpdateVF: No Heat Template ID defined in catalog database for " + vfModuleType - + ", modelCustomizationUuid=" + modelCustomizationUuid + ", vfModuleUuid=" + vfModule.getModelUUID() - + ", reqType=" + requestType; - logger.error(LoggingAnchor.SIX, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Template ID", - vfModuleType, "VNF", ErrorCode.DataError.getValue(), error); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - logger.debug("Got HEAT Template from DB: " + heatTemplate.getHeatTemplate()); - } - - if (heatEnvironment == null) { - String error = "Update VNF: undefined Heat Environment. VF=" + vfModuleType + ", modelCustomizationUuid=" - + modelCustomizationUuid + ", vfModuleUuid=" + vfModule.getModelUUID() + ", reqType=" + requestType; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_VNF_UNKNOWN_PARAM.toString(), "Heat Environment ID", - "OpenStack", ErrorCode.DataError.getValue(), error); - throw new VnfException(error, MsoExceptionCategory.INTERNAL); - } else { - logger.debug("Got Heat Environment from DB: " + heatEnvironment.getEnvironment()); - } - - - // Create the combined set of parameters from the incoming request, base-module outputs, - // volume-module outputs. Also, convert all variables to their native object types. - - HashMap<String, Object> goldenInputs = new HashMap<>(); - List<String> extraInputs = new ArrayList<>(); - - Boolean skipInputChecks = false; - - if (skipInputChecks) { - goldenInputs = new HashMap<>(); - for (String key : inputs.keySet()) { - goldenInputs.put(key, inputs.get(key)); - } - } else { - // Build maps for the parameters (including aliases) to simplify checks - HashMap<String, HeatTemplateParam> params = new HashMap<>(); - - Set<HeatTemplateParam> paramSet = heatTemplate.getParameters(); - logger.debug("paramSet has " + paramSet.size() + " entries"); - - for (HeatTemplateParam htp : paramSet) { - params.put(htp.getParamName(), htp); - - // Include aliases. - String alias = htp.getParamAlias(); - if (alias != null && !"".equals(alias) && !params.containsKey(alias)) { - params.put(alias, htp); - } - } - - // First, convert all inputs to their "template" type - for (String key : inputs.keySet()) { - if (params.containsKey(key)) { - Object value = convertInputValue(inputs.get(key), params.get(key)); - if (value != null) { - goldenInputs.put(key, value); - } else { - logger.debug("Failed to convert input " + key + "='" + inputs.get(key) + "' to " - + params.get(key).getParamType()); - } - } else { - extraInputs.add(key); - } - } - - if (!extraInputs.isEmpty()) { - // Add multicloud inputs - for (String key : MsoMulticloudUtils.MULTICLOUD_INPUTS) { - if (extraInputs.contains(key)) { - goldenInputs.put(key, inputs.get(key)); - extraInputs.remove(key); - if (extraInputs.isEmpty()) { - break; - } - } - } - logger.debug("Ignoring extra inputs: " + extraInputs); - } - - // Next add in Volume Group Outputs if there are any. Copy directly without conversions. - if (volumeGroupOutputs != null && !volumeGroupOutputs.isEmpty()) { - for (String key : volumeGroupOutputs.keySet()) { - if (params.containsKey(key) && !goldenInputs.containsKey(key)) { - goldenInputs.put(key, volumeGroupOutputs.get(key)); - } - } - } - - // Next add in Base Module Outputs if there are any. Copy directly without conversions. - if (baseModuleOutputs != null && !baseModuleOutputs.isEmpty()) { - for (String key : baseModuleOutputs.keySet()) { - if (params.containsKey(key) && !goldenInputs.containsKey(key)) { - goldenInputs.put(key, baseModuleOutputs.get(key)); - } - } - } - - // TODO: The model should support a mechanism to pre-assign default parameter values - // per "customization" (i.e. usage) of a given module. In HEAT, this is specified by - // an Environment file. There is not a general mechanism in the model to handle this. - // For the general case, any such parameter/values can be added dynamically to the - // inputs (only if not already specified). - - // Check that required parameters have been supplied from any of the sources - String missingParams = null; - boolean checkRequiredParameters = true; - try { - String propertyString = this.environment.getProperty(MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS); - if ("false".equalsIgnoreCase(propertyString) || "n".equalsIgnoreCase(propertyString)) { - checkRequiredParameters = false; - logger.debug("CheckRequiredParameters is FALSE. Will still check but then skip blocking..." - + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS); - } - } catch (Exception e) { - // No problem - default is true - logger.debug("An exception occured trying to get property " + MsoVnfPluginAdapterImpl.CHECK_REQD_PARAMS, - e); - } - - // Do the actual parameter checking. - // Include looking at the ENV file as a valid definition of a parameter value. - // TODO: This handling of ENV applies only to Heat. A general mechanism to - // support pre-set parameter/values does not yet exist in the model. - // - StringBuilder sb = new StringBuilder(heatEnvironment.getEnvironment()); - MsoHeatEnvironmentEntry mhee = new MsoHeatEnvironmentEntry(sb); - for (HeatTemplateParam parm : heatTemplate.getParameters()) { - if (parm.isRequired() && (!goldenInputs.containsKey(parm.getParamName()))) { - if (mhee != null && mhee.containsParameter(parm.getParamName())) { - logger.debug("Required parameter " + parm.getParamName() - + " appears to be in environment - do not count as missing"); - } else { - logger.debug("adding to missing parameters list: " + parm.getParamName()); - if (missingParams == null) { - missingParams = parm.getParamName(); - } else { - missingParams += "," + parm.getParamName(); - } - } - } - } - - if (missingParams != null) { - if (checkRequiredParameters) { - // Problem - missing one or more required parameters - String error = "Create VFModule: Missing Required inputs: " + missingParams; - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_MISSING_PARAM.toString(), missingParams, "VDU", - ErrorCode.DataError.getValue(), "Create VFModule: Missing Required inputs"); - logger.debug(error); - throw new VnfException(error, MsoExceptionCategory.USERDATA); - } else { - logger.debug("found missing parameters [" + missingParams - + "] - but checkRequiredParameters is false - " + "will not block"); - } - } else { - logger.debug("No missing parameters found - ok to proceed"); - } - - } // NOTE: END PARAMETER CHECKING - - - // Here we go... ready to deploy the VF Module. - if (backout == null) - backout = true; - - try { - // Construct the VDU Model structure to pass to the targeted VduPlugin - VduModelInfo vduModel = null; - if (!isVolumeRequest) { - vduModel = vduMapper.mapVfModuleCustomizationToVdu(vfModuleCust); - } else { - vduModel = vduMapper.mapVfModuleCustVolumeToVdu(vfModuleCust); - } - - // Invoke the VduPlugin to instantiate the VF Module - vduInstance = vduPlugin.instantiateVdu(cloudInfo, vfModuleName, goldenInputs, vduModel, backout); - - } catch (VduException me) { - // Failed to instantiate the VDU. - me.addContext("CreateVFModule"); - String error = "Create VF Module " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + ": " + me; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner, - cloudSiteId, tenantId, "VDU", ErrorCode.DataError.getValue(), "MsoException - instantiateVdu", me); - logger.debug(error); - // Convert to a generic VnfException - throw new VnfException(me); - } catch (NullPointerException npe) { - String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + ": " + npe; - logger.error(LoggingAnchor.EIGHT, MessageEnum.RA_CREATE_VNF_ERR.toString(), vfModuleType, cloudOwner, - cloudSiteId, tenantId, "VDU", ErrorCode.DataError.getValue(), - "NullPointerException - instantiateVdu", npe); - logger.debug(error); - logger.debug("NULL POINTER EXCEPTION at vduPlugin.instantiateVdu", npe); - throw new VnfException("NullPointerException during instantiateVdu"); - } catch (Exception e) { - String error = "Create VFModule " + vfModuleType + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId - + ": " + e; - logger.debug("Unhandled exception at vduPlugin.instantiateVdu", e); - logger.debug(error); - throw new VnfException("Exception during instantiateVdu: " + e.getMessage()); - } - - - // Reach this point if create is successful. - // Populate remaining rollback info and response parameters. - vfRollback.setVnfCreated(true); - vfRollback.setVnfId(vduInstance.getVduInstanceId()); - vnfId.value = vduInstance.getVduInstanceId(); - outputs.value = copyStringOutputs(vduInstance.getOutputs()); - - rollback.value = vfRollback; - - logger.debug("VF Module " + vfModuleName + " successfully created"); - return; - } - - - public void deleteVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vfModuleId, String vnfId, - String aaiVfModuleId, String modelCustomizationUuid, MsoRequest msoRequest, - Holder<Map<String, String>> outputs) throws VnfException { - - logger.debug("Deleting VF Module " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId); - - // Capture the output parameters on a delete, so need to query first - VduInstance vduInstance; - CloudInfo cloudInfo = new CloudInfo(cloudSiteId, cloudOwner, tenantId, null); - - // Use the VduPlugin. - VduPlugin vduPlugin = getVduPlugin(cloudSiteId, cloudOwner); - - try { - vduInstance = vduPlugin.queryVdu(cloudInfo, vfModuleId); - } catch (VduException e) { - // Failed to query the VDU due to a plugin exception. - // Convert to a generic VnfException - e.addContext("QueryVFModule"); - String error = "Query VfModule (VDU): " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" - + tenantId + ": " + e; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleId, cloudOwner, - cloudSiteId, tenantId, "VDU", "QueryVFModule", ErrorCode.DataError.getValue(), - "Exception - queryVDU", e); - logger.debug(error); - throw new VnfException(e); - } - - // call method which handles the conversion from Map<String,Object> to Map<String,String> for our expected - // Object types - outputs.value = convertMapStringObjectToStringString(vduInstance.getOutputs()); - - // Use the VduPlugin to delete the VDU. - // The possible outcomes of deleteVdu are - // - a vnfInstance object with status of DELETED (success) - // - a vnfInstance object with status of NOTFOUND (VDU did not exist, treat as success) - // - a vnfInstance object with status of FAILED (error) - // Also, VduException could be thrown. - try { - // TODO: Get an appropriate timeout value - require access to the model - vduPlugin.deleteVdu(cloudInfo, vfModuleId, 5); - } catch (VduException me) { - me.addContext("DeleteVfModule"); - // Convert to a generic VnfException - String error = - "Delete VF: " + vfModuleId + " in " + cloudOwner + "/" + cloudSiteId + "/" + tenantId + ": " + me; - logger.error(LoggingAnchor.NINE, MessageEnum.RA_DELETE_VNF_ERR.toString(), vfModuleId, cloudOwner, - cloudSiteId, tenantId, "VDU", "DeleteVdu", ErrorCode.DataError.getValue(), - "Exception - DeleteVdu: " + me.getMessage()); - logger.debug(error); - throw new VnfException(me); - } - - // On success, nothing is returned. - return; - } - - // Update VF Module not yet implemented for generic VDU plug-in model. - @Override - public void updateVfModule(String cloudSiteId, String cloudOwner, String tenantId, String vnfType, - String vnfVersion, String vnfName, String requestType, String volumeGroupHeatStackId, - String baseVfHeatStackId, String vfModuleStackId, String modelCustomizationUuid, Map<String, Object> inputs, - MsoRequest msoRequest, Holder<Map<String, String>> outputs, Holder<VnfRollback> rollback) - throws VnfException { - // This operation is not currently supported for VduPlugin-orchestrated VF Modules. - logger.debug("Update VF Module command attempted but not supported"); - throw new VnfException("UpdateVfModule: Unsupported command", MsoExceptionCategory.USERDATA); - } - - /* - * Dynamic selection of a VduPlugin version. For initial tests, base on the "orchestrator" defined for the target - * cloud. Should really be looking at the VNF Model (ochestration_mode) but we don't currently have access to that - * in Query and Delete cases. - */ - private VduPlugin getVduPlugin(String cloudSiteId, String cloudOwner) { - Optional<CloudSite> cloudSiteOp = cloudConfig.getCloudSite(cloudSiteId); - if (cloudSiteOp.isPresent()) { - CloudSite cloudSite = cloudSiteOp.get(); - String orchestrator = cloudSite.getOrchestrator(); - - if ("CLOUDIFY".equalsIgnoreCase(orchestrator)) { - return cloudifyUtils; - } else if ("HEAT".equalsIgnoreCase(orchestrator)) { - return heatUtils; - } else if ("MULTICLOUD".equalsIgnoreCase(orchestrator)) { - return multicloudUtils; - } else { - // Default if cloudSite record exists - return HEAT plugin - will fail later - return heatUtils; - } - } - // Default if no cloudSite record exists - return multicloud plugin - return multicloudUtils; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java deleted file mode 100644 index 5b78d2f066..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRest.java +++ /dev/null @@ -1,578 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - - -import java.util.Map; -import javax.inject.Provider; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.onap.so.logger.LoggingAnchor; -import org.apache.http.HttpStatus; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; -import org.onap.so.adapters.vnfrest.CreateVfModuleResponse; -import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; -import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse; -import org.onap.so.adapters.vnfrest.QueryVfModuleResponse; -import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest; -import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse; -import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest; -import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; -import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; -import org.onap.so.adapters.vnfrest.VfModuleRollback; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -/** - * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v1/vnfs) Both XML and JSON - * can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For testing, call - * with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___ - */ -@Deprecated -@Path("/v1/vnfs") -@Api(value = "/v1/vnfs", description = "root of vnf adapters restful web service") -@Transactional -@Component -public class VnfAdapterRest { - private static Logger logger = LoggerFactory.getLogger(VnfAdapterRest.class); - private static final String TESTING_KEYWORD = "___TESTING___"; - private static final String RESP = ", resp="; - - @Autowired - private MsoVnfAdapterImpl vnfAdapter; - - @Autowired - private Provider<BpelRestClient> bpelRestClientProvider; - - @DELETE - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteVfModule", response = Response.class, - notes = "Delete an existing vnfModule, DeleteVfModuleRequest JSON is required") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully deleted"), - @ApiResponse(code = 202, message = "delete vnfModule request has been accepted (async only)"), - @ApiResponse(code = 500, message = "delete vnfModule failed, examine entity object for details")}) - public Response deleteVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) { - logger.debug("Delete VfModule enter: " + req.toJsonString()); - if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vnfid in URL does not match content").build(); - } - if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) { - logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vfModuleId in URL does not match content").build(); - } - DeleteVfModuleTask task = new DeleteVfModuleTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling delete, send generic failure as sync resp to caller - logger.error("", MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("deleteVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class DeleteVfModuleTask implements Runnable { - private final DeleteVfModuleRequest req; - private DeleteVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - - public DeleteVfModuleTask(DeleteVfModuleRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<DeleteVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - String cloudsite = req.getCloudSiteId(); - Holder<Map<String, String>> outputs = new Holder<>(); - if (cloudsite != null && !cloudsite.equals(TESTING_KEYWORD)) { - vnfAdapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), - req.getModelCustomizationUuid(), req.getMsoRequest(), outputs); - } - response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, - req.getMessageId(), outputs.value); - } catch (VnfException e) { - logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(), - ErrorCode.BusinessProcessError.getValue(), "VnfException - Delete VNF Module", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse()); - } - } - - - @GET - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryVfModule", response = Response.class, notes = "Query an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully queried"), - @ApiResponse(code = 500, message = "query vnfModule failed, examine entity object for details")}) - public Response queryVfModule(@ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner, - @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId, - @ApiParam(value = "vfModuleName", required = true) @QueryParam("vfModuleName") String vfModuleName, // RAA? - // Id in - // doc - @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI, - @ApiParam(value = "msoRequest.requestId", - required = true) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) { - // This request responds synchronously only - logger.debug("Query vfModule enter:" + vfModuleName); - MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); - - try { - int respStatus = HttpStatus.SC_OK; - QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null); - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vfModuleId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, - status, outputs); - if (!vnfExists.value) { - logger.debug("vfModule not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - } else { - logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value); - qryResp.setVfModuleId(vfModuleId.value); - qryResp.setVnfStatus(status.value); - qryResp.setVfModuleOutputs(outputs.value); - } - logger.debug("Query vfModule exit"); - return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build(); - } catch (VnfException e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", - ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e); - VfModuleExceptionResponse excResp = - new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}).build(); - } - } - - /* - * URL: http://localhost:8080/vnfs/rest/v1/vnfs/<aaivnfid>/vf-modules REQUEST: {"createVfModuleRequest": - * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId": - * "somemodid", "vfModuleName": "RaaVnf1", "vnfType": "ApacheVnf", "vfModuleParams": {"entry": [ {"key": - * "network_id", "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, {"key": "subnet_id", "value": - * "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, {"key": "server_name_0", "value": "RaaVnf1"} ]}, "failIfExists": true, - * "messageId": "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { - * "requestId": "ra1", "serviceInstanceId": "sa1" }} } - */ - @POST - @Path("{aaiVnfId}/vf-modules") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateVfModule", response = Response.class, notes = "Create a vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully created"), - @ApiResponse(code = 202, message = "create vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "create vnfModule failed, examine entity object for details")}) - public Response createVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) { - logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); - if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vnfid in URL does not match content").build(); - } - CreateVfModuleTask task = new CreateVfModuleTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(LoggingAnchor.FOUR, MessageEnum.RA_CREATE_VNF_ERR, "createVfModule", - ErrorCode.BusinessProcessError, "Exception - createVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("createVfModule exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class CreateVfModuleTask implements Runnable { - private final CreateVfModuleRequest req; - private CreateVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - - public CreateVfModuleTask(CreateVfModuleRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<CreateVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - logger.debug("CreateVfModuleTask start"); - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - // Synchronous Web Service Outputs - Holder<String> vfModuleStackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); - String cloudsite = req.getCloudSiteId(); - String cloudOwner = req.getCloudOwner(); - if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { - String tenant = req.getTenantId(); - if (tenant != null && tenant.equals(TESTING_KEYWORD)) { - throw new VnfException("testing."); - } - vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudOwner, cloudsite, true, false, - new MsoRequest("reqid", "svcid"), req.getVolumeGroupId(), req.getVolumeGroupId(), - req.getRequestType(), req.getModelCustomizationUuid()); - vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; - outputs.value = VolumeAdapterRest.testMap(); - } else { - vnfAdapter.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(), - req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(), - req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(), - req.getFailIfExists(), req.getBackout(), req.getEnableBridge(), req.getMsoRequest(), - vfModuleStackId, outputs, vnfRollback); - } - VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), - vfModuleStackId.value, req.getMessageId()); - response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, - Boolean.TRUE, outputs.value, modRollback, req.getMessageId()); - } catch (VnfException e) { - logger.debug("Exception :", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("CreateVfModuleTask exit: code=" + getStatusCode()); - } - } - - @PUT - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "UpdateVfModule", response = Response.class, notes = "Update an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully updated"), - @ApiResponse(code = 202, message = "update vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "update vnfModule failed, examine entity object for details")}) - public Response updateVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) { - logger.debug("Update VfModule enter: " + req.toJsonString()); - UpdateVfModulesTask task = new UpdateVfModulesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(LoggingAnchor.FOUR, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("updateVfModules exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class UpdateVfModulesTask implements Runnable { - private final UpdateVfModuleRequest req; - private UpdateVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - - public UpdateVfModulesTask(UpdateVfModuleRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<UpdateVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - Holder<String> vfModuleStackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); - - vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - // req.getVnfType(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVfModuleName(), req.getRequestType(), - req.getVolumeGroupStackId(), req.getBaseVfModuleStackId(), req.getVfModuleStackId(), - req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs, - vnfRollback); - - response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, - outputs.value, req.getMessageId()); - } catch (VnfException e) { - logger.debug("Exception :", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse()); - } - } - - - @DELETE - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackVfModule", response = Response.class, notes = "Rollback an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully rolled back"), - @ApiResponse(code = 202, - message = "rollback vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "rollback vnfModule failed, examine entity object for details")}) - public Response rollbackVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "RollbackVfModuleRequest", required = true) - // @QueryParam("rollback") String rollback, - final RollbackVfModuleRequest req) { - logger.debug("Rollback VfModule enter: " + req.toJsonString()); - RollbackVfModulesTask task = new RollbackVfModulesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(LoggingAnchor.FOUR, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("rollbackVfModule exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class RollbackVfModulesTask implements Runnable { - private final RollbackVfModuleRequest req; - private RollbackVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - - public RollbackVfModulesTask(RollbackVfModuleRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<RollbackVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - VfModuleRollback vmr = req.getVfModuleRollback(); - VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(), - vmr.getCloudSiteId(), true, true, vmr.getMsoRequest(), null, null, null, null); - vnfAdapter.rollbackVnf(vrb); - response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); - } catch (VnfException e) { - logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR, ErrorCode.BusinessProcessError, - "Exception" + " - " + "rollbackVfModule", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse()); - } - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java deleted file mode 100644 index b53ac0f899..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestUtils.java +++ /dev/null @@ -1,104 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - -import java.util.Optional; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.db.catalog.beans.CloudSite; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class VnfAdapterRestUtils { - private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestUtils.class); - - private static final String HEAT_MODE = "HEAT"; - private static final String CLOUDIFY_MODE = "CLOUDIFY"; - private static final String MULTICLOUD_MODE = "MULTICLOUD"; - - @Autowired - private CloudConfig cloudConfig; - - @Autowired - private MsoVnfCloudifyAdapterImpl cloudifyImpl; - - @Autowired - private MsoVnfAdapterImpl vnfImpl; - - @Autowired - private MsoVnfPluginAdapterImpl vnfPluginImpl; - - /* - * Choose which implementation of VNF Adapter to use, based on the orchestration mode. Currently, the two supported - * orchestrators are HEAT and CLOUDIFY. - */ - public MsoVnfAdapter getVnfAdapterImpl(String mode, String cloudSiteId) { - // First, determine the orchestration mode to use. - // If was explicitly provided as a parameter, use that. Else if specified for the - // cloudsite, use that. Otherwise, the default is the (original) HEAT-based impl. - - logger.debug("Entered GetVnfAdapterImpl: mode=" + mode + ", cloudSite=" + cloudSiteId); - - if (mode == null) { - // Didn't get an explicit mode type requested. - // Use the CloudSite to determine which Impl to use, based on whether the target cloutSite - // has a CloudifyManager assigned to it - Optional<CloudSite> cloudSite = cloudConfig.getCloudSite(cloudSiteId); - if (cloudSite.isPresent()) { - logger.debug("Got CloudSite: " + cloudSite.toString()); - if (cloudConfig.getCloudifyManager(cloudSite.get().getCloudifyId()) != null) { - mode = CLOUDIFY_MODE; - } else if (MULTICLOUD_MODE.equalsIgnoreCase(cloudSite.get().getOrchestrator())) { - mode = MULTICLOUD_MODE; - } else { - mode = HEAT_MODE; - } - } - } - - logger.debug("GetVnfAdapterImpl: mode=" + mode); - - MsoVnfAdapter vnfAdapter = null; - - // TODO: Make this more dynamic (e.g. Service Loader) - if (CLOUDIFY_MODE.equalsIgnoreCase(mode)) { - logger.debug("GetVnfAdapterImpl: Return Cloudify Adapter"); - vnfAdapter = cloudifyImpl; - } else if (HEAT_MODE.equalsIgnoreCase(mode)) { - logger.debug("GetVnfAdapterImpl: Return Heat Adapter"); - vnfAdapter = vnfImpl; - } else if (MULTICLOUD_MODE.equalsIgnoreCase(mode)) { - logger.debug("GetVnfAdapterImpl: Return Plugin (multicloud) Adapter"); - vnfAdapter = vnfPluginImpl; - } else { - // Don't expect this, but default is the HEAT adapter - logger.debug("GetVnfAdapterImpl: Return Default (Heat) Adapter"); - vnfAdapter = vnfImpl; - } - - return vnfAdapter; - } - -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java deleted file mode 100644 index 63b4c5d0f3..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VnfAdapterRestV2.java +++ /dev/null @@ -1,626 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - - -import java.util.Map; -import javax.inject.Provider; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; -import org.onap.so.adapters.vnfrest.CreateVfModuleResponse; -import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; -import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse; -import org.onap.so.adapters.vnfrest.QueryVfModuleResponse; -import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest; -import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse; -import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest; -import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; -import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; -import org.onap.so.adapters.vnfrest.VfModuleRollback; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -/** - * This class services calls to the REST interface for VF Modules (http://host:port/vnfs/rest/v2/vnfs) Both XML and JSON - * can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For testing, call - * with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___ - * - * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify) based on the target cloud. - */ -@Deprecated -@Path("/v2/vnfs") -@Api(value = "/v2/vnfs", description = "root of vnf adapters restful web service v2") -@Component -public class VnfAdapterRestV2 { - private static Logger logger = LoggerFactory.getLogger(VnfAdapterRestV2.class); - private static final String TESTING_KEYWORD = "___TESTING___"; - private static final String RESP = ", resp="; - private static final String BRACKETS = LoggingAnchor.FOUR; - - @Autowired - private VnfAdapterRestUtils vnfAdapterRestUtils; - - @Autowired - private Provider<BpelRestClient> bpelRestClientProvider; - - /* - * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid> REQUEST: {"deleteVfModuleRequest": - * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId": - * "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId": "ra.1", "notificationUrl": - * "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1", "serviceInstanceId": "sa1" - * }} } - */ - @DELETE - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteVfModule", response = Response.class, - notes = "Delete an existing vnfModule, DeleteVfModuleRequest JSON is required") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully deleted"), - @ApiResponse(code = 202, message = "delete vnfModule request has been accepted (async only)"), - @ApiResponse(code = 500, message = "delete vnfModule failed, examine entity object for details")}) - public Response deleteVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "DeleteVfModuleRequest", required = true) final DeleteVfModuleRequest req) { - logger.debug("Delete VfModule enter: " + req.toJsonString()); - if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vnfid in URL does not match content").build(); - } - if (aaiVfModuleId == null || !aaiVfModuleId.equals(req.getVfModuleId())) { - logger.debug("Req rejected - aaiVfModuleId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vfModuleId in URL does not match content").build(); - } - - DeleteVfModuleTask task = new DeleteVfModuleTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - MDC.getCopyOfContextMap(); - t1.start(); - } catch (Exception e) { - // problem handling delete, send generic failure as sync resp to caller - logger.error(BRACKETS, MessageEnum.RA_DELETE_VNF_ERR.toString(), "deleteVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception in deleteVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("deleteVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class DeleteVfModuleTask implements Runnable { - private final DeleteVfModuleRequest req; - private DeleteVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public DeleteVfModuleTask(DeleteVfModuleRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<DeleteVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - String cloudsite = req.getCloudSiteId(); - Holder<Map<String, String>> outputs = new Holder<>(); - if (cloudsite != null) { - MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsite); - adapter.deleteVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVfModuleStackId(), req.getVnfId(), req.getVfModuleId(), - req.getModelCustomizationUuid(), req.getMsoRequest(), outputs); - } - response = new DeleteVfModuleResponse(req.getVnfId(), req.getVfModuleId(), Boolean.TRUE, - req.getMessageId(), outputs.value); - } catch (VnfException e) { - logger.error(LoggingAnchor.THREE, MessageEnum.RA_DELETE_VNF_ERR.toString(), - ErrorCode.BusinessProcessError.getValue(), "VnfException - " + "Delete VNF Module", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("Delete vfModule exit: code=" + getStatusCode() + RESP + getResponse()); - MDC.clear(); - } - } - - /* - * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaiVnfId>/vf-modules/<aaiVfModuleId>?cloudSiteId=DAN&tenantId= - * vfModule?&skipAAI=TRUE&msoRequest.requestId=ra1&msoRequest.serviceInstanceId=si1&vfModuleName=T2N2S1 RESP: - * {"queryVfModuleResponse": { "vfModuleId": "AvfmodId", "vfModuleOutputs": {"entry": { "key": - * "server_private_ip_1", "value": "10.100.1.25" }}, "vfModuleStackId": - * "RaaVnf1/abfa8a6d-feb1-40af-aea3-109403b1cf6b", "vnfId": "AvnfID", "vnfStatus": "ACTIVE" }} - */ - @GET - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryVfModule", response = Response.class, notes = "Query an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully queried"), - @ApiResponse(code = 500, message = "query vnfModule failed, examine entity object for details")}) - public Response queryVfModule(@ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner, - @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId, - @ApiParam(value = "vfModuleName", required = true) @QueryParam("vfModuleName") String vfModuleName, // RAA? - // Id in - // doc - @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI, - @ApiParam(value = "msoRequest.requestId", - required = true) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode) { - // This request responds synchronously only - logger.debug("Query vfModule enter:" + vfModuleName); - MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); - - try { - int respStatus = HttpStatus.SC_OK; - QueryVfModuleResponse qryResp = new QueryVfModuleResponse(aaiVnfId, aaiVfModuleId, null, null, null); - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vfModuleId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - - // Support different Adapter Implementations - MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId); - adapter.queryVnf(cloudSiteId, cloudOwner, tenantId, vfModuleName, msoRequest, vnfExists, vfModuleId, status, - outputs); - - if (!vnfExists.value) { - logger.debug("vfModule not found"); - respStatus = HttpStatus.SC_NOT_FOUND; - } else { - logger.debug("vfModule found" + vfModuleId.value + ", status=" + status.value); - qryResp.setVfModuleId(vfModuleId.value); - qryResp.setVnfStatus(status.value); - qryResp.setVfModuleOutputs(outputs.value); - } - logger.debug("Query vfModule exit"); - return Response.status(respStatus).entity(new GenericEntity<QueryVfModuleResponse>(qryResp) {}).build(); - } catch (VnfException e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.RA_QUERY_VNF_ERR.toString(), vfModuleName, "queryVfModule", - ErrorCode.BusinessProcessError.getValue(), "VnfException - queryVfModule", e); - VfModuleExceptionResponse excResp = - new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VfModuleExceptionResponse>(excResp) {}).build(); - } - } - - /* - * URL: http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules REQUEST: {"createVfModuleRequest": - * {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": "somevnfid", "vfModuleId": - * "somemodid", "vfModuleName": "RaaVnf1", "vnfType": "ApacheVnf", "vfModuleParams": {"entry": [ {"key": - * "network_id", "value": "59ed7b41-2983-413f-ba93-e7d437433916"}, {"key": "subnet_id", "value": - * "086c9298-5c57-49b7-bb2b-6fd5730c5d92"}, {"key": "server_name_0", "value": "RaaVnf1"} ]}, "failIfExists": true, - * "messageId": "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { - * "requestId": "ra1", "serviceInstanceId": "sa1" }} } - */ - @POST - @Path("{aaiVnfId}/vf-modules") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateVfModule", response = Response.class, notes = "Create a vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully created"), - @ApiResponse(code = 202, message = "create vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "create vnfModule failed, examine entity object for details")}) - public Response createVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "CreateVfModuleRequest", required = true) final CreateVfModuleRequest req) { - logger.debug("Create VfModule enter inside VnfAdapterRest: " + req.toJsonString()); - if (aaiVnfId == null || !aaiVnfId.equals(req.getVnfId())) { - logger.debug("Req rejected - aaiVnfId not provided or doesn't match URL"); - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity("vnfid in URL does not match content").build(); - } - - CreateVfModuleTask task = new CreateVfModuleTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(BRACKETS, MessageEnum.RA_CREATE_VNF_ERR.toString(), "createVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception - createVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("createVfModule exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class CreateVfModuleTask implements Runnable { - private final CreateVfModuleRequest req; - private CreateVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public CreateVfModuleTask(CreateVfModuleRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<CreateVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - logger.debug("CreateVfModuleTask start"); - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - // Synchronous Web Service Outputs - Holder<String> vfModuleStackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("completeVnfVfModuleType=" + completeVnfVfModuleType); - - String cloudsiteId = req.getCloudSiteId(); - String cloudOwner = req.getCloudOwner(); - if (cloudsiteId != null && cloudsiteId.equals(TESTING_KEYWORD)) { - String tenant = req.getTenantId(); - if (tenant != null && tenant.equals(TESTING_KEYWORD)) { - throw new VnfException("testing."); - } - vnfRollback.value = new VnfRollback(req.getVnfId(), tenant, cloudOwner, cloudsiteId, true, false, - new MsoRequest("reqid", "svcid"), req.getVolumeGroupId(), req.getVolumeGroupId(), - req.getRequestType(), req.getModelCustomizationUuid()); - vfModuleStackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; - outputs.value = VolumeAdapterRest.testMap(); - } else { - // Support different Adapter Implementations - MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId); - adapter.createVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVnfId(), req.getVfModuleName(), - req.getVfModuleId(), req.getRequestType(), req.getVolumeGroupStackId(), - req.getBaseVfModuleStackId(), req.getModelCustomizationUuid(), req.getVfModuleParams(), - req.getFailIfExists(), req.getBackout(), req.getEnableBridge(), req.getMsoRequest(), - vfModuleStackId, outputs, vnfRollback); - } - VfModuleRollback modRollback = new VfModuleRollback(vnfRollback.value, req.getVfModuleId(), - vfModuleStackId.value, req.getMessageId()); - response = new CreateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, - Boolean.TRUE, outputs.value, modRollback, req.getMessageId()); - } catch (VnfException e) { - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("CreateVfModuleTask exit: code=" + getStatusCode() + RESP + getResponse()); - } - } - - @PUT - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "UpdateVfModule", response = Response.class, notes = "Update an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully updated"), - @ApiResponse(code = 202, message = "update vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "update vnfModule failed, examine entity object for details")}) - public Response updateVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "UpdateVfModuleRequest", required = true) final UpdateVfModuleRequest req) { - logger.debug("Update VfModule enter: " + req.toJsonString()); - UpdateVfModulesTask task = new UpdateVfModulesTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(BRACKETS, MessageEnum.RA_UPDATE_VNF_ERR.toString(), "updateVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception - updateVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("updateVfModules exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class UpdateVfModulesTask implements Runnable { - private final UpdateVfModuleRequest req; - private UpdateVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public UpdateVfModulesTask(UpdateVfModuleRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<UpdateVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - // Synchronous Web Service Outputs - Holder<String> vfModuleStackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in updateVf - completeVnfVfModuleType=" + completeVnfVfModuleType); - - String cloudsiteId = req.getCloudSiteId(); - - // Support different Adapter Implementations - MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId); - adapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVfModuleName(), req.getRequestType(), - req.getVolumeGroupStackId(), req.getBaseVfModuleId(), req.getVfModuleStackId(), - req.getModelCustomizationUuid(), req.getVfModuleParams(), req.getMsoRequest(), outputs, - vnfRollback); - - response = new UpdateVfModuleResponse(req.getVnfId(), req.getVfModuleId(), vfModuleStackId.value, - outputs.value, req.getMessageId()); - } catch (VnfException e) { - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("Update VfModule exit: code=" + getStatusCode() + RESP + getResponse()); - } - } - - /* - * URL:http://localhost:8080/vnfs/rest/v2/vnfs/<aaivnfid>/vf-modules/<aaimodid>/rollback REQUEST: - * {"deleteVfModuleRequest": {"cloudSiteId": "DAN", "tenantId": "214b428a1f554c02935e66330f6a5409", "vnfId": - * "somevnfid", "vfModuleId": "somemodid", "vfModuleStackId": "4e567676-e266-4594-a3a6-131c8a2baf73", "messageId": - * "ra.1", "notificationUrl": "http://localhost:8089/vnfmock", "skipAAI": true, "msoRequest": { "requestId": "ra1", - * "serviceInstanceId": "sa1" }} } - */ - @DELETE - @Path("{aaiVnfId}/vf-modules/{aaiVfModuleId}/rollback") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackVfModule", response = Response.class, notes = "Rollback an existing vnfModule") - @ApiResponses({@ApiResponse(code = 200, message = "vnfModule has been successfully rolled back"), - @ApiResponse(code = 202, - message = "rollback vnfModule request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "rollback vnfModule failed, examine entity object for details")}) - public Response rollbackVfModule( - @ApiParam(value = "aaiVnfId", required = true) @PathParam("aaiVnfId") String aaiVnfId, - @ApiParam(value = "aaiVfModuleId", required = true) @PathParam("aaiVfModuleId") String aaiVfModuleId, - @ApiParam(value = "RollbackVfModuleRequest", required = true) - // @QueryParam("rollback") String rollback, - final RollbackVfModuleRequest req) { - logger.debug("Rollback VfModule enter: " + req.toJsonString()); - RollbackVfModulesTask task = new RollbackVfModulesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error(BRACKETS, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), "rollbackVfModule", - ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("rollbackVfModule exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class RollbackVfModulesTask implements Runnable { - private final RollbackVfModuleRequest req; - private RollbackVfModuleResponse response = null; - private VfModuleExceptionResponse eresp = null; - private boolean sendxml; - - public RollbackVfModulesTask(RollbackVfModuleRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<RollbackVfModuleResponse>(response) {} - : new GenericEntity<VfModuleExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVfModuleRollback().getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - VfModuleRollback vmr = req.getVfModuleRollback(); - VnfRollback vrb = new VnfRollback(vmr.getVfModuleStackId(), vmr.getTenantId(), vmr.getCloudOwner(), - vmr.getCloudSiteId(), true, vmr.isVfModuleCreated(), vmr.getMsoRequest(), null, null, null, - null); - - // Support multiple adapter implementations - MsoVnfAdapter adapter = vnfAdapterRestUtils.getVnfAdapterImpl(vmr.getMode(), vmr.getCloudSiteId()); - adapter.rollbackVnf(vrb); - - response = new RollbackVfModuleResponse(Boolean.TRUE, req.getMessageId()); - } catch (VnfException e) { - logger.error(LoggingAnchor.THREE, MessageEnum.RA_ROLLBACK_VNF_ERR.toString(), - ErrorCode.BusinessProcessError.getValue(), "Exception - rollbackVfModule", e); - eresp = new VfModuleExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, false, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("RollbackVfModulesTask exit: code=" + getStatusCode() + RESP + getResponse()); - } - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java deleted file mode 100644 index 7e12735e05..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRest.java +++ /dev/null @@ -1,626 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2017 Huawei Technologies Co., Ltd. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - - -import java.util.HashMap; -import java.util.Map; -import javax.inject.Provider; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupRollback; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -/** - * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both - * XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For - * testing, call with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___ - */ -@Path("/v1/volume-groups") -@Api(value = "/v1/volume-groups", description = "root of volume-groups adapters restful web service") -@Component -public class VolumeAdapterRest { - - private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRest.class); - private static final String TESTING_KEYWORD = "___TESTING___"; - private static final String EXCEPTION = "Exception :"; - private static final String RESP = ", resp="; - private static final String VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT = - "VolumeGroupId in URL does not match content"; - @Autowired - private MsoVnfAdapterImpl vnfAdapter; - - @Autowired - private Provider<BpelRestClient> bpelRestClientProvider; - - @POST - @Path("") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateVNFVolumes", response = Response.class, notes = "Create a new vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully created"), - @ApiResponse(code = 202, message = "create vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "create vnfVolume failed, examine entity object for details")}) - public Response createVNFVolumes( - @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req) { - logger.debug("createVNFVolumes enter: {}", req.toJsonString()); - CreateVNFVolumesTask task = new CreateVNFVolumesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("createVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class CreateVNFVolumesTask implements Runnable { - private final CreateVolumeGroupRequest req; - private CreateVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - - public CreateVNFVolumesTask(CreateVolumeGroupRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<CreateVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("CreateVFModule VolumesTask start"); - try { - // Synchronous Web Service Outputs - Holder<String> stackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType); - - String cloudsite = req.getCloudSiteId(); - if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { - String tenant = req.getTenantId(); - if (tenant != null && tenant.equals(TESTING_KEYWORD)) { - throw new VnfException("testing."); - } - stackId.value = "479D3D8B-6360-47BC-AB75-21CC91981484"; - outputs.value = testMap(); - } else { - // vnfAdapter.createVnf( - // req.getCloudSiteId(), - // req.getTenantId(), - // req.getVnfType(), - // req.getVnfVersion(), - // req.getVolumeGroupName(), - // "VOLUME", // request type is VOLUME - // null, // not sure about this - // req.getVolumeGroupParams(), - // req.getFailIfExists(), - // req.getSuppressBackout(), - // req.getMsoRequest(), - // stackId, - // outputs, - // vnfRollback); - vnfAdapter.createVfModule(req.getCloudSiteId(), // cloudSiteId, - req.getCloudOwner(), // cloudOwner, - req.getTenantId(), // tenantId, - // req.getVnfType(), //vnfType, - completeVnfVfModuleType, req.getVnfVersion(), // vnfVersion, - "", // genericVnfId - req.getVolumeGroupName(), // vnfName, - "", // vfModuleid - "VOLUME", // requestType, - null, // volumeGroupHeatStackId, - null, // baseVfHeatStackId, - req.getModelCustomizationUuid(), req.getVolumeGroupParams(), // inputs, - req.getFailIfExists(), // failIfExists, - req.getSuppressBackout(), // backout, - req.getEnableBridge(), req.getMsoRequest(), // msoRequest, - stackId, outputs, vnfRollback); - } - VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value, true, // TODO - // boolean - // volumeGroupCreated, - // when - // would - // it be - // false? - req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(), req.getMsoRequest(), - req.getMessageId()); - response = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value, true, // TODO boolean - // volumeGroupCreated, - // when would it - // be false? - outputs.value, rb, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("CreateVFModule VolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @DELETE - @Path("{aaiVolumeGroupId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully deleted"), - @ApiResponse(code = 202, message = "delete vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "delete vnfVolume failed, examine entity object for details")}) - public Response deleteVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "DeleteVolumeGroupRequest", required = true) final DeleteVolumeGroupRequest req) { - logger.debug("deleteVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build(); - } - DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("deleteVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class DeleteVNFVolumesTask implements Runnable { - private final DeleteVolumeGroupRequest req; - private DeleteVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - - public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<DeleteVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("DeleteVNFVolumesTask start"); - try { - if (!req.getCloudSiteId().equals(TESTING_KEYWORD)) { - vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVolumeGroupStackId(), req.getMsoRequest()); - } - response = new DeleteVolumeGroupResponse(true, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @DELETE - @Path("{aaiVolumeGroupId}/rollback") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully rolled back"), - @ApiResponse(code = 202, - message = "rollback vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "rollback vnfVolume failed, examine entity object for details")}) - public Response rollbackVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "RollbackVolumeGroupRequest", required = true) final RollbackVolumeGroupRequest req) { - logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null - || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build(); - } - RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("rollbackVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class RollbackVNFVolumesTask implements Runnable { - private final RollbackVolumeGroupRequest req; - private RollbackVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - - public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<RollbackVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("DeleteVNFVolumesTask start"); - try { - VolumeGroupRollback vgr = req.getVolumeGroupRollback(); - VnfRollback vrb = new VnfRollback(vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudOwnerId(), - vgr.getCloudSiteId(), true, true, vgr.getMsoRequest(), null, null, null, null); - vnfAdapter.rollbackVnf(vrb); - response = new RollbackVolumeGroupResponse(true, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("DeleteVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); - } - - } - - @PUT - @Path("{aaiVolumeGroupId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "UpdateVNFVolumes", response = Response.class, notes = "Update an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully updated"), - @ApiResponse(code = 202, message = "update vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "update vnfVolume failed, examine entity object for details")}) - public Response updateVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "UpdateVolumeGroupRequest", required = true) final UpdateVolumeGroupRequest req) { - logger.debug("updateVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN) - .entity(VOLUME_GROUPID_IN_URL_DOESNT_MATCH_CONTENT).build(); - } - UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("updateVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class UpdateVNFVolumesTask implements Runnable { - private final UpdateVolumeGroupRequest req; - private UpdateVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - - public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<UpdateVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - logger.debug("UpdateVNFVolumesTask start"); - try { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType); - - if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { - outputs.value = testMap(); - } else { - // vnfAdapter.updateVnf( - // req.getCloudSiteId(), - // req.getTenantId(), - // req.getVnfType(), - // req.getVnfVersion(), - // req.getVfModuleType(), - // "VOLUME", // request type is VOLUME - // req.getVolumeGroupStackId(), - // req.getVolumeGroupParams(), - // req.getMsoRequest(), - // outputs, - // vnfRollback); - vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - // req.getVnfType(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVolumeGroupStackId(), "VOLUME", null, - null, req.getVolumeGroupStackId(), req.getModelCustomizationUuid(), - req.getVolumeGroupParams(), req.getMsoRequest(), outputs, vnfRollback); - } - response = new UpdateVolumeGroupResponse(req.getVolumeGroupId(), req.getVolumeGroupStackId(), - outputs.value, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("UpdateVNFVolumesTask exit: code={} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @GET - @Path("{aaiVolumeGroupId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryVNFVolumes", response = Response.class, notes = "Query an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully queried"), - @ApiResponse(code = 500, message = "query vnfVolume failed, examine entity object for details")}) - public Response queryVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner, - @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId, - @ApiParam(value = "volumeGroupStackId", - required = true) @QueryParam("volumeGroupStackId") String volumeGroupStackId, - @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI, - @ApiParam(value = "msoRequest.requestId", - required = true) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId) { - // This request responds synchronously only - logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId); - MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); - - try { - int respStatus = HttpStatus.SC_OK; - QueryVolumeGroupResponse qryResp = - new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null); - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vfModuleId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) { - if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) { - throw new VnfException("testing."); - } - vnfExists.value = true; - vfModuleId.value = TESTING_KEYWORD; - status.value = VnfStatus.ACTIVE; - outputs.value = testMap(); - } else { - vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, volumeGroupStackId, msoRequest, vnfExists, - vfModuleId, status, outputs); - } - if (!vnfExists.value) { - logger.debug("VNFVolumes not found"); - qryResp.setVolumeGroupStatus(status.value); - respStatus = HttpStatus.SC_NOT_FOUND; - } else { - logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value); - qryResp.setVolumeGroupStatus(status.value); - qryResp.setVolumeGroupOutputs(outputs.value); - } - logger.debug("Query queryVNFVolumes exit"); - return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build(); - } catch (VnfException e) { - logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e); - VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), - MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - logger.debug("Query queryVNFVolumes exit"); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}).build(); - } - } - - public static Map<String, String> testMap() { - Map<String, String> m = new HashMap<>(); - m.put("mickey", "7"); - m.put("clyde", "10"); - m.put("wayne", "99"); - return m; - } -} diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java deleted file mode 100644 index a424fa92fd..0000000000 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2.java +++ /dev/null @@ -1,606 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * OPENECOMP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (C) 2018 IBM. - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.vnf; - - -import java.util.HashMap; -import java.util.Map; -import javax.inject.Provider; -import javax.ws.rs.Consumes; -import javax.ws.rs.DELETE; -import javax.ws.rs.GET; -import javax.ws.rs.POST; -import javax.ws.rs.PUT; -import javax.ws.rs.Path; -import javax.ws.rs.PathParam; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.GenericEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.onap.logging.ref.slf4j.ONAPLogConstants; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupRollback; -import org.onap.so.entity.MsoRequest; -import org.onap.logging.filter.base.ErrorCode; -import org.onap.so.logger.MessageEnum; -import org.onap.so.openstack.beans.VnfRollback; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoExceptionCategory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.slf4j.MDC; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; -import io.swagger.annotations.ApiResponse; -import io.swagger.annotations.ApiResponses; - -/** - * This class services calls to the REST interface for VNF Volumes (http://host:port/vnfs/rest/v1/volume-groups) Both - * XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default. For - * testing, call with cloudSiteId = ___TESTING___ To test exceptions, also set tenantId = ___TESTING___ - * - * V2 incorporates run-time selection of sub-orchestrator implementation (Heat or Cloudify) based on the target cloud. - */ -@Path("/v2/volume-groups") -@Api(value = "/v2/volume-groups", description = "root of volume-groups adapters restful web service v2") -@Component -public class VolumeAdapterRestV2 { - - private static final Logger logger = LoggerFactory.getLogger(VolumeAdapterRestV2.class); - private static final String TESTING_KEYWORD = "___TESTING___"; - private static final String RESP = ", resp="; - private static final String EXCEPTION = "Exception :"; - private static final String VOLUME_GROUPID_MISSING = "VolumeGroupId in URL does not match content"; - - @Autowired - private VnfAdapterRestUtils vnfAdapterRestUtils; - - @Autowired - private Provider<BpelRestClient> bpelRestClientProvider; - - @POST - @Path("") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "CreateVNFVolumes", response = Response.class, notes = "Create a new vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully created"), - @ApiResponse(code = 202, message = "create vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "create vnfVolume failed, examine entity object for details")}) - public Response createVNFVolumes(@ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "CreateVolumeGroupRequest", required = true) final CreateVolumeGroupRequest req) { - CreateVNFVolumesTask task = new CreateVNFVolumesTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - createVNFVolumes: ", MessageEnum.RA_CREATE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("createVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class CreateVNFVolumesTask implements Runnable { - private final CreateVolumeGroupRequest req; - private CreateVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public CreateVNFVolumesTask(CreateVolumeGroupRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<CreateVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("CreateVFModule VolumesTask start"); - try { - // Synchronous Web Service Outputs - Holder<String> stackId = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in createVfModuleVolumes - completeVnfVfModuleType={}", completeVnfVfModuleType); - - String cloudsiteId = req.getCloudSiteId(); - - // Support different Adapter Implementations - MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudsiteId); - vnfAdapter.createVfModule(req.getCloudSiteId(), // cloudSiteId, - req.getCloudOwner(), // cloudOwner, - req.getTenantId(), // tenantId, - completeVnfVfModuleType, // vnfType, - req.getVnfVersion(), // vnfVersion, - "", // genericVnfId - req.getVolumeGroupName(), // vnfName, - "", // vfModuleId - "VOLUME", // requestType, - null, // volumeGroupHeatStackId, - null, // baseVfHeatStackId, - req.getModelCustomizationUuid(), req.getVolumeGroupParams(), // inputs, - req.getFailIfExists(), // failIfExists, - req.getSuppressBackout(), // backout, - req.getEnableBridge(), req.getMsoRequest(), // msoRequest, - stackId, outputs, vnfRollback); - - - VolumeGroupRollback rb = new VolumeGroupRollback(req.getVolumeGroupId(), stackId.value, - vnfRollback.value.getVnfCreated(), req.getTenantId(), req.getCloudOwner(), req.getCloudSiteId(), - req.getMsoRequest(), req.getMessageId()); - - response = new CreateVolumeGroupResponse(req.getVolumeGroupId(), stackId.value, - vnfRollback.value.getVnfCreated(), outputs.value, rb, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("CreateVFModule VolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @DELETE - @Path("{aaiVolumeGroupId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "DeleteVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully deleted"), - @ApiResponse(code = 202, message = "delete vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "delete vnfVolume failed, examine entity object for details")}) - public Response deleteVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "DeleteVolumeGroupRequest", required = true) final DeleteVolumeGroupRequest req) { - logger.debug("deleteVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING) - .build(); - } - DeleteVNFVolumesTask task = new DeleteVNFVolumesTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - deleteVNFVolumes: ", MessageEnum.RA_DELETE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("deleteVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class DeleteVNFVolumesTask implements Runnable { - private final DeleteVolumeGroupRequest req; - private DeleteVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public DeleteVNFVolumesTask(DeleteVolumeGroupRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<DeleteVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("DeleteVNFVolumesTask start"); - String cloudSiteId = req.getCloudSiteId(); - try { - if (!cloudSiteId.equals(TESTING_KEYWORD)) { - // Support different Adapter Implementations - MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId); - vnfAdapter.deleteVnf(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - req.getVolumeGroupStackId(), req.getMsoRequest()); - } - response = new DeleteVolumeGroupResponse(true, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("DeleteVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @DELETE - @Path("{aaiVolumeGroupId}/rollback") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "RollbackVNFVolumes", response = Response.class, notes = "Delete an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully rolled back"), - @ApiResponse(code = 202, - message = "rollback vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "rollback vnfVolume failed, examine entity object for details")}) - public Response rollbackVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "RollbackVolumeGroupRequest", required = true) final RollbackVolumeGroupRequest req) { - logger.debug("rollbackVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || req.getVolumeGroupRollback() == null - || !aaiVolumeGroupId.equals(req.getVolumeGroupRollback().getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING) - .build(); - } - RollbackVNFVolumesTask task = new RollbackVNFVolumesTask(req); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - rollbackVNFVolumes: ", MessageEnum.RA_ROLLBACK_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("rollbackVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class RollbackVNFVolumesTask implements Runnable { - private final RollbackVolumeGroupRequest req; - private RollbackVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - - public RollbackVNFVolumesTask(RollbackVolumeGroupRequest req) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<RollbackVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getVolumeGroupRollback().getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("RollbackVNFVolumesTask start"); - try { - VolumeGroupRollback vgr = req.getVolumeGroupRollback(); - VnfRollback vrb = new VnfRollback(vgr.getVolumeGroupStackId(), vgr.getTenantId(), vgr.getCloudOwnerId(), - vgr.getCloudSiteId(), true, true, vgr.getMsoRequest(), null, null, null, null); - - // Support different Adapter Implementations - MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(vrb.getMode(), vrb.getCloudSiteId()); - vnfAdapter.rollbackVnf(vrb); - response = new RollbackVolumeGroupResponse(true, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("RollbackVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); - } - - } - - @PUT - @Path("{aaiVolumeGroupId}") - @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "UpdateVNFVolumes", response = Response.class, notes = "Update an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully updated"), - @ApiResponse(code = 202, message = "update vnfVolume request has been successfully accepted (async only)"), - @ApiResponse(code = 500, message = "update vnfVolume failed, examine entity object for details")}) - public Response updateVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode, - @ApiParam(value = "UpdateVolumeGroupRequest", required = true) final UpdateVolumeGroupRequest req) { - logger.debug("updateVNFVolumes enter: {}", req.toJsonString()); - if (aaiVolumeGroupId == null || !aaiVolumeGroupId.equals(req.getVolumeGroupId())) { - return Response.status(HttpStatus.SC_BAD_REQUEST).type(MediaType.TEXT_PLAIN).entity(VOLUME_GROUPID_MISSING) - .build(); - } - UpdateVNFVolumesTask task = new UpdateVNFVolumesTask(req, mode); - if (req.isSynchronous()) { - // This is a synchronous request - task.run(); - return Response.status(task.getStatusCode()).entity(task.getGenericEntityResponse()).build(); - } else { - // This is an asynchronous request - try { - Thread t1 = new Thread(task); - t1.start(); - } catch (Exception e) { - // problem handling create, send generic failure as sync resp to caller - logger.error("{} {} Exception - updateVNFVolumes: ", MessageEnum.RA_UPDATE_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), e); - return Response.serverError().build(); - } - // send sync response (ACK) to caller - logger.debug("updateVNFVolumes exit"); - return Response.status(HttpStatus.SC_ACCEPTED).build(); - } - } - - public class UpdateVNFVolumesTask implements Runnable { - private final UpdateVolumeGroupRequest req; - private UpdateVolumeGroupResponse response = null; - private VolumeGroupExceptionResponse eresp = null; - private boolean sendxml; - private String mode; - - public UpdateVNFVolumesTask(UpdateVolumeGroupRequest req, String mode) { - this.req = req; - this.sendxml = true; // can be set with a field or header later - this.mode = mode; - } - - public int getStatusCode() { - return (response != null) ? HttpStatus.SC_OK : HttpStatus.SC_BAD_REQUEST; - } - - public Object getGenericEntityResponse() { - return (response != null) ? new GenericEntity<UpdateVolumeGroupResponse>(response) {} - : new GenericEntity<VolumeGroupExceptionResponse>(eresp) {}; - } - - private String getResponse() { - if (response != null) { - return sendxml ? response.toXmlString() : response.toJsonString(); - } else { - return sendxml ? eresp.toXmlString() : eresp.toJsonString(); - } - } - - @Override - public void run() { - try { - MDC.put(ONAPLogConstants.MDCs.REQUEST_ID, req.getMsoRequest().getRequestId()); - } catch (Exception e) { - logger.error("Error adding RequestId to MDC", e); - } - logger.debug("UpdateVNFVolumesTask start"); - try { - Holder<Map<String, String>> outputs = new Holder<>(); - Holder<VnfRollback> vnfRollback = new Holder<>(); - String completeVnfVfModuleType = req.getVnfType() + "::" + req.getVfModuleType(); - logger.debug("in updateVfModuleVolume - completeVnfVfModuleType={}", completeVnfVfModuleType); - - if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { - outputs.value = testMap(); - } else { - // Support different Adapter Implementations - MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, req.getCloudSiteId()); - vnfAdapter.updateVfModule(req.getCloudSiteId(), req.getCloudOwner(), req.getTenantId(), - // req.getVnfType(), - completeVnfVfModuleType, req.getVnfVersion(), req.getVolumeGroupStackId(), "VOLUME", null, - null, req.getVolumeGroupStackId(), req.getModelCustomizationUuid(), - req.getVolumeGroupParams(), req.getMsoRequest(), outputs, vnfRollback); - } - response = new UpdateVolumeGroupResponse(req.getVolumeGroupId(), req.getVolumeGroupStackId(), - outputs.value, req.getMessageId()); - } catch (VnfException e) { - logger.debug(EXCEPTION, e); - eresp = new VolumeGroupExceptionResponse(e.getMessage(), MsoExceptionCategory.INTERNAL, true, - req.getMessageId()); - } - if (!req.isSynchronous()) { - // This is asynch, so POST response back to caller - BpelRestClient bpelClient = bpelRestClientProvider.get(); - bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); - } - logger.debug("UpdateVNFVolumesTask exit: code= {} {} {}", getStatusCode(), RESP, getResponse()); - } - } - - @GET - @Path("{aaiVolumeGroupId}") - @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON}) - @ApiOperation(value = "QueryVNFVolumes", response = Response.class, notes = "Query an existing vnfVolume") - @ApiResponses({@ApiResponse(code = 200, message = "vnfVolume has been successfully queried"), - @ApiResponse(code = 500, message = "query vnfVolume failed, examine entity object for details")}) - public Response queryVNFVolumes( - @ApiParam(value = "aaiVolumeGroupId", - required = true) @PathParam("aaiVolumeGroupId") String aaiVolumeGroupId, - @ApiParam(value = "cloudSiteId", required = true) @QueryParam("cloudSiteId") String cloudSiteId, - @ApiParam(value = "cloudOwner", required = true) @QueryParam("cloudOwner") String cloudOwner, - @ApiParam(value = "tenantId", required = true) @QueryParam("tenantId") String tenantId, - @ApiParam(value = "volumeGroupStackId", - required = true) @QueryParam("volumeGroupStackId") String volumeGroupStackId, - @ApiParam(value = "skipAAI", required = true) @QueryParam("skipAAI") Boolean skipAAI, - @ApiParam(value = "msoRequest.requestId", - required = true) @QueryParam("msoRequest.requestId") String requestId, - @ApiParam(value = "msoRequest.serviceInstanceId", - required = true) @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId, - @ApiParam(value = "mode", required = true) @QueryParam("mode") String mode) { - // This request responds synchronously only - logger.debug("queryVNFVolumes enter: {} {}", aaiVolumeGroupId, volumeGroupStackId); - MsoRequest msoRequest = new MsoRequest(requestId, serviceInstanceId); - - try { - int respStatus = HttpStatus.SC_OK; - QueryVolumeGroupResponse qryResp = - new QueryVolumeGroupResponse(aaiVolumeGroupId, volumeGroupStackId, null, null); - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vfModuleId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - if (cloudSiteId != null && cloudSiteId.equals(TESTING_KEYWORD)) { - if (tenantId != null && tenantId.equals(TESTING_KEYWORD)) { - throw new VnfException("testing."); - } - vnfExists.value = true; - vfModuleId.value = TESTING_KEYWORD; - status.value = VnfStatus.ACTIVE; - outputs.value = testMap(); - } else { - // Support different Adapter Implementations - MsoVnfAdapter vnfAdapter = vnfAdapterRestUtils.getVnfAdapterImpl(mode, cloudSiteId); - vnfAdapter.queryVnf(cloudSiteId, cloudOwner, tenantId, volumeGroupStackId, msoRequest, vnfExists, - vfModuleId, status, outputs); - } - if (!vnfExists.value) { - logger.debug("VNFVolumes not found"); - qryResp.setVolumeGroupStatus(status.value); - respStatus = HttpStatus.SC_NOT_FOUND; - } else { - logger.debug("VNFVolumes found {}, status={}", vfModuleId.value, status.value); - qryResp.setVolumeGroupStatus(status.value); - qryResp.setVolumeGroupOutputs(outputs.value); - } - logger.debug("Query queryVNFVolumes exit"); - return Response.status(respStatus).entity(new GenericEntity<QueryVolumeGroupResponse>(qryResp) {}).build(); - } catch (VnfException e) { - logger.error("{} {} AaiVolumeGroupId: {} VnfException - queryVNFVolumes: ", MessageEnum.RA_QUERY_VNF_ERR, - ErrorCode.BusinessProcessError.getValue(), aaiVolumeGroupId, e); - VolumeGroupExceptionResponse excResp = new VolumeGroupExceptionResponse(e.getMessage(), - MsoExceptionCategory.INTERNAL, Boolean.FALSE, null); - logger.debug("Query queryVNFVolumes exit"); - return Response.status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .entity(new GenericEntity<VolumeGroupExceptionResponse>(excResp) {}).build(); - } - } - - public static Map<String, String> testMap() { - Map<String, String> m = new HashMap<>(); - m.put("mickey", "7"); - m.put("clyde", "10"); - m.put("wayne", "99"); - return m; - } -} 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 6d3b0ab680..4df58484d8 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 @@ -68,7 +68,6 @@ import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.entities.uri.Depth; import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed; -import org.onap.so.client.PreconditionFailedException; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.onap.so.heatbridge.factory.MsoCloudClientFactoryImpl; 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 c578b29664..adcde92917 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 @@ -148,10 +148,16 @@ public class AaiHelper { public Pserver buildPserver(final Server server) { Pserver pserver = new Pserver(); pserver.setInMaint(false); - pserver.setPserverId(server.getId()); pserver.setHostname(server.getHypervisorHostname()); - pserver.setPserverName2(server.getHost()); - pserver.setProvStatus(server.getStatus().value()); + if (server.getId() != null) { + pserver.setPserverId(server.getId()); + } + if (server.getHost() != null) { + pserver.setPserverName2(server.getHost()); + } + if (server.getStatus() != null && server.getStatus().value() != null) { + pserver.setProvStatus(server.getStatus().value()); + } return pserver; } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java index 284067a766..88c6992a0a 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MSONetworkAdapterImplTest.java @@ -63,86 +63,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { public static final String NETWORK_NAME = "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0"; - - @Test - public void createNetworkByModelNameNeutronModeGetNetworkException() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenstackGet(wireMockServer, "/mockPublicUrl/v2.0/networks", HttpStatus.SC_INTERNAL_SERVER_ERROR); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/CreateNetwork_NEUTRON_Mode.xml"), uri, HttpMethod.POST); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void createNetworkByModelNameNeutronModeCreateNetworkException() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc"); - - mockOpenStackGetAllNeutronNetworks_404(wireMockServer); - - mockOpenstackPost(wireMockServer, "/mockPublicUrl/v2.0/networks", HttpStatus.SC_INTERNAL_SERVER_ERROR); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/CreateNetwork_NEUTRON_Mode.xml"), uri, HttpMethod.POST); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void createNetworkByModelNameNeutronMode() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork_404(wireMockServer, "dvspg-VCE_VPE-mtjnj40avbc"); - - mockOpenStackGetAllNeutronNetworks_404(wireMockServer); - - mockOpenStackPostNeutronNetwork_200(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json"); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/CreateNetwork_NEUTRON_Mode.xml"), uri, HttpMethod.POST); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void createNetworkByModelNameAlreadyExistNeutronMode() throws IOException { - - mockUpdateRequestDb(wireMockServer, "9733c8d1-2668-4e5f-8b51-2cacc9b662c0"); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json"); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/CreateNetwork_NEUTRON_Mode.xml"), uri, HttpMethod.POST); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void createNetworkByModelNameAlreadyExistNeutronModeFailIfExistTrue() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetAllNeutronNetworks_200(wireMockServer, "OpenstackGetNeutronNetworks.json"); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/CreateNetwork_NEUTRON_Mode_Fail_If_Exist_True.xml"), uri, HttpMethod.POST); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - @Test public void createNetworkByModelNameHeatMode() throws IOException { @@ -300,61 +220,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); } - - @Test - public void deleteNetworkNeureonMode() throws IOException { - - mockUpdateRequestDb(wireMockServer, "5a29d907-b8c7-47bf-85f3-3940c0cce0f7"); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); - - mockOpenStackDeleteNeutronNetwork(wireMockServer, NETWORK_ID, HttpStatus.SC_OK); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/DeleteNetwork.xml").replace("CONTRAIL30_BASIC", "CONTRAIL31_GNDIRECT"), - uri, HttpMethod.POST); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void deleteNetworkNeutronModeDeleteStackException() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); - - mockOpenStackDeleteNeutronNetwork(wireMockServer, NETWORK_ID, HttpStatus.SC_INTERNAL_SERVER_ERROR); - - // mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", NETWORK_ID); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/DeleteNetwork.xml").replace("CONTRAIL30_BASIC", "CONTRAIL31_GNDIRECT"), - uri, HttpMethod.POST); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void updateNetworkNeutronModeSuccess() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork(wireMockServer, "GetNeutronNetwork.json", NETWORK_ID, HttpStatus.SC_OK); - mockOpenStackPutNeutronNetwork_200(wireMockServer, "OpenstackCreateNeutronNetworkResponse.json", NETWORK_ID); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/UpdateNetwork.xml").replace("CONTRAIL30_BASIC", "CONTRAIL31_GNDIRECT"), - uri, HttpMethod.POST); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - @Test public void updateNetworkNeutronUpdateException() throws IOException { @@ -487,21 +352,6 @@ public class MSONetworkAdapterImplTest extends BaseRestTestUtils { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); } - @Test - public void queryNetworkNeutronModeException() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetNeutronNetwork(wireMockServer, NETWORK_ID, HttpStatus.SC_INTERNAL_SERVER_ERROR); - - String uri = "/services/NetworkAdapter"; - headers.set("X-ECOMP-RequestID", "123456789456127"); - ResponseEntity<String> response = - sendXMLRequest(inputStream("/QueryNetwork.xml").replace("CONTRAIL30_BASIC", "CONTRAIL31_GNDIRECT"), uri, - HttpMethod.POST); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - public ResponseEntity<String> sendXMLRequest(String requestJson, String uriPath, HttpMethod reqMethod) { headers.set("Accept", MediaType.APPLICATION_XML); headers.set("Content-Type", MediaType.APPLICATION_XML); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java index 46d9f89303..1a308b7c4c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfAdapterAsyncImplTest.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -30,13 +30,11 @@ import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; import java.util.HashMap; -import java.util.Map; import org.apache.http.HttpStatus; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.VnfRollback; import org.springframework.beans.factory.annotation.Autowired; public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { @@ -86,48 +84,6 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { } @Test - public void updateVnfTest() throws Exception { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")) - .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK))); - String notificationUrl = - "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest"; - instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl); - } - - @Test - public void updateVnfTest_Exception() throws Exception { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - wireMockServer.stubFor(post(urlPathEqualTo("/notify/adapterNotify/updateVnfNotificationRequest")) - .withRequestBody(containing("messageId")).willReturn(aResponse().withStatus(HttpStatus.SC_OK))); - String notificationUrl = - "http://localhost:" + wireMockPort + "/notify/adapterNotify/updateVnfNotificationRequest"; - instance.updateVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", map, "messageId", msoRequest, notificationUrl); - wireMockServer.verify(1, postRequestedFor(urlEqualTo("/notify/adapterNotify/updateVnfNotificationRequest"))); - } - - @Test - public void queryVnfTest() { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - instance.queryVnfA("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", "messageId", msoRequest, - "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest"); - } - - @Test public void deleteVnfTest() { MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345"); @@ -136,14 +92,4 @@ public class MsoVnfAdapterAsyncImplTest extends BaseRestTestUtils { msoRequest, "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest"); } - @Test - public void rollbackVnfTest() { - VnfRollback vnfRollBack = new VnfRollback(); - vnfRollBack.setCloudSiteId("mdt1"); - vnfRollBack.setCloudOwner("CloudOwner"); - vnfRollBack.setTenantId("88a6ca3ee0394ade9403f075db23167e"); - vnfRollBack.setVnfId("ff5256d1-5a33-55df-13ab-12abad84e7ff"); - instance.rollbackVnfA(vnfRollBack, "messageId", - "http://org.onap.so/notify/adapterNotify/updateVnfNotificationRequest"); - } } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java deleted file mode 100644 index 45504fcab5..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfCloudifyAdapterImplTest.java +++ /dev/null @@ -1,308 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved. - * Copyright (C) 2018 Huawei 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.vnf; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlMatching; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.junit.Assert.assertTrue; -import java.util.HashMap; -import java.util.Map; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.db.catalog.beans.CloudifyManager; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.VnfRollback; -import org.springframework.beans.factory.annotation.Autowired; - -public class MsoVnfCloudifyAdapterImplTest extends BaseRestTestUtils { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Autowired - private MsoVnfCloudifyAdapterImpl instance; - - @Autowired - private CloudConfig cloudConfig; - - @Before - public void before() throws Exception { - super.setUp(); - CloudifyManager cloudifyManager = new CloudifyManager(); - cloudifyManager.setId("mtn13"); - cloudifyManager.setCloudifyUrl("http://localhost:" + wireMockPort + "/v2.0"); - cloudifyManager.setUsername("m93945"); - cloudifyManager.setPassword("93937EA01B94A10A49279D4572B48369"); - } - - /* - * @Test public void queryVnfExceptionTest() throws Exception { MsoRequest msoRequest = new MsoRequest(); - * msoRequest.setRequestId("12345"); msoRequest.setServiceInstanceId("12345"); Holder<Map<String, String>> outputs = - * new Holder<>(); instance.queryVnf("siteid", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new - * Holder<>(), new Holder<>(), outputs); - * - * assertTrue(outputs.value.isEmpty()); } - */ - - /* - * @Test public void queryVnfTest() throws Exception { - * - * - * MsoRequest msoRequest = new MsoRequest(); msoRequest.setRequestId("12345"); - * msoRequest.setServiceInstanceId("12345"); - * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")) - * .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - * - * wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")) - * .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }") - * .withStatus(HttpStatus.SC_OK))); - * - * wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse() - * .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ") - * .withStatus(HttpStatus.SC_OK))); - * - * instance.queryVnf("mtn13", "CloudOwner", "1234", "vfname", msoRequest, new Holder<>(), new Holder<>(), new - * Holder<>(), new Holder<>()); - * - * } - */ - - @Test - public void deleteVfModuleTest_ExceptionWhileQueryDeployment() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); - } - - @Test - public void deleteVfModuleTest_ExceptionWhileDeleteDeployment() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")) - .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")) - .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }") - .withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse() - .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ") - .withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")) - .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK))); - - instance.deleteVfModule("mtn13", "CloudOwner", "1234", "vfname", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); - } - - @Test - public void deleteVnfVnfExceptionTest() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.deleteVnf("12344", "CloudOwner", "234", "vnfname", msoRequest); - - } - - @Test - public void rollbackVnf() throws Exception { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - VnfRollback vnfRollback = new VnfRollback(); - vnfRollback.setModelCustomizationUuid("1234"); - vnfRollback.setVfModuleStackId("2134"); - vnfRollback.setVnfId("123"); - vnfRollback.setModelCustomizationUuid("1234"); - - instance.rollbackVnf(vnfRollback); - } - - @Test - public void rollbackVnf_Created() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - VnfRollback vnfRollback = new VnfRollback(); - vnfRollback.setModelCustomizationUuid("1234"); - vnfRollback.setVfModuleStackId("2134"); - vnfRollback.setVnfId("123"); - vnfRollback.setModelCustomizationUuid("1234"); - vnfRollback.setVnfCreated(true); - - instance.rollbackVnf(vnfRollback); - } - - @Test - public void createVfModuleVnfException() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234", - "123", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); - } - - @Test - public void createVfModule_ModelCustUuidIsNull() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234", - null, new HashMap<>(), true, true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); - } - - @Test - public void createVfModule_CloudSiteIdNotFound() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.createVfModule("123", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), - new Holder<>(), new Holder<>()); - } - - @Test - public void createVfModule_MsoCloudifyManagerNotFound() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "module-005", "", "create", "3245", "234", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), - new Holder<>(), new Holder<>()); - } - - @Test - public void createVfModule() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname")) - .willReturn(aResponse().withBody("{ \"id\": \"123\" }").withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/deployments/vfname/outputs")) - .willReturn(aResponse().withBody("{ \"deployment_id\": \"123\",\"outputs\":{\"abc\":\"abc\"} }") - .withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlMatching("/v2.0/api/v3/executions?.*")).willReturn(aResponse() - .withBody("{ \"items\": {\"id\": \"123\",\"workflow_id\":\"install\",\"status\":\"terminated\" } } ") - .withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo("/v2.0/api/v3/tokens")) - .willReturn(aResponse().withBodyFile("OpenstackResponse_Access.json").withStatus(HttpStatus.SC_OK))); - - instance.createVfModule("mtn13", "CloudOwner", "123", "vf", "v1", "", "vfname", "", "create", "3245", "234", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", new HashMap<>(), true, true, true, msoRequest, new Holder<>(), - new Holder<>(), new Holder<>()); - } - - @Test - public void updateVfModuleVnfException() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - instance.updateVfModule("123", "CloudOwner", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234", - new HashMap<>(), msoRequest, new Holder<>(), new Holder<>()); - } - - @Test - public void healthCheckVNFTest() { - instance.healthCheck(); - } - - @Test - public void createVnfTest() { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - try { - instance.createVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", map, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE, msoRequest, - new Holder<>(), new Holder<>(), new Holder<>()); - } catch (Exception e) { - } - } - - @Test - public void updateVnfTest() { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - Map<String, Object> map = new HashMap<>(); - - map.put("key1", "value1"); - try { - instance.updateVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD", - "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(), new Holder<>()); - } catch (Exception e) { - - } - } - - @Test - public void deleteVnfTest() { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - try { - instance.deleteVnf("mdt1", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest); - } catch (Exception e) { - - } - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java deleted file mode 100644 index 3bf784c50b..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Intel Corp. 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.vnf; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.post; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import java.util.HashMap; -import java.util.Map; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.adapters.vdu.VduModelInfo; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.cloud.CloudConfig; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.StackInfo; -import org.onap.so.openstack.exceptions.MsoException; -import org.springframework.beans.factory.annotation.Autowired; - -public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Autowired - private MsoVnfPluginAdapterImpl instance; - - @Autowired - private CloudConfig cloudConfig; - - private static final String UPDATE_STACK_RESPONSE = - "{\"template_type\": \"heat\", \"workload_id\": " + "\"workload-id\"}"; - private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": " - + "\"workload-id\", \"workload_status\": \"CREATE_COMPLETE\"}"; - private static final String GET_UPDATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": " - + "\"workload-id\", \"workload_status\": \"UPDATE_COMPLETE\"}"; - - private static final String MULTICLOUD_CREATE_PATH = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload"; - private static final String MULTICLOUD_UPDATE_PATH = - "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"; - private static final String MULTICLOUD_GET_PATH_BY_NAME = - "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/vfname"; - private static final String MULTICLOUD_GET_PATH_BY_ID = - "/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id"; - - @Before - public void before() throws Exception { - super.orchestrator = "multicloud"; - super.cloudEndpoint = "/api/multicloud/v1/CloudOwner/MTN13/infra_workload"; - super.setUp(); - } - - @Test - public void createVfModule() throws Exception { - - Map<String, Object> stackInputs = new HashMap<>(); - stackInputs.put("oof_directives", "{}"); - stackInputs.put("sdnc_directives", "{}"); - stackInputs.put("user_directives", "{}"); - stackInputs.put("generic_vnf_id", "genVNFID"); - stackInputs.put("vf_module_id", "vfMODULEID"); - - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn( - aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND))); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") - .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") - .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE") - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("MulticloudResponse_Stack_Create.json").withStatus(HttpStatus.SC_CREATED)) - .willSetStateTo("CREATING")); - - wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH)) - .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED)) - .willSetStateTo("UPDATING")); - - try { - instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId", - "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, - msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); - } catch (VnfException e) { - fail("createVfModule success expected, failed with exception: " + e.toString()); - } - wireMockServer.resetScenarios(); - } - - @Test - public void createVfModule2() throws Exception { - - Map<String, Object> stackInputs = new HashMap<>(); - stackInputs.put("oof_directives", "{}"); - stackInputs.put("sdnc_directives", "{}"); - stackInputs.put("user_directives", "{}"); - stackInputs.put("generic_vnf_id", "genVNFID"); - stackInputs.put("vf_module_id", "vfMODULEID"); - - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn( - aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND))); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") - .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") - .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE") - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("MulticloudResponse_Stack_Create2.json").withStatus(HttpStatus.SC_CREATED)) - .willSetStateTo("CREATING")); - - wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH)) - .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED)) - .willSetStateTo("UPDATING")); - - try { - instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId", - "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, - msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); - } catch (VnfException e) { - fail("createVfModule success expected, failed with exception: " + e.toString()); - } - wireMockServer.resetScenarios(); - } - - @Test - public void createVfModuleAlreadyExists() throws Exception { - - Map<String, Object> stackInputs = new HashMap<>(); - stackInputs.put("oof_directives", "{}"); - stackInputs.put("sdnc_directives", "{}"); - stackInputs.put("user_directives", "{}"); - stackInputs.put("generic_vnf_id", "genVNFID"); - stackInputs.put("vf_module_id", "vfMODULEID"); - - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor( - get(urlEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload?name=vfname")).willReturn(aResponse() - // .withHeader() - .withBodyFile("MulticloudGetStackExists.json").withStatus(HttpStatus.SC_OK))); - - try { - instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId", - "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, - msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); - } catch (VnfException e) { - assertTrue(e.toString().contains( - "Resource vfname already exists in owner/cloud/tenant CloudOwner/MTN13/123 with ID vfname/vfname")); - return; - } - fail("VnfAlreadyExists Exception expected!"); - } - - @Test - public void deleteVfModule() throws Exception { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")) - .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK))); - - wireMockServer.stubFor(delete(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")) - .willReturn(aResponse().withStatus(HttpStatus.SC_NO_CONTENT))); - - instance.deleteVfModule("MTN13", "CloudOwner", "123", "workload-id", "5aae1e49-805c-4f9f-bd78-055bf7451157", - "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", msoRequest, new Holder<>()); - } - - @Test - public void queryVfModule() throws Exception { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - - wireMockServer.stubFor(get(urlPathEqualTo("/api/multicloud/v1/CloudOwner/MTN13/infra_workload/workload-id")) - .willReturn(aResponse().withBodyFile("MulticloudResponse_Stack.json").withStatus(HttpStatus.SC_OK))); - - instance.queryVnf("MTN13", "CloudOwner", "123", "workload-id", msoRequest, new Holder<>(), new Holder<>(), - new Holder<>(), new Holder<>()); - } - - // TODO Error Tests -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java deleted file mode 100644 index a68efbe130..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfPluginAdapterImplTest.java +++ /dev/null @@ -1,166 +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.vnf; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.delete; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; -import java.util.HashMap; -import java.util.Map; -import javax.xml.ws.Holder; -import org.apache.http.HttpStatus; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.entity.MsoRequest; -import org.onap.so.openstack.beans.VnfRollback; -import org.springframework.beans.factory.annotation.Autowired; - -public class MsoVnfPluginAdapterImplTest extends BaseRestTestUtils { - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Autowired - MsoVnfPluginAdapterImpl msoVnfPluginAdapter; - - String vnfName = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId"; - - @Test - public void createVfModule_ModelCustUuidIsNull() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", null, map, Boolean.FALSE, - Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), new Holder<Map<String, String>>(), - new Holder<VnfRollback>()); - } - - @Test - public void createVfModule_ModelCustUuidIsNotFound() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", - "88a6ca3ee0394ade9403f075db23167e", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, - new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - } - - @Test - public void createVfModule_VduException() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, - new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - } - - @Test - public void createVfModule_INSTANTIATED() throws Exception { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStackVfModule_200(wireMockServer); - - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", null, "baseVfHeatStackId", "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, - Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, new Holder<>(), - new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - } - - @Test - public void createVfModule_queryVduNotFoundWithVolumeGroupId() throws Exception { - expectedException.expect(VnfException.class); - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", "volumeGroupHeatStackId|1", "baseVfHeatStackId", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, - new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - } - - @Test - public void createVfModule_CreateVduException() throws Exception { - expectedException.expect(VnfException.class); - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStackVfModule_404(wireMockServer); - wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/volumeGroupHeatStackId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK))); - MsoRequest msoRequest = getMsoRequest(); - Map<String, Object> map = new HashMap<>(); - map.put("key1", "value1"); - msoVnfPluginAdapter.createVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "", - vnfName, "", "VFMOD", "volumeGroupHeatStackId", "baseVfHeatStackId", - "9b339a61-69ca-465f-86b8-1c72c582b8e8", map, Boolean.FALSE, Boolean.TRUE, Boolean.FALSE, msoRequest, - new Holder<>(), new Holder<Map<String, String>>(), new Holder<VnfRollback>()); - } - - @Test - public void deleteVfModule_QueryVduException() throws Exception { - expectedException.expect(VnfException.class); - MsoRequest msoRequest = getMsoRequest(); - msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", - msoRequest, new Holder<Map<String, String>>()); - } - - @Test - public void deleteVfModule_DeleteVduException() throws Exception { - expectedException.expect(VnfException.class); - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStackVfModule_200(wireMockServer); - wireMockServer.stubFor(get(urlPathEqualTo("/mockPublicUrl/stacks/vSAMP12")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withBodyFile("OpenstackResponse_Stack_Created_VfModule.json").withStatus(HttpStatus.SC_OK))); - wireMockServer.stubFor(delete( - urlPathEqualTo("/mockPublicUrl/stacks/DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001/stackId")) - .willReturn(aResponse().withHeader("Content-Type", "application/json") - .withStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR))); - MsoRequest msoRequest = getMsoRequest(); - msoVnfPluginAdapter.deleteVfModule("mtn13", "CloudOwner", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", - "5aae1e49-805c-4f9f-bd78-055bf7451157", "11420693-3f69-4c61-b3ee-9787c744e760", "customizationId", - msoRequest, new Holder<Map<String, String>>()); - } - - private MsoRequest getMsoRequest() { - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId("12345"); - msoRequest.setServiceInstanceId("12345"); - return msoRequest; - } - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java deleted file mode 100644 index 7e7c130e33..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/QueryTest.java +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 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.vnf; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.hasProperty; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.mockito.Mockito.when; -import java.util.Map; -import javax.xml.ws.Holder; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; -import org.onap.so.adapters.vnf.exceptions.VnfException; -import org.onap.so.openstack.beans.HeatStatus; -import org.onap.so.openstack.beans.StackInfo; -import org.onap.so.openstack.beans.VnfStatus; -import org.onap.so.openstack.exceptions.MsoException; -import org.onap.so.openstack.exceptions.MsoOpenstackException; -import org.onap.so.openstack.utils.MsoHeatUtils; - -@RunWith(MockitoJUnitRunner.class) -public class QueryTest { - - @Mock - private MsoHeatUtils heat; - @InjectMocks - private MsoVnfAdapterImpl vnfAdapter = new MsoVnfAdapterImpl(); - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Test - public void testQueryCreatedVnf() throws VnfException, MsoException { - StackInfo info = new StackInfo("stackName", HeatStatus.CREATED); - when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info); - String cloudId = "MT"; - String cloudOwner = "CloudOwner"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vnfId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - - vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); - - assertTrue(vnfExists.value); - } - - @Test - public void testQueryNotFoundVnf() throws VnfException, MsoException { - StackInfo info = new StackInfo("stackName", HeatStatus.NOTFOUND); - when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(info); - String cloudId = "MT"; - String cloudOwner = "CloudOwner"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vnfId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - - vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); - - assertFalse(vnfExists.value); - } - - @Test() - // @Ignore // 1802 merge - public void testQueryVnfWithException() throws VnfException, MsoException { - String cloudId = "MT"; - String cloudOwner = "CloudOwner"; - String tenantId = "MSO_Test"; - String vnfName = "VNF_TEST1"; - Holder<Boolean> vnfExists = new Holder<>(); - Holder<String> vnfId = new Holder<>(); - Holder<VnfStatus> status = new Holder<>(); - Holder<Map<String, String>> outputs = new Holder<>(); - thrown.expect(VnfException.class); - thrown.expectCause(hasProperty("context", is("QueryVNF"))); - when(heat.queryStack(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())) - .thenThrow(new MsoOpenstackException(1, "test messsage", "test detail")); - vnfAdapter.queryVnf(cloudId, cloudOwner, tenantId, vnfName, null, vnfExists, vnfId, status, outputs); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java deleted file mode 100644 index 9655e90e46..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VnfAdapterRestTest.java +++ /dev/null @@ -1,557 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.adapters.vnf; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.github.tomakehurst.wiremock.WireMockServer; -import org.apache.http.HttpStatus; -import org.json.JSONException; -import org.junit.Ignore; -import org.junit.Test; -import org.onap.so.adapters.vnfrest.CreateVfModuleRequest; -import org.onap.so.adapters.vnfrest.CreateVfModuleResponse; -import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest; -import org.onap.so.adapters.vnfrest.DeleteVfModuleResponse; -import org.onap.so.adapters.vnfrest.QueryVfModuleResponse; -import org.onap.so.adapters.vnfrest.RollbackVfModuleRequest; -import org.onap.so.adapters.vnfrest.RollbackVfModuleResponse; -import org.onap.so.adapters.vnfrest.UpdateVfModuleRequest; -import org.onap.so.adapters.vnfrest.UpdateVfModuleResponse; -import org.onap.so.adapters.vnfrest.VfModuleExceptionResponse; -import org.onap.so.adapters.vnfrest.VfModuleRollback; -import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.entity.MsoRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.File; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static com.shazam.shazamcrest.MatcherAssert.assertThat; -import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeletePublicUrlStackByNameAndID_204; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackDeleteStacks; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetPublicUrlStackByNameAndID_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksBaseStack_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksStackId_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVUSP_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModuleWithLocationHeader_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacks_404; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStacks_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; - -public class VnfAdapterRestTest extends BaseRestTestUtils { - - - @Autowired - private JettisonStyleMapperProvider jettisonTypeObjectMapper; - private static final String MESSAGE_ID = "62265093-277d-4388-9ba6-449838ade586-1517252396874"; - private static final String AAI_VNF_ID = "c93e0d34-5b63-45de-bbae-b0fe49dd3bd9"; - private static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586"; - private static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - private static final String CLOUDSITE_ID = "mtn13"; - private static final String CLOUD_OWNER = "CloudOwner"; - private static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8"; - private static final String VNF_TYPE = "MSOTADevInfra_vSAMP10a_Service/vSAMP10a 1"; - private static final String VNF_NAME = "MSO-DEV-VNF-1802-it3-pwt3-vSAMP10a-1XXX-Replace"; - private static final String VNF_VERSION = "1.0"; - private static final String VF_MODULE_ID = "1d48aaec-b7f3-4c24-ba4a-4e798ed3223c"; - private static final String VF_MODULE_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"; - private static final String VF_MODULE_TYPE = "vSAMP10aDEV::PCM::module-2"; - private static final String MODEL_CUSTOMIZATION_UUID = "cb82ffd8-252a-11e7-93ae-92361f002671"; - private static final String BASE_VF_MODULE_ID = "3d7ff7b4-720b-4604-be0a-1974fc58ed96"; - // vfModuleParams specific variables - private static final String NETWORK_NAME = "Dev-vSAMP10a-ntwk-1802-pwt3-v6-Replace-1001"; - private static final String SERVER_NAME = "Dev-vSAMP10a-addon2-1802-pwt3-v6-Replace-1001"; - private static final String IMAGE = "ubuntu_14.04_IPv6"; - private static final String EXN_DIRECT_NET_FQDN = "direct"; - private static final String EXN_HSL_NET_FQDN = "hsl"; - private static final String AVAILABILITY_ZONE_0 = "nova"; - private static final String VF_MODULE_INDEX = "0"; - - @Test - public void testCreateVfModule() throws JSONException, JsonParseException, JsonMappingException, IOException { - - CreateVfModuleRequest request = populateCreateVfModuleRequest(); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetStackVfModule_404(wireMockServer); - - mockOpenStackPostStacks_200(wireMockServer); - - mockOpenStackGetStackVfModule_200(wireMockServer); - - mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); - - ResponseEntity<CreateVfModuleResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, CreateVfModuleResponse.class); - - ResponseEntity<CreateVfModuleResponse> responseV2 = - restTemplate.exchange(createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, CreateVfModuleResponse.class); - - CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - - assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value()); - assertThat(responseV2.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateVfModuleAsyncCall() throws Exception { - CreateVfModuleRequest request = populateCreateVfModuleRequest(); - request.setNotificationUrl(createURLWithPort("/mso/WorkflowMesssage")); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStackVfModule_404(wireMockServer); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackGetStackVfModule_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); - - ResponseEntity<CreateVfModuleResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, CreateVfModuleResponse.class); - - CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class); - - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testCreateVfModuleWithEnableBridgeNull() - throws JSONException, JsonParseException, JsonMappingException, IOException { - - CreateVfModuleRequest request = new CreateVfModuleRequest(); - request.setBackout(true); - request.setSkipAAI(true); - request.setFailIfExists(false); - MsoRequest msoReq = new MsoRequest(); - boolean failIfExists = true; - Boolean enableBridge = null; - Map<String, Object> vfModuleParams = new HashMap<>(); - - - vfModuleParams.put("vf_module_id", VF_MODULE_ID); - vfModuleParams.put("vnf_id", AAI_VNF_ID); - vfModuleParams.put("network_name", NETWORK_NAME); - vfModuleParams.put("vnf_name", VNF_NAME); - vfModuleParams.put("environment_context", ""); - vfModuleParams.put("server_name", SERVER_NAME); - vfModuleParams.put("image", IMAGE); - vfModuleParams.put("workload_context", ""); - vfModuleParams.put("vf_module_index", VF_MODULE_INDEX); - vfModuleParams.put("vf_module_name", VF_MODULE_NAME); - vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0); - vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN); - vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN); - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setVnfId(AAI_VNF_ID); - request.setVnfVersion(VNF_VERSION); - request.setVfModuleId(VF_MODULE_ID); - request.setVfModuleName(VF_MODULE_NAME); - request.setBaseVfModuleId(BASE_VF_MODULE_ID); - request.setFailIfExists(failIfExists); - request.setEnableBridge(enableBridge); - request.setVfModuleParams(vfModuleParams); - request.setMessageId(MESSAGE_ID); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetStackVfModule_404(wireMockServer); - - mockOpenStackPostStacks_200(wireMockServer); - - mockOpenStackGetStackVfModule_200(wireMockServer); - - mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); - - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); - - ResponseEntity<CreateVfModuleResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, CreateVfModuleResponse.class); - - CreateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/CreateVfModuleResponse.json"), CreateVfModuleResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testCreateVfModuleFail() throws IOException { - - CreateVfModuleRequest request = new CreateVfModuleRequest(); - request.setBackout(true); - request.setSkipAAI(true); - request.setFailIfExists(false); - MsoRequest msoReq = new MsoRequest(); - boolean failIfExists = true; - boolean enableBridge = false; - Map<String, Object> vfModuleParams = new HashMap<>(); - - vfModuleParams.put("vf_module_id", VF_MODULE_ID); - vfModuleParams.put("vnf_id", AAI_VNF_ID); - vfModuleParams.put("network_name", NETWORK_NAME); - vfModuleParams.put("vnf_name", VNF_NAME); - vfModuleParams.put("environment_context", ""); - vfModuleParams.put("server_name", SERVER_NAME); - vfModuleParams.put("image", IMAGE); - vfModuleParams.put("workload_context", ""); - vfModuleParams.put("vf_module_index", VF_MODULE_INDEX); - vfModuleParams.put("vf_module_name", VF_MODULE_NAME); - vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0); - vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN); - vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN); - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setVnfId(AAI_VNF_ID); - request.setVnfType(VNF_TYPE); - request.setVnfVersion(VNF_VERSION); - request.setVfModuleId(VF_MODULE_ID); - request.setVfModuleName(VF_MODULE_NAME); - request.setVfModuleType(VF_MODULE_TYPE); - request.setBaseVfModuleStackId(BASE_VF_MODULE_ID); - request.setFailIfExists(failIfExists); - request.setEnableBridge(enableBridge); - request.setVfModuleParams(vfModuleParams); - request.setMessageId(MESSAGE_ID); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetStackVfModule_404(wireMockServer); - - mockOpenStackGetStacks_404(wireMockServer); - - mockOpenStackPostStacks_200(wireMockServer); - - mockOpenStackGetStackVfModule_200(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<CreateVfModuleRequest> entity = new HttpEntity<CreateVfModuleRequest>(request, headers); - - ResponseEntity<VfModuleExceptionResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, VfModuleExceptionResponse.class); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - - mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_IN_PROGRESS"); - - response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, VfModuleExceptionResponse.class); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - - mockOpenStackGetStacksWithBody_200(wireMockServer, "DELETE_FAILED"); - - response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, VfModuleExceptionResponse.class); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - - mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - - response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, VfModuleExceptionResponse.class); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - - mockOpenStackGetStacksWithBody_404(wireMockServer); - - response = restTemplate.exchange(createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules"), - HttpMethod.POST, entity, VfModuleExceptionResponse.class); - - assertEquals(Response.Status.BAD_REQUEST.getStatusCode(), response.getStatusCode().value()); - - } - - @Test - public void testDeleteVfModule() throws IOException { - - DeleteVfModuleRequest request = new DeleteVfModuleRequest(); - MsoRequest msoRequest = new MsoRequest(); - String vfModuleStackId = "stackId"; - - msoRequest.setRequestId(MSO_REQUEST_ID); - msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setVfModuleId(VF_MODULE_ID); - request.setVfModuleStackId(vfModuleStackId); - request.setVnfId(AAI_VNF_ID); - request.setMsoRequest(msoRequest); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackPostStacks_200(wireMockServer); - - mockOpenStackGetStacksStackId_404(wireMockServer); - - mockOpenStackGetPublicUrlStackByNameAndID_200(wireMockServer, wireMockPort); - - mockOpenStackDeletePublicUrlStackByNameAndID_204(wireMockServer); - - mockUpdateRequestDb(wireMockServer, "62265093-277d-4388-9ba6-449838ade586"); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<DeleteVfModuleRequest> entity = new HttpEntity<DeleteVfModuleRequest>(request, headers); - - ResponseEntity<DeleteVfModuleResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID), - HttpMethod.DELETE, entity, DeleteVfModuleResponse.class); - - ResponseEntity<DeleteVfModuleResponse> responseV2 = restTemplate.exchange( - createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID), - HttpMethod.DELETE, entity, DeleteVfModuleResponse.class); - - - DeleteVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/DeleteVfModuleResponse.json"), DeleteVfModuleResponse.class); - - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - - assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value()); - assertThat(responseV2.getBody(), sameBeanAs(expectedResponse)); - } - - @Test - public void testUpdateVfModule() throws IOException { - - UpdateVfModuleRequest request = new UpdateVfModuleRequest(); - MsoRequest msoRequest = new MsoRequest(); - String vfModuleStackId = "vfModuleStackId"; - Boolean failIfExists = false; - Boolean backout = false; - msoRequest.setRequestId(MSO_REQUEST_ID); - msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - - Map<String, Object> vfModuleParams = new HashMap<>(); - - vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN); - vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN); - - Map<String, String> vfModuleOutputs = new HashMap<String, String>(); - - vfModuleOutputs.put("output name", "output value"); - - request.setBackout(backout); - request.setCloudSiteId(CLOUDSITE_ID); - request.setFailIfExists(failIfExists); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setMsoRequest(msoRequest); - request.setTenantId(TENANT_ID); - request.setVfModuleId(VF_MODULE_ID); - request.setVfModuleName(VF_MODULE_NAME); - request.setVfModuleStackId(vfModuleStackId); - request.setBackout(backout); - request.setVfModuleParams(vfModuleParams); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetStacksVfModuleWithLocationHeader_200(wireMockServer, wireMockPort); - - mockOpenStackGetStacksVfModule_200(wireMockServer, wireMockPort); - - mockOpenStackGetStacksBaseStack_200(wireMockServer, wireMockPort); - - mockOpenStackPutStacks_200(wireMockServer); - - UpdateVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/UpdateVfModuleResponse.json"), UpdateVfModuleResponse.class); - expectedResponse.setVfModuleOutputs(vfModuleOutputs); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<UpdateVfModuleRequest> entity = new HttpEntity<UpdateVfModuleRequest>(request, headers); - - ResponseEntity<UpdateVfModuleResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE), - HttpMethod.PUT, entity, UpdateVfModuleResponse.class); - - ResponseEntity<UpdateVfModuleResponse> responseV2 = restTemplate.exchange( - createURLWithPort("/services/rest/v2/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_TYPE), - HttpMethod.PUT, entity, UpdateVfModuleResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - - assertEquals(Response.Status.OK.getStatusCode(), responseV2.getStatusCode().value()); - assertThat(responseV2.getBody(), sameBeanAs(expectedResponse)); - - } - - @Test - public void testRollbackVfModule() throws IOException { - - - MsoRequest msoRequest = new MsoRequest(); - msoRequest.setRequestId(MSO_REQUEST_ID); - msoRequest.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - - VfModuleRollback vfModuleRollback = new VfModuleRollback(AAI_VNF_ID, VF_MODULE_ID, "StackId", false, TENANT_ID, - CLOUD_OWNER, CLOUDSITE_ID, msoRequest, "messageId"); - - RollbackVfModuleRequest request = new RollbackVfModuleRequest(); - request.setVfModuleRollback(vfModuleRollback); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - mockOpenStackGetStacksStackId_200(wireMockServer, wireMockPort); - - mockOpenStackDeleteStacks(wireMockServer); - - mockOpenStackGetStacksVUSP_404(wireMockServer); - - headers.add("Accept", MediaType.APPLICATION_JSON); - HttpEntity<RollbackVfModuleRequest> entity = new HttpEntity<RollbackVfModuleRequest>(request, headers); - - ResponseEntity<RollbackVfModuleResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID + "/rollback"), - HttpMethod.DELETE, entity, RollbackVfModuleResponse.class); - - RollbackVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/RollbackVfModuleResponse.json"), RollbackVfModuleResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - - } - - @Ignore - @Test - public void testQueryVfModule() throws IOException { - - String testUrl = createURLWithPort("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID); - String testUri = UriBuilder.fromPath("/services/rest/v1/vnfs/" + AAI_VNF_ID + "/vf-modules/" + VF_MODULE_ID) - .host("localhost").port(wireMockPort).scheme("http") - // .queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID) - .build().toString(); - System.out.println(testUri); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - - - headers.add("Accept", MediaType.APPLICATION_JSON); - // HttpEntity entity = new HttpEntity(null, headers); - ResponseEntity<QueryVfModuleResponse> response = - restTemplate.getForEntity(testUri, QueryVfModuleResponse.class); - // System.out.println(response); - - QueryVfModuleResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( - new File("src/test/resources/__files/QueryVfModuleResponse.json"), QueryVfModuleResponse.class); - - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - assertThat(response.getBody(), sameBeanAs(expectedResponse)); - } - - private CreateVfModuleRequest populateCreateVfModuleRequest() { - CreateVfModuleRequest request = new CreateVfModuleRequest(); - request.setBackout(true); - request.setSkipAAI(true); - request.setFailIfExists(false); - MsoRequest msoReq = new MsoRequest(); - boolean failIfExists = true; - boolean enableBridge = false; - Map<String, Object> vfModuleParams = new HashMap<>(); - - vfModuleParams.put("vf_module_id", VF_MODULE_ID); - vfModuleParams.put("vnf_id", AAI_VNF_ID); - vfModuleParams.put("network_name", NETWORK_NAME); - vfModuleParams.put("vnf_name", VNF_NAME); - vfModuleParams.put("environment_context", ""); - vfModuleParams.put("server_name", SERVER_NAME); - vfModuleParams.put("image", IMAGE); - vfModuleParams.put("workload_context", ""); - vfModuleParams.put("vf_module_index", VF_MODULE_INDEX); - vfModuleParams.put("vf_module_name", VF_MODULE_NAME); - vfModuleParams.put("availability_zone_0", AVAILABILITY_ZONE_0); - vfModuleParams.put("exn_direct_net_fqdn", EXN_DIRECT_NET_FQDN); - vfModuleParams.put("exn_hsl_net_fqdn", EXN_HSL_NET_FQDN); - - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - request.setMsoRequest(msoReq); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setVnfId(AAI_VNF_ID); - request.setVnfType(VNF_TYPE); - request.setVnfVersion(VNF_VERSION); - request.setVfModuleId(VF_MODULE_ID); - request.setVfModuleName(VF_MODULE_NAME); - request.setVfModuleType(VF_MODULE_TYPE); - request.setBaseVfModuleId(BASE_VF_MODULE_ID); - request.setFailIfExists(failIfExists); - request.setEnableBridge(enableBridge); - request.setVfModuleParams(vfModuleParams); - request.setMessageId(MESSAGE_ID); - - return request; - } - - public static void mockUpdateRequestDb(WireMockServer wireMockServer, String requestId) throws IOException { - wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/" + requestId)) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java deleted file mode 100644 index c2e2b567f1..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestTest.java +++ /dev/null @@ -1,194 +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.vnf; - -import org.apache.http.HttpStatus; -import org.junit.Test; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.IOException; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; - -public class VolumeAdapterRestTest extends VolumeGroupAdapterCommon { - - @Test - public void testCreateVNFVolumes() throws IOException { - - wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackGetStackVfModule_200(wireMockServer); - CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); - - HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<CreateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity, - CreateVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testCreateVNFVolumesAsync() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackGetStackVfModule_200(wireMockServer); - CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); - request.setNotificationUrl("http://localhost:8080"); - - HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<CreateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups"), HttpMethod.POST, entity, - CreateVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testDeleteVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest(); - HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<DeleteVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testDeleteVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<DeleteVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testRollbackVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest(); - HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"), - HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testRollbackVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID + "/rollback"), - HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testQueryVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID); - builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID) - .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true) - .queryParam("msoRequest.requestId", MSO_REQUEST_ID) - .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID); - - ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testQueryVNFVolumesError() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID); - builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME) - .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID) - .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID); - - ResponseEntity<VolumeGroupExceptionResponse> response = - restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null, - VolumeGroupExceptionResponse.class); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testUpdateVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE"); - mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200); - mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest(); - HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<UpdateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testUpdateVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE"); - mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200); - mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<UpdateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v1/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java deleted file mode 100644 index 6fd9f02cfe..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeAdapterRestV2Test.java +++ /dev/null @@ -1,190 +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.vnf; - -import org.apache.http.HttpStatus; -import org.junit.Test; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.VolumeGroupExceptionResponse; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.UriBuilder; -import java.io.IOException; -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.patch; -import static com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo; -import static org.junit.Assert.assertEquals; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackVfModule_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStackWithBody_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackGetStacksWithBody_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPostStacks_200; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackPutStack; -import static org.onap.so.bpmn.mock.StubOpenStack.mockOpenStackResponseAccess; - -public class VolumeAdapterRestV2Test extends VolumeGroupAdapterCommon { - - @Test - public void testCreateVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackGetStackVfModule_200(wireMockServer); - wireMockServer.stubFor(patch(urlPathEqualTo("/infraActiveRequests/62265093-277d-4388-9ba6-449838ade586")) - .willReturn(aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_OK))); - - CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); - - HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<CreateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity, - CreateVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testCreateVNFVolumesAsync() throws IOException { - - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackPostStacks_200(wireMockServer); - mockOpenStackGetStackVfModule_200(wireMockServer); - CreateVolumeGroupRequest request = buildCreateVfModuleRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<CreateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<CreateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups"), HttpMethod.POST, entity, - CreateVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testDeleteVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest(); - HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<DeleteVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testDeleteVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - DeleteVolumeGroupRequest request = buildDeleteVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<DeleteVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<DeleteVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.DELETE, entity, DeleteVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testRollbackVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest(); - HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"), - HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testRollbackVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - RollbackVolumeGroupRequest request = buildRollbackVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<RollbackVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<RollbackVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID + "/rollback"), - HttpMethod.DELETE, entity, RollbackVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testQueryVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID); - builder.queryParam("cloudSiteId", CLOUDSITE_ID).queryParam("tenantId", TENANT_ID) - .queryParam("volumeGroupStackId", VOUME_GROUP_NAME).queryParam("skipAAI", true) - .queryParam("msoRequest.requestId", MSO_REQUEST_ID) - .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID); - - ResponseEntity<QueryVolumeGroupResponse> response = restTemplate.exchange( - createURLWithPort(builder.build().toString()), HttpMethod.GET, null, QueryVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testQueryVNFVolumesError() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - javax.ws.rs.core.UriBuilder builder = UriBuilder.fromPath("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID); - builder.queryParam("tenantId", TENANT_ID).queryParam("volumeGroupStackId", VOUME_GROUP_NAME) - .queryParam("skipAAI", true).queryParam("msoRequest.requestId", MSO_REQUEST_ID) - .queryParam("msoRequest.serviceInstanceId", MSO_SERVICE_INSTANCE_ID); - - ResponseEntity<VolumeGroupExceptionResponse> response = - restTemplate.exchange(createURLWithPort(builder.build().toString()), HttpMethod.GET, null, - VolumeGroupExceptionResponse.class); - assertEquals(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testUpdateVNFVolumes() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE"); - mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200); - mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest(); - HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<UpdateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); - } - - @Test - public void testUpdateVNFVolumesAsync() throws IOException { - mockOpenStackResponseAccess(wireMockServer, wireMockPort); - mockOpenStackGetStacksWithBody_200(wireMockServer, "CREATE_COMPLETE"); - mockOpenStackPutStack(wireMockServer, VOUME_GROUP_NAME + "/stackId", 200); - mockOpenStackGetStackWithBody_200(wireMockServer, "UPDATE_COMPLETE"); - UpdateVolumeGroupRequest request = buildUpdateVolumeGroupRequest(); - request.setNotificationUrl("http://localhost:8080"); - HttpEntity<UpdateVolumeGroupRequest> entity = new HttpEntity<>(request, headers); - ResponseEntity<UpdateVolumeGroupResponse> response = - restTemplate.exchange(createURLWithPort("/services/rest/v2/volume-groups/" + VOLUME_GROUP_ID), - HttpMethod.PUT, entity, UpdateVolumeGroupResponse.class); - assertEquals(Response.Status.ACCEPTED.getStatusCode(), response.getStatusCode().value()); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java deleted file mode 100644 index 14fa1df6c9..0000000000 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/VolumeGroupAdapterCommon.java +++ /dev/null @@ -1,129 +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.vnf; - -import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; -import org.onap.so.adapters.vnfrest.VolumeGroupRollback; -import org.onap.so.entity.MsoRequest; -import java.util.HashMap; -import java.util.Map; - -public class VolumeGroupAdapterCommon extends BaseRestTestUtils { - - - - protected static final String MSO_REQUEST_ID = "62265093-277d-4388-9ba6-449838ade586"; - protected static final String MSO_SERVICE_INSTANCE_ID = "4147e06f-1b89-49c5-b21f-4faf8dc9805a"; - protected static final String CLOUDSITE_ID = "mtn13"; - protected static final String TENANT_ID = "0422ffb57ba042c0800a29dc85ca70f8"; - protected static final String VOUME_GROUP_NAME = "DEV-VF-1802-it3-pwt3-v6-vSAMP10a-addon2-Replace-1001"; - protected static final String VOLUME_GROUP_ID = "0422ffb57ba042c0800a29dc85ca70v1"; - protected static final String VNF_TYPE = "TestVnfType"; - protected static final String VNF_VERSION = "1.0"; - protected static final String VF_MODULE_TYPE = "TestModule-0"; - protected static final String MODEL_CUSTOMIZATION_UUID = "9b339a61-69ca-465f-86b8-1c72c582b8e8"; - - protected UpdateVolumeGroupRequest buildUpdateVolumeGroupRequest() { - UpdateVolumeGroupRequest request = new UpdateVolumeGroupRequest(); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setVolumeGroupId(VOLUME_GROUP_ID); - request.setVnfType(VNF_TYPE); - request.setVnfVersion(VNF_VERSION); - request.setVfModuleType(VF_MODULE_TYPE); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setSkipAAI(true); - request.setVolumeGroupStackId(VOUME_GROUP_NAME); - Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap(); - request.setVolumeGroupParams(volumeGroupParams); - MsoRequest msoReq = getMsoRequest(); - request.setMsoRequest(msoReq); - return request; - } - - protected RollbackVolumeGroupRequest buildRollbackVolumeGroupRequest() { - RollbackVolumeGroupRequest request = new RollbackVolumeGroupRequest(); - VolumeGroupRollback volumeGroupRollback = new VolumeGroupRollback(); - volumeGroupRollback.setCloudSiteId(CLOUDSITE_ID); - volumeGroupRollback.setMessageId(MSO_REQUEST_ID); - volumeGroupRollback.setTenantId(TENANT_ID); - MsoRequest msoReq = getMsoRequest(); - volumeGroupRollback.setVolumeGroupCreated(true); - volumeGroupRollback.setVolumeGroupId(VOLUME_GROUP_ID); - volumeGroupRollback.setVolumeGroupStackId(VOLUME_GROUP_ID); - volumeGroupRollback.setMsoRequest(msoReq); - request.setVolumeGroupRollback(volumeGroupRollback); - return request; - } - - protected DeleteVolumeGroupRequest buildDeleteVolumeGroupRequest() { - DeleteVolumeGroupRequest request = new DeleteVolumeGroupRequest(); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setVolumeGroupStackId("testStackId"); - request.setVolumeGroupId(VOLUME_GROUP_ID); - MsoRequest msoReq = getMsoRequest(); - request.setMsoRequest(msoReq); - return request; - } - - protected CreateVolumeGroupRequest buildCreateVfModuleRequest() { - CreateVolumeGroupRequest request = new CreateVolumeGroupRequest(); - request.setCloudSiteId(CLOUDSITE_ID); - request.setTenantId(TENANT_ID); - request.setVolumeGroupName(VOUME_GROUP_NAME); - request.setVolumeGroupId(VOLUME_GROUP_ID); - request.setVnfType(VNF_TYPE); - request.setVnfVersion(VNF_VERSION); - request.setVfModuleType(VF_MODULE_TYPE); - request.setModelCustomizationUuid(MODEL_CUSTOMIZATION_UUID); - request.setSkipAAI(true); - request.setFailIfExists(false); - request.setFailIfExists(true); - request.setEnableBridge(false); - request.setSuppressBackout(true); - Map<String, Object> volumeGroupParams = getVolumeGroupParamsMap(); - request.setVolumeGroupParams(volumeGroupParams); - MsoRequest msoReq = getMsoRequest(); - request.setMsoRequest(msoReq); - - return request; - } - - private Map<String, Object> getVolumeGroupParamsMap() { - Map<String, Object> volumeGroupParams = new HashMap<>(); - volumeGroupParams.put("fsb_volume_type_0", "volume_type"); - volumeGroupParams.put("fsb_volume_image_name_1", "vol_img_1"); - volumeGroupParams.put("fsb_volume_image_name_0", "vol_img_0"); - volumeGroupParams.put("fsb_volume_size_0", "100"); - return volumeGroupParams; - } - - private MsoRequest getMsoRequest() { - MsoRequest msoReq = new MsoRequest(); - msoReq.setRequestId(MSO_REQUEST_ID); - msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); - return msoReq; - } -} diff --git a/adapters/mso-ve-vnfm-adapter/pom.xml b/adapters/mso-ve-vnfm-adapter/pom.xml index 3d054d9eca..42d20dc021 100644 --- a/adapters/mso-ve-vnfm-adapter/pom.xml +++ b/adapters/mso-ve-vnfm-adapter/pom.xml @@ -35,7 +35,12 @@ </dependency> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter-ext-clients</artifactId> + <artifactId>etsi-sol003-lcm-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>etsi-sol003-lcm-ext-clients</artifactId> <version>${project.version}</version> </dependency> <dependency> diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java index 5b1f27f2ca..1560b3be4d 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/controller/NotificationController.java @@ -24,7 +24,7 @@ import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.constant.NotificationVnfFilterType; import org.onap.so.adapters.vevnfm.service.DmaapService; import org.onap.so.adapters.vevnfm.service.VnfAaiChecker; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java index dc0c5502dd..8ef3f24d2f 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/event/DmaapEvent.java @@ -24,7 +24,7 @@ import static java.time.temporal.ChronoField.INSTANT_SECONDS; import com.fasterxml.jackson.annotation.JsonProperty; import java.time.Instant; import java.util.UUID; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; public class DmaapEvent { diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java index d6fa86cd29..c13811d9d0 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/DmaapService.java @@ -22,7 +22,7 @@ package org.onap.so.adapters.vevnfm.service; import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.event.DmaapEvent; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model.VnfLcmOperationOccurrenceNotification; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.lcn.model.VnfLcmOperationOccurrenceNotification; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java index 4cce0773fb..be71c04c89 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscribeSender.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; import org.onap.so.rest.service.HttpRestServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java index cad44eaeed..32cd6ae22f 100644 --- a/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java +++ b/adapters/mso-ve-vnfm-adapter/src/main/java/org/onap/so/adapters/vevnfm/service/SubscriberService.java @@ -28,10 +28,10 @@ import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; import org.onap.so.adapters.vevnfm.provider.AuthorizationHeadersProvider; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthentication; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilter; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthentication; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsAuthenticationParamsBasic; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.SubscriptionsFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; diff --git a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java index 02d664e206..e67e19fd8d 100644 --- a/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java +++ b/adapters/mso-ve-vnfm-adapter/src/test/java/org/onap/so/adapters/vevnfm/service/SubscribeSenderTest.java @@ -36,7 +36,7 @@ import org.onap.aai.domain.yang.EsrSystemInfo; import org.onap.so.adapters.vevnfm.configuration.ConfigProperties; import org.onap.so.adapters.vevnfm.configuration.StartupConfiguration; import org.onap.so.adapters.vevnfm.exception.VeVnfmException; -import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.LccnSubscriptionRequest; +import org.onap.so.adapters.etsi.sol003.adapter.lcm.extclients.vnfm.model.LccnSubscriptionRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpMethod; diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java index 83a8a56756..e66bb90bbd 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/InstantiatedVnfInfo.java @@ -13,7 +13,6 @@ package org.onap.so.adapters.vfc.model; import javax.validation.constraints.NotNull; import java.util.List; -import java.util.Map; public class InstantiatedVnfInfo { @NotNull diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java index 20c8972c98..2dff432c3b 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/model/NsLinkPortInfo.java @@ -12,7 +12,6 @@ package org.onap.so.adapters.vfc.model; import javax.validation.constraints.NotNull; -import java.util.List; public class NsLinkPortInfo { @NotNull diff --git a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java index a708c2641c..54a2a98a00 100644 --- a/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java +++ b/adapters/mso-vfc-adapter/src/main/java/org/onap/so/adapters/vfc/util/RestfulUtil.java @@ -28,7 +28,6 @@ import java.net.HttpURLConnection; import java.net.SocketTimeoutException; import java.util.Base64; import java.util.HashMap; -import java.util.List; import java.util.Map; import javax.ws.rs.core.UriBuilder; import org.onap.so.logger.LoggingAnchor; diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml deleted file mode 100644 index ab524ca808..0000000000 --- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml +++ /dev/null @@ -1,325 +0,0 @@ -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter</artifactId> - <version>1.6.0-SNAPSHOT</version> - </parent> - <artifactId>mso-vnfm-adapter-ext-clients</artifactId> - <properties> - <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> - <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> - <swagger-core-version>1.5.15</swagger-core-version> - <okhttp-version>2.7.5</okhttp-version> - <gson-fire-version>1.8.2</gson-fire-version> - <threetenbp-version>1.3.5</threetenbp-version> - <retrofit2-version>2.4.0</retrofit2-version> - <okhttp3-version>3.14.0</okhttp3-version> - <oltu-version>1.0.1</oltu-version> - </properties> - <name>mso-vnfm-adapter-ext-clients</name> - <description>Clients for the vnfm adpater to use towards REST endpoints which are external to the VNFM adapter/</description> - - <build> - <plugins> - <plugin> - <groupId>io.swagger</groupId> - <artifactId>swagger-codegen-maven-plugin</artifactId> - <version>2.3.1</version> - <executions> - <execution> - <id>sol003-vnf-lcm-api</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleManagement-API.json</inputSpec> - <language>java</language> - <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/sol003-vnf-lcm</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.model</modelPackage> - <configOptions> - <jackson>true</jackson> - <sourceFolder>src/gen/java/main</sourceFolder> - <withXml>true</withXml> - <useRxJava2>true</useRxJava2> - <serializableModel>true</serializableModel> - </configOptions> - </configuration> - </execution> - <execution> - <id>sol003-vnf-lcn-api</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleManagementNotification-API.json</inputSpec> - <language>java</language> - <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/sol003-vnf-lcn</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model</modelPackage> - <configOptions> - <sourceFolder>src/gen/java/main</sourceFolder> - <withXml>true</withXml> - <useRxJava2>true</useRxJava2> - <serializableModel>true</serializableModel> - </configOptions> - </configuration> - </execution> - <execution> - <id>sol003-vnf-grant-api</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json</inputSpec> - <language>java</language> - <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/sol003-vnf-grant</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model</modelPackage> - <configOptions> - <generateSupportingFiles>false</generateSupportingFiles> - <sourceFolder>src/gen/java/main</sourceFolder> - <withXml>true</withXml> - <useRxJava2>true</useRxJava2> - <serializableModel>true</serializableModel> - </configOptions> - </configuration> - </execution> - <execution> - <id>sol003-vnf-packagemanagement-api</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <inputSpec>${basedir}/src/main/resources/SOL003-VNFPackageManagement-API.json</inputSpec> - <language>java</language> - <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/sol003-vnf-packagemanagement</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.packagemanagement.model</modelPackage> - <configOptions> - <sourceFolder>src/gen/java/main</sourceFolder> - <withXml>true</withXml> - <useRxJava2>true</useRxJava2> - <serializableModel>true</serializableModel> - </configOptions> - </configuration> - </execution> - <execution> - <id>etsicatalog-api</id> - <goals> - <goal>generate</goal> - </goals> - <configuration> - <inputSpec>${basedir}/src/main/resources/ETSI-Catalog-API.json</inputSpec> - <language>java</language> - <library>okhttp-gson</library> - <output>${project.build.directory}/generated-sources/etsicatalog</output> - <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.api</apiPackage> - <modelPackage>org.onap.so.adapters.vnfmadapter.extclients.etsicatalog.model</modelPackage> - <configOptions> - <sourceFolder>src/gen/java/main</sourceFolder> - <withXml>true</withXml> - <useRxJava2>true</useRxJava2> - <serializableModel>true</serializableModel> - </configOptions> - </configuration> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>add-source</id> - <phase>generate-sources</phase> - <goals> - <goal>add-source</goal> - </goals> - <configuration> - <sources> - <source>${project.basedir}/target/generated-sources/etsicatalog/src/gen/java/main</source> - <source>${project.basedir}/target/generated-sources/sol003-vnf-packagemanagement/src/gen/java/main</source> - <source>${project.basedir}/target/generated-sources/sol003-vnf-grant/src/gen/java/main</source> - <source>${project.basedir}/target/generated-sources/sol003-vnf-lcn/src/gen/java/main</source> - <source>${project.basedir}/target/generated-sources/sol003-vnf-lcm/src/gen/java/main</source> - - </sources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - <pluginManagement> - <plugins> - <plugin> - <groupId>org.eclipse.m2e</groupId> - <artifactId>lifecycle-mapping</artifactId> - <version>1.0.0</version> - <configuration> - <lifecycleMappingMetadata> - <pluginExecutions> - <pluginExecution> - <pluginExecutionFilter> - <groupId>io.swagger</groupId> - <artifactId>swagger-codegen-maven-plugin</artifactId> - <goals> - <goal>generate</goal> - </goals> - <versionRange>[2.2.0,)</versionRange> - </pluginExecutionFilter> - <action> - <execute> - <runOnIncremental>false</runOnIncremental> - </execute> - </action> - </pluginExecution> - </pluginExecutions> - </lifecycleMappingMetadata> - </configuration> - </plugin> - </plugins> - </pluginManagement> - </build> - - <dependencies> - <dependency> - <groupId>io.swagger</groupId> - <artifactId>swagger-annotations</artifactId> - <version>${swagger-core-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>okhttp</artifactId> - <version>${okhttp-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp-version}</version> - </dependency> - <dependency> - <groupId>com.google.code.gson</groupId> - <artifactId>gson</artifactId> - </dependency> - <dependency> - <groupId>io.gsonfire</groupId> - <artifactId>gson-fire</artifactId> - <version>${gson-fire-version}</version> - </dependency> - <dependency> - <groupId>org.threeten</groupId> - <artifactId>threetenbp</artifactId> - <version>${threetenbp-version}</version> - </dependency> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>4.12</version> - <!-- the test code is generated into the main source code :( --> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.squareup.retrofit2</groupId> - <artifactId>converter-gson</artifactId> - <version>${retrofit2-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.retrofit2</groupId> - <artifactId>retrofit</artifactId> - <version>${retrofit2-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.retrofit2</groupId> - <artifactId>converter-scalars</artifactId> - <version>${retrofit2-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.retrofit2</groupId> - <artifactId>adapter-rxjava2</artifactId> - <version>${retrofit2-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp3</groupId> - <artifactId>okhttp</artifactId> - <version>${okhttp3-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp3</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp3-version}</version> - </dependency> - <dependency> - <groupId>com.squareup.okhttp</groupId> - <artifactId>logging-interceptor</artifactId> - <version>${okhttp-version}</version> - </dependency> - - <!-- Will clean these dependencies before commit From here--> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.client</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.common</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.client</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.httpclient4</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.dynamicreg.client</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.dynamicreg.common</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.authzserver</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.resourceserver</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.resourceserver-filter</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.dynamicreg.server</artifactId> - <version>${oltu-version}</version> - </dependency> - <dependency> - <groupId>org.apache.oltu.oauth2</groupId> - <artifactId>org.apache.oltu.oauth2.jwt</artifactId> - <version>${oltu-version}</version> - </dependency> - <!-- To here--> - - - - </dependencies> -</project> diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties deleted file mode 100644 index 86cc3f0a0e..0000000000 --- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/META-INF/services/org.onap.so.client.RestProperties +++ /dev/null @@ -1 +0,0 @@ -org.onap.so.adapters.vnfmadapter.extclients.aai.AaiPropertiesImpl
\ No newline at end of file diff --git a/adapters/mso-vnfm-adapter/pom.xml b/adapters/mso-vnfm-adapter/pom.xml deleted file mode 100644 index 3e295aa184..0000000000 --- a/adapters/mso-vnfm-adapter/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so</groupId> - <artifactId>adapters</artifactId> - <version>1.6.0-SNAPSHOT</version> - </parent> - <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-adapter</artifactId> - <name>MSO VNFM Adapter</name> - <description>MSO Adapter for VNFM</description> - <packaging>pom</packaging> - - <modules> - <module>mso-vnfm-adapter-api</module> - <module>mso-vnfm-adapter-ext-clients</module> - <module>mso-vnfm-etsi-adapter</module> - </modules> -</project> diff --git a/adapters/pom.xml b/adapters/pom.xml index 5d382fd4dd..7d2ad74c61 100644 --- a/adapters/pom.xml +++ b/adapters/pom.xml @@ -21,7 +21,7 @@ <module>mso-catalog-db-adapter</module> <module>mso-vfc-adapter</module> <module>mso-openstack-adapters</module> - <module>mso-vnfm-adapter</module> + <module>etsi-sol003-adapter</module> <module>mso-ve-vnfm-adapter</module> <module>mso-nssmf-adapter</module> <module>so-appc-orchestrator</module> diff --git a/adapters/so-appc-orchestrator/pom.xml b/adapters/so-appc-orchestrator/pom.xml index 66dcc4dd30..64eefaa151 100644 --- a/adapters/so-appc-orchestrator/pom.xml +++ b/adapters/so-appc-orchestrator/pom.xml @@ -14,7 +14,6 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> - <appc.client.version>1.7.1-SNAPSHOT</appc.client.version> </properties> <name>so-appc-orchestrator</name> <description>MSO APPC-C Orchestrator</description> diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java index f2c6b2f16a..37ad7db1c9 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java @@ -23,8 +23,6 @@ import org.onap.sdc.api.notification.INotificationData; import org.onap.sdc.api.notification.IResourceInstance; import org.onap.sdc.api.results.IDistributionClientDownloadResult; import org.onap.so.asdc.client.exceptions.ArtifactInstallerException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Abstract class to represent the resource structure. diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy deleted file mode 100644 index e8f842471c..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1.groovy +++ /dev/null @@ -1,458 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.bpmn.common.scripts - -import org.onap.so.logger.LoggingAnchor -import org.onap.so.client.HttpClientFactory -import org.onap.logging.filter.base.ErrorCode - -import javax.ws.rs.core.Response -import org.apache.commons.lang3.* -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution -import org.onap.so.bpmn.core.UrnPropertiesReader -import org.onap.so.client.HttpClient -import org.onap.so.logger.MessageEnum -import org.slf4j.Logger -import org.slf4j.LoggerFactory -import org.onap.logging.filter.base.ONAPComponents; -import java.util.UUID -import org.onap.so.utils.Components - - -@Deprecated //Use vnfAdapterRestV2 -class VnfAdapterRestV1 extends AbstractServiceTaskProcessor { - private static final Logger logger = LoggerFactory.getLogger( VnfAdapterRestV1.class); - - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - // VNF Response Processing - public void preProcessRequest (DelegateExecution execution) { - def method = getClass().getSimpleName() + '.preProcessRequest(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - def prefix="VNFREST_" - execution.setVariable("prefix", prefix) - setSuccessIndicator(execution, false) - - try { - String request = validateRequest(execution, "mso-request-id") - - // Get the request type (the name of the root element) from the request - - Node root = new XmlParser().parseText(request) - String requestType = root.name() - execution.setVariable(prefix + 'requestType', requestType) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType) - - logger.debug('VnfAdapterRestV1, request: ' + request) - // Get the messageId from the request - - String messageId = getChildText(root, 'messageId') - - if ('rollbackVolumeGroupRequest'.equals(requestType)) { - messageId = getMessageIdForVolumeGroupRollback(root) - } - - if (messageId == null || messageId.isEmpty()) { - String msg = getProcessKey(execution) + ': no messageId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - execution.setVariable('VNFAResponse_CORRELATOR', messageId) - logger.debug(getProcessKey(execution) + ': VNFAResponse_CORRELATOR = ' + messageId) - - // Get the notificationUrl from the request - - String notificationUrl = getChildText(root, 'notificationUrl') - - if (notificationUrl == null || notificationUrl.isEmpty()) { - String msg = getProcessKey(execution) + ': no notificationUrl in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - execution.setVariable(prefix + 'notificationUrl', notificationUrl) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'notificationUrl = ' + notificationUrl) - - // Determine the VnfAdapter endpoint - - String vnfAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.vnf.rest.endpoint", execution) - - if (vnfAdapterEndpoint == null || vnfAdapterEndpoint.isEmpty()) { - String msg = getProcessKey(execution) + ': mso:adapters:vnf:rest:endpoint URN mapping is not defined' - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - while (vnfAdapterEndpoint.endsWith('/')) { - vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, vnfAdapterEndpoint.length()-1) - } - - String vnfAdapterMethod = null - String vnfAdapterUrl = null - String vnfAdapterRequest = request - - if ('createVfModuleRequest'.equals(requestType)) { - String vnfId = getChildText(root, 'vnfId') - - if (vnfId == null || vnfId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'POST' - vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + '/vf-modules' - - } else if ('updateVfModuleRequest'.equals(requestType)) { - String vnfId = getChildText(root, 'vnfId') - - if (vnfId == null || vnfId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - String vfModuleId = getChildText(root, 'vfModuleId') - - if (vfModuleId == null || vfModuleId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'PUT' - vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + - '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') - - } else if ('deleteVfModuleRequest'.equals(requestType)) { - String vnfId = getChildText(root, 'vnfId') - - if (vnfId == null || vnfId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - String vfModuleId = getChildText(root, 'vfModuleId') - - if (vfModuleId == null || vfModuleId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'DELETE' - vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + - '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') - - } else if ('rollbackVfModuleRequest'.equals(requestType)) { - Node vfModuleRollbackNode = getChild(root, 'vfModuleRollback') - - if (vfModuleRollbackNode == null) { - String msg = getProcessKey(execution) + ': no vfModuleRollback in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - String vnfId = getChildText(vfModuleRollbackNode, 'vnfId') - - if (vnfId == null || vnfId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vnfId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - String vfModuleId = getChildText(vfModuleRollbackNode, 'vfModuleId') - - if (vfModuleId == null || vfModuleId.isEmpty()) { - String msg = getProcessKey(execution) + ': no vfModuleId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'DELETE' - vnfAdapterUrl = vnfAdapterEndpoint + '/' + URLEncoder.encode(vnfId, 'UTF-8') + - '/vf-modules/' + URLEncoder.encode(vfModuleId, 'UTF-8') + '/rollback' - - } else if ('createVolumeGroupRequest'.equals(requestType)) { - vnfAdapterMethod = 'POST' - if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { - vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) - } - vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups' - - } else if ('updateVolumeGroupRequest'.equals(requestType)) { - String volumeGroupId = getChildText(root, 'volumeGroupId') - - if (volumeGroupId == null || volumeGroupId.isEmpty()) { - String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'PUT' - if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { - vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) - } - vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') - - } else if ('deleteVolumeGroupRequest'.equals(requestType)) { - String volumeGroupId = getChildText(root, 'volumeGroupId') - - if (volumeGroupId == null || volumeGroupId.isEmpty()) { - String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'DELETE' - if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { - vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) - } - vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') - - } else if ('rollbackVolumeGroupRequest'.equals(requestType)) { - String volumeGroupId = getVolumeGroupIdFromRollbackRequest(root) - - if (volumeGroupId == null || volumeGroupId.isEmpty()) { - String msg = getProcessKey(execution) + ': no volumeGroupId in ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - vnfAdapterMethod = 'DELETE' - if (vnfAdapterEndpoint.endsWith('v1/vnfs')) { - vnfAdapterEndpoint = vnfAdapterEndpoint.substring(0, (vnfAdapterEndpoint.length()-'/vnfs'.length())) - } - vnfAdapterUrl = vnfAdapterEndpoint + '/volume-groups/' + URLEncoder.encode(volumeGroupId, 'UTF-8') + '/rollback' - - } else { - String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - execution.setVariable(prefix + 'vnfAdapterMethod', vnfAdapterMethod) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterMethod = ' + vnfAdapterMethod) - execution.setVariable(prefix + 'vnfAdapterUrl', vnfAdapterUrl) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterUrl = ' + vnfAdapterUrl) - execution.setVariable(prefix + 'vnfAdapterRequest', vnfAdapterRequest) - logger.debug(getProcessKey(execution) + ': ' + prefix + 'vnfAdapterRequest = \n' + vnfAdapterRequest) - - // Get the Basic Auth credentials for the VnfAdapter - - String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution) - - if (basicAuthValue == null || basicAuthValue.isEmpty()) { - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN", - ErrorCode.UnknownError.getValue()); - } else { - try { - def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution)) - execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString) - } catch (IOException ex) { - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - getProcessKey(execution) + ": Unable to encode BasicAuth credentials for VnfAdapter", - "BPMN", ErrorCode.UnknownError.getValue(), ex); - } - } - - } catch (BpmnError e) { - logger.debug(" Rethrowing MSOWorkflowException") - throw e - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - } - - public String getVolumeGroupIdFromRollbackRequest(Node root) { - return root.'volumeGroupRollback'.'volumeGroupId'.text() - } - - public String getMessageIdForVolumeGroupRollback(Node root) { - return root.'volumeGroupRollback'.'messageId'.text() - } - - /** - * This method is used instead of an HTTP Connector task because the - * connector does not allow DELETE with a body. - */ - public void sendRequestToVnfAdapter(DelegateExecution execution) { - def method = getClass().getSimpleName() + '.sendRequestToVnfAdapter(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String prefix = execution.getVariable('prefix') - - try { - String vnfAdapterMethod = execution.getVariable(prefix + 'vnfAdapterMethod') - String vnfAdapterUrl = execution.getVariable(prefix + 'vnfAdapterUrl') - String vnfAdapterRequest = execution.getVariable(prefix + 'vnfAdapterRequest') - - URL url = new URL(vnfAdapterUrl); - - HttpClient httpClient = new HttpClientFactory().newXmlClient(url, ONAPComponents.VNF_ADAPTER) - httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue")) - - httpClient.addAdditionalHeader("X-ONAP-RequestID", execution.getVariable("mso-request-id")) - httpClient.addAdditionalHeader("X-ONAP-InvocationID", UUID.randomUUID().toString()) - httpClient.addAdditionalHeader("X-ONAP-PartnerName", "SO-VNFAdapter") - Response response; - - if ("GET".equals(vnfAdapterMethod)) { - response = httpClient.get() - } else if ("PUT".equals(vnfAdapterMethod)) { - response = httpClient.put(vnfAdapterRequest) - } else if ("POST".equals(vnfAdapterMethod)) { - response = httpClient.post(vnfAdapterRequest) - } else if ("DELETE".equals(vnfAdapterMethod)) { - response = httpClient.delete(vnfAdapterRequest) - } else { - String msg = 'Unsupported HTTP method "' + vnfAdapterMethod + '" in ' + method + ": " + e - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - - execution.setVariable(prefix + "vnfAdapterStatusCode", response.getStatus()) - if(response.hasEntity()){ - execution.setVariable(prefix + "vnfAdapterResponse", response.readEntity(String.class)) - } - } catch (BpmnError e) { - throw e - } catch (Exception e) { - String msg = 'Caught exception in ' + method + ": " + e - logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN", - ErrorCode.UnknownError.getValue()); - exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg, ONAPComponents.SO) - } - } - - public void processCallback(DelegateExecution execution){ - def method = getClass().getSimpleName() + '.processCallback(' + - 'execution=' + execution.getId() + - ')' - logger.trace('Entered ' + method) - - String callback = execution.getVariable('VNFAResponse_MESSAGE') - - try { - logger.debug(getProcessKey(execution) + ": received callback:\n" + callback) - - // The XML callback is available to the calling flow in any case, - // even if a WorkflowException is generated. - execution.setVariable(getProcessKey(execution) + 'Response', callback) - // TODO: Should deprecate use of processKey+Response variable for the response. Will use "WorkflowResponse" instead. - execution.setVariable("WorkflowResponse", callback) - - callback = utils.removeXmlPreamble(callback) - - Node root = new XmlParser().parseText(callback) - if (root.name().endsWith('Exception')) { - vnfAdapterWorkflowException(execution, callback) - } - } catch (Exception e) { - logger.debug("Error encountered within VnfAdapterRest ProcessCallback method: {}", e.getMessage(), e) - exceptionUtil.buildAndThrowWorkflowException(execution, 7020, "Error encountered within VnfAdapterRest ProcessCallback method", ONAPComponents.SO) - } - } - - /** - * Tries to parse the response as XML to extract the information to create - * a WorkflowException. If the response cannot be parsed, a more generic - * WorkflowException is created. - */ - public void vnfAdapterWorkflowException(DelegateExecution execution, Object response) { - try { - Node root = new XmlParser().parseText(response) - String category = getChildText(root, "category") - category = category == null || category.isEmpty() ? "" : " category='" + category + "'" - String message = getChildText(root, "message") - message = message == null || message.isEmpty() ? "" : " message='" + message + "'" - String rolledBack = getChildText(root, "rolledBack") - rolledBack = rolledBack == null || rolledBack.isEmpty() ? "" : " rolledBack='" + rolledBack + "'" - exceptionUtil.buildWorkflowException(execution, 7020, "Received " + root.name() + - " from VnfAdapter:" + category + message + rolledBack, Components.OPENSTACK); - } catch (Exception e) { - response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response - exceptionUtil.buildWorkflowException(execution, 7020, "Received error from VnfAdapter: " + response, Components.OPENSTACK) - } - } - - /** - * Gets the named child of the specified node. - * @param node the node - * @param name the child name - * @return the child node, or null if no such child exists - */ - private Node getChild(Node node, String name) { - for (Node child : node.children()) { - if (child.name() == name) { - return child - } - } - return null - } - - /** - * Gets the text of the named child of the specified node. - * @param node the node - * @param name the child name - * @return the child node text, or null if no such child exists - */ - private String getChildText(Node node, String name) { - Node child = getChild(node, name) - return child == null ? null : child.text() - } - - public Logger getLogger() { - return logger; - } -} diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy deleted file mode 100644 index 91b29d3867..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterUtils.groovy +++ /dev/null @@ -1,97 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Modifications Copyright (c) 2019 Samsung - * ================================================================================ - * 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.bpmn.common.scripts - -import org.onap.so.logger.LoggingAnchor -import org.camunda.bpm.engine.delegate.BpmnError -import org.camunda.bpm.engine.delegate.DelegateExecution; -import org.onap.so.bpmn.core.WorkflowException -import org.onap.logging.filter.base.ErrorCode -import org.onap.so.logger.MessageEnum -import org.slf4j.Logger -import org.slf4j.LoggerFactory - - - -class VnfAdapterUtils { - private static final Logger logger = LoggerFactory.getLogger( VnfAdapterUtils.class); - - - private AbstractServiceTaskProcessor taskProcessor - - public VnfAdapterUtils(AbstractServiceTaskProcessor taskProcessor) { - this.taskProcessor = taskProcessor - } - - ExceptionUtil exceptionUtil = new ExceptionUtil() - - public void validateVnfResponse(DelegateExecution execution, String responseVar, String responseCodeVar, String errorResponseVar) { - def method = getClass().getSimpleName() + '.validateVnfResponse(' + - 'execution=' + execution.getId() + - ', responseVar=' + responseVar + - ', responseCodeVar=' + responseCodeVar + - ', errorResponseVar=' + errorResponseVar + - ')' - logger.trace('Entered ' + method) - - try { - def prefix = execution.getVariable('prefix') - - def response = execution.getVariable(responseVar) - def responseCode = execution.getVariable(responseCodeVar) - def errorResponse = execution.getVariable(errorResponseVar) - - // The following if statement never appears to be true as any VNF Adapter error seems to be stored in 'errorResponse'. - // Also, the value is stored as a WorkflowException object, not a String. Added the else if to provide the proper - // functionality but leaving the original code in case it is hit under some circumstances. - if (response.contains("WorkflowException")) { - execution.setVariable(prefix + "ErrorResponse", response) - //execution.setVariable(prefix + "ResponseCode", responseCode) - logger.debug(" Sub Vnf flow Error WorkflowException Response - " + "\n" + response) - throw new BpmnError("MSOWorkflowException") - } else if (errorResponse != null && errorResponse instanceof WorkflowException) { - // Not sure the variables with the associated prefix are still used - execution.setVariable(prefix + "ErrorResponse", errorResponse.getErrorMessage()) - execution.setVariable(prefix + "ResponseCode", errorResponse.getErrorCode()) - logger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage()) - // this is the important part to ensure we hit the Fallout Handler - throw new BpmnError("MSOWorkflowException") - } else if (errorResponse != null && errorResponse instanceof WorkflowException) { - // Not sure the variables with the associated prefix are still used - execution.setVariable(prefix + "ErrorResponse", errorResponse.getErrorMessage()) - execution.setVariable(prefix + "ResponseCode", errorResponse.getErrorCode()) - logger.debug("Sub Vnf flow Error WorkflowException " + prefix + "ErrorResponse" + " - " + errorResponse.getErrorMessage()) - // this is the important part to ensure we hit the Fallout Handler - throw new BpmnError("MSOWorkflowException") - } - } catch (BpmnError e) { - throw e; - } catch (Exception e) { - logger.error(LoggingAnchor.FIVE, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), - 'Caught exception in ' + method, "BPMN", - ErrorCode.UnknownError.getValue(), "Exception is:\n" + e); - exceptionUtil.buildAndThrowWorkflowException(execution, 5000, 'Internal Error- Unable to validate VNF Response ' + e.getMessage()) - } - } - -} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java index 9e9c4b5cfa..d966528f6c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/appc/payload/PayloadClient.java @@ -21,7 +21,6 @@ package org.onap.so.bpmn.appc.payload; import java.util.Optional; -import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersHealthCheck; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersQuiesce; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersResumeTraffic; import org.onap.so.bpmn.appc.payload.beans.ConfigurationParametersDistributeTraffic; diff --git a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn b/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn deleted file mode 100644 index db93df9f09..0000000000 --- a/bpmn/MSOCommonBPMN/src/main/resources/subprocess/VnfAdapterRestV1.bpmn +++ /dev/null @@ -1,441 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<bpmn2:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bpmn2="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xsi:schemaLocation="http://www.omg.org/spec/BPMN/20100524/MODEL BPMN20.xsd" id="_GraPIIyxEeWmdMDkx6Uftw" exporter="camunda modeler" exporterVersion="2.7.0" targetNamespace="http://camunda.org/schema/1.0/bpmn"> - <bpmn2:process id="vnfAdapterRestV1" name="vnfAdapterRestV1" isExecutable="true"> - <bpmn2:scriptTask id="ScriptTask_2" name="Log Response" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_3</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_14</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def vnfAdapterRestV1 = new VnfAdapterRestV1() -def statusCode = execution.getVariable('VNFREST_vnfAdapterStatusCode') -String response = String.valueOf(execution.getVariable('VNFREST_vnfAdapterResponse')) -def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled') -def processKey = vnfAdapterRestV1.getProcessKey(execution) -vnfAdapterRestV1.getLogger().debug("{} received response from VnfAdapter: statusCode= {} response={}", processKey, statusCode, (response.isEmpty() ? "" : "\n" + response))]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_3" name="Workflow Exception (no connection)"> - <bpmn2:incoming>SequenceFlow_17</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_35</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def exceptionUtil = new ExceptionUtil() -exceptionUtil.buildAndThrowWorkflowException(execution, 7000, "Failed to communicate with VnfAdapter")]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:scriptTask id="ScriptTask_4" name="Workflow Exception (bad response)" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_23</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_36</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* - -String res = execution.getVariable(VNFREST_vnfAdapterResponse) - -def vnfAdapterRestV1 = new VnfAdapterRestV1() -vnfAdapterRestV1.vnfAdapterWorkflowException(execution, res)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_14" name="" sourceRef="ScriptTask_2" targetRef="ExclusiveGateway_1"/> - <bpmn2:exclusiveGateway id="ExclusiveGateway_1" default="SequenceFlow_23"> - <bpmn2:incoming>SequenceFlow_14</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_17</bpmn2:outgoing> - <bpmn2:outgoing>SequenceFlow_23</bpmn2:outgoing> - <bpmn2:outgoing>SequenceFlow_24</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="SequenceFlow_17" name="404" sourceRef="ExclusiveGateway_1" targetRef="ScriptTask_3"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("VNFREST_vnfAdapterStatusCode") == '404'}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:sequenceFlow id="SequenceFlow_23" name="other" sourceRef="ExclusiveGateway_1" targetRef="ScriptTask_4"/> - <bpmn2:sequenceFlow id="SequenceFlow_24" name="2xx" sourceRef="ExclusiveGateway_1" targetRef="waitForAsyncMessage"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("VNFREST_vnfAdapterStatusCode") == '200' || execution.getVariable("VNFREST_vnfAdapterStatusCode") == '202'}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:boundaryEvent id="BoundaryEvent_1" name="Timeout" attachedToRef="waitForAsyncMessage"> - <bpmn2:outgoing>SequenceFlow_27</bpmn2:outgoing> - <bpmn2:timerEventDefinition id="TimerEventDefinition_1"> - <bpmn2:timeDuration xsi:type="bpmn2:tFormalExpression"><![CDATA[${UrnPropertiesReader.getVariable("mso.po.timeout", execution)}]]></bpmn2:timeDuration> - </bpmn2:timerEventDefinition> - </bpmn2:boundaryEvent> - <bpmn2:subProcess id="waitForAsyncMessage" name="Wait for Callback"> - <bpmn2:incoming>SequenceFlow_24</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_28</bpmn2:outgoing> - <bpmn2:intermediateCatchEvent id="IntermediateCatchEvent_1" name="Catch Event"> - <bpmn2:incoming>SequenceFlow_25</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_26</bpmn2:outgoing> - <bpmn2:messageEventDefinition id="MessageEventDefinition_1" messageRef="Message_1"/> - </bpmn2:intermediateCatchEvent> - <bpmn2:sequenceFlow id="SequenceFlow_26" name="" sourceRef="IntermediateCatchEvent_1" targetRef="EndEvent_2"/> - <bpmn2:startEvent id="StartEvent_3"> - <bpmn2:outgoing>SequenceFlow_25</bpmn2:outgoing> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_25" name="" sourceRef="StartEvent_3" targetRef="IntermediateCatchEvent_1"/> - <bpmn2:endEvent id="EndEvent_2"> - <bpmn2:incoming>SequenceFlow_26</bpmn2:incoming> - </bpmn2:endEvent> - </bpmn2:subProcess> - <bpmn2:sequenceFlow id="SequenceFlow_27" name="" sourceRef="BoundaryEvent_1" targetRef="ScriptTask_5"/> - <bpmn2:scriptTask id="ScriptTask_5" name="Workflow Exception (timeout)" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_27</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_34</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def exceptionUtil = new ExceptionUtil() -exceptionUtil.buildAndThrowWorkflowException(execution, 7010, "VnfAdapter Callback Timeout Error")]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_28" name="" sourceRef="waitForAsyncMessage" targetRef="ScriptTask_6"/> - <bpmn2:scriptTask id="ScriptTask_6" name="Process Callback" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_28</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_33</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def vnfAdapterRestV1 = new VnfAdapterRestV1() -vnfAdapterRestV1.processCallback(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_33" name="" sourceRef="ScriptTask_6" targetRef="ExclusiveGateway_2"/> - <bpmn2:sequenceFlow id="SequenceFlow_34" name="" sourceRef="ScriptTask_5" targetRef="EndEvent_8"/> - <bpmn2:endEvent id="EndEvent_8"> - <bpmn2:incoming>SequenceFlow_34</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_21" errorRef="Error_1"/> - </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_35" name="" sourceRef="ScriptTask_3" targetRef="EndEvent_9"/> - <bpmn2:endEvent id="EndEvent_9"> - <bpmn2:incoming>SequenceFlow_35</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_22" errorRef="Error_1"/> - </bpmn2:endEvent> - <bpmn2:endEvent id="EndEvent_10"> - <bpmn2:incoming>SequenceFlow_36</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_23" errorRef="Error_1"/> - </bpmn2:endEvent> - <bpmn2:sequenceFlow id="SequenceFlow_36" name="" sourceRef="ScriptTask_4" targetRef="EndEvent_10"/> - <bpmn2:endEvent id="EndEvent_7"> - <bpmn2:incoming>SequenceFlow_32</bpmn2:incoming> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_20" errorRef="Error_1"/> - </bpmn2:endEvent> - <bpmn2:exclusiveGateway id="ExclusiveGateway_2" name="Callback
Exception?" default="SequenceFlow_31"> - <bpmn2:incoming>SequenceFlow_33</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_31</bpmn2:outgoing> - <bpmn2:outgoing>SequenceFlow_32</bpmn2:outgoing> - </bpmn2:exclusiveGateway> - <bpmn2:sequenceFlow id="SequenceFlow_31" name="no" sourceRef="ExclusiveGateway_2" targetRef="ScriptTask_setSuccess"/> - <bpmn2:sequenceFlow id="SequenceFlow_32" name="yes" sourceRef="ExclusiveGateway_2" targetRef="EndEvent_7"> - <bpmn2:conditionExpression xsi:type="bpmn2:tFormalExpression"><![CDATA[#{execution.getVariable("WorkflowException") != null}]]></bpmn2:conditionExpression> - </bpmn2:sequenceFlow> - <bpmn2:scriptTask id="ScriptTask_setSuccess" name="Set Success Indicator" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_31</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_1</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def vnfAdapterRestV1 = new VnfAdapterRestV1() -vnfAdapterRestV1.setSuccessIndicator(execution, true)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_1" name="" sourceRef="ScriptTask_setSuccess" targetRef="EndEvent_6"/> - <bpmn2:endEvent id="EndEvent_6" name="End Flow"> - <bpmn2:incoming>SequenceFlow_1</bpmn2:incoming> - </bpmn2:endEvent> - <bpmn2:scriptTask id="ScriptTask_7" name="Send Request to Vnf Adapter" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_2</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_3</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def vnfAdapterRestV1 = new VnfAdapterRestV1() -vnfAdapterRestV1.sendRequestToVnfAdapter(execution)]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_3" name="" sourceRef="ScriptTask_7" targetRef="ScriptTask_2"/> - <bpmn2:subProcess id="SubProcess_1" name="Error Handling Sub Process" triggeredByEvent="true"> - <bpmn2:scriptTask id="ScriptTask_8" name="Process Error" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_4</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_5</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def exUtil = new ExceptionUtil() -exUtil.processSubflowsBPMNException(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_5" name="" sourceRef="ScriptTask_8" targetRef="EndEvent_1"/> - <bpmn2:endEvent id="EndEvent_1"> - <bpmn2:incoming>SequenceFlow_5</bpmn2:incoming> - </bpmn2:endEvent> - <bpmn2:startEvent id="StartEvent_2"> - <bpmn2:outgoing>SequenceFlow_4</bpmn2:outgoing> - <bpmn2:errorEventDefinition id="_ErrorEventDefinition_89"/> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_4" name="" sourceRef="StartEvent_2" targetRef="ScriptTask_8"/> - </bpmn2:subProcess> - <bpmn2:scriptTask id="ScriptTask_1" name="Pre-Process Request" scriptFormat="groovy"> - <bpmn2:incoming>SequenceFlow_9</bpmn2:incoming> - <bpmn2:outgoing>SequenceFlow_2</bpmn2:outgoing> - <bpmn2:script><![CDATA[import org.onap.so.bpmn.common.scripts.* -def vnfAdapterRestV1 = new VnfAdapterRestV1() -vnfAdapterRestV1.preProcessRequest(execution) -]]></bpmn2:script> - </bpmn2:scriptTask> - <bpmn2:sequenceFlow id="SequenceFlow_2" name="" sourceRef="ScriptTask_1" targetRef="ScriptTask_7"/> - <bpmn2:startEvent id="StartEvent_1" name="Start"> - <bpmn2:outgoing>SequenceFlow_9</bpmn2:outgoing> - </bpmn2:startEvent> - <bpmn2:sequenceFlow id="SequenceFlow_9" name="" sourceRef="StartEvent_1" targetRef="ScriptTask_1"/> - </bpmn2:process> - <bpmn2:error id="Error_1" errorCode="MSOWorkflowException" name="MSO Workflow Exception"/> - <bpmn2:message id="Message_1" name="WorkflowMessage"/> - <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="vnfAdapterRestV1"> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_56" bpmnElement="ScriptTask_1"> - <dc:Bounds height="80.0" width="100.0" x="204.0" y="148.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_14" bpmnElement="waitForAsyncMessage" isExpanded="true"> - <dc:Bounds height="154.0" width="265.0" x="744.0" y="275.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_58" bpmnElement="ScriptTask_6"> - <dc:Bounds height="80.0" width="100.0" x="1046.0" y="311.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_59" bpmnElement="ScriptTask_5"> - <dc:Bounds height="80.0" width="100.0" x="827.0" y="492.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_BoundaryEvent_24" bpmnElement="BoundaryEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="859.0" y="411.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="52.0" x="894.0" y="441.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_IntermediateCatchEvent_20" bpmnElement="IntermediateCatchEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="863.0" y="330.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="76.0" x="843.0" y="371.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_78" bpmnElement="ScriptTask_4"> - <dc:Bounds height="80.0" width="97.0" x="744.0" y="148.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_79" bpmnElement="ScriptTask_2"> - <dc:Bounds height="80.0" width="100.0" x="492.0" y="148.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_54" bpmnElement="StartEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="84.0" y="170.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="34.0" x="85.0" y="211.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_168" bpmnElement="ScriptTask_3"> - <dc:Bounds height="80.0" width="97.0" x="744.0" y="24.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_2" bpmnElement="SequenceFlow_9" sourceElement="_BPMNShape_StartEvent_54" targetElement="_BPMNShape_ScriptTask_56"> - <di:waypoint xsi:type="dc:Point" x="120.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="204.0" y="188.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="130.0" y="188.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_105" bpmnElement="ExclusiveGateway_1" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="624.0" y="162.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="649.0" y="217.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_18" bpmnElement="SequenceFlow_14" sourceElement="_BPMNShape_ScriptTask_79" targetElement="_BPMNShape_ExclusiveGateway_105"> - <di:waypoint xsi:type="dc:Point" x="592.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="624.0" y="187.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="611.0" y="187.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_19" bpmnElement="SequenceFlow_17" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_ScriptTask_168"> - <di:waypoint xsi:type="dc:Point" x="649.0" y="162.0"/> - <di:waypoint xsi:type="dc:Point" x="649.0" y="64.0"/> - <di:waypoint xsi:type="dc:Point" x="744.0" y="64.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="27.0" x="688.0" y="64.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_20" bpmnElement="SequenceFlow_23" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_ScriptTask_78"> - <di:waypoint xsi:type="dc:Point" x="674.0" y="187.0"/> - <di:waypoint xsi:type="dc:Point" x="709.0" y="187.0"/> - <di:waypoint xsi:type="dc:Point" x="709.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="744.0" y="188.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="35.0" x="684.0" y="188.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_25" bpmnElement="SequenceFlow_24" sourceElement="_BPMNShape_ExclusiveGateway_105" targetElement="_BPMNShape_SubProcess_14"> - <di:waypoint xsi:type="dc:Point" x="649.0" y="212.0"/> - <di:waypoint xsi:type="dc:Point" x="649.0" y="353.0"/> - <di:waypoint xsi:type="dc:Point" x="708.0" y="353.0"/> - <di:waypoint xsi:type="dc:Point" x="744.0" y="353.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="27.0" x="688.0" y="328.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_55" bpmnElement="StartEvent_3"> - <dc:Bounds height="36.0" width="36.0" x="768.0" y="330.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="786.0" y="371.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_27" bpmnElement="SequenceFlow_25" sourceElement="_BPMNShape_StartEvent_55" targetElement="_BPMNShape_IntermediateCatchEvent_20"> - <di:waypoint xsi:type="dc:Point" x="804.0" y="348.0"/> - <di:waypoint xsi:type="dc:Point" x="863.0" y="348.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="833.0" y="348.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_156" bpmnElement="EndEvent_2"> - <dc:Bounds height="36.0" width="36.0" x="948.0" y="330.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="966.0" y="371.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_28" bpmnElement="SequenceFlow_26" sourceElement="_BPMNShape_IntermediateCatchEvent_20" targetElement="_BPMNShape_EndEvent_156"> - <di:waypoint xsi:type="dc:Point" x="899.0" y="348.0"/> - <di:waypoint xsi:type="dc:Point" x="929.0" y="348.0"/> - <di:waypoint xsi:type="dc:Point" x="929.0" y="347.0"/> - <di:waypoint xsi:type="dc:Point" x="948.0" y="348.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="926.0" y="348.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_29" bpmnElement="SequenceFlow_27" sourceElement="_BPMNShape_BoundaryEvent_24" targetElement="_BPMNShape_ScriptTask_59"> - <di:waypoint xsi:type="dc:Point" x="877.0" y="447.0"/> - <di:waypoint xsi:type="dc:Point" x="877.0" y="492.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="874.0" y="472.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_30" bpmnElement="SequenceFlow_28" sourceElement="_BPMNShape_SubProcess_14" targetElement="_BPMNShape_ScriptTask_58"> - <di:waypoint xsi:type="dc:Point" x="1008.0" y="351.0"/> - <di:waypoint xsi:type="dc:Point" x="1046.0" y="351.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="1023.0" y="351.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ExclusiveGateway_106" bpmnElement="ExclusiveGateway_2" isMarkerVisible="true"> - <dc:Bounds height="50.0" width="50.0" x="1188.0" y="325.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="38.0" width="71.0" x="1179.0" y="288.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_158" bpmnElement="EndEvent_6"> - <dc:Bounds height="36.0" width="36.0" x="1463.0" y="333.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="60.0" x="1451.0" y="374.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_33" bpmnElement="SequenceFlow_31" sourceElement="_BPMNShape_ExclusiveGateway_106" targetElement="_BPMNShape_ScriptTask_236"> - <di:waypoint xsi:type="dc:Point" x="1238.0" y="350.0"/> - <di:waypoint xsi:type="dc:Point" x="1308.0" y="350.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="20.0" x="1248.0" y="350.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_159" bpmnElement="EndEvent_7"> - <dc:Bounds height="36.0" width="36.0" x="1196.0" y="426.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="1214.0" y="467.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_34" bpmnElement="SequenceFlow_32" sourceElement="_BPMNShape_ExclusiveGateway_106" targetElement="_BPMNShape_EndEvent_159"> - <di:waypoint xsi:type="dc:Point" x="1213.0" y="375.0"/> - <di:waypoint xsi:type="dc:Point" x="1213.0" y="392.0"/> - <di:waypoint xsi:type="dc:Point" x="1214.0" y="392.0"/> - <di:waypoint xsi:type="dc:Point" x="1214.0" y="426.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="22.0" width="27.0" x="1223.0" y="390.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_35" bpmnElement="SequenceFlow_33" sourceElement="_BPMNShape_ScriptTask_58" targetElement="_BPMNShape_ExclusiveGateway_106"> - <di:waypoint xsi:type="dc:Point" x="1146.0" y="351.0"/> - <di:waypoint xsi:type="dc:Point" x="1173.0" y="351.0"/> - <di:waypoint xsi:type="dc:Point" x="1173.0" y="350.0"/> - <di:waypoint xsi:type="dc:Point" x="1188.0" y="350.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="1170.0" y="350.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_160" bpmnElement="EndEvent_8"> - <dc:Bounds height="36.0" width="36.0" x="974.0" y="514.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="992.0" y="555.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_36" bpmnElement="SequenceFlow_34" sourceElement="_BPMNShape_ScriptTask_59" targetElement="_BPMNShape_EndEvent_160"> - <di:waypoint xsi:type="dc:Point" x="927.0" y="532.0"/> - <di:waypoint xsi:type="dc:Point" x="974.0" y="532.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="951.0" y="532.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_161" bpmnElement="EndEvent_9"> - <dc:Bounds height="36.0" width="36.0" x="891.0" y="46.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="909.0" y="87.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_37" bpmnElement="SequenceFlow_35" sourceElement="_BPMNShape_ScriptTask_168" targetElement="_BPMNShape_EndEvent_161"> - <di:waypoint xsi:type="dc:Point" x="840.0" y="64.0"/> - <di:waypoint xsi:type="dc:Point" x="891.0" y="64.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="865.0" y="64.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_162" bpmnElement="EndEvent_10"> - <dc:Bounds height="36.0" width="36.0" x="892.0" y="170.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="910.0" y="211.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_38" bpmnElement="SequenceFlow_36" sourceElement="_BPMNShape_ScriptTask_78" targetElement="_BPMNShape_EndEvent_162"> - <di:waypoint xsi:type="dc:Point" x="840.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="892.0" y="188.0"/> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_236" bpmnElement="ScriptTask_setSuccess"> - <dc:Bounds height="83.0" width="97.0" x="1308.0" y="309.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_1" bpmnElement="SequenceFlow_1" sourceElement="_BPMNShape_ScriptTask_236" targetElement="_BPMNShape_EndEvent_158"> - <di:waypoint xsi:type="dc:Point" x="1404.0" y="350.0"/> - <di:waypoint xsi:type="dc:Point" x="1422.0" y="350.0"/> - <di:waypoint xsi:type="dc:Point" x="1422.0" y="351.0"/> - <di:waypoint xsi:type="dc:Point" x="1463.0" y="351.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="1419.0" y="351.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_237" bpmnElement="ScriptTask_7"> - <dc:Bounds height="83.0" width="97.0" x="360.0" y="146.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_3" bpmnElement="SequenceFlow_2" sourceElement="_BPMNShape_ScriptTask_56" targetElement="_BPMNShape_ScriptTask_237"> - <di:waypoint xsi:type="dc:Point" x="304.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="344.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="344.0" y="187.0"/> - <di:waypoint xsi:type="dc:Point" x="360.0" y="187.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="317.0" y="188.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_4" bpmnElement="SequenceFlow_3" sourceElement="_BPMNShape_ScriptTask_237" targetElement="_BPMNShape_ScriptTask_79"> - <di:waypoint xsi:type="dc:Point" x="456.0" y="187.0"/> - <di:waypoint xsi:type="dc:Point" x="474.0" y="187.0"/> - <di:waypoint xsi:type="dc:Point" x="474.0" y="188.0"/> - <di:waypoint xsi:type="dc:Point" x="492.0" y="188.0"/> - </bpmndi:BPMNEdge> - <bpmndi:BPMNShape id="_BPMNShape_SubProcess_24" bpmnElement="SubProcess_1" isExpanded="true"> - <dc:Bounds height="181.0" width="382.0" x="180.0" y="532.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_StartEvent_66" bpmnElement="StartEvent_2"> - <dc:Bounds height="36.0" width="36.0" x="225.0" y="605.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="243.0" y="646.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_EndEvent_207" bpmnElement="EndEvent_1"> - <dc:Bounds height="36.0" width="36.0" x="477.0" y="605.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="0.0" width="0.0" x="495.0" y="646.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="_BPMNShape_ScriptTask_266" bpmnElement="ScriptTask_8"> - <dc:Bounds height="83.0" width="97.0" x="323.0" y="581.0"/> - </bpmndi:BPMNShape> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_5" bpmnElement="SequenceFlow_4" sourceElement="_BPMNShape_StartEvent_66" targetElement="_BPMNShape_ScriptTask_266"> - <di:waypoint xsi:type="dc:Point" x="261.0" y="623.0"/> - <di:waypoint xsi:type="dc:Point" x="323.0" y="622.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="273.0" y="623.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - <bpmndi:BPMNEdge id="BPMNEdge_SequenceFlow_6" bpmnElement="SequenceFlow_5" sourceElement="_BPMNShape_ScriptTask_266" targetElement="_BPMNShape_EndEvent_207"> - <di:waypoint xsi:type="dc:Point" x="419.0" y="622.0"/> - <di:waypoint xsi:type="dc:Point" x="477.0" y="623.0"/> - <bpmndi:BPMNLabel> - <dc:Bounds height="6.0" width="6.0" x="445.0" y="623.0"/> - </bpmndi:BPMNLabel> - </bpmndi:BPMNEdge> - </bpmndi:BPMNPlane> - </bpmndi:BPMNDiagram> -</bpmn2:definitions>
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy b/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy deleted file mode 100644 index 75ddca5e98..0000000000 --- a/bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/VnfAdapterRestV1Test.groovy +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.bpmn.common.scripts - -import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity -import org.junit.Before -import org.junit.Test -import org.junit.runner.RunWith -import org.mockito.MockitoAnnotations -import org.mockito.internal.debugging.MockitoDebuggerImpl -import org.mockito.runners.MockitoJUnitRunner -import org.onap.so.bpmn.mock.FileUtil - -import static org.mockito.Mockito.* -import static org.junit.Assert.*; - -@RunWith(MockitoJUnitRunner.class) -public class VnfAdapterRestV1Test { - - @Before - public void init() - { - MockitoAnnotations.initMocks(this) - } - - - @Test - public void testPreProcessRequest() { - - String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfadapter_request.xml"); - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - when(mockExecution.getVariable("prefix")).thenReturn("VNFREST_") - when(mockExecution.getVariable("mso-request-id")).thenReturn("testMsoRequestId") - when(mockExecution.getVariable("VNFREST_Request")).thenReturn(sdncAdapterWorkflowRequest) - when(mockExecution.getVariable("mso.adapters.po.auth")).thenReturn("5E12ACACBD552A415E081E29F2C4772F9835792A51C766CCFDD7433DB5220B59969CB2798C") - when(mockExecution.getVariable("mso.msoKey")).thenReturn("07a7159d3bf51a0e53be7a8f89699be7") - - when(mockExecution.getVariable("mso.adapters.vnf.rest.endpoint")).thenReturn("http://localhost:18080/vnfs/rest/v1/vnfs") - - when(mockExecution.getVariable("mso.adapters.sdnc.timeout")).thenReturn("PT5M") - - when(mockExecution.getVariable("isDebugLogEnabled")).thenReturn("true") - when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey") - - - VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1() - vnfAdapterRestV1.preProcessRequest(mockExecution) - - MockitoDebuggerImpl debugger = new MockitoDebuggerImpl() - //debugger.printInvocations(mockExecution) - - - verify(mockExecution).setVariable("prefix","VNFREST_") - - verify(mockExecution).setVariable("VNFREST_SuccessIndicator",false) - verify(mockExecution).setVariable("VNFREST_requestType","createVfModuleRequest") - verify(mockExecution).setVariable("VNFAResponse_CORRELATOR","8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000") - verify(mockExecution).setVariable("VNFREST_vnfAdapterMethod","POST") - verify(mockExecution).setVariable("VNFREST_notificationUrl","http://localhost:18080/mso/WorkflowMessage/VNFAResponse/8892cffa-3514-45d4-b2b0-0fde9a96e323-1511813289000") - verify(mockExecution).setVariable("VNFREST_vnfAdapterUrl","http://localhost:18080/vnfs/rest/v1/vnfs/6d2e2469-8708-47c3-a0d4-73fa28a8a50b/vf-modules") - - } - - String rollbackReq = """ -<rollbackVolumeGroupRequest> - <volumeGroupRollback> - <volumeGroupId>8a07b246-155e-4b08-b56e-76e98a3c2d66</volumeGroupId> - <volumeGroupStackId>phmaz401me6-vpevre-VOLUMEGROUP/dbd560b6-b03f-4a17-92e7-8942459a60c1</volumeGroupStackId> - <cloudSiteId>mtrnj1b</cloudSiteId> - <cloudOwnerId>CloudOwner</cloudOwnerId> - <tenantId>cfb5e0a790374c9a98a1c0d2044206a7</tenantId> - <volumeGroupCreated>true</volumeGroupCreated> - <msoRequest> - <requestId>1e1a72ca-7300-4ac4-b718-30351f3b6845</requestId> - <serviceInstanceId>15eb2c68-f771-4030-b185-cff179fdad44</serviceInstanceId> - </msoRequest> - <messageId>683ca1ac-2145-4a00-9484-20d48bd701aa</messageId> - </volumeGroupRollback> - <skipAAI>true</skipAAI> - <notificationUrl>http://localhost:8080/mso/WorkflowMessage/VNFAResponse/683ca1ac-2145-4a00-9484-20d48bd701aa</notificationUrl> -</rollbackVolumeGroupRequest> -""" - - @Test - public void testGetVolumeGroupId() { - Node root = new XmlParser().parseText(rollbackReq) - VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1() - def volGrpId = vnfAdapterRestV1.getVolumeGroupIdFromRollbackRequest(root) - assertEquals('8a07b246-155e-4b08-b56e-76e98a3c2d66', volGrpId) - } - - - @Test - public void testGetMessageId() { - Node root = new XmlParser().parseText(rollbackReq) - - VnfAdapterRestV1 p = new VnfAdapterRestV1() - def messageId = p.getMessageIdForVolumeGroupRollback(root) - assertEquals('683ca1ac-2145-4a00-9484-20d48bd701aa', messageId) - } - - @Test - public void testProcessCallback() { - - String sdncAdapterWorkflowRequest = FileUtil.readResourceFile("__files/vnfAdapterMocks/vnfAdapterCallback.xml"); - ExecutionEntity mockExecution = mock(ExecutionEntity.class) - - when(mockExecution.getVariable("VNFAResponse_MESSAGE")).thenReturn(sdncAdapterWorkflowRequest) - when(mockExecution.getVariable("testProcessKey")).thenReturn("testProcessKey") - - VnfAdapterRestV1 vnfAdapterRestV1 = new VnfAdapterRestV1() - vnfAdapterRestV1.processCallback(mockExecution) - - verify(mockExecution).setVariable("testProcessKeyResponse" ,sdncAdapterWorkflowRequest) - - } -} diff --git a/bpmn/pom.xml b/bpmn/pom.xml index e680cb025c..4ef4eb74dd 100644 --- a/bpmn/pom.xml +++ b/bpmn/pom.xml @@ -25,7 +25,6 @@ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <sdnc.northbound.version>1.5.2</sdnc.northbound.version> - <appc.client.version>1.7.1-SNAPSHOT</appc.client.version> </properties> <modules> diff --git a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn index 279fdc0983..f12a3d241f 100644 --- a/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn +++ b/bpmn/so-bpmn-building-blocks/src/main/resources/subprocess/BuildingBlock/ControllerExecutionBB.bpmn @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:camunda="http://camunda.org/schema/1.0/bpmn" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1ahlzqg" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="1.14.0"> - <bpmn:process id="ControllerExecution" name="ControllerExecutionBB" isExecutable="true"> + <bpmn:process id="ControllerExecutionBB" name="ControllerExecutionBB" isExecutable="true"> <bpmn:startEvent id="StartEvent_1"> <bpmn:outgoing>SequenceFlow_0gmfit3</bpmn:outgoing> </bpmn:startEvent> @@ -86,7 +86,7 @@ </bpmn:process> <bpmn:error id="Error_0aovtfv" name="MSOWorkflowException" errorCode="MSOWorkflowException" /> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> - <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ControllerExecution"> + <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="ControllerExecutionBB"> <bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1"> <dc:Bounds x="160" y="323" width="36" height="36" /> <bpmndi:BPMNLabel> diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java index f4e4ce8cb1..acb2e452da 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClient.java @@ -24,7 +24,6 @@ import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; @@ -41,8 +40,4 @@ public interface VnfVolumeAdapterClient { UpdateVolumeGroupResponse updateVNFVolumes(String aaiVolumeGroupId, UpdateVolumeGroupRequest req) throws VnfAdapterClientException; - - QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId, - String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) - throws VnfAdapterClientException; } diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java index c5e8bf7416..073b752348 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/adapter/vnf/VnfVolumeAdapterClientImpl.java @@ -27,7 +27,6 @@ import org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest; import org.onap.so.adapters.vnfrest.CreateVolumeGroupResponse; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupRequest; import org.onap.so.adapters.vnfrest.DeleteVolumeGroupResponse; -import org.onap.so.adapters.vnfrest.QueryVolumeGroupResponse; import org.onap.so.adapters.vnfrest.RollbackVolumeGroupRequest; import org.onap.so.adapters.vnfrest.RollbackVolumeGroupResponse; import org.onap.so.adapters.vnfrest.UpdateVolumeGroupRequest; @@ -93,20 +92,6 @@ public class VnfVolumeAdapterClientImpl implements VnfVolumeAdapterClient { } } - @Override - public QueryVolumeGroupResponse queryVNFVolumes(String aaiVolumeGroupId, String cloudSiteId, String tenantId, - String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) - throws VnfAdapterClientException { - try { - String path = buildQueryPath(aaiVolumeGroupId, cloudSiteId, tenantId, volumeGroupStackId, skipAAI, - requestId, serviceInstanceId); - return this.getAdapterRestClient(path).get(QueryVolumeGroupResponse.class).get(); - } catch (InternalServerErrorException e) { - logger.error("InternalServerErrorException in queryVNFVolumes", e); - throw new VnfAdapterClientException(e.getMessage()); - } - } - protected String buildQueryPath(String aaiVolumeGroupId, String cloudSiteId, String tenantId, String volumeGroupStackId, Boolean skipAAI, String requestId, String serviceInstanceId) { javax.ws.rs.core.UriBuilder builder = this.getUri("/" + aaiVolumeGroupId); diff --git a/common/pom.xml b/common/pom.xml index d373d620cd..b998a0adfa 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -16,7 +16,6 @@ <protobuf.version>3.6.1</protobuf.version> <grpc.netty.version>4.1.30.Final</grpc.netty.version> <ccsdk.version>0.4.2</ccsdk.version> - <appc.client.version>1.7.1-SNAPSHOT</appc.client.version> </properties> <dependencies> diff --git a/docs/architecture/architecture.rst b/docs/architecture/architecture.rst index a75591b885..d59429a366 100644 --- a/docs/architecture/architecture.rst +++ b/docs/architecture/architecture.rst @@ -16,6 +16,8 @@ SO Deployment View .. image:: ../images/SO_Architecture_Internal.png +.. image:: ../images/so-architecture.png + SO Sub-Components ------------------ diff --git a/docs/images/so-architecture.png b/docs/images/so-architecture.png Binary files differnew file mode 100644 index 0000000000..3904c46cf3 --- /dev/null +++ b/docs/images/so-architecture.png diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml index 3a9ec375da..538f13c7ec 100644 --- a/packages/docker/pom.xml +++ b/packages/docker/pom.xml @@ -95,7 +95,7 @@ <dependencySets> <dependencySet> <includes> - <include>org.onap.so.adapters:mso-vnfm-etsi-adapter</include> + <include>org.onap.so.adapters:etsi-sol003-adapter-application</include> </includes> <outputFileNameMapping>app.jar</outputFileNameMapping> </dependencySet> @@ -249,29 +249,29 @@ </build> </image> <image> - <name>${docker.image.prefix}/nssmf-adapter</name> + <name>${docker.image.prefix}/nssmf-adapter</name> <build> - <cleanup>try</cleanup> - <dockerFile>docker-files/Dockerfile.so-app</dockerFile> - <tags> - <tag>${project.version}</tag> - <tag>${project.version}-${maven.build.timestamp}</tag> - <tag>${project.docker.latesttag.version}</tag> - </tags> - <assembly> - <inline> - <dependencySets> - <dependencySet> - <includes> - <include>org.onap.so.adapters:mso-nssmf-adapter</include> - </includes> - <outputFileNameMapping>app.jar</outputFileNameMapping> - </dependencySet> - </dependencySets> - </inline> - </assembly> - </build> - </image> + <cleanup>try</cleanup> + <dockerFile>docker-files/Dockerfile.so-app</dockerFile> + <tags> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}</tag> + <tag>${project.docker.latesttag.version}</tag> + </tags> + <assembly> + <inline> + <dependencySets> + <dependencySet> + <includes> + <include>org.onap.so.adapters:mso-nssmf-adapter</include> + </includes> + <outputFileNameMapping>app.jar</outputFileNameMapping> + </dependencySet> + </dependencySets> + </inline> + </assembly> + </build> + </image> <image> <name>${docker.image.prefix}/so-appc-orchestrator</name> <build> @@ -467,7 +467,7 @@ <dependencies> <dependency> <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-vnfm-etsi-adapter</artifactId> + <artifactId>etsi-sol003-adapter-application</artifactId> <version>${project.version}</version> </dependency> <dependency> @@ -71,6 +71,7 @@ <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> <io.fabric8.version>4.1.0</io.fabric8.version> + <appc.client.version>1.7.1</appc.client.version> </properties> <distributionManagement> <repository> @@ -560,7 +561,7 @@ <images> <image> <alias>service</alias> - <name>${artifactId}:${project.version}</name> + <name>${project.artifactId}:${project.version}</name> <build> <dockerFileDir>${project.build.directory}</dockerFileDir> </build> @@ -670,17 +671,14 @@ <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-slf4j</artifactId> - <version>1.6.6</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-base</artifactId> - <version>1.6.6</version> </dependency> <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-filter-spring</artifactId> - <version>1.6.6</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> @@ -830,6 +828,21 @@ <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <!-- force use of version 4.5 everywhere in transient deps, aligned on WildFly 10 version --> <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-slf4j</artifactId> + <version>1.6.6</version> + </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-filter-base</artifactId> + <version>1.6.6</version> + </dependency> + <dependency> + <groupId>org.onap.logging-analytics</groupId> + <artifactId>logging-filter-spring</artifactId> + <version>1.6.6</version> + </dependency> + <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpcore</artifactId> <version>4.4.4</version> diff --git a/so-simulator/pom.xml b/so-simulator/pom.xml index 35964d6de6..e264c534d2 100644 --- a/so-simulator/pom.xml +++ b/so-simulator/pom.xml @@ -62,7 +62,6 @@ <dependency> <groupId>org.onap.logging-analytics</groupId> <artifactId>logging-slf4j</artifactId> - <version>1.6.3-SNAPSHOT</version> </dependency> <dependency> <groupId>com.consol.citrus</groupId> diff --git a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryStackByIdDoubleFailure.java b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryStackByIdDoubleFailure.java index 2fa8725d56..a9f879413f 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryStackByIdDoubleFailure.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/scenarios/openstack/QueryStackByIdDoubleFailure.java @@ -39,23 +39,18 @@ public class QueryStackByIdDoubleFailure extends AbstractSimulatorScenario { scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); - // Rollback Delete of the stack - scenario.http().receive().delete(); // step 7 - scenario.action(new DeleteVServers()); - scenario.http().send().response(HttpStatus.NO_CONTENT); - // Rollback Poll - scenario.http().receive().get(); // step 10 + scenario.http().receive().get(); // step 7 scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); // Rollback Poll Retry - scenario.http().receive().get(); + scenario.http().receive().get(); // step 9 scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); // Create Poll - scenario.http().receive().get(); // step 14 + scenario.http().receive().get(); // step 11 scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); @@ -64,30 +59,16 @@ public class QueryStackByIdDoubleFailure extends AbstractSimulatorScenario { scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); - // Rollback Delete - scenario.http().receive().delete(); - scenario.action(new DeleteVServers()); - scenario.http().send().response(HttpStatus.NO_CONTENT); - // Rollback Poll - scenario.http().receive().get(); // step 18 + scenario.http().receive().get(); // step 15 scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); // Rollback Poll Retry - scenario.http().receive().get(); + scenario.http().receive().get(); // step 17 scenario.http().send().response(HttpStatus.OK) .payload(new ClassPathResource("openstack/gr_api/Stack_Failure.json")); - // Delete - scenario.http().receive().delete(); - scenario.http().send().response(HttpStatus.NO_CONTENT); - - // Delete Poll - scenario.http().receive().get(); - scenario.http().send().response(HttpStatus.OK) - .payload(new ClassPathResource("openstack/gr_api/Stack_Deleted.json")); - } } |