aboutsummaryrefslogtreecommitdiffstats
path: root/asdc-controller
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-08 14:14:34 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-08 14:24:59 -0400
commitf47919f1fe367b612fa9c96d34c59f01a541e882 (patch)
tree5b6aa2fc36747d868897e68ccbec0c6db0aee81c /asdc-controller
parent54452b80a1cf4d22ef750bc1377f8c1b05431d57 (diff)
Replaced all tabs with spaces in java and pom.xml
Added in maven plugins to enforce coding style rules Added in eclipse java formatting xml Change-Id: I3727bbf4ce8dc66abfd8ad21b6cfd0890c5d3ff0 Issue-ID: SO-1765 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'asdc-controller')
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java45
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/Application.java44
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java54
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java30
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java47
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java29
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java269
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java315
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCControllerStatus.java2
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCNotificationCallBack.java13
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java60
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/DistributionStatusMessage.java95
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java119
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java63
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCControllerException.java22
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCDownloadException.java22
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCParametersException.java20
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerException.java20
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java317
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulator.java282
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java177
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java122
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java348
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java298
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java112
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java354
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/BigDecimalVersion.java42
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/IArtifactOrchestrator.java6
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfModuleData.java36
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfResourceInstaller.java4
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java25
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java25
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java23
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java884
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java125
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleMetaData.java97
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java109
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java27
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java238
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java4569
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java71
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/DistributionStatus.java5
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java316
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java1860
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/NotificationLogging.java249
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/ToLog.java1
-rw-r--r--asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java92
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java36
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java6
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java36
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java68
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java62
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java20
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java113
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java179
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java96
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java27
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java33
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java234
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java43
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java44
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java32
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java286
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java8
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java46
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java53
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java34
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java195
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java37
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java95
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java165
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java28
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java2
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java623
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java55
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java193
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java300
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java71
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java32
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java140
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java112
-rw-r--r--asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java26
86 files changed, 7870 insertions, 7897 deletions
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
index 9e75c7c339..a5e3340c76 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/ASDCControllerSingleton.java
@@ -23,7 +23,6 @@
package org.onap.so.asdc;
import javax.annotation.PreDestroy;
-
import org.onap.so.asdc.client.ASDCController;
import org.onap.so.asdc.client.exceptions.ASDCControllerException;
import org.slf4j.Logger;
@@ -38,32 +37,32 @@ import java.security.SecureRandom;
@Component
@Profile("!test")
public class ASDCControllerSingleton {
-
-
+
+
@Autowired
private ASDCController asdcController;
private static Logger logger = LoggerFactory.getLogger(ASDCControllerSingleton.class);
-
- @Scheduled (fixedRate = 50000)
- public void periodicControllerTask() {
- try {
- int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE);
- asdcController.setControllerName("mso-controller" + randomNumber);
- asdcController.initASDC();
- } catch (ASDCControllerException e) {
- logger.error("Exception occurred", e);
- }
- }
-
- @PreDestroy
- private void terminate () {
- try {
- asdcController.closeASDC();
- } catch (ASDCControllerException e) {
- logger.error("Exception occurred", e);
- }
- }
+
+ @Scheduled(fixedRate = 50000)
+ public void periodicControllerTask() {
+ try {
+ int randomNumber = new SecureRandom().nextInt(Integer.MAX_VALUE);
+ asdcController.setControllerName("mso-controller" + randomNumber);
+ asdcController.initASDC();
+ } catch (ASDCControllerException e) {
+ logger.error("Exception occurred", e);
+ }
+ }
+
+ @PreDestroy
+ private void terminate() {
+ try {
+ asdcController.closeASDC();
+ } catch (ASDCControllerException e) {
+ logger.error("Exception occurred", e);
+ }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java
index 2f56668c74..1f66291283 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/Application.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/Application.java
@@ -24,29 +24,29 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
-@SpringBootApplication(scanBasePackages = { "org.onap.so" })
+@SpringBootApplication(scanBasePackages = {"org.onap.so"})
@EnableScheduling
public class Application {
- private static final String MSO_CONFIG_PATH = "mso.config.path";
- private static final String LOGS_DIR = "logs_dir";
-
- private static void setLogsDir() {
- if (System.getProperty(LOGS_DIR) == null) {
- System.getProperties().setProperty(LOGS_DIR, "./logs/asdc/");
- }
- }
-
- private static void setConfigPath() {
- if(System.getProperty(MSO_CONFIG_PATH) == null)
- System.getProperties().setProperty(MSO_CONFIG_PATH, ".");
- }
-
- public static void main(String[] args) {
- SpringApplication.run(Application.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
-
- System.getProperties().setProperty("server.name", "Springboot");
- setLogsDir();
- }
+ private static final String MSO_CONFIG_PATH = "mso.config.path";
+ private static final String LOGS_DIR = "logs_dir";
+
+ private static void setLogsDir() {
+ if (System.getProperty(LOGS_DIR) == null) {
+ System.getProperties().setProperty(LOGS_DIR, "./logs/asdc/");
+ }
+ }
+
+ private static void setConfigPath() {
+ if (System.getProperty(MSO_CONFIG_PATH) == null)
+ System.getProperties().setProperty(MSO_CONFIG_PATH, ".");
+ }
+
+ public static void main(String[] args) {
+ SpringApplication.run(Application.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+
+ System.getProperties().setProperty("server.name", "Springboot");
+ setLogsDir();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
index 953c517702..3494945020 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/CatalogDBConfig.java
@@ -39,41 +39,31 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "entityManagerFactory",
- basePackages = {"org.onap.so.db.catalog.data.repository"}
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.db.catalog.data.repository"})
@Profile({"!test"})
public class CatalogDBConfig {
-
- @Primary
- @Bean(name = "dataSource")
- @ConfigurationProperties(prefix = "spring.datasource")
- public DataSource dataSource() {
- return DataSourceBuilder.create().build();
- }
- @Primary
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("dataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.catalog.beans")
- .persistenceUnit("catalogDB")
- .build();
- }
+ @Primary
+ @Bean(name = "dataSource")
+ @ConfigurationProperties(prefix = "spring.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
- @Primary
- @Bean(name = "transactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("entityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("dataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.catalog.beans").persistenceUnit("catalogDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java
index 3a26b7b60c..902506974a 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/JerseyConfiguration.java
@@ -34,19 +34,19 @@ import io.swagger.jaxrs.listing.SwaggerSerializers;
public class JerseyConfiguration extends ResourceConfig {
- @PostConstruct
- public void setUp() {
- register(ASDCRestInterface.class);
- register(ApiListingResource.class);
- register(SwaggerSerializers.class);
-
- BeanConfig beanConfig = new BeanConfig();
- beanConfig.setVersion("1.0.2");
- beanConfig.setSchemes(new String[] { "http" });
- beanConfig.setHost("localhost:8080");
- beanConfig.setBasePath("/mso");
- beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
- beanConfig.setPrettyPrint(true);
- beanConfig.setScan(true);
- }
+ @PostConstruct
+ public void setUp() {
+ register(ASDCRestInterface.class);
+ register(ApiListingResource.class);
+ register(SwaggerSerializers.class);
+
+ BeanConfig beanConfig = new BeanConfig();
+ beanConfig.setVersion("1.0.2");
+ beanConfig.setSchemes(new String[] {"http"});
+ beanConfig.setHost("localhost:8080");
+ beanConfig.setBasePath("/mso");
+ beanConfig.setResourcePackage("org.onap.so.apihandlerinfra");
+ beanConfig.setPrettyPrint(true);
+ beanConfig.setScan(true);
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
index c623552113..8320da01cf 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/RequestDBConfig.java
@@ -23,7 +23,6 @@ package org.onap.so.asdc;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -39,40 +38,30 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
@Configuration
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository" }
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
@Profile({"!test"})
public class RequestDBConfig {
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "request.datasource")
- public DataSource dataSource() {
- return DataSourceBuilder.create().build();
- }
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "request.datasource")
+ public DataSource dataSource() {
+ return DataSourceBuilder.create().build();
+ }
- @Bean(name = "requestEntityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("requestDataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.request.beans")
- .persistenceUnit("requestDB")
- .build();
- }
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
- @Bean(name = "requestTransactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("requestEntityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java
index 2383e7d810..b45b4f0749 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/WebSecurityConfigImpl.java
@@ -31,21 +31,18 @@ import org.springframework.util.StringUtils;
@EnableWebSecurity
public class WebSecurityConfigImpl extends WebSecurityConfig {
- @Override
- protected void configure(HttpSecurity http) throws Exception {
- http.csrf().disable()
- .authorizeRequests()
- .antMatchers("/manage/health","/manage/info").permitAll()
- .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(),","))
- .and()
- .httpBasic();
- }
-
- @Override
- public void configure(WebSecurity web) throws Exception {
- super.configure(web);
- StrictHttpFirewall firewall = new MSOSpringFirewall();
- web.httpFirewall(firewall);
- }
+ @Override
+ protected void configure(HttpSecurity http) throws Exception {
+ http.csrf().disable().authorizeRequests().antMatchers("/manage/health", "/manage/info").permitAll()
+ .antMatchers("/**").hasAnyRole(StringUtils.collectionToDelimitedString(getRoles(), ",")).and()
+ .httpBasic();
+ }
+
+ @Override
+ public void configure(WebSecurity web) throws Exception {
+ super.configure(web);
+ StrictHttpFirewall firewall = new MSOSpringFirewall();
+ web.httpFirewall(firewall);
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java
index 20e7c873e6..7d92c637ad 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCConfiguration.java
@@ -27,7 +27,6 @@ import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-
import org.onap.sdc.api.consumer.IConfiguration;
import org.onap.so.utils.CryptoUtils;
import org.slf4j.Logger;
@@ -44,7 +43,7 @@ public class ASDCConfiguration implements IConfiguration {
// echo -n "This is a test string" | openssl aes-128-ecb -e -K 546573746F736973546573746F736973 -nosalt | xxd
private static Logger logger = LoggerFactory.getLogger(ASDCConfiguration.class);
-
+
private String asdcControllerName;
@@ -66,199 +65,193 @@ public class ASDCConfiguration implements IConfiguration {
public static final String KEY_STORE_PASSWORD = "keyStorePassword";
public static final String KEY_STORE_PATH = "keyStorePath";
- public static final String HEAT="HEAT";
- public static final String HEAT_ARTIFACT="HEAT_ARTIFACT";
- public static final String HEAT_ENV="HEAT_ENV";
- public static final String HEAT_NESTED="HEAT_NESTED";
- public static final String HEAT_NET="HEAT_NET";
- public static final String HEAT_VOL="HEAT_VOL";
- public static final String OTHER="OTHER";
- public static final String TOSCA_CSAR="TOSCA_CSAR";
- public static final String WORKFLOWS="Workflows";
- public static final String VF_MODULES_METADATA="VF_MODULES_METADATA";
-
- private static final String[] SUPPORTED_ARTIFACT_TYPES = {HEAT,
- HEAT_ARTIFACT,
- HEAT_ENV,
- HEAT_NESTED,
- HEAT_NET,
- HEAT_VOL,
- OTHER,
- TOSCA_CSAR,
- VF_MODULES_METADATA};
-
- public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
+ public static final String HEAT = "HEAT";
+ public static final String HEAT_ARTIFACT = "HEAT_ARTIFACT";
+ public static final String HEAT_ENV = "HEAT_ENV";
+ public static final String HEAT_NESTED = "HEAT_NESTED";
+ public static final String HEAT_NET = "HEAT_NET";
+ public static final String HEAT_VOL = "HEAT_VOL";
+ public static final String OTHER = "OTHER";
+ public static final String TOSCA_CSAR = "TOSCA_CSAR";
+ public static final String WORKFLOWS = "Workflows";
+ public static final String VF_MODULES_METADATA = "VF_MODULES_METADATA";
+
+ private static final String[] SUPPORTED_ARTIFACT_TYPES =
+ {HEAT, HEAT_ARTIFACT, HEAT_ENV, HEAT_NESTED, HEAT_NET, HEAT_VOL, OTHER, TOSCA_CSAR, VF_MODULES_METADATA};
+
+ public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST =
+ Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES));
@Autowired
private Environment env;
-
+
@Value("${mso.asdc.config.key}")
private String configKey;
-
- @Value("${mso.asdc-connections.asdc-controller1.messageBusAddress}")
+
+ @Value("${mso.asdc-connections.asdc-controller1.messageBusAddress}")
private String[] messageBusAddress;
-
-
+
+
public void setAsdcControllerName(String asdcControllerName) {
- this.asdcControllerName = asdcControllerName;
- }
+ this.asdcControllerName = asdcControllerName;
+ }
- @Override
+ @Override
public java.lang.Boolean isUseHttpsWithDmaap() {
- return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.useHttpsWithDmaap", true);
+ return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.useHttpsWithDmaap", true);
}
-
+
@Override
- public boolean isConsumeProduceStatusTopic(){
- return true;
+ public boolean isConsumeProduceStatusTopic() {
+ return true;
}
-
+
@Override
- public List<String> getMsgBusAddress(){
+ public List<String> getMsgBusAddress() {
if (messageBusAddress.length > 0) {
- return Arrays.asList(messageBusAddress);
+ return Arrays.asList(messageBusAddress);
} else {
return Collections.emptyList();
- }
-
-
+ }
+
+
}
-
- public String getAsdcControllerName () {
+
+ public String getAsdcControllerName() {
return asdcControllerName;
}
- @Override
- public String getConsumerGroup() {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.consumerGroup");
- }
-
- public int getWatchDogTimeout () {
- return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.watchDogTimeout");
-
+ @Override
+ public String getConsumerGroup() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.consumerGroup");
+ }
+
+ public int getWatchDogTimeout() {
+ return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.watchDogTimeout");
+
}
@Override
- public String getConsumerID () {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.consumerId");
+ public String getConsumerID() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.consumerId");
}
-
- public int getIntegerPropertyOrZero (String propertyName) {
- String property = env.getProperty(propertyName);
- if (property == null || "NULL".equals(property) || property.isEmpty()) {
- return 0;
- } else {
- try {
- return Integer.parseInt(property);
- } catch (NumberFormatException e) {
- return 0;
- }
- }
+
+ public int getIntegerPropertyOrZero(String propertyName) {
+ String property = env.getProperty(propertyName);
+ if (property == null || "NULL".equals(property) || property.isEmpty()) {
+ return 0;
+ } else {
+ try {
+ return Integer.parseInt(property);
+ } catch (NumberFormatException e) {
+ return 0;
+ }
+ }
+ }
+
+ public String getPropertyOrNull(String propertyName) {
+ String config = env.getProperty(propertyName);
+ if (config == null || "NULL".equals(config) || config.isEmpty()) {
+ return null;
+ } else {
+ return config;
+ }
}
-
- public String getPropertyOrNull (String propertyName) {
- String config = env.getProperty(propertyName);
- if (config==null || "NULL".equals(config) || config.isEmpty()) {
- return null;
- } else {
- return config;
- }
+
+ public String getEncryptedPropertyOrNull(String propertyName) {
+ String decryptedKey;
+ String config = env.getProperty(propertyName);
+
+ if (config == null || "NULL".equals(config) || config.isEmpty()) {
+ return null;
+ }
+
+ try {
+ decryptedKey = CryptoUtils.decrypt(config, this.configKey);
+ } catch (GeneralSecurityException e) {
+ logger.debug("Exception while decrypting property: {}", propertyName, e);
+ return null;
+ }
+
+ if (decryptedKey.isEmpty()) {
+ return null;
+ } else {
+ return decryptedKey;
+ }
}
-
- public String getEncryptedPropertyOrNull (String propertyName) {
- String decryptedKey;
- String config = env.getProperty(propertyName);
-
- if (config==null || "NULL".equals(config) || config.isEmpty()) {
- return null;
- }
-
- try {
- decryptedKey = CryptoUtils.decrypt(config, this.configKey);
- } catch (GeneralSecurityException e) {
- logger.debug("Exception while decrypting property: {}", propertyName, e);
- return null;
- }
-
- if (decryptedKey.isEmpty ()) {
- return null;
- } else {
- return decryptedKey;
+
+ public boolean getBooleanPropertyWithDefault(String propertyName, boolean defaultValue) {
+ String config = env.getProperty(propertyName);
+ if (config == null || "NULL".equals(config) || config.isEmpty()) {
+ return defaultValue;
+ } else {
+ try {
+ return Boolean.valueOf(config);
+ } catch (Exception e) {
+ return defaultValue;
}
- }
-
- public boolean getBooleanPropertyWithDefault (String propertyName, boolean defaultValue) {
- String config = env.getProperty(propertyName);
- if (config == null || "NULL".equals(config) || config.isEmpty()) {
- return defaultValue;
- } else {
- try {
- return Boolean.valueOf(config);
- } catch (Exception e) {
- return defaultValue;
- }
- }
+ }
}
@Override
- public String getEnvironmentName () {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.environmentName");
+ public String getEnvironmentName() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.environmentName");
}
@Override
- public String getPassword () {
- return getEncryptedPropertyOrNull("mso.asdc-connections.asdc-controller1.password");
+ public String getPassword() {
+ return getEncryptedPropertyOrNull("mso.asdc-connections.asdc-controller1.password");
}
@Override
- public int getPollingInterval () {
- return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.pollingInterval");
+ public int getPollingInterval() {
+ return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.pollingInterval");
}
@Override
- public List <String> getRelevantArtifactTypes () {
- // DO not return the Static List SUPPORTED_ARTIFACT_TYPES_LIST because the ASDC Client will try to modify it !!!
- return Arrays.asList(SUPPORTED_ARTIFACT_TYPES);
+ public List<String> getRelevantArtifactTypes() {
+ // DO not return the Static List SUPPORTED_ARTIFACT_TYPES_LIST because the ASDC Client will try to modify it !!!
+ return Arrays.asList(SUPPORTED_ARTIFACT_TYPES);
}
@Override
- public String getUser () {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.user");
+ public String getUser() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.user");
}
@Override
- public String getAsdcAddress () {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.asdcAddress");
+ public String getAsdcAddress() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.asdcAddress");
}
@Override
- public int getPollingTimeout () {
- return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.pollingTimeout");
+ public int getPollingTimeout() {
+ return getIntegerPropertyOrZero("mso.asdc-connections.asdc-controller1.pollingTimeout");
}
- @Override
- public boolean activateServerTLSAuth() {
- return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.activateServerTLSAuth", true);
- }
+ @Override
+ public boolean activateServerTLSAuth() {
+ return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.activateServerTLSAuth", true);
+ }
- @Override
- public String getKeyStorePassword() {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.keyStorePassword");
- }
+ @Override
+ public String getKeyStorePassword() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.keyStorePassword");
+ }
- @Override
- public String getKeyStorePath() {
- return getPropertyOrNull("mso.asdc-connections.asdc-controller1.keyStorePath");
- }
+ @Override
+ public String getKeyStorePath() {
+ return getPropertyOrNull("mso.asdc-connections.asdc-controller1.keyStorePath");
+ }
/**
- * The flag allows the client to receive metadata for all resources of the service regardless of the artifacts associated to them.
- * Setting the flag to false will preserve legacy behavior.
+ * The flag allows the client to receive metadata for all resources of the service regardless of the artifacts
+ * associated to them. Setting the flag to false will preserve legacy behavior.
*/
- @Override
+ @Override
public boolean isFilterInEmptyResources() {
- return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.isFilterInEmptyResources", true);
+ return getBooleanPropertyWithDefault("mso.asdc-connections.asdc-controller1.isFilterInEmptyResources", true);
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
index c9332e8f84..92326b1907 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCController.java
@@ -160,7 +160,7 @@ public class ASDCController {
}
public ASDCController(String controllerConfigName, IDistributionClient asdcClient,
- IVfResourceInstaller resourceinstaller) {
+ IVfResourceInstaller resourceinstaller) {
distributionClient = asdcClient;
}
@@ -181,7 +181,7 @@ public class ASDCController {
* This method initializes the ASDC Controller and the ASDC Client.
*
* @throws ASDCControllerException It throws an exception if the ASDC Client cannot be instantiated or if an init
- * attempt is done when already initialized
+ * attempt is done when already initialized
* @throws ASDCParametersException If there is an issue with the parameters provided
* @throws IOException In case of issues when trying to load the key file
*/
@@ -201,25 +201,25 @@ public class ASDCController {
distributionClient = DistributionClientFactory.createDistributionClient();
}
- IDistributionClientResult result = this.distributionClient.init(asdcConfig,
- asdcNotificationCallBack, asdcStatusCallBack);
+ IDistributionClientResult result =
+ this.distributionClient.init(asdcConfig, asdcNotificationCallBack, asdcStatusCallBack);
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- String endEvent = "ASDC distribution client init failed with reason:"
- + result.getDistributionMessageResult();
+ String endEvent =
+ "ASDC distribution client init failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
throw new ASDCControllerException("Initialization of the ASDC Controller failed with reason: "
- + result.getDistributionMessageResult());
+ + result.getDistributionMessageResult());
}
result = this.distributionClient.start();
if (!result.getDistributionActionResult().equals(DistributionActionResultEnum.SUCCESS)) {
- String endEvent = "ASDC distribution client start failed with reason:"
- + result.getDistributionMessageResult();
+ String endEvent =
+ "ASDC distribution client start failed with reason:" + result.getDistributionMessageResult();
logger.debug(endEvent);
this.changeControllerStatus(ASDCControllerStatus.STOPPED);
- throw new ASDCControllerException("Startup of the ASDC Controller failed with reason: "
- + result.getDistributionMessageResult());
+ throw new ASDCControllerException(
+ "Startup of the ASDC Controller failed with reason: " + result.getDistributionMessageResult());
}
this.changeControllerStatus(ASDCControllerStatus.IDLE);
@@ -230,7 +230,7 @@ public class ASDCController {
* This method closes the ASDC Controller and the ASDC Client.
*
* @throws ASDCControllerException It throws an exception if the ASDC Client cannot be closed because it's currently
- * BUSY in processing notifications.
+ * BUSY in processing notifications.
*/
public void closeASDC() throws ASDCControllerException {
@@ -254,9 +254,8 @@ public class ASDCController {
if (toscaInstaller.isResourceAlreadyDeployed(resource)) {
logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST.toString(),
- resource.getResourceInstance().getResourceInstanceName(),
- resource.getResourceInstance().getResourceUUID(),
- resource.getResourceInstance().getResourceName());
+ resource.getResourceInstance().getResourceInstanceName(),
+ resource.getResourceInstance().getResourceUUID(), resource.getResourceInstance().getResourceName());
this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DOWNLOADED, null);
this.sendDeployNotificationsForResource(resource, DistributionStatusEnum.ALREADY_DEPLOYED, null);
@@ -268,11 +267,11 @@ public class ASDCController {
}
- protected IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact,
- String distributionId) throws ASDCDownloadException {
+ protected IDistributionClientDownloadResult downloadTheArtifact(IArtifactInfo artifact, String distributionId)
+ throws ASDCDownloadException {
logger.info("Trying to download the artifact UUID: {} from URL: {}", artifact.getArtifactUUID(),
- artifact.getArtifactURL());
+ artifact.getArtifactURL());
IDistributionClientDownloadResult downloadResult;
try {
@@ -283,67 +282,47 @@ public class ASDCController {
}
} catch (RuntimeException e) {
logger.debug("Not able to download the artifact due to an exception: " + artifact.getArtifactURL());
- this.sendASDCNotification(NotificationType.DOWNLOAD,
- artifact.getArtifactURL(),
- asdcConfig.getConsumerID(),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_ERROR,
- e.getMessage(),
- System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DOWNLOAD, artifact.getArtifactURL(), asdcConfig.getConsumerID(),
+ distributionId, DistributionStatusEnum.DOWNLOAD_ERROR, e.getMessage(), System.currentTimeMillis());
throw new ASDCDownloadException("Exception caught when downloading the artifact", e);
}
if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult())) {
logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC.toString(), artifact.getArtifactURL(),
- artifact.getArtifactUUID(), String.valueOf(downloadResult.getArtifactPayload().length));
+ artifact.getArtifactUUID(), String.valueOf(downloadResult.getArtifactPayload().length));
} else {
logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
- artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
- downloadResult.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
- "ASDC artifact download fail");
-
- this.sendASDCNotification(NotificationType.DOWNLOAD,
- artifact.getArtifactURL(),
- asdcConfig.getConsumerID(),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_ERROR,
- downloadResult.getDistributionMessageResult(),
- System.currentTimeMillis());
+ artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
+ downloadResult.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
+ "ASDC artifact download fail");
+
+ this.sendASDCNotification(NotificationType.DOWNLOAD, artifact.getArtifactURL(), asdcConfig.getConsumerID(),
+ distributionId, DistributionStatusEnum.DOWNLOAD_ERROR,
+ downloadResult.getDistributionMessageResult(), System.currentTimeMillis());
throw new ASDCDownloadException("Artifact " + artifact.getArtifactName()
- + " could not be downloaded from ASDC URL "
- + artifact.getArtifactURL()
- + UUID_PARAM
- + artifact.getArtifactUUID()
- + ")"
- + System.lineSeparator()
- + "Error message is "
- + downloadResult.getDistributionMessageResult()
- + System.lineSeparator());
+ + " could not be downloaded from ASDC URL " + artifact.getArtifactURL() + UUID_PARAM
+ + artifact.getArtifactUUID() + ")" + System.lineSeparator() + "Error message is "
+ + downloadResult.getDistributionMessageResult() + System.lineSeparator());
}
- this.sendASDCNotification(NotificationType.DOWNLOAD,
- artifact.getArtifactURL(),
- asdcConfig.getConsumerID(),
- distributionId,
- DistributionStatusEnum.DOWNLOAD_OK,
- null,
- System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DOWNLOAD, artifact.getArtifactURL(), asdcConfig.getConsumerID(),
+ distributionId, DistributionStatusEnum.DOWNLOAD_OK, null, System.currentTimeMillis());
return downloadResult;
}
private void writeArtifactToFile(IArtifactInfo artifact, IDistributionClientDownloadResult resultArtifact) {
- String filePath = Paths
- .get(getMsoConfigPath(), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize()
- .toString();
+ String filePath =
+ Paths.get(getMsoConfigPath(), "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName())
+ .normalize().toString();
logger.info("Trying to write artifact UUID: {}, URL: {} to file: {}", artifact.getArtifactUUID(),
- artifact.getArtifactURL(), filePath);
+ artifact.getArtifactURL(), filePath);
// make parent directory
File file = new File(filePath);
@@ -356,101 +335,88 @@ public class ASDCController {
try (FileOutputStream outFile = new FileOutputStream(filePath)) {
logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***WRITE FILE ARTIFACT NAME",
- "ASDC", artifact.getArtifactName());
+ "ASDC", artifact.getArtifactName());
outFile.write(payloadBytes, 0, payloadBytes.length);
} catch (Exception e) {
logger.debug("Exception :", e);
logger.error("{} {} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
- artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
- resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
- "ASDC write to file failed");
+ artifact.getArtifactName(), artifact.getArtifactURL(), artifact.getArtifactUUID(),
+ resultArtifact.getDistributionMessageResult(), ErrorCode.DataError.getValue(),
+ "ASDC write to file failed");
}
}
protected void sendDeployNotificationsForResource(ResourceStructure resourceStructure,
- DistributionStatusEnum distribStatus, String errorReason) {
+ DistributionStatusEnum distribStatus, String errorReason) {
for (IArtifactInfo artifactInfo : resourceStructure.getResourceInstance().getArtifacts()) {
- if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) && !artifactInfo.getArtifactType()
- .equalsIgnoreCase("OTHER") && !resourceStructure.isAlreadyDeployed())
- // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP
- && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null
- && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb()
- == 0) {
- this.sendASDCNotification(NotificationType.DEPLOY,
- artifactInfo.getArtifactURL(),
- asdcConfig.getConsumerID(),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_ERROR,
- "The artifact has not been used by the modules defined in the resource",
- System.currentTimeMillis());
+ if ((DistributionStatusEnum.DEPLOY_OK.equals(distribStatus)
+ && !artifactInfo.getArtifactType().equalsIgnoreCase("OTHER")
+ && !resourceStructure.isAlreadyDeployed())
+ // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP
+ && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null
+ && resourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID())
+ .getDeployedInDb() == 0) {
+ this.sendASDCNotification(NotificationType.DEPLOY, artifactInfo.getArtifactURL(),
+ asdcConfig.getConsumerID(), resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_ERROR,
+ "The artifact has not been used by the modules defined in the resource",
+ System.currentTimeMillis());
} else {
- this.sendASDCNotification(NotificationType.DEPLOY,
- artifactInfo.getArtifactURL(),
- asdcConfig.getConsumerID(),
- resourceStructure.getNotification().getDistributionID(),
- distribStatus,
- errorReason,
- System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DEPLOY, artifactInfo.getArtifactURL(),
+ asdcConfig.getConsumerID(), resourceStructure.getNotification().getDistributionID(),
+ distribStatus, errorReason, System.currentTimeMillis());
}
}
}
protected void sendCsarDeployNotification(INotificationData iNotif, ResourceStructure resourceStructure,
- ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
+ ToscaResourceStructure toscaResourceStructure, boolean deploySuccessful, String errorReason) {
IArtifactInfo csarArtifact = toscaResourceStructure.getToscaArtifact();
if (deploySuccessful) {
- this.sendASDCNotification(NotificationType.DEPLOY,
- csarArtifact.getArtifactURL(),
- asdcConfig.getConsumerID(),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_OK,
- errorReason,
- System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DEPLOY, csarArtifact.getArtifactURL(),
+ asdcConfig.getConsumerID(), resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_OK, errorReason, System.currentTimeMillis());
} else {
- this.sendASDCNotification(NotificationType.DEPLOY,
- csarArtifact.getArtifactURL(),
- asdcConfig.getConsumerID(),
- resourceStructure.getNotification().getDistributionID(),
- DistributionStatusEnum.DEPLOY_ERROR,
- errorReason,
- System.currentTimeMillis());
+ this.sendASDCNotification(NotificationType.DEPLOY, csarArtifact.getArtifactURL(),
+ asdcConfig.getConsumerID(), resourceStructure.getNotification().getDistributionID(),
+ DistributionStatusEnum.DEPLOY_ERROR, errorReason, System.currentTimeMillis());
}
}
protected void deployResourceStructure(ResourceStructure resourceStructure,
- ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
+ ToscaResourceStructure toscaResourceStructure) throws ArtifactInstallerException {
logger.info("{} {} {} {}", MessageEnum.ASDC_START_DEPLOY_ARTIFACT.toString(),
- resourceStructure.getResourceInstance().getResourceInstanceName(),
- resourceStructure.getResourceInstance().getResourceUUID(), "ASDC");
+ resourceStructure.getResourceInstance().getResourceInstanceName(),
+ resourceStructure.getResourceInstance().getResourceUUID(), "ASDC");
try {
resourceStructure.prepareInstall();
toscaInstaller.installTheResource(toscaResourceStructure, resourceStructure);
} catch (ArtifactInstallerException e) {
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL.toString(),
- resourceStructure.getResourceInstance().getResourceName(),
- resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
+ resourceStructure.getResourceInstance().getResourceName(),
+ resourceStructure.getResourceInstance().getResourceUUID(),
+ String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage());
throw e;
}
if (resourceStructure.isDeployedSuccessfully() || toscaResourceStructure.isDeployedSuccessfully()) {
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(),
- resourceStructure.getResourceInstance().getResourceName(),
- resourceStructure.getResourceInstance().getResourceUUID(),
- String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
+ resourceStructure.getResourceInstance().getResourceName(),
+ resourceStructure.getResourceInstance().getResourceUUID(),
+ String.valueOf(resourceStructure.getNumberOfResources()), "ASDC", "deployResourceStructure");
sendDeployNotificationsForResource(resourceStructure, DistributionStatusEnum.DEPLOY_OK, null);
}
@@ -461,35 +427,23 @@ public class ASDCController {
DOWNLOAD, DEPLOY
}
- protected void sendASDCNotification(NotificationType notificationType,
- String artifactURL,
- String consumerID,
- String distributionID,
- DistributionStatusEnum status,
- String errorReason,
- long timestamp) {
-
- String event = "Sending " + notificationType.name()
- + "("
- + status.name()
- + ")"
- + " notification to ASDC for artifact:"
- + artifactURL;
+ protected void sendASDCNotification(NotificationType notificationType, String artifactURL, String consumerID,
+ String distributionID, DistributionStatusEnum status, String errorReason, long timestamp) {
+
+ String event = "Sending " + notificationType.name() + "(" + status.name() + ")"
+ + " notification to ASDC for artifact:" + artifactURL;
if (errorReason != null) {
event = event + "(" + errorReason + ")";
}
logger.info("{} {} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC.toString(), notificationType.name(),
- status.name(), artifactURL, "ASDC", "sendASDCNotification");
+ status.name(), artifactURL, "ASDC", "sendASDCNotification");
logger.debug(event);
String action = "";
try {
- IDistributionStatusMessage message = new DistributionStatusMessage(artifactURL,
- consumerID,
- distributionID,
- status,
- timestamp);
+ IDistributionStatusMessage message =
+ new DistributionStatusMessage(artifactURL, consumerID, distributionID, status, timestamp);
switch (notificationType) {
case DOWNLOAD:
@@ -513,25 +467,22 @@ public class ASDCController {
}
} catch (RuntimeException e) {
logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC",
- "sendASDCNotification", ErrorCode.SchemaError.getValue(),
- "RuntimeException - sendASDCNotification", e);
+ "sendASDCNotification", ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification",
+ e);
}
}
- protected void sendFinalDistributionStatus(
- String distributionID,
- DistributionStatusEnum status,
- String errorReason) {
+ protected void sendFinalDistributionStatus(String distributionID, DistributionStatusEnum status,
+ String errorReason) {
- logger.debug(
- "Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of " + status
- .name() + " and ErrorReason " + errorReason);
+ logger.debug("Enter sendFinalDistributionStatus with DistributionID " + distributionID + " and Status of "
+ + status.name() + " and ErrorReason " + errorReason);
long subStarttime = System.currentTimeMillis();
try {
IFinalDistrStatusMessage finalDistribution = new FinalDistributionStatusMessage(distributionID, status,
- subStarttime, asdcConfig.getConsumerID());
+ subStarttime, asdcConfig.getConsumerID());
if (errorReason == null) {
this.distributionClient.sendFinalDistrStatus(finalDistribution);
@@ -543,8 +494,8 @@ public class ASDCController {
} catch (RuntimeException e) {
logger.debug("Exception caught in sendFinalDistributionStatus {}", e.getMessage());
logger.warn("{} {} {} {} {}", MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC.toString(), "ASDC",
- "sendASDCNotification",
- ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification", e);
+ "sendASDCNotification", ErrorCode.SchemaError.getValue(), "RuntimeException - sendASDCNotification",
+ e);
}
}
@@ -572,25 +523,24 @@ public class ASDCController {
noOfArtifacts += resource.getArtifacts().size();
}
logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF.toString(), String.valueOf(noOfArtifacts),
- iNotif.getServiceUUID(), "ASDC");
+ iNotif.getServiceUUID(), "ASDC");
try {
logger.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif));
- logger
- .info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(), "ASDC",
- "treatNotification");
+ logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), iNotif.getServiceUUID(),
+ "ASDC", "treatNotification");
this.changeControllerStatus(ASDCControllerStatus.BUSY);
Optional<String> notificationMessage = getNotificationJson(iNotif);
toscaInstaller.processWatchdog(iNotif.getDistributionID(), iNotif.getServiceUUID(), notificationMessage,
- asdcConfig.getConsumerID());
+ asdcConfig.getConsumerID());
// Process only the Resource artifacts in MSO
this.processResourceNotification(iNotif);
- //********************************************************************************************************
- //Start Watchdog loop and wait for all components to complete before reporting final status back.
+ // ********************************************************************************************************
+ // Start Watchdog loop and wait for all components to complete before reporting final status back.
// **If timer expires first then we will report a Distribution Error back to ASDC
- //********************************************************************************************************
+ // ********************************************************************************************************
long initialStartTime = System.currentTimeMillis();
boolean componentsComplete = false;
String distributionStatus = null;
@@ -609,8 +559,8 @@ public class ASDCController {
Thread.sleep(watchDogTimeout / 10);
}
- if (distributionStatus != null && !distributionStatus
- .equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())) {
+ if (distributionStatus != null
+ && !distributionStatus.equalsIgnoreCase(DistributionStatus.INCOMPLETE.name())) {
if (distributionStatus.equalsIgnoreCase(DistributionStatus.SUCCESS.name())) {
isDeploySuccess = true;
@@ -623,8 +573,8 @@ public class ASDCController {
}
if (!componentsComplete) {
- logger
- .debug("Timeout of {} seconds was reached before all components reported status", watchDogTimeout);
+ logger.debug("Timeout of {} seconds was reached before all components reported status",
+ watchDogTimeout);
watchdogError = "Timeout occurred while waiting for all components to report status";
overallStatus = DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name();
}
@@ -647,13 +597,13 @@ public class ASDCController {
if (isDeploySuccess && watchdogError == null) {
sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK,
- null);
+ null);
WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_OK.toString());
wdsRepo.save(wds);
} else {
sendFinalDistributionStatus(iNotif.getDistributionID(),
- DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError);
+ DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR, watchdogError);
WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
wdsRepo.save(wds);
@@ -662,25 +612,24 @@ public class ASDCController {
} catch (ObjectOptimisticLockingFailureException e) {
- logger.debug("OptimisticLockingFailure for DistributionId: {} Another process "
- + "has already altered this distribution, so not going to process it on this site.",
- iNotif.getDistributionID());
+ logger.debug(
+ "OptimisticLockingFailure for DistributionId: {} Another process "
+ + "has already altered this distribution, so not going to process it on this site.",
+ iNotif.getDistributionID());
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Database concurrency exception: ", "ASDC", "treatNotification",
- ErrorCode.BusinessProcesssError.getValue(), "RuntimeException in treatNotification", e);
+ "Database concurrency exception: ", "ASDC", "treatNotification",
+ ErrorCode.BusinessProcesssError.getValue(), "RuntimeException in treatNotification", e);
} catch (Exception e) {
logger.error("", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Unexpected exception caught during the notification processing", "ASDC",
- "treatNotification", ErrorCode.SchemaError.getValue(),
- "RuntimeException in treatNotification",
- e);
+ "Unexpected exception caught during the notification processing", "ASDC", "treatNotification",
+ ErrorCode.SchemaError.getValue(), "RuntimeException in treatNotification", e);
try {
wd.executePatchAAI(iNotif.getDistributionID(), iNotif.getServiceInvariantUUID(),
- DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
+ DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
logger.debug("A&AI Updated succefully with Distribution Status of {}",
- DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
+ DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.name());
} catch (Exception aaiException) {
logger.debug("Exception in executePatchAAI(): {}", aaiException);
if (aaiException.getCause() != null) {
@@ -689,7 +638,7 @@ public class ASDCController {
}
sendFinalDistributionStatus(iNotif.getDistributionID(), DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR,
- e.getMessage());
+ e.getMessage());
WatchdogDistributionStatus wds = new WatchdogDistributionStatus(iNotif.getDistributionID());
wds.setDistributionIdStatus(DistributionStatusEnum.DISTRIBUTION_COMPLETE_ERROR.toString());
@@ -712,8 +661,7 @@ public class ASDCController {
this.processCsarServiceArtifacts(iNotif, toscaResourceStructure);
IArtifactInfo iArtifact = toscaResourceStructure.getToscaArtifact();
String filePath =
- msoConfigPath + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact
- .getArtifactName();
+ msoConfigPath + "/ASDC/" + iArtifact.getArtifactVersion() + "/" + iArtifact.getArtifactName();
File csarFile = new File(filePath);
String csarFilePath = csarFile.getAbsolutePath();
if (bpmnInstaller.containsWorkflows(csarFilePath)) {
@@ -739,14 +687,14 @@ public class ASDCController {
}
for (IArtifactInfo artifact : resource.getArtifacts()) {
- IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact,
- iNotif.getDistributionID());
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
if (resultArtifact != null) {
resourceStructure.addArtifactToStructure(distributionClient, artifact, resultArtifact);
}
}
- //Deploy VF resource and artifacts
+ // Deploy VF resource and artifacts
logger.debug("Preparing to deploy Service: {}", iNotif.getServiceUUID());
try {
this.deployResourceStructure(resourceStructure, toscaResourceStructure);
@@ -757,14 +705,14 @@ public class ASDCController {
}
this.sendCsarDeployNotification(iNotif, resourceStructure, toscaResourceStructure, deploySuccessful,
- errorMessage);
+ errorMessage);
}
} catch (ASDCDownloadException | UnsupportedEncodingException e) {
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during Installation of artifact", "ASDC", "processResourceNotification",
- ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e);
+ "Exception caught during Installation of artifact", "ASDC", "processResourceNotification",
+ ErrorCode.BusinessProcesssError.getValue(), "Exception in processResourceNotification", e);
}
}
@@ -783,7 +731,7 @@ public class ASDCController {
}
protected void processCsarServiceArtifacts(INotificationData iNotif,
- ToscaResourceStructure toscaResourceStructure) {
+ ToscaResourceStructure toscaResourceStructure) {
List<IArtifactInfo> serviceArtifacts = iNotif.getServiceArtifacts();
@@ -795,8 +743,8 @@ public class ASDCController {
toscaResourceStructure.setToscaArtifact(artifact);
- IDistributionClientDownloadResult resultArtifact = this
- .downloadTheArtifact(artifact, iNotif.getDistributionID());
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
writeArtifactToFile(artifact, resultArtifact);
@@ -809,16 +757,16 @@ public class ASDCController {
} catch (Exception e) {
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
- ErrorCode.BusinessProcesssError.getValue(),
- "Exception in processCsarServiceArtifacts", e);
+ "Exception caught during processCsarServiceArtifacts", "ASDC",
+ "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(),
+ "Exception in processCsarServiceArtifacts", e);
}
} else if (artifact.getArtifactType().equals(ASDCConfiguration.WORKFLOWS)) {
try {
- IDistributionClientDownloadResult resultArtifact = this
- .downloadTheArtifact(artifact, iNotif.getDistributionID());
+ IDistributionClientDownloadResult resultArtifact =
+ this.downloadTheArtifact(artifact, iNotif.getDistributionID());
writeArtifactToFile(artifact, resultArtifact);
@@ -830,10 +778,9 @@ public class ASDCController {
} catch (Exception e) {
logger.info("Whats the error {}", e.getMessage());
logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during processCsarServiceArtifacts", "ASDC", "processCsarServiceArtifacts",
- ErrorCode.BusinessProcesssError.getValue(),
- "Exception in processCsarServiceArtifacts",
- e);
+ "Exception caught during processCsarServiceArtifacts", "ASDC",
+ "processCsarServiceArtifacts", ErrorCode.BusinessProcesssError.getValue(),
+ "Exception in processCsarServiceArtifacts", e);
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCControllerStatus.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCControllerStatus.java
index e358fee4a1..9cc2a8fd14 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCControllerStatus.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCControllerStatus.java
@@ -23,5 +23,5 @@ package org.onap.so.asdc.client;
public enum ASDCControllerStatus {
- STOPPED, IDLE, BUSY
+ STOPPED, IDLE, BUSY
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCNotificationCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCNotificationCallBack.java
index 876c5e164f..48ae2f145d 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCNotificationCallBack.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCNotificationCallBack.java
@@ -37,19 +37,18 @@ import org.springframework.stereotype.Component;
@Component
public final class ASDCNotificationCallBack implements INotificationCallback {
- @Autowired
+ @Autowired
private ASDCController asdcController;
-
+
protected static final Logger logger = LoggerFactory.getLogger(ASDCNotificationCallBack.class);
/**
- * This method can be called multiple times at the same moment.
- * The controller must be thread safe !
+ * This method can be called multiple times at the same moment. The controller must be thread safe !
*/
@Override
- public void activateCallback (INotificationData iNotif) {
- String event = "Receive a callback notification in ASDC, nb of resources: " + iNotif.getResources ().size ();
+ public void activateCallback(INotificationData iNotif) {
+ String event = "Receive a callback notification in ASDC, nb of resources: " + iNotif.getResources().size();
logger.debug(event);
- asdcController.treatNotification (iNotif);
+ asdcController.treatNotification(iNotif);
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
index 612599b2ed..d0f86c722e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ASDCStatusCallBack.java
@@ -37,37 +37,39 @@ import org.springframework.stereotype.Component;
@Component
public final class ASDCStatusCallBack implements IStatusCallback {
- @Autowired
- private ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ private ToscaResourceInstaller toscaInstaller;
- protected static final Logger logger = LoggerFactory.getLogger(ASDCStatusCallBack.class);
-
- @Autowired
- private WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
+ protected static final Logger logger = LoggerFactory.getLogger(ASDCStatusCallBack.class);
- @Override
- public void activateCallback (IStatusData iStatus) {
- String event = "Receive a callback componentStatus in ASDC, for componentName: " + iStatus.getComponentName() + " and status of " + iStatus.getStatus() + " distributionID of " + iStatus.getDistributionID();
+ @Autowired
+ private WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
- try{
+ @Override
+ public void activateCallback(IStatusData iStatus) {
+ String event = "Receive a callback componentStatus in ASDC, for componentName: " + iStatus.getComponentName()
+ + " and status of " + iStatus.getStatus() + " distributionID of " + iStatus.getDistributionID();
- if(iStatus.getStatus() != null){
- if(iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK) || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
- WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository.findById(iStatus.getDistributionID ())
- .orElseGet( () -> null);
- if(watchdogDistributionStatus==null){
- watchdogDistributionStatus = new WatchdogDistributionStatus();
- watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID ());
- watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
- }
- logger.debug(event);
- toscaInstaller.installTheComponentStatus(iStatus);
-
- }
- }
- }catch(ArtifactInstallerException e){
- logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e);
- logger.debug("Error in ASDCStatusCallback {}", e.getMessage());
- }
- }
+ try {
+
+ if (iStatus.getStatus() != null) {
+ if (iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_OK)
+ || iStatus.getStatus().equals(DistributionStatusEnum.COMPONENT_DONE_ERROR)) {
+ WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository
+ .findById(iStatus.getDistributionID()).orElseGet(() -> null);
+ if (watchdogDistributionStatus == null) {
+ watchdogDistributionStatus = new WatchdogDistributionStatus();
+ watchdogDistributionStatus.setDistributionId(iStatus.getDistributionID());
+ watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
+ }
+ logger.debug(event);
+ toscaInstaller.installTheComponentStatus(iStatus);
+
+ }
+ }
+ } catch (ArtifactInstallerException e) {
+ logger.error("Error in ASDCStatusCallback {}", e.getMessage(), e);
+ logger.debug("Error in ASDCStatusCallback {}", e.getMessage());
+ }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/DistributionStatusMessage.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/DistributionStatusMessage.java
index db2d2c3bd3..19e55615a1 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/DistributionStatusMessage.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/DistributionStatusMessage.java
@@ -26,52 +26,53 @@ import org.onap.sdc.utils.DistributionStatusEnum;
public class DistributionStatusMessage implements IDistributionStatusMessage {
- private String artifactURL;
-
- private String consumerID;
-
- private String distributionID;
-
- private DistributionStatusEnum distributionStatus;
-
- private long timestamp;
-
- public DistributionStatusMessage (final String artifactUrl, final String consumerId,final String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL) {
- artifactURL = artifactUrl;
- consumerID = consumerId;
- distributionID = distributionId;
- distributionStatus = distributionStatusEnum;
- timestamp = timestampL;
- }
-
- @Override
- public String getArtifactURL() {
-
- return artifactURL;
- }
-
- @Override
- public String getConsumerID() {
-
- return consumerID;
- }
-
- @Override
- public String getDistributionID() {
-
- return distributionID;
- }
-
- @Override
- public DistributionStatusEnum getStatus() {
-
- return distributionStatus;
- }
-
- @Override
- public long getTimestamp() {
-
- return timestamp;
- }
+ private String artifactURL;
+
+ private String consumerID;
+
+ private String distributionID;
+
+ private DistributionStatusEnum distributionStatus;
+
+ private long timestamp;
+
+ public DistributionStatusMessage(final String artifactUrl, final String consumerId, final String distributionId,
+ final DistributionStatusEnum distributionStatusEnum, final long timestampL) {
+ artifactURL = artifactUrl;
+ consumerID = consumerId;
+ distributionID = distributionId;
+ distributionStatus = distributionStatusEnum;
+ timestamp = timestampL;
+ }
+
+ @Override
+ public String getArtifactURL() {
+
+ return artifactURL;
+ }
+
+ @Override
+ public String getConsumerID() {
+
+ return consumerID;
+ }
+
+ @Override
+ public String getDistributionID() {
+
+ return distributionID;
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+
+ return distributionStatus;
+ }
+
+ @Override
+ public long getTimestamp() {
+
+ return timestamp;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
index 376b678c0e..13cace404e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/FinalDistributionStatusMessage.java
@@ -23,64 +23,65 @@ package org.onap.so.asdc.client;
import org.onap.sdc.api.consumer.IFinalDistrStatusMessage;
import org.onap.sdc.utils.DistributionStatusEnum;
-public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage{
-
- private String componentName;
-
- private String consumerID;
-
- private String distributionID;
-
- private DistributionStatusEnum status;
-
- private long timestamp;
-
- public FinalDistributionStatusMessage (String distributionId, final DistributionStatusEnum distributionStatusEnum, final long timestampL, String consumerId) {
- //componentName = componentname;
- consumerID = consumerId;
- distributionID = distributionId;
- status = distributionStatusEnum;
- timestamp = timestampL;
- }
-
- public DistributionStatusEnum getStatus() {
- return status;
- }
-
- public void setStatus(DistributionStatusEnum status) {
- this.status = status;
- }
-
- public String getDistributionID() {
- return distributionID;
- }
-
- public void setDistributionID(String distributionID) {
- this.distributionID = distributionID;
- }
-
- public long getTimestamp() {
- return timestamp;
- }
-
- public void setTimestamp(long timestamp) {
- this.timestamp = timestamp;
- }
-
- public String getComponentName() {
- return componentName;
- }
-
- public void setComponentName(String componentName) {
- this.componentName = componentName;
- }
-
- public String getConsumerID() {
- return consumerID;
- }
-
- public void setConsumerID(String consumerID) {
- this.consumerID = consumerID;
- }
+public class FinalDistributionStatusMessage implements IFinalDistrStatusMessage {
+
+ private String componentName;
+
+ private String consumerID;
+
+ private String distributionID;
+
+ private DistributionStatusEnum status;
+
+ private long timestamp;
+
+ public FinalDistributionStatusMessage(String distributionId, final DistributionStatusEnum distributionStatusEnum,
+ final long timestampL, String consumerId) {
+ // componentName = componentname;
+ consumerID = consumerId;
+ distributionID = distributionId;
+ status = distributionStatusEnum;
+ timestamp = timestampL;
+ }
+
+ public DistributionStatusEnum getStatus() {
+ return status;
+ }
+
+ public void setStatus(DistributionStatusEnum status) {
+ this.status = status;
+ }
+
+ public String getDistributionID() {
+ return distributionID;
+ }
+
+ public void setDistributionID(String distributionID) {
+ this.distributionID = distributionID;
+ }
+
+ public long getTimestamp() {
+ return timestamp;
+ }
+
+ public void setTimestamp(long timestamp) {
+ this.timestamp = timestamp;
+ }
+
+ public String getComponentName() {
+ return componentName;
+ }
+
+ public void setComponentName(String componentName) {
+ this.componentName = componentName;
+ }
+
+ public String getConsumerID() {
+ return consumerID;
+ }
+
+ public void setConsumerID(String consumerID) {
+ this.consumerID = consumerID;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
index 9115ed3ef2..1e243e6d41 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/ResourceInstance.java
@@ -21,59 +21,58 @@
package org.onap.so.asdc.client;
import java.util.ArrayList;
-
import org.onap.sdc.api.notification.IResourceInstance;
public class ResourceInstance implements IResourceInstance {
-
+
@Override
- public String getResourceInstanceName(){
- return new String();
+ public String getResourceInstanceName() {
+ return new String();
}
-
+
@Override
- public String getResourceName(){
- return new String();
+ public String getResourceName() {
+ return new String();
}
-
+
@Override
- public String getResourceVersion(){
- return new String();
+ public String getResourceVersion() {
+ return new String();
}
-
+
@Override
- public String getResourceType(){
- return new String();
+ public String getResourceType() {
+ return new String();
}
-
+
@Override
- public String getResourceUUID(){
- return new String();
+ public String getResourceUUID() {
+ return new String();
}
-
+
@Override
- public java.util.List getArtifacts(){
- return new ArrayList();
+ public java.util.List getArtifacts() {
+ return new ArrayList();
}
-
+
@Override
- public String getResourceInvariantUUID(){
- return new String();
+ public String getResourceInvariantUUID() {
+ return new String();
}
-
+
@Override
- public String getResourceCustomizationUUID(){
- return new String();
+ public String getResourceCustomizationUUID() {
+ return new String();
}
-
+
@Override
- public String getCategory(){
- return new String();
+ public String getCategory() {
+ return new String();
}
-
+
@Override
- public String getSubcategory(){
- return new String();
+ public String getSubcategory() {
+ return new String();
}
-
+
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCControllerException.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCControllerException.java
index 98257f761c..c80156b070 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCControllerException.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCControllerException.java
@@ -26,26 +26,26 @@ package org.onap.so.asdc.client.exceptions;
*/
public class ASDCControllerException extends Exception {
- /**
+ /**
* serialization id.
- */
- private static final long serialVersionUID = -4236006447255525130L;
+ */
+ private static final long serialVersionUID = -4236006447255525130L;
- /**
+ /**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCControllerException (final String message) {
- super (message);
-
+ public ASDCControllerException(final String message) {
+ super(message);
+
}
-
+
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCControllerException (final String message, final Throwable cause) {
- super (message, cause);
-
+ public ASDCControllerException(final String message, final Throwable cause) {
+ super(message, cause);
+
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCDownloadException.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCDownloadException.java
index f4e0bf0327..4271bb7779 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCDownloadException.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCDownloadException.java
@@ -26,26 +26,26 @@ package org.onap.so.asdc.client.exceptions;
*/
public class ASDCDownloadException extends Exception {
- /**
+ /**
* serialization id.
- */
- private static final long serialVersionUID = -5276848693231134901L;
+ */
+ private static final long serialVersionUID = -5276848693231134901L;
- /**
+ /**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCDownloadException (final String message) {
- super (message);
-
+ public ASDCDownloadException(final String message) {
+ super(message);
+
}
-
+
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCDownloadException (final String message, final Throwable cause) {
- super (message, cause);
-
+ public ASDCDownloadException(final String message, final Throwable cause) {
+ super(message, cause);
+
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCParametersException.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCParametersException.java
index aecb9223c9..51f51d2fe0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCParametersException.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ASDCParametersException.java
@@ -26,26 +26,26 @@ package org.onap.so.asdc.client.exceptions;
*/
public class ASDCParametersException extends Exception {
- /**
+ /**
* serialization id.
- */
- private static final long serialVersionUID = 8425657297510362736L;
+ */
+ private static final long serialVersionUID = 8425657297510362736L;
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCParametersException (final String message) {
- super (message);
-
+ public ASDCParametersException(final String message) {
+ super(message);
+
}
-
+
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ASDCParametersException (final String message, final Throwable cause) {
- super (message, cause);
-
+ public ASDCParametersException(final String message, final Throwable cause) {
+ super(message, cause);
+
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerException.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerException.java
index 78ccb5da0a..7d214d363e 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerException.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerException.java
@@ -26,26 +26,26 @@ package org.onap.so.asdc.client.exceptions;
*/
public class ArtifactInstallerException extends Exception {
- /**
+ /**
* serialization id.
- */
- private static final long serialVersionUID = 4095937499475915021L;
+ */
+ private static final long serialVersionUID = 4095937499475915021L;
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ArtifactInstallerException (final String message) {
- super (message);
-
+ public ArtifactInstallerException(final String message) {
+ super(message);
+
}
-
+
/**
* @param message The message to dump
* @param cause The Throwable cause object
*/
- public ArtifactInstallerException (final String message, final Throwable cause) {
- super (message, cause);
-
+ public ArtifactInstallerException(final String message, final Throwable cause) {
+ super(message, cause);
+
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
index 759d88f196..b3618a8095 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImpl.java
@@ -22,171 +22,168 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.ArrayList;
import java.util.List;
-
import org.onap.sdc.api.notification.IArtifactInfo;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.EqualsBuilder;
public class ArtifactInfoImpl implements IArtifactInfo {
- private String artifactName;
- private String artifactType;
- private String artifactURL;
- private String artifactChecksum;
- private String artifactDescription;
- private Integer artifactTimeout;
- private String artifactVersion;
- private String artifactUUID;
- private String generatedFromUUID;
- private ArtifactInfoImpl generatedArtifact;
- private List<IArtifactInfo> relatedArtifactsInfo;
- private List<ArtifactInfoImpl> relatedArtifactsImpl;
- public ArtifactInfoImpl(){}
-
- private ArtifactInfoImpl(IArtifactInfo iArtifactInfo){
- artifactName = iArtifactInfo.getArtifactName();
- artifactType = iArtifactInfo.getArtifactType();
- artifactURL = iArtifactInfo.getArtifactURL();
- artifactChecksum = iArtifactInfo.getArtifactChecksum();
- artifactDescription = iArtifactInfo.getArtifactDescription();
- artifactTimeout = iArtifactInfo.getArtifactTimeout();
- artifactVersion = iArtifactInfo.getArtifactVersion();
- artifactUUID = iArtifactInfo.getArtifactUUID();
- generatedArtifact = (ArtifactInfoImpl) iArtifactInfo.getGeneratedArtifact();
- relatedArtifactsInfo = iArtifactInfo.getRelatedArtifacts();
- }
-
- public static List<ArtifactInfoImpl> convertToArtifactInfoImpl(List<IArtifactInfo> list){
- List<ArtifactInfoImpl> ret = new ArrayList<ArtifactInfoImpl>();
- if( list != null ){
- for(IArtifactInfo artifactInfo : list ){
- ret.add(new ArtifactInfoImpl(artifactInfo));
- }
- }
- return ret;
- }
-
- public String getArtifactName() {
- return artifactName;
- }
-
- public void setArtifactName(String artifactName) {
- this.artifactName = artifactName;
- }
-
- public String getArtifactType() {
- return artifactType;
- }
-
- public void setArtifactType(String artifactType) {
- this.artifactType = artifactType;
- }
-
- public String getArtifactURL() {
- return artifactURL;
- }
-
- public void setArtifactURL(String artifactURL) {
- this.artifactURL = artifactURL;
- }
-
- public String getArtifactChecksum() {
- return artifactChecksum;
- }
-
- public void setArtifactChecksum(String artifactChecksum) {
- this.artifactChecksum = artifactChecksum;
- }
-
- public String getArtifactDescription() {
- return artifactDescription;
- }
-
- public void setArtifactDescription(String artifactDescription) {
- this.artifactDescription = artifactDescription;
- }
-
- public Integer getArtifactTimeout() {
- return artifactTimeout;
- }
-
- public void setArtifactTimeout(Integer artifactTimeout) {
- this.artifactTimeout = artifactTimeout;
- }
-
- @Override
- public String toString() {
- return "BaseArtifactInfoImpl [artifactName=" + artifactName
- + ", artifactType=" + artifactType + ", artifactURL="
- + artifactURL + ", artifactChecksum=" + artifactChecksum
- + ", artifactDescription=" + artifactDescription
- + ", artifactVersion=" + artifactVersion
- + ", artifactUUID=" + artifactUUID
- + ", artifactTimeout=" + artifactTimeout + "]";
- }
-
- public String getArtifactVersion() {
- return artifactVersion;
- }
-
- public void setArtifactVersion(String artifactVersion) {
- this.artifactVersion = artifactVersion;
- }
-
- public String getArtifactUUID() {
- return artifactUUID;
- }
-
- public void setArtifactUUID(String artifactUUID) {
- this.artifactUUID = artifactUUID;
- }
-
- public String getGeneratedFromUUID() {
- return generatedFromUUID;
- }
-
- public void setGeneratedFromUUID(String generatedFromUUID) {
- this.generatedFromUUID = generatedFromUUID;
- }
-
- @Override
- public ArtifactInfoImpl getGeneratedArtifact() {
- return generatedArtifact;
- }
-
- public void setGeneratedArtifact(ArtifactInfoImpl generatedArtifact) {
- this.generatedArtifact = generatedArtifact;
- }
-
- @Override
- public List<IArtifactInfo> getRelatedArtifacts(){
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
- if( relatedArtifactsInfo != null ){
- temp.addAll(relatedArtifactsImpl);
- }
- return temp;
- }
-
- public void setRelatedArtifacts(List<ArtifactInfoImpl> relatedArtifacts) {
- this.relatedArtifactsImpl = relatedArtifacts;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof ArtifactInfoImpl)) {
- return false;
- }
- ArtifactInfoImpl castOther = (ArtifactInfoImpl) other;
- return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID)
- .append(artifactVersion, castOther.artifactVersion).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(artifactName).append(artifactType).append(artifactURL)
- .append(artifactChecksum).append(artifactDescription).append(artifactTimeout).append(artifactVersion)
- .append(artifactUUID).append(generatedFromUUID).append(generatedArtifact).append(relatedArtifactsInfo)
- .append(relatedArtifactsImpl).toHashCode();
- }
+ private String artifactName;
+ private String artifactType;
+ private String artifactURL;
+ private String artifactChecksum;
+ private String artifactDescription;
+ private Integer artifactTimeout;
+ private String artifactVersion;
+ private String artifactUUID;
+ private String generatedFromUUID;
+ private ArtifactInfoImpl generatedArtifact;
+ private List<IArtifactInfo> relatedArtifactsInfo;
+ private List<ArtifactInfoImpl> relatedArtifactsImpl;
+
+ public ArtifactInfoImpl() {}
+
+ private ArtifactInfoImpl(IArtifactInfo iArtifactInfo) {
+ artifactName = iArtifactInfo.getArtifactName();
+ artifactType = iArtifactInfo.getArtifactType();
+ artifactURL = iArtifactInfo.getArtifactURL();
+ artifactChecksum = iArtifactInfo.getArtifactChecksum();
+ artifactDescription = iArtifactInfo.getArtifactDescription();
+ artifactTimeout = iArtifactInfo.getArtifactTimeout();
+ artifactVersion = iArtifactInfo.getArtifactVersion();
+ artifactUUID = iArtifactInfo.getArtifactUUID();
+ generatedArtifact = (ArtifactInfoImpl) iArtifactInfo.getGeneratedArtifact();
+ relatedArtifactsInfo = iArtifactInfo.getRelatedArtifacts();
+ }
+
+ public static List<ArtifactInfoImpl> convertToArtifactInfoImpl(List<IArtifactInfo> list) {
+ List<ArtifactInfoImpl> ret = new ArrayList<ArtifactInfoImpl>();
+ if (list != null) {
+ for (IArtifactInfo artifactInfo : list) {
+ ret.add(new ArtifactInfoImpl(artifactInfo));
+ }
+ }
+ return ret;
+ }
+
+ public String getArtifactName() {
+ return artifactName;
+ }
+
+ public void setArtifactName(String artifactName) {
+ this.artifactName = artifactName;
+ }
+
+ public String getArtifactType() {
+ return artifactType;
+ }
+
+ public void setArtifactType(String artifactType) {
+ this.artifactType = artifactType;
+ }
+
+ public String getArtifactURL() {
+ return artifactURL;
+ }
+
+ public void setArtifactURL(String artifactURL) {
+ this.artifactURL = artifactURL;
+ }
+
+ public String getArtifactChecksum() {
+ return artifactChecksum;
+ }
+
+ public void setArtifactChecksum(String artifactChecksum) {
+ this.artifactChecksum = artifactChecksum;
+ }
+
+ public String getArtifactDescription() {
+ return artifactDescription;
+ }
+
+ public void setArtifactDescription(String artifactDescription) {
+ this.artifactDescription = artifactDescription;
+ }
+
+ public Integer getArtifactTimeout() {
+ return artifactTimeout;
+ }
+
+ public void setArtifactTimeout(Integer artifactTimeout) {
+ this.artifactTimeout = artifactTimeout;
+ }
+
+ @Override
+ public String toString() {
+ return "BaseArtifactInfoImpl [artifactName=" + artifactName + ", artifactType=" + artifactType
+ + ", artifactURL=" + artifactURL + ", artifactChecksum=" + artifactChecksum + ", artifactDescription="
+ + artifactDescription + ", artifactVersion=" + artifactVersion + ", artifactUUID=" + artifactUUID
+ + ", artifactTimeout=" + artifactTimeout + "]";
+ }
+
+ public String getArtifactVersion() {
+ return artifactVersion;
+ }
+
+ public void setArtifactVersion(String artifactVersion) {
+ this.artifactVersion = artifactVersion;
+ }
+
+ public String getArtifactUUID() {
+ return artifactUUID;
+ }
+
+ public void setArtifactUUID(String artifactUUID) {
+ this.artifactUUID = artifactUUID;
+ }
+
+ public String getGeneratedFromUUID() {
+ return generatedFromUUID;
+ }
+
+ public void setGeneratedFromUUID(String generatedFromUUID) {
+ this.generatedFromUUID = generatedFromUUID;
+ }
+
+ @Override
+ public ArtifactInfoImpl getGeneratedArtifact() {
+ return generatedArtifact;
+ }
+
+ public void setGeneratedArtifact(ArtifactInfoImpl generatedArtifact) {
+ this.generatedArtifact = generatedArtifact;
+ }
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if (relatedArtifactsInfo != null) {
+ temp.addAll(relatedArtifactsImpl);
+ }
+ return temp;
+ }
+
+ public void setRelatedArtifacts(List<ArtifactInfoImpl> relatedArtifacts) {
+ this.relatedArtifactsImpl = relatedArtifacts;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ArtifactInfoImpl)) {
+ return false;
+ }
+ ArtifactInfoImpl castOther = (ArtifactInfoImpl) other;
+ return new EqualsBuilder().append(artifactUUID, castOther.artifactUUID)
+ .append(artifactVersion, castOther.artifactVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(artifactName).append(artifactType).append(artifactURL)
+ .append(artifactChecksum).append(artifactDescription).append(artifactTimeout).append(artifactVersion)
+ .append(artifactUUID).append(generatedFromUUID).append(generatedArtifact).append(relatedArtifactsInfo)
+ .append(relatedArtifactsImpl).toHashCode();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulator.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulator.java
index ffb7f7a7f4..efa564c3e9 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulator.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulator.java
@@ -27,7 +27,6 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
-
import org.onap.so.asdc.installer.IVfModuleData;
import org.onap.sdc.api.IDistributionClient;
import org.onap.sdc.api.consumer.IComponentDoneStatusMessage;
@@ -48,143 +47,148 @@ import org.slf4j.LoggerFactory;
public class DistributionClientEmulator implements IDistributionClient {
- private String resourcePath;
-
- private List<IVfModuleData> listVFModuleMetaData;
-
- private List<IDistributionStatusMessage> distributionMessageReceived = new LinkedList<>();
-
-
- private static final Logger logger = LoggerFactory.getLogger(DistributionClientEmulator.class );
-
- public DistributionClientEmulator() {
- }
-
- public DistributionClientEmulator(String notifFolderInResource) {
- resourcePath = notifFolderInResource;
- }
-
- public List<IDistributionStatusMessage> getDistributionMessageReceived() {
- return distributionMessageReceived;
- }
-
- @Override
- public List<IVfModuleMetadata> decodeVfModuleArtifact(byte[] arg0) {
- return null;
- }
-
- public String getResourcePath() {
- return resourcePath;
- }
-
- public void setResourcePath(String resourcePath) {
- this.resourcePath = resourcePath;
- }
-
- public List<IVfModuleData> getListVFModuleMetaData() {
- return listVFModuleMetaData;
- }
-
- @Override
- public IDistributionClientDownloadResult download (IArtifactInfo arg0) {
-
- String filename = arg0.getArtifactURL();
-
- byte[] inputStream=null;
- try {
- inputStream = getData(filename);
- } catch (IOException e) {
- logger.error("IOException in DistributionClientEmulator.download() method", e);
- }
-
- return new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name(),arg0.getArtifactName(),inputStream);
- }
-
- private byte[] getData(String filename) throws IOException {
- return Files.readAllBytes(Paths.get(resourcePath + filename));
- }
-
- @Override
- public IConfiguration getConfiguration() {
- return null;
- }
-
- @Override
- public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1) {
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1, IStatusCallback arg2) {
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0) {
- this.distributionMessageReceived.add(arg0);
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0, String arg1) {
- this.distributionMessageReceived.add(arg0);
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0) {
- this.distributionMessageReceived.add(arg0);
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0, String arg1) {
- this.distributionMessageReceived.add(arg0);
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult start() {
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult stop() {
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
-
- }
-
- @Override
- public IDistributionClientResult updateConfiguration(IConfiguration arg0) {
- return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- }
-
- @Override
- public IDistributionClientResult sendComponentDoneStatus(
- IComponentDoneStatusMessage arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IDistributionClientResult sendFinalDistrStatus(
- IFinalDistrStatusMessage arg0) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IDistributionClientResult sendComponentDoneStatus(
- IComponentDoneStatusMessage arg0, String arg1) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public IDistributionClientResult sendFinalDistrStatus(
- IFinalDistrStatusMessage arg0, String arg1) {
- // TODO Auto-generated method stub
- return null;
- }
+ private String resourcePath;
+
+ private List<IVfModuleData> listVFModuleMetaData;
+
+ private List<IDistributionStatusMessage> distributionMessageReceived = new LinkedList<>();
+
+
+ private static final Logger logger = LoggerFactory.getLogger(DistributionClientEmulator.class);
+
+ public DistributionClientEmulator() {}
+
+ public DistributionClientEmulator(String notifFolderInResource) {
+ resourcePath = notifFolderInResource;
+ }
+
+ public List<IDistributionStatusMessage> getDistributionMessageReceived() {
+ return distributionMessageReceived;
+ }
+
+ @Override
+ public List<IVfModuleMetadata> decodeVfModuleArtifact(byte[] arg0) {
+ return null;
+ }
+
+ public String getResourcePath() {
+ return resourcePath;
+ }
+
+ public void setResourcePath(String resourcePath) {
+ this.resourcePath = resourcePath;
+ }
+
+ public List<IVfModuleData> getListVFModuleMetaData() {
+ return listVFModuleMetaData;
+ }
+
+ @Override
+ public IDistributionClientDownloadResult download(IArtifactInfo arg0) {
+
+ String filename = arg0.getArtifactURL();
+
+ byte[] inputStream = null;
+ try {
+ inputStream = getData(filename);
+ } catch (IOException e) {
+ logger.error("IOException in DistributionClientEmulator.download() method", e);
+ }
+
+ return new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name(), arg0.getArtifactName(), inputStream);
+ }
+
+ private byte[] getData(String filename) throws IOException {
+ return Files.readAllBytes(Paths.get(resourcePath + filename));
+ }
+
+ @Override
+ public IConfiguration getConfiguration() {
+ return null;
+ }
+
+ @Override
+ public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1) {
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult init(IConfiguration arg0, INotificationCallback arg1, IStatusCallback arg2) {
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0) {
+ this.distributionMessageReceived.add(arg0);
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult sendDeploymentStatus(IDistributionStatusMessage arg0, String arg1) {
+ this.distributionMessageReceived.add(arg0);
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0) {
+ this.distributionMessageReceived.add(arg0);
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult sendDownloadStatus(IDistributionStatusMessage arg0, String arg1) {
+ this.distributionMessageReceived.add(arg0);
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult start() {
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult stop() {
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+
+ }
+
+ @Override
+ public IDistributionClientResult updateConfiguration(IConfiguration arg0) {
+ return new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name());
+ }
+
+ @Override
+ public IDistributionClientResult sendComponentDoneStatus(IComponentDoneStatusMessage arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IDistributionClientResult sendFinalDistrStatus(IFinalDistrStatusMessage arg0) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IDistributionClientResult sendComponentDoneStatus(IComponentDoneStatusMessage arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public IDistributionClientResult sendFinalDistrStatus(IFinalDistrStatusMessage arg0, String arg1) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
index 58193dbee6..7bd9c752a4 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonStatusData.java
@@ -24,101 +24,100 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
-
import org.onap.sdc.api.notification.IStatusData;
import org.onap.sdc.utils.DistributionStatusEnum;
-
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
public class JsonStatusData implements IStatusData {
-
- @JsonIgnore
- private static ObjectMapper mapper = new ObjectMapper();
-
- @JsonIgnore
- private Map<String,Object> attributesMap = new HashMap<>();
-
- public JsonStatusData() {
-
- }
-
- @Override
- public String getErrorReason(){
- return "MSO FAILURE";
- }
-
- @Override
- public String getDistributionID(){
- //return (String)this.attributesMap.get("distributionID");
- return "35120a87-1f82-4276-9735-f6de5a244d65";
- }
-
- @Override
- public String getConsumerID(){
- //return (String)this.attributesMap.get("consumerID");
- return "mso.123456";
- }
-
- @Override
- public String getComponentName(){
- //return (String)this.attributesMap.get("componentName");
- return "SDN-C";
- }
-
- @Override
- public Long getTimestamp(){
- //return (String)this.attributesMap.get("timestamp");
- return null;
- }
-
- @Override
- public String getArtifactURL(){
- //return (String)this.attributesMap.get("artifactURL");
- return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
- }
-
- @Override
- public DistributionStatusEnum getStatus(){
- //return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
- return DistributionStatusEnum.COMPONENT_DONE_OK;
- }
-
- /**
- * Method instantiate a INotificationData implementation from a JSON file.
- *
- * @param notifFilePath The file path in String
- * @return A JsonNotificationData instance
- * @throws IOException in case of the file is not readable or not accessible
- */
- public static JsonStatusData instantiateNotifFromJsonFile(String notifFilePath) throws IOException {
-
- InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(notifFilePath + "status-structure.json");
-
- //String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
-
- //String source = fileLocation;
- //InputStream is = IOUtils.toInputStream(source, "UTF-8");
-
- //String myString = IOUtils.toString(is, "UTF-8");
-
-
- //System.out.println(myString);
-
- if (is == null) {
- //throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
- }
- return mapper.readValue(is, JsonStatusData.class);
- }
-
- @SuppressWarnings("unused")
- @JsonAnySetter
- public final void setAttribute(String attrName, Object attrValue) {
- if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
- this.attributesMap.put(attrName,attrValue);
- }
- }
-
+
+ @JsonIgnore
+ private static ObjectMapper mapper = new ObjectMapper();
+
+ @JsonIgnore
+ private Map<String, Object> attributesMap = new HashMap<>();
+
+ public JsonStatusData() {
+
+ }
+
+ @Override
+ public String getErrorReason() {
+ return "MSO FAILURE";
+ }
+
+ @Override
+ public String getDistributionID() {
+ // return (String)this.attributesMap.get("distributionID");
+ return "35120a87-1f82-4276-9735-f6de5a244d65";
+ }
+
+ @Override
+ public String getConsumerID() {
+ // return (String)this.attributesMap.get("consumerID");
+ return "mso.123456";
+ }
+
+ @Override
+ public String getComponentName() {
+ // return (String)this.attributesMap.get("componentName");
+ return "SDN-C";
+ }
+
+ @Override
+ public Long getTimestamp() {
+ // return (String)this.attributesMap.get("timestamp");
+ return null;
+ }
+
+ @Override
+ public String getArtifactURL() {
+ // return (String)this.attributesMap.get("artifactURL");
+ return "/sdc/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml";
+ }
+
+ @Override
+ public DistributionStatusEnum getStatus() {
+ // return (DistributionStatusEnum)this.attributesMap.get(DistributionStatusEnum.DEPLOY_OK);
+ return DistributionStatusEnum.COMPONENT_DONE_OK;
+ }
+
+ /**
+ * Method instantiate a INotificationData implementation from a JSON file.
+ *
+ * @param notifFilePath The file path in String
+ * @return A JsonNotificationData instance
+ * @throws IOException in case of the file is not readable or not accessible
+ */
+ public static JsonStatusData instantiateNotifFromJsonFile(String notifFilePath) throws IOException {
+
+ InputStream is = Thread.currentThread().getContextClassLoader()
+ .getResourceAsStream(notifFilePath + "status-structure.json");
+
+ // String fileLocation = System.getProperty("mso.config.path") + "notif-structure.json";
+
+ // String source = fileLocation;
+ // InputStream is = IOUtils.toInputStream(source, "UTF-8");
+
+ // String myString = IOUtils.toString(is, "UTF-8");
+
+
+ // System.out.println(myString);
+
+ if (is == null) {
+ // throw new FileExistsException("Resource Path does not exist: "+notifFilePath);
+ }
+ return mapper.readValue(is, JsonStatusData.class);
+ }
+
+ @SuppressWarnings("unused")
+ @JsonAnySetter
+ public final void setAttribute(String attrName, Object attrValue) {
+ if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
+ this.attributesMap.put(attrName, attrValue);
+ }
+ }
+
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
index 9202559868..f4d3e5ce48 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaData.java
@@ -23,74 +23,72 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.onap.so.asdc.installer.IVfModuleData;
-
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class JsonVfModuleMetaData implements IVfModuleData {
- @JsonProperty("artifacts")
- private List<String> artifacts;
- @JsonProperty("properties")
- //private List<Map<String, Object>> properties = new ArrayList<>();
- private Map<String,String> properties = new HashMap<>();
-
- public Map<String, String> getProperties() {
- return properties;
- }
-
- @JsonIgnore
- private Map<String,Object> attributesMap = new HashMap<>();
-
- @Override
- public List<String> getArtifacts() {
- return artifacts;
- }
-
- @Override
- public String getVfModuleModelDescription() {
- return (String)attributesMap.get("vfModuleModelDescription");
- }
-
- @Override
- public String getVfModuleModelInvariantUUID() {
- return (String)attributesMap.get("vfModuleModelInvariantUUID");
- }
-
- @Override
- public String getVfModuleModelCustomizationUUID() {
- return (String)attributesMap.get("vfModuleModelCustomizationUUID");
- }
-
- @Override
- public String getVfModuleModelName() {
- return (String)attributesMap.get("vfModuleModelName");
- }
-
- @Override
- public String getVfModuleModelUUID() {
- return (String)attributesMap.get("vfModuleModelUUID");
- }
-
- @Override
- public String getVfModuleModelVersion() {
- return (String)attributesMap.get("vfModuleModelVersion");
- }
-
- @Override
- public boolean isBase() {
- return (boolean)attributesMap.get("isBase");
- }
-
- @SuppressWarnings("unused")
- @JsonAnySetter
- public final void setAttribute(String attrName, Object attrValue) {
- if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
- this.attributesMap.put(attrName,attrValue);
- }
- }
+ @JsonProperty("artifacts")
+ private List<String> artifacts;
+ @JsonProperty("properties")
+ // private List<Map<String, Object>> properties = new ArrayList<>();
+ private Map<String, String> properties = new HashMap<>();
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @JsonIgnore
+ private Map<String, Object> attributesMap = new HashMap<>();
+
+ @Override
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
+
+ @Override
+ public String getVfModuleModelDescription() {
+ return (String) attributesMap.get("vfModuleModelDescription");
+ }
+
+ @Override
+ public String getVfModuleModelInvariantUUID() {
+ return (String) attributesMap.get("vfModuleModelInvariantUUID");
+ }
+
+ @Override
+ public String getVfModuleModelCustomizationUUID() {
+ return (String) attributesMap.get("vfModuleModelCustomizationUUID");
+ }
+
+ @Override
+ public String getVfModuleModelName() {
+ return (String) attributesMap.get("vfModuleModelName");
+ }
+
+ @Override
+ public String getVfModuleModelUUID() {
+ return (String) attributesMap.get("vfModuleModelUUID");
+ }
+
+ @Override
+ public String getVfModuleModelVersion() {
+ return (String) attributesMap.get("vfModuleModelVersion");
+ }
+
+ @Override
+ public boolean isBase() {
+ return (boolean) attributesMap.get("isBase");
+ }
+
+ @SuppressWarnings("unused")
+ @JsonAnySetter
+ public final void setAttribute(String attrName, Object attrValue) {
+ if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
+ this.attributesMap.put(attrName, attrValue);
+ }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
index 9462cc85d8..f8d7bb09f5 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/NotificationDataImpl.java
@@ -22,192 +22,192 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
import org.springframework.stereotype.Component;
-
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
@Component
-@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE)
+@JsonAutoDetect(fieldVisibility = Visibility.ANY, getterVisibility = Visibility.NONE,
+ setterVisibility = Visibility.NONE)
public class NotificationDataImpl implements INotificationData {
- @JsonProperty("distributionID")
- private String distributionID;
- @JsonProperty("serviceName")
- private String serviceName;
- @JsonProperty("serviceVersion")
- private String serviceVersion;
- @JsonProperty("serviceUUID")
- private String serviceUUID;
- @JsonProperty("serviceDescription")
- private String serviceDescription;
- @JsonProperty("serviceInvariantUUID")
- private String serviceInvariantUUID;
- @JsonProperty("resources")
- private List<ResourceInfoImpl> resources;
- @JsonProperty("serviceArtifacts")
- private List<ArtifactInfoImpl> serviceArtifacts;
- @JsonProperty("workloadContext")
- private String workloadContext;
-
- @Override
- public String getDistributionID() {
- return distributionID;
- }
-
- @Override
- public String getServiceName() {
- return serviceName;
- }
-
- @Override
- public String getServiceVersion() {
- return serviceVersion;
- }
-
- @Override
- public String getServiceUUID() {
- return serviceUUID;
- }
-
- public void setDistributionID(String distributionID) {
- this.distributionID = distributionID;
- }
-
- public void setServiceName(String serviceName) {
- this.serviceName = serviceName;
- }
-
- public void setServiceVersion(String serviceVersion) {
- this.serviceVersion = serviceVersion;
- }
-
- public void setServiceUUID(String serviceUUID) {
- this.serviceUUID = serviceUUID;
- }
-
-
-
- public String getServiceDescription() {
- return serviceDescription;
- }
-
- public void setServiceDescription(String serviceDescription) {
- this.serviceDescription = serviceDescription;
- }
-
- @Override
- public String getWorkloadContext() {
- return workloadContext;
- }
-
- @Override
- public void setWorkloadContext(String workloadContext) {
- this.workloadContext = workloadContext;
- }
-
- @Override
- public String toString() {
- return "NotificationDataImpl [distributionID=" + distributionID + ", serviceName=" + serviceName
- + ", serviceVersion=" + serviceVersion + ", serviceUUID=" + serviceUUID + ", serviceDescription="
- + serviceDescription + ", serviceInvariantUUID=" + serviceInvariantUUID + ", resources=" + resources
- + ", serviceArtifacts=" + serviceArtifacts + ", workloadContext=" + workloadContext + "]";
- }
-
- @Override
- public List<IResourceInstance> getResources() {
- List<IResourceInstance> ret = new ArrayList<IResourceInstance>();
- if( resources != null ){
- ret.addAll(resources);
- }
- return ret;
- }
-
- public void setResources(List<ResourceInfoImpl> resources){
- this.resources = resources;
- }
-
- public List<ResourceInfoImpl> getResourcesImpl(){
- return resources;
- }
-
- List<ArtifactInfoImpl> getServiceArtifactsImpl(){
- return serviceArtifacts;
- }
-
- @Override
- public List<IArtifactInfo> getServiceArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
- if( serviceArtifacts != null ){
- temp.addAll(serviceArtifacts);
- }
- return temp;
- }
-
- public void setServiceArtifacts(List<ArtifactInfoImpl> relevantServiceArtifacts) {
- serviceArtifacts = relevantServiceArtifacts;
-
- }
-
- @Override
- public String getServiceInvariantUUID() {
- return serviceInvariantUUID;
- }
-
-
- public void setServiceInvariantUUID(String serviceInvariantUUID) {
- this.serviceInvariantUUID = serviceInvariantUUID;
- }
- @Override
- public IArtifactInfo getArtifactMetadataByUUID(String artifactUUID){
- IArtifactInfo ret = findArtifactInfoByUUID(artifactUUID, serviceArtifacts);
- if( ret == null && resources != null ){
- for( ResourceInfoImpl currResourceInstance : resources ){
- ret = findArtifactInfoByUUID(artifactUUID, currResourceInstance.getArtifactsImpl());
- if( ret != null ){
- break;
- }
- }
- }
- return ret;
-
- }
-
- private IArtifactInfo findArtifactInfoByUUID(String artifactUUID, List<ArtifactInfoImpl> listToCheck) {
- IArtifactInfo ret = null;
- if( listToCheck != null ){
- for(IArtifactInfo curr: listToCheck ){
- if(curr.getArtifactUUID().equals(artifactUUID) ){
- ret = curr;
- break;
- }
- }
- }
- return ret;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof NotificationDataImpl)) {
- return false;
- }
- NotificationDataImpl castOther = (NotificationDataImpl) other;
- return new EqualsBuilder().append(serviceUUID, castOther.serviceUUID)
- .append(serviceVersion, castOther.serviceVersion).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(distributionID).append(serviceName).append(serviceVersion)
- .append(serviceUUID).append(serviceDescription).append(serviceInvariantUUID).append(resources)
- .append(serviceArtifacts).append(workloadContext).toHashCode();
- }
+ @JsonProperty("distributionID")
+ private String distributionID;
+ @JsonProperty("serviceName")
+ private String serviceName;
+ @JsonProperty("serviceVersion")
+ private String serviceVersion;
+ @JsonProperty("serviceUUID")
+ private String serviceUUID;
+ @JsonProperty("serviceDescription")
+ private String serviceDescription;
+ @JsonProperty("serviceInvariantUUID")
+ private String serviceInvariantUUID;
+ @JsonProperty("resources")
+ private List<ResourceInfoImpl> resources;
+ @JsonProperty("serviceArtifacts")
+ private List<ArtifactInfoImpl> serviceArtifacts;
+ @JsonProperty("workloadContext")
+ private String workloadContext;
+
+ @Override
+ public String getDistributionID() {
+ return distributionID;
+ }
+
+ @Override
+ public String getServiceName() {
+ return serviceName;
+ }
+
+ @Override
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ @Override
+ public String getServiceUUID() {
+ return serviceUUID;
+ }
+
+ public void setDistributionID(String distributionID) {
+ this.distributionID = distributionID;
+ }
+
+ public void setServiceName(String serviceName) {
+ this.serviceName = serviceName;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+ public void setServiceUUID(String serviceUUID) {
+ this.serviceUUID = serviceUUID;
+ }
+
+
+
+ public String getServiceDescription() {
+ return serviceDescription;
+ }
+
+ public void setServiceDescription(String serviceDescription) {
+ this.serviceDescription = serviceDescription;
+ }
+
+ @Override
+ public String getWorkloadContext() {
+ return workloadContext;
+ }
+
+ @Override
+ public void setWorkloadContext(String workloadContext) {
+ this.workloadContext = workloadContext;
+ }
+
+ @Override
+ public String toString() {
+ return "NotificationDataImpl [distributionID=" + distributionID + ", serviceName=" + serviceName
+ + ", serviceVersion=" + serviceVersion + ", serviceUUID=" + serviceUUID + ", serviceDescription="
+ + serviceDescription + ", serviceInvariantUUID=" + serviceInvariantUUID + ", resources=" + resources
+ + ", serviceArtifacts=" + serviceArtifacts + ", workloadContext=" + workloadContext + "]";
+ }
+
+ @Override
+ public List<IResourceInstance> getResources() {
+ List<IResourceInstance> ret = new ArrayList<IResourceInstance>();
+ if (resources != null) {
+ ret.addAll(resources);
+ }
+ return ret;
+ }
+
+ public void setResources(List<ResourceInfoImpl> resources) {
+ this.resources = resources;
+ }
+
+ public List<ResourceInfoImpl> getResourcesImpl() {
+ return resources;
+ }
+
+ List<ArtifactInfoImpl> getServiceArtifactsImpl() {
+ return serviceArtifacts;
+ }
+
+ @Override
+ public List<IArtifactInfo> getServiceArtifacts() {
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if (serviceArtifacts != null) {
+ temp.addAll(serviceArtifacts);
+ }
+ return temp;
+ }
+
+ public void setServiceArtifacts(List<ArtifactInfoImpl> relevantServiceArtifacts) {
+ serviceArtifacts = relevantServiceArtifacts;
+
+ }
+
+ @Override
+ public String getServiceInvariantUUID() {
+ return serviceInvariantUUID;
+ }
+
+
+ public void setServiceInvariantUUID(String serviceInvariantUUID) {
+ this.serviceInvariantUUID = serviceInvariantUUID;
+ }
+
+ @Override
+ public IArtifactInfo getArtifactMetadataByUUID(String artifactUUID) {
+ IArtifactInfo ret = findArtifactInfoByUUID(artifactUUID, serviceArtifacts);
+ if (ret == null && resources != null) {
+ for (ResourceInfoImpl currResourceInstance : resources) {
+ ret = findArtifactInfoByUUID(artifactUUID, currResourceInstance.getArtifactsImpl());
+ if (ret != null) {
+ break;
+ }
+ }
+ }
+ return ret;
+
+ }
+
+ private IArtifactInfo findArtifactInfoByUUID(String artifactUUID, List<ArtifactInfoImpl> listToCheck) {
+ IArtifactInfo ret = null;
+ if (listToCheck != null) {
+ for (IArtifactInfo curr : listToCheck) {
+ if (curr.getArtifactUUID().equals(artifactUUID)) {
+ ret = curr;
+ break;
+ }
+ }
+ }
+ return ret;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof NotificationDataImpl)) {
+ return false;
+ }
+ NotificationDataImpl castOther = (NotificationDataImpl) other;
+ return new EqualsBuilder().append(serviceUUID, castOther.serviceUUID)
+ .append(serviceVersion, castOther.serviceVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(distributionID).append(serviceName).append(serviceVersion)
+ .append(serviceUUID).append(serviceDescription).append(serviceInvariantUUID).append(resources)
+ .append(serviceArtifacts).append(workloadContext).toHashCode();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
index 9103ae132e..91597611fd 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImpl.java
@@ -22,159 +22,159 @@ package org.onap.so.asdc.client.test.emulators;
import java.util.ArrayList;
import java.util.List;
-
import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
-
import com.fasterxml.jackson.annotation.JsonIgnore;
-public class ResourceInfoImpl implements IResourceInstance{
- public ResourceInfoImpl (){}
- private String resourceInstanceName;
- private String resourceCustomizationUUID;
- private String resourceName;
- private String resourceVersion;
- private String resourceType;
- private String resourceUUID;
- private String resourceInvariantUUID;
- private String category;
- private String subcategory;
- private List<ArtifactInfoImpl> artifacts;
-
- private ResourceInfoImpl(IResourceInstance resourceInstance){
- resourceInstanceName = resourceInstance.getResourceInstanceName();
- resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
- resourceName = resourceInstance.getResourceName();
- resourceVersion = resourceInstance.getResourceVersion();
- resourceType = resourceInstance.getResourceType();
- resourceUUID = resourceInstance.getResourceUUID();
- resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
- category = resourceInstance.getCategory();
- subcategory = resourceInstance.getSubcategory();
- artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
- }
-
- public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources){
- List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
- if( resources != null ){
- for( IResourceInstance resourceInstance : resources ){
- buildResources.add(new ResourceInfoImpl(resourceInstance));
- }
- }
- return buildResources;
- }
-
- @Override
- public String getResourceInstanceName() {
- return resourceInstanceName;
- }
-
- public void setResourceInstanceName(String resourceInstanceName) {
- this.resourceInstanceName = resourceInstanceName;
- }
-
- @Override
- public String getResourceName() {
- return resourceName;
- }
-
- public void setResourceName(String resourceName) {
- this.resourceName = resourceName;
- }
-
- @Override
- public String getResourceVersion() {
- return resourceVersion;
- }
-
- public void setResourceVersion(String resourceVersion) {
- this.resourceVersion = resourceVersion;
- }
-
- @Override
- public String getResourceType() {
- return resourceType;
- }
-
- public void setResoucreType(String resourceType) {
- this.resourceType = resourceType;
- }
-
- @Override
- public String getResourceUUID() {
- return resourceUUID;
- }
-
- public void setResourceUUID(String resourceUUID) {
- this.resourceUUID = resourceUUID;
- }
-
- @Override
- public List<IArtifactInfo> getArtifacts() {
- List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
- if( artifacts != null ){
- temp.addAll(artifacts);
- }
- return temp;
- }
-
- public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
- this.artifacts = artifacts;
- }
-
- @JsonIgnore
- public List<ArtifactInfoImpl> getArtifactsImpl() {
- return artifacts;
- }
-
- @Override
- public String getResourceInvariantUUID() {
- return resourceInvariantUUID;
- }
-
- public void setResourceInvariantUUID(String resourceInvariantUUID) {
- this.resourceInvariantUUID = resourceInvariantUUID;
- }
- public String getResourceCustomizationUUID() {
- return resourceCustomizationUUID;
- }
-
- public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
- this.resourceCustomizationUUID = resourceCustomizationUUID;
- }
-
- public String getCategory() {
- return category;
- }
-
- public void setCategory(String category) {
- this.category = category;
- }
-
- public String getSubcategory() {
- return subcategory;
- }
-
- public void setSubcategory(String subcategory) {
- this.subcategory = subcategory;
- }
-
- @Override
- public boolean equals(final Object other) {
- if (!(other instanceof ResourceInfoImpl)) {
- return false;
- }
- ResourceInfoImpl castOther = (ResourceInfoImpl) other;
- return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
- .append(resourceVersion, castOther.resourceVersion).isEquals();
- }
-
- @Override
- public int hashCode() {
- return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName)
- .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID)
- .append(category).append(subcategory).append(artifacts).toHashCode();
- }
+public class ResourceInfoImpl implements IResourceInstance {
+ public ResourceInfoImpl() {}
+
+ private String resourceInstanceName;
+ private String resourceCustomizationUUID;
+ private String resourceName;
+ private String resourceVersion;
+ private String resourceType;
+ private String resourceUUID;
+ private String resourceInvariantUUID;
+ private String category;
+ private String subcategory;
+ private List<ArtifactInfoImpl> artifacts;
+
+ private ResourceInfoImpl(IResourceInstance resourceInstance) {
+ resourceInstanceName = resourceInstance.getResourceInstanceName();
+ resourceCustomizationUUID = resourceInstance.getResourceCustomizationUUID();
+ resourceName = resourceInstance.getResourceName();
+ resourceVersion = resourceInstance.getResourceVersion();
+ resourceType = resourceInstance.getResourceType();
+ resourceUUID = resourceInstance.getResourceUUID();
+ resourceInvariantUUID = resourceInstance.getResourceInvariantUUID();
+ category = resourceInstance.getCategory();
+ subcategory = resourceInstance.getSubcategory();
+ artifacts = ArtifactInfoImpl.convertToArtifactInfoImpl(resourceInstance.getArtifacts());
+ }
+
+ public static List<ResourceInfoImpl> convertToJsonContainer(List<IResourceInstance> resources) {
+ List<ResourceInfoImpl> buildResources = new ArrayList<ResourceInfoImpl>();
+ if (resources != null) {
+ for (IResourceInstance resourceInstance : resources) {
+ buildResources.add(new ResourceInfoImpl(resourceInstance));
+ }
+ }
+ return buildResources;
+ }
+
+ @Override
+ public String getResourceInstanceName() {
+ return resourceInstanceName;
+ }
+
+ public void setResourceInstanceName(String resourceInstanceName) {
+ this.resourceInstanceName = resourceInstanceName;
+ }
+
+ @Override
+ public String getResourceName() {
+ return resourceName;
+ }
+
+ public void setResourceName(String resourceName) {
+ this.resourceName = resourceName;
+ }
+
+ @Override
+ public String getResourceVersion() {
+ return resourceVersion;
+ }
+
+ public void setResourceVersion(String resourceVersion) {
+ this.resourceVersion = resourceVersion;
+ }
+
+ @Override
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ public void setResoucreType(String resourceType) {
+ this.resourceType = resourceType;
+ }
+
+ @Override
+ public String getResourceUUID() {
+ return resourceUUID;
+ }
+
+ public void setResourceUUID(String resourceUUID) {
+ this.resourceUUID = resourceUUID;
+ }
+
+ @Override
+ public List<IArtifactInfo> getArtifacts() {
+ List<IArtifactInfo> temp = new ArrayList<IArtifactInfo>();
+ if (artifacts != null) {
+ temp.addAll(artifacts);
+ }
+ return temp;
+ }
+
+ public void setArtifacts(List<ArtifactInfoImpl> artifacts) {
+ this.artifacts = artifacts;
+ }
+
+ @JsonIgnore
+ public List<ArtifactInfoImpl> getArtifactsImpl() {
+ return artifacts;
+ }
+
+ @Override
+ public String getResourceInvariantUUID() {
+ return resourceInvariantUUID;
+ }
+
+ public void setResourceInvariantUUID(String resourceInvariantUUID) {
+ this.resourceInvariantUUID = resourceInvariantUUID;
+ }
+
+ public String getResourceCustomizationUUID() {
+ return resourceCustomizationUUID;
+ }
+
+ public void setResourceCustomizationUUID(String resourceCustomizationUUID) {
+ this.resourceCustomizationUUID = resourceCustomizationUUID;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getSubcategory() {
+ return subcategory;
+ }
+
+ public void setSubcategory(String subcategory) {
+ this.subcategory = subcategory;
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof ResourceInfoImpl)) {
+ return false;
+ }
+ ResourceInfoImpl castOther = (ResourceInfoImpl) other;
+ return new EqualsBuilder().append(resourceUUID, castOther.resourceUUID)
+ .append(resourceVersion, castOther.resourceVersion).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(resourceInstanceName).append(resourceCustomizationUUID).append(resourceName)
+ .append(resourceVersion).append(resourceType).append(resourceUUID).append(resourceInvariantUUID)
+ .append(category).append(subcategory).append(artifacts).toHashCode();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
index e9e5372d98..14ea0cde4b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/client/test/rest/ASDCRestInterface.java
@@ -24,7 +24,6 @@ package org.onap.so.asdc.client.test.rest;
import java.io.IOException;
-
import javax.transaction.Transactional;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
@@ -32,7 +31,6 @@ import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-
import org.onap.so.asdc.client.ASDCController;
import org.onap.so.asdc.client.exceptions.ASDCControllerException;
import org.onap.so.asdc.client.exceptions.ASDCParametersException;
@@ -49,8 +47,9 @@ import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
/**
- * This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on jboss without the need to be connected
- * to the ASDC service broker. It starts the test at the treatNotification step and simulates both the notification step as well as the artifact download step.
+ * This is a TEST only rest interface. It is not used in production, it is used to aid in testing the ASDC service on
+ * jboss without the need to be connected to the ASDC service broker. It starts the test at the treatNotification step
+ * and simulates both the notification step as well as the artifact download step.
*
* i.e. http://localhost:8080/asdc/treatNotification/v1
*
@@ -65,57 +64,58 @@ import org.springframework.stereotype.Component;
@Profile("test")
public class ASDCRestInterface {
- private static DistributionClientEmulator distributionClientEmulator;
-
- private static JsonStatusData statusData;
-
- private static final Logger logger = LoggerFactory.getLogger(ASDCRestInterface.class );
-
- @Autowired
- private ASDCController asdcController;
-
- @Autowired
- private ToscaResourceInstaller toscaInstaller;
+ private static DistributionClientEmulator distributionClientEmulator;
+
+ private static JsonStatusData statusData;
+
+ private static final Logger logger = LoggerFactory.getLogger(ASDCRestInterface.class);
+
+ @Autowired
+ private ASDCController asdcController;
+
+ @Autowired
+ private ToscaResourceInstaller toscaInstaller;
+
+ @POST
+ @Path("/treatNotification/v1")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Transactional
+ public Response invokeASDCService(NotificationDataImpl request,
+ @HeaderParam("resource-location") String resourceLocation)
+ throws ASDCControllerException, ASDCParametersException, IOException {
+ distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
+
+ asdcController.setControllerName("asdc-controller1");
+ asdcController.setDistributionClient(distributionClientEmulator);
+ asdcController.initASDC();
+ asdcController.treatNotification(request);
+ asdcController.closeASDC();
+ return Response.status(200).build();
+ }
+
+ @POST
+ @Path("/statusData/v1")
+ @Produces(MediaType.APPLICATION_JSON)
+ @Transactional
+ public Response invokeASDCStatusData(String request) {
+
+ try {
+ distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
+ statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
- @POST
- @Path("/treatNotification/v1")
- @Produces(MediaType.APPLICATION_JSON)
- @Transactional
- public Response invokeASDCService(NotificationDataImpl request, @HeaderParam("resource-location") String resourceLocation)
- throws ASDCControllerException, ASDCParametersException, IOException {
- distributionClientEmulator = new DistributionClientEmulator(resourceLocation);
-
- asdcController.setControllerName("asdc-controller1");
- asdcController.setDistributionClient(distributionClientEmulator);
- asdcController.initASDC();
- asdcController.treatNotification(request);
- asdcController.closeASDC();
- return Response.status(200).build();
- }
-
- @POST
- @Path("/statusData/v1")
- @Produces(MediaType.APPLICATION_JSON)
- @Transactional
- public Response invokeASDCStatusData(String request) {
-
- try{
- distributionClientEmulator = new DistributionClientEmulator("resource-examples/");
- statusData = JsonStatusData.instantiateNotifFromJsonFile("resource-examples/");
-
- ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
- asdcController.initASDC();
- toscaInstaller.installTheComponentStatus(statusData);
- asdcController.closeASDC();
- }catch(Exception e){
- logger.info("Error caught " + e.getMessage());
- logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION.toString(),
- "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService",
- ErrorCode.BusinessProcesssError.getValue(), "Exception in invokeASDCService", e);
- }
- logger.info("ASDC Updates are complete");
- logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(), "ASDC",
- "ASDC Updates Are Complete");
- return null;
- }
+ ASDCController asdcController = new ASDCController("asdc-controller1", distributionClientEmulator);
+ asdcController.initASDC();
+ toscaInstaller.installTheComponentStatus(statusData);
+ asdcController.closeASDC();
+ } catch (Exception e) {
+ logger.info("Error caught " + e.getMessage());
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION.toString(),
+ "Exception caught during ASDCRestInterface", "ASDC", "invokeASDCService",
+ ErrorCode.BusinessProcesssError.getValue(), "Exception in invokeASDCService", e);
+ }
+ logger.info("ASDC Updates are complete");
+ logger.info("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC.toString(), statusData.getDistributionID(),
+ "ASDC", "ASDC Updates Are Complete");
+ return null;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
index 1e227aefa1..043055e23c 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ASDCElementInfo.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.so.asdc.client.ASDCConfiguration;
@@ -35,177 +34,184 @@ import org.onap.so.asdc.client.ASDCConfiguration;
*/
public class ASDCElementInfo {
- /**
- * A default, empty instance used in case a source element was not correctly provided.
- */
- public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo();
-
- /**
- * Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/>
- * <br/>
- * Possible types allowed:<br/>
- * <ul>
- * <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
- * <ul>
- */
- public static enum ASDCElementTypeEnum {
- /**
- * The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
- */
- VNF_RESOURCE
- };
-
- /**
- * The map of element information fields useful for logging. The complete contents of this list will be concatenated.
- */
- private final Map<String, String> elementInfoMap = new HashMap<>();
-
- /**
- * The type of this element.
- */
- private final String type;
-
- private ASDCElementInfo () {
- // Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE.
- this.type = "";
- }
-
- /**
- * Artifact-type based constructor. Requires a valid artifact type.
- * @param artifactType The artifact type
- */
- private ASDCElementInfo (String artifactType) {
- // We need the exact type name here...
- this.type = artifactType;
- }
-
- /**
- * 'Other element type'-based constructor. Requires a valid element type.
- * @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing
- */
- private ASDCElementInfo (ASDCElementTypeEnum elementType) {
- // We need the exact type name here...
- this.type = elementType.name();
- }
-
- /**
- * Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time.
- *
- * @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.)
- * @param value The value bound to the information entry.
- */
- public final void addElementInfo(String key, String value) {
- if ((key != null) && (value != null)) {
- this.getElementInfoMap().put(key, value);
- }
- }
-
- /**
- * Returns an aggregated, formatted list of the expected details about an ASDC element.
- * (non-Javadoc)
- * @return An aggregated list of element information entries, comma-separated.
- * @see java.lang.Object#toString()
- */
- @Override
- public final String toString() {
- StringBuilder sb = new StringBuilder();
- List<String> aggregatedElements = new ArrayList<>();
- for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) {
- aggregatedElements.add(entry.getKey() + ": " + entry.getValue());
- }
- sb.append(aggregatedElements.size() > 0 ? aggregatedElements.get(0) : "");
- if (aggregatedElements.size() > 1) {
- for (int i = 1; i < aggregatedElements.size(); ++i) {
- sb.append (", ");
- sb.append(aggregatedElements.get(i));
- }
- }
- return sb.toString();
- }
-
- /**
- * The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc.
- * @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or an ASDCElementTypeEnum entry name.
- * @see ASDCElementInfo.ASDCElementTypeEnum
- */
- public String getType() {
- return type;
- }
-
- /**
- * Provides the map of all element information entries for this type.
- * @return A map of all element information entries which will be used by the toString() method.
- * @see ASDCElementInfo#toString()
- */
- protected Map<String, String> getElementInfoMap() {
- return elementInfoMap;
- }
-
- /**
- * Create an ASDCElementInfo object from a VNF Resource.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>Resource Instance Name</li>
- * <li>Resource Instance UUID</li>
- * </ul>
- *
- * @param vfResourceStructure The VfResourceStructure to use as source of information (see {@link VfResourceStructure}).
- * @return an ASDCElementInfo using the information held in the VNF Resource.
- */
- public static final ASDCElementInfo createElementFromVfResourceStructure (VfResourceStructure vfResourceStructure) {
- if (vfResourceStructure == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCElementTypeEnum.VNF_RESOURCE);
- IResourceInstance resourceInstance = vfResourceStructure.getResourceInstance();
- elementInfo.addElementInfo("Resource Instance Name", resourceInstance.getResourceInstanceName());
- elementInfo.addElementInfo("Resource Instance Invariant UUID", resourceInstance.getResourceInvariantUUID());
- return elementInfo;
- }
-
- /**
- * Create an ASDCElementInfo object from a VF Module.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>Module Model Name</li>
- * <li>Module Model UUID</li>
- * </ul>
- *
- * @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}).
- * @return an ASDCElementInfo using the information held in the VF Module.
- */
- public static final ASDCElementInfo createElementFromVfModuleStructure (VfModuleStructure vfModuleStructure) {
- if (vfModuleStructure == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA);
- IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata();
- elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName());
- elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID());
- return elementInfo;
- }
-
- /**
- * Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/>
- * <br/>
- * <b>Used information:</b><br/>
- * <ul>
- * <li>IArtifactInfo Name</li>
- * <li>IArtifactInfo UUID</li>
- * </ul>
- *
- * @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}).
- * @return an ASDCElementInfo using the information held in the IArtifactInfo instance.
- */
- public static final ASDCElementInfo createElementFromVfArtifactInfo (IArtifactInfo artifactInfo) {
- if (artifactInfo == null) {
- return EMPTY_INSTANCE;
- }
- ASDCElementInfo elementInfo = new ASDCElementInfo(artifactInfo.getArtifactType());
- elementInfo.addElementInfo(elementInfo.getType() + " Name", artifactInfo.getArtifactName());
- elementInfo.addElementInfo(elementInfo.getType() + " UUID", artifactInfo.getArtifactUUID());
- return elementInfo;
- }
+ /**
+ * A default, empty instance used in case a source element was not correctly provided.
+ */
+ public static final ASDCElementInfo EMPTY_INSTANCE = new ASDCElementInfo();
+
+ /**
+ * Used to define the other possible ASDC Element types (usually in addition to existing artifact types, etc.).<br/>
+ * <br/>
+ * Possible types allowed:<br/>
+ * <ul>
+ * <li>{@link ASDCElementTypeEnum#VNF_RESOURCE}</li>
+ * <ul>
+ */
+ public static enum ASDCElementTypeEnum {
+ /**
+ * The type VNF_RESOURCE. Represents a VNF_RESOURCE element.
+ */
+ VNF_RESOURCE
+ };
+
+ /**
+ * The map of element information fields useful for logging. The complete contents of this list will be
+ * concatenated.
+ */
+ private final Map<String, String> elementInfoMap = new HashMap<>();
+
+ /**
+ * The type of this element.
+ */
+ private final String type;
+
+ private ASDCElementInfo() {
+ // Private parameterless constructor. Not visible, only used for EMPTY_INSTANCE.
+ this.type = "";
+ }
+
+ /**
+ * Artifact-type based constructor. Requires a valid artifact type.
+ *
+ * @param artifactType The artifact type
+ */
+ private ASDCElementInfo(String artifactType) {
+ // We need the exact type name here...
+ this.type = artifactType;
+ }
+
+ /**
+ * 'Other element type'-based constructor. Requires a valid element type.
+ *
+ * @param elementType An ASDCElementTypeEnum entry. This will usually contain enumerated types not in the existing
+ */
+ private ASDCElementInfo(ASDCElementTypeEnum elementType) {
+ // We need the exact type name here...
+ this.type = elementType.name();
+ }
+
+ /**
+ * Add an information entry (name, UUID, etc.) from an artifact/resource/..., once a at time.
+ *
+ * @param key The key (name) of the information entry (Artifact UUID, Resource Name, etc.)
+ * @param value The value bound to the information entry.
+ */
+ public final void addElementInfo(String key, String value) {
+ if ((key != null) && (value != null)) {
+ this.getElementInfoMap().put(key, value);
+ }
+ }
+
+ /**
+ * Returns an aggregated, formatted list of the expected details about an ASDC element. (non-Javadoc)
+ *
+ * @return An aggregated list of element information entries, comma-separated.
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public final String toString() {
+ StringBuilder sb = new StringBuilder();
+ List<String> aggregatedElements = new ArrayList<>();
+ for (Entry<String, String> entry : this.getElementInfoMap().entrySet()) {
+ aggregatedElements.add(entry.getKey() + ": " + entry.getValue());
+ }
+ sb.append(aggregatedElements.size() > 0 ? aggregatedElements.get(0) : "");
+ if (aggregatedElements.size() > 1) {
+ for (int i = 1; i < aggregatedElements.size(); ++i) {
+ sb.append(", ");
+ sb.append(aggregatedElements.get(i));
+ }
+ }
+ return sb.toString();
+ }
+
+ /**
+ * The type that was defined at creation time. This is typically VNF_RESOURCE, VF_MODULE_METADATA, HEAT_ENV, etc.
+ *
+ * @return The type of this element information type. This will usually be either an ArtifactTypeEnum entry name or
+ * an ASDCElementTypeEnum entry name.
+ * @see ASDCElementInfo.ASDCElementTypeEnum
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * Provides the map of all element information entries for this type.
+ *
+ * @return A map of all element information entries which will be used by the toString() method.
+ * @see ASDCElementInfo#toString()
+ */
+ protected Map<String, String> getElementInfoMap() {
+ return elementInfoMap;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from a VNF Resource.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>Resource Instance Name</li>
+ * <li>Resource Instance UUID</li>
+ * </ul>
+ *
+ * @param vfResourceStructure The VfResourceStructure to use as source of information (see
+ * {@link VfResourceStructure}).
+ * @return an ASDCElementInfo using the information held in the VNF Resource.
+ */
+ public static final ASDCElementInfo createElementFromVfResourceStructure(VfResourceStructure vfResourceStructure) {
+ if (vfResourceStructure == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCElementTypeEnum.VNF_RESOURCE);
+ IResourceInstance resourceInstance = vfResourceStructure.getResourceInstance();
+ elementInfo.addElementInfo("Resource Instance Name", resourceInstance.getResourceInstanceName());
+ elementInfo.addElementInfo("Resource Instance Invariant UUID", resourceInstance.getResourceInvariantUUID());
+ return elementInfo;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from a VF Module.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>Module Model Name</li>
+ * <li>Module Model UUID</li>
+ * </ul>
+ *
+ * @param vfModuleStructure The VfModuleStructure to use as source of information (see {@link VfModuleStructure}).
+ * @return an ASDCElementInfo using the information held in the VF Module.
+ */
+ public static final ASDCElementInfo createElementFromVfModuleStructure(VfModuleStructure vfModuleStructure) {
+ if (vfModuleStructure == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(ASDCConfiguration.VF_MODULES_METADATA);
+ IVfModuleData moduleMetadata = vfModuleStructure.getVfModuleMetadata();
+ elementInfo.addElementInfo("Module Model Name", moduleMetadata.getVfModuleModelName());
+ elementInfo.addElementInfo("Module Model Invariant UUID", moduleMetadata.getVfModuleModelInvariantUUID());
+ return elementInfo;
+ }
+
+ /**
+ * Create an ASDCElementInfo object from an IArtfiactInfo instance.<br/>
+ * <br/>
+ * <b>Used information:</b><br/>
+ * <ul>
+ * <li>IArtifactInfo Name</li>
+ * <li>IArtifactInfo UUID</li>
+ * </ul>
+ *
+ * @param artifactInfo The VfModuleStructure to use as source of information (see {@link IArtifactInfo}).
+ * @return an ASDCElementInfo using the information held in the IArtifactInfo instance.
+ */
+ public static final ASDCElementInfo createElementFromVfArtifactInfo(IArtifactInfo artifactInfo) {
+ if (artifactInfo == null) {
+ return EMPTY_INSTANCE;
+ }
+ ASDCElementInfo elementInfo = new ASDCElementInfo(artifactInfo.getArtifactType());
+ elementInfo.addElementInfo(elementInfo.getType() + " Name", artifactInfo.getArtifactName());
+ elementInfo.addElementInfo(elementInfo.getType() + " UUID", artifactInfo.getArtifactUUID());
+ return elementInfo;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/BigDecimalVersion.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/BigDecimalVersion.java
index 1dd92eac7a..616afe03d0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/BigDecimalVersion.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/BigDecimalVersion.java
@@ -24,39 +24,39 @@ package org.onap.so.asdc.installer;
import java.math.BigDecimal;
public class BigDecimalVersion {
-
- /**
+
+ /**
* This method truncates and convert the version String provided in the notification.
*
* @param version The version to check
* @return A BigDecimal value checked and truncated
*/
public static BigDecimal castAndCheckNotificationVersion(String version) {
- // Truncate the version if bad type
- String[] splitVersion = version.split("\\.");
- StringBuilder newVersion = new StringBuilder();
- if (splitVersion.length > 1) {
- newVersion.append(splitVersion[0]);
- newVersion.append(".");
- newVersion.append(splitVersion[1]);
- } else {
- return new BigDecimal(splitVersion[0]);
- }
-
- for (int i=2;i<splitVersion.length;i++) {
- newVersion.append(splitVersion[i]);
- }
-
- return new BigDecimal(newVersion.toString());
+ // Truncate the version if bad type
+ String[] splitVersion = version.split("\\.");
+ StringBuilder newVersion = new StringBuilder();
+ if (splitVersion.length > 1) {
+ newVersion.append(splitVersion[0]);
+ newVersion.append(".");
+ newVersion.append(splitVersion[1]);
+ } else {
+ return new BigDecimal(splitVersion[0]);
+ }
+
+ for (int i = 2; i < splitVersion.length; i++) {
+ newVersion.append(splitVersion[i]);
+ }
+
+ return new BigDecimal(newVersion.toString());
}
-
+
/**
* This method truncates and convert the version String provided in the notification.
*
* @param version The version to check
* @return A String value checked and truncated to Decimal format
*/
- public static String castAndCheckNotificationVersionToString (String version) {
- return castAndCheckNotificationVersion(version).toString();
+ public static String castAndCheckNotificationVersionToString(String version) {
+ return castAndCheckNotificationVersion(version).toString();
}
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IArtifactOrchestrator.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IArtifactOrchestrator.java
index ac43a66ffa..f396d80191 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IArtifactOrchestrator.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IArtifactOrchestrator.java
@@ -30,8 +30,10 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
public interface IArtifactOrchestrator {
- void installTheArtifact (INotificationData iNotif, IResourceInstance resource, IArtifactInfo artifact, IDistributionClientDownloadResult downloadResult) throws ArtifactInstallerException;
+ void installTheArtifact(INotificationData iNotif, IResourceInstance resource, IArtifactInfo artifact,
+ IDistributionClientDownloadResult downloadResult) throws ArtifactInstallerException;
- boolean isArtifactAlreadyDeployed (INotificationData iNotif,IResourceInstance resource,IArtifactInfo artifact) throws ArtifactInstallerException;
+ boolean isArtifactAlreadyDeployed(INotificationData iNotif, IResourceInstance resource, IArtifactInfo artifact)
+ throws ArtifactInstallerException;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfModuleData.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfModuleData.java
index f9524de2a1..5751c2b33b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfModuleData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfModuleData.java
@@ -22,30 +22,30 @@ package org.onap.so.asdc.installer;
public interface IVfModuleData {
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelName();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelName();
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelInvariantUUID();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelInvariantUUID();
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelCustomizationUUID();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelCustomizationUUID();
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelVersion();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelVersion();
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelUUID();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelUUID();
- // Method descriptor #4 ()Ljava/lang/String;
- public abstract java.lang.String getVfModuleModelDescription();
+ // Method descriptor #4 ()Ljava/lang/String;
+ public abstract java.lang.String getVfModuleModelDescription();
- // Method descriptor #10 ()Z
- public abstract boolean isBase();
+ // Method descriptor #10 ()Z
+ public abstract boolean isBase();
- // Method descriptor #12 ()Ljava/util/List;
- // Signature: ()Ljava/util/List<Ljava/lang/String;>;
- public abstract java.util.List<String> getArtifacts();
+ // Method descriptor #12 ()Ljava/util/List;
+ // Signature: ()Ljava/util/List<Ljava/lang/String;>;
+ public abstract java.util.List<String> getArtifacts();
- public abstract java.util.Map<String,String> getProperties();
+ public abstract java.util.Map<String, String> getProperties();
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfResourceInstaller.java
index 445b10b588..6a173df2f3 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/IVfResourceInstaller.java
@@ -26,7 +26,7 @@ import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
public interface IVfResourceInstaller {
- boolean isResourceAlreadyDeployed (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException;
+ boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStructure) throws ArtifactInstallerException;
- public void installTheResource (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException;
+ public void installTheResource(VfResourceStructure vfResourceStructure) throws ArtifactInstallerException;
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java
index 1c1351b272..8aa9684426 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/PnfResourceStructure.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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.
+ * 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=========================================================
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
*/
package org.onap.so.asdc.installer;
@@ -39,7 +34,7 @@ public class PnfResourceStructure extends ResourceStructure {
@Override
public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
}
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 53cc74f7e4..9965a05294 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
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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.
+ * 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=========================================================
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
*/
package org.onap.so.asdc.installer;
@@ -88,7 +83,7 @@ public abstract class ResourceStructure {
* @throws UnsupportedEncodingException
*/
public abstract void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException;
/**
* Prepare the resource for installation.
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java
index 8d55f57dfa..7e5b7c905b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceType.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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.
+ * 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=========================================================
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
*/
package org.onap.so.asdc.installer;
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
index 3efc503fcb..749a397ee0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ToscaResourceStructure.java
@@ -25,7 +25,6 @@ package org.onap.so.asdc.installer;
import java.io.File;
import java.nio.file.Paths;
import java.util.List;
-
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.tosca.parser.api.ISdcCsarHelper;
import org.onap.sdc.tosca.parser.impl.SdcToscaParserFactory;
@@ -59,450 +58,443 @@ import org.springframework.beans.factory.annotation.Value;
public class ToscaResourceStructure {
- protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class);
-
- /**
- * mso config path, used for the config files, like download csar files.
- */
- private String msoConfigPath;
-
- Metadata serviceMetadata;
- private Service catalogService;
- ISdcCsarHelper sdcCsarHelper;
- List<NodeTemplate> allottedList;
- List<NodeTemplate> networkTypes;
- List<NodeTemplate> vfTypes;
- String heatTemplateUUID;
- String volHeatTemplateUUID;
- String volHeatEnvTemplateUUID;
- String envHeatTemplateUUID;
- String heatFilesUUID;
- String workloadPerformance;
- String serviceVersion;
- private boolean isDeployedSuccessfully=false;
-
-
- private NetworkResourceCustomization catalogNetworkResourceCustomization;
-
- private NetworkResource catalogNetworkResource;
-
- private List<NetworkInstanceGroup> catalogNetworkInstanceGroup;
-
- private CollectionNetworkResourceCustomization catalogCollectionNetworkResourceCustomization;
-
- private CollectionResource catalogCollectionResource;
-
- private CollectionResourceCustomization catalogCollectionResourceCustomization;
-
- private NetworkCollectionResourceCustomization catalogNetworkCollectionResourceCustomization;
-
- private ServiceProxyResourceCustomization catalogServiceProxyResourceCustomization;
-
- private ConfigurationResource catalogConfigurationResource;
-
- private ConfigurationResourceCustomization catalogConfigurationResourceCustomization;
-
- private AllottedResourceCustomization catalogResourceCustomization;
-
- private VfModule vfModule;
-
- private VfModuleCustomization vfModuleCustomization;
-
- private VnfResourceCustomization vnfResourceCustomization;
-
- private PnfResourceCustomization pnfResourceCustomization;
-
- private AllottedResource allottedResource;
-
- private AllottedResourceCustomization allottedResourceCustomization;
-
- private TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup;
-
- private IArtifactInfo toscaArtifact;
-
- private ToscaCsar toscaCsar;
-
- public ToscaResourceStructure(){
- this(System.getProperty("mso.config.path"));
- }
-
- public ToscaResourceStructure(final String msoConfigPath){
- this.msoConfigPath = msoConfigPath;
- logger.info("MSO config path is: {}", msoConfigPath);
- }
-
- public void updateResourceStructure(IArtifactInfo artifact) throws ASDCDownloadException {
-
- try {
- SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();//Autoclosable
-
- String filePath = Paths.get(msoConfigPath, "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName()).normalize().toString();
-
- File spoolFile = new File(filePath);
-
- logger.debug("ASDC File path is: {}", spoolFile.getAbsolutePath());
- logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***PATH", "ASDC",
- spoolFile.getAbsolutePath());
-
- sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(),false);
-
- }catch(Exception e){
- logger.debug(e.getMessage(), e);
- logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
- "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC",
- "processResourceNotification", ErrorCode.BusinessProcesssError.getValue(),
- "Exception in " + "processResourceNotification", e);
-
- throw new ASDCDownloadException ("Exception caught when passing the csar file to the parser ", e);
- }
-
- serviceMetadata = sdcCsarHelper.getServiceMetadata();
-
- }
-
- public String getHeatTemplateUUID() {
- return heatTemplateUUID;
- }
-
- public void setHeatTemplateUUID(String heatTemplateUUID) {
- this.heatTemplateUUID = heatTemplateUUID;
- }
-
- public List<NodeTemplate> getAllottedList() {
- return allottedList;
- }
-
- public void setAllottedList(List<NodeTemplate> allottedList) {
- this.allottedList = allottedList;
- }
-
- public ISdcCsarHelper getSdcCsarHelper() {
- return sdcCsarHelper;
- }
-
- public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) {
- this.sdcCsarHelper = sdcCsarHelper;
- }
-
- public Metadata getServiceMetadata() {
- return serviceMetadata;
- }
-
- public Service getCatalogService() {
- return catalogService;
- }
-
- public void setServiceMetadata(Metadata serviceMetadata) {
- this.serviceMetadata = serviceMetadata;
- }
-
- public void setCatalogService(Service catalogService) {
- this.catalogService = catalogService;
- }
-
- public List<NodeTemplate> getNetworkTypes() {
- return networkTypes;
- }
-
- public void setNetworkTypes(List<NodeTemplate> networkTypes) {
- this.networkTypes = networkTypes;
- }
-
- public List<NodeTemplate> getVfTypes() {
- return vfTypes;
- }
-
- public void setVfTypes(List<NodeTemplate> vfTypes) {
- this.vfTypes = vfTypes;
- }
-
- public AllottedResourceCustomization getCatalogResourceCustomization() {
- return catalogResourceCustomization;
- }
-
- public void setCatalogResourceCustomization(
- AllottedResourceCustomization catalogResourceCustomization) {
- this.catalogResourceCustomization = catalogResourceCustomization;
- }
-
- // Network Only
- public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
- return catalogNetworkResourceCustomization;
- }
- // Network Only
- public void setCatalogNetworkResourceCustomization(NetworkResourceCustomization catalogNetworkResourceCustomization) {
- this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
- }
-
- public NetworkResource getCatalogNetworkResource() {
- return catalogNetworkResource;
- }
-
- public void setCatalogNetworkResource(NetworkResource catalogNetworkResource) {
- this.catalogNetworkResource = catalogNetworkResource;
- }
-
- public VfModule getCatalogVfModule() {
- return vfModule;
- }
-
- public void setCatalogVfModule(VfModule vfModule) {
- this.vfModule = vfModule;
- }
-/*
- public VnfResource getCatalogVnfResource() {
- return vnfResource;
- }
-
- public void setCatalogVnfResource(VnfResource vnfResource) {
- this.vnfResource = vnfResource;
- }
-
- */
-
- public VnfResourceCustomization getCatalogVnfResourceCustomization() {
- return vnfResourceCustomization;
- }
-
- public void setCatalogVnfResourceCustomization(
- VnfResourceCustomization vnfResourceCustomization) {
- this.vnfResourceCustomization = vnfResourceCustomization;
- }
-
- public PnfResourceCustomization getPnfResourceCustomization() {
- return pnfResourceCustomization;
- }
-
- public void setPnfResourceCustomization(PnfResourceCustomization pnfResourceCustomization) {
- this.pnfResourceCustomization = pnfResourceCustomization;
- }
-
-
- public VfModuleCustomization getCatalogVfModuleCustomization() {
- return vfModuleCustomization;
- }
-
- public void setCatalogVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
- this.vfModuleCustomization = vfModuleCustomization;
- }
-
- public AllottedResource getAllottedResource() {
- return allottedResource;
- }
-
- public void setAllottedResource(AllottedResource allottedResource) {
- this.allottedResource = allottedResource;
- }
-
- public AllottedResourceCustomization getCatalogAllottedResourceCustomization() {
- return allottedResourceCustomization;
- }
-
- public void setCatalogAllottedResourceCustomization(
- AllottedResourceCustomization allottedResourceCustomization) {
- this.allottedResourceCustomization = allottedResourceCustomization;
- }
-
- public TempNetworkHeatTemplateLookup getCatalogTempNetworkHeatTemplateLookup() {
- return tempNetworkHeatTemplateLookup;
- }
-
- public void setCatalogTempNetworkHeatTemplateLookup(
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
- this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
- }
-
- public String getHeatFilesUUID() {
- return heatFilesUUID;
- }
-
- public void setHeatFilesUUID(String heatFilesUUID) {
- this.heatFilesUUID = heatFilesUUID;
- }
-
- public IArtifactInfo getToscaArtifact() {
- return toscaArtifact;
- }
-
- public void setToscaArtifact(IArtifactInfo toscaArtifact) {
- this.toscaArtifact = toscaArtifact;
- }
-
- public ToscaCsar getCatalogToscaCsar() {
- return toscaCsar;
- }
-
- public void setCatalogToscaCsar(ToscaCsar toscaCsar) {
- this.toscaCsar = toscaCsar;
- }
-
- public String getVolHeatTemplateUUID() {
- return volHeatTemplateUUID;
- }
-
- public void setVolHeatTemplateUUID(String volHeatTemplateUUID) {
- this.volHeatTemplateUUID = volHeatTemplateUUID;
- }
-
- public String getEnvHeatTemplateUUID() {
- return envHeatTemplateUUID;
- }
-
- public void setEnvHeatTemplateUUID(String envHeatTemplateUUID) {
- this.envHeatTemplateUUID = envHeatTemplateUUID;
- }
-
- public String getVolHeatEnvTemplateUUID() {
- return volHeatEnvTemplateUUID;
- }
-
- public void setVolHeatEnvTemplateUUID(String volHeatEnvTemplateUUID) {
- this.volHeatEnvTemplateUUID = volHeatEnvTemplateUUID;
- }
-
- public String getServiceVersion() {
- return serviceVersion;
- }
-
- public void setServiceVersion(String serviceVersion) {
- this.serviceVersion = serviceVersion;
- }
-
- public String getWorkloadPerformance() {
- return workloadPerformance;
- }
-
- public void setWorkloadPerformance(String workloadPerformance) {
- this.workloadPerformance = workloadPerformance;
- }
-
- public VfModule getVfModule() {
- return vfModule;
- }
-
- public void setVfModule(VfModule vfModule) {
- this.vfModule = vfModule;
- }
-
- public VfModuleCustomization getVfModuleCustomization() {
- return vfModuleCustomization;
- }
-
- public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
- this.vfModuleCustomization = vfModuleCustomization;
- }
-
-
- public VnfResourceCustomization getVnfResourceCustomization() {
- return vnfResourceCustomization;
- }
-
- public void setVnfResourceCustomization(
- VnfResourceCustomization vnfResourceCustomization) {
- this.vnfResourceCustomization = vnfResourceCustomization;
- }
-
- public AllottedResourceCustomization getAllottedResourceCustomization() {
- return allottedResourceCustomization;
- }
-
- public void setAllottedResourceCustomization(
- AllottedResourceCustomization allottedResourceCustomization) {
- this.allottedResourceCustomization = allottedResourceCustomization;
- }
-
- public TempNetworkHeatTemplateLookup getTempNetworkHeatTemplateLookup() {
- return tempNetworkHeatTemplateLookup;
- }
-
- public void setTempNetworkHeatTemplateLookup(
- TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
- this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
- }
-
- public List<NetworkInstanceGroup> getCatalogNetworkInstanceGroup() {
- return catalogNetworkInstanceGroup;
- }
-
- public void setCatalogNetworkInstanceGroup(List<NetworkInstanceGroup> catalogNetworkInstanceGroup) {
- this.catalogNetworkInstanceGroup = catalogNetworkInstanceGroup;
- }
-
- public CollectionNetworkResourceCustomization getCatalogCollectionNetworkResourceCustomization() {
- return catalogCollectionNetworkResourceCustomization;
- }
-
- public void setCatalogCollectionNetworkResourceCustomization(
- CollectionNetworkResourceCustomization catalogCollectionNetworkResourceCustomization) {
- this.catalogCollectionNetworkResourceCustomization = catalogCollectionNetworkResourceCustomization;
- }
-
- public CollectionResource getCatalogCollectionResource() {
- return catalogCollectionResource;
- }
-
- public void setCatalogCollectionResource(CollectionResource catalogCollectionResource) {
- this.catalogCollectionResource = catalogCollectionResource;
- }
-
- public CollectionResourceCustomization getCatalogCollectionResourceCustomization() {
- return catalogCollectionResourceCustomization;
- }
-
- public void setCatalogCollectionResourceCustomization(
- CollectionResourceCustomization catalogCollectionResourceCustomization) {
- this.catalogCollectionResourceCustomization = catalogCollectionResourceCustomization;
- }
-
- public NetworkCollectionResourceCustomization getCatalogNetworkCollectionResourceCustomization() {
- return catalogNetworkCollectionResourceCustomization;
- }
-
- public void setCatalogNetworkCollectionResourceCustomization(
- NetworkCollectionResourceCustomization catalogNetworkCollectionResourceCustomization) {
- this.catalogNetworkCollectionResourceCustomization = catalogNetworkCollectionResourceCustomization;
- }
-
- public ServiceProxyResourceCustomization getCatalogServiceProxyResourceCustomization() {
- return catalogServiceProxyResourceCustomization;
- }
-
- public void setCatalogServiceProxyResourceCustomization(
- ServiceProxyResourceCustomization catalogServiceProxyResourceCustomization) {
- this.catalogServiceProxyResourceCustomization = catalogServiceProxyResourceCustomization;
- }
-
- public ConfigurationResource getCatalogConfigurationResource() {
- return catalogConfigurationResource;
- }
-
- public void setCatalogConfigurationResource(ConfigurationResource catalogConfigurationResource) {
- this.catalogConfigurationResource = catalogConfigurationResource;
- }
-
- public ConfigurationResourceCustomization getCatalogConfigurationResourceCustomization() {
- return catalogConfigurationResourceCustomization;
- }
-
- public void setCatalogConfigurationResourceCustomization(
- ConfigurationResourceCustomization catalogConfigurationResourceCustomization) {
- this.catalogConfigurationResourceCustomization = catalogConfigurationResourceCustomization;
- }
-
- public ToscaCsar getToscaCsar() {
- return toscaCsar;
- }
-
- public void setToscaCsar(ToscaCsar toscaCsar) {
- this.toscaCsar = toscaCsar;
- }
-
- public boolean isDeployedSuccessfully() {
- return isDeployedSuccessfully;
- }
-
- public void setSuccessfulDeployment() {
- isDeployedSuccessfully = true;
- }
+ protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceStructure.class);
+
+ /**
+ * mso config path, used for the config files, like download csar files.
+ */
+ private String msoConfigPath;
+
+ Metadata serviceMetadata;
+ private Service catalogService;
+ ISdcCsarHelper sdcCsarHelper;
+ List<NodeTemplate> allottedList;
+ List<NodeTemplate> networkTypes;
+ List<NodeTemplate> vfTypes;
+ String heatTemplateUUID;
+ String volHeatTemplateUUID;
+ String volHeatEnvTemplateUUID;
+ String envHeatTemplateUUID;
+ String heatFilesUUID;
+ String workloadPerformance;
+ String serviceVersion;
+ private boolean isDeployedSuccessfully = false;
+
+
+ private NetworkResourceCustomization catalogNetworkResourceCustomization;
+
+ private NetworkResource catalogNetworkResource;
+
+ private List<NetworkInstanceGroup> catalogNetworkInstanceGroup;
+
+ private CollectionNetworkResourceCustomization catalogCollectionNetworkResourceCustomization;
+
+ private CollectionResource catalogCollectionResource;
+
+ private CollectionResourceCustomization catalogCollectionResourceCustomization;
+
+ private NetworkCollectionResourceCustomization catalogNetworkCollectionResourceCustomization;
+
+ private ServiceProxyResourceCustomization catalogServiceProxyResourceCustomization;
+
+ private ConfigurationResource catalogConfigurationResource;
+
+ private ConfigurationResourceCustomization catalogConfigurationResourceCustomization;
+
+ private AllottedResourceCustomization catalogResourceCustomization;
+
+ private VfModule vfModule;
+
+ private VfModuleCustomization vfModuleCustomization;
+
+ private VnfResourceCustomization vnfResourceCustomization;
+
+ private PnfResourceCustomization pnfResourceCustomization;
+
+ private AllottedResource allottedResource;
+
+ private AllottedResourceCustomization allottedResourceCustomization;
+
+ private TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup;
+
+ private IArtifactInfo toscaArtifact;
+
+ private ToscaCsar toscaCsar;
+
+ public ToscaResourceStructure() {
+ this(System.getProperty("mso.config.path"));
+ }
+
+ public ToscaResourceStructure(final String msoConfigPath) {
+ this.msoConfigPath = msoConfigPath;
+ logger.info("MSO config path is: {}", msoConfigPath);
+ }
+
+ public void updateResourceStructure(IArtifactInfo artifact) throws ASDCDownloadException {
+
+ try {
+ SdcToscaParserFactory factory = SdcToscaParserFactory.getInstance();// Autoclosable
+
+ String filePath =
+ Paths.get(msoConfigPath, "ASDC", artifact.getArtifactVersion(), artifact.getArtifactName())
+ .normalize().toString();
+
+ File spoolFile = new File(filePath);
+
+ logger.debug("ASDC File path is: {}", spoolFile.getAbsolutePath());
+ logger.info("{} {} {} {}", MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF.toString(), "***PATH", "ASDC",
+ spoolFile.getAbsolutePath());
+
+ sdcCsarHelper = factory.getSdcCsarHelper(spoolFile.getAbsolutePath(), false);
+
+ } catch (Exception e) {
+ logger.debug(e.getMessage(), e);
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_GENERAL_EXCEPTION_ARG.toString(),
+ "Exception caught during parser *****LOOK********* " + artifact.getArtifactName(), "ASDC",
+ "processResourceNotification", ErrorCode.BusinessProcesssError.getValue(),
+ "Exception in " + "processResourceNotification", e);
+
+ throw new ASDCDownloadException("Exception caught when passing the csar file to the parser ", e);
+ }
+
+ serviceMetadata = sdcCsarHelper.getServiceMetadata();
+
+ }
+
+ public String getHeatTemplateUUID() {
+ return heatTemplateUUID;
+ }
+
+ public void setHeatTemplateUUID(String heatTemplateUUID) {
+ this.heatTemplateUUID = heatTemplateUUID;
+ }
+
+ public List<NodeTemplate> getAllottedList() {
+ return allottedList;
+ }
+
+ public void setAllottedList(List<NodeTemplate> allottedList) {
+ this.allottedList = allottedList;
+ }
+
+ public ISdcCsarHelper getSdcCsarHelper() {
+ return sdcCsarHelper;
+ }
+
+ public void setSdcCsarHelper(ISdcCsarHelper sdcCsarHelper) {
+ this.sdcCsarHelper = sdcCsarHelper;
+ }
+
+ public Metadata getServiceMetadata() {
+ return serviceMetadata;
+ }
+
+ public Service getCatalogService() {
+ return catalogService;
+ }
+
+ public void setServiceMetadata(Metadata serviceMetadata) {
+ this.serviceMetadata = serviceMetadata;
+ }
+
+ public void setCatalogService(Service catalogService) {
+ this.catalogService = catalogService;
+ }
+
+ public List<NodeTemplate> getNetworkTypes() {
+ return networkTypes;
+ }
+
+ public void setNetworkTypes(List<NodeTemplate> networkTypes) {
+ this.networkTypes = networkTypes;
+ }
+
+ public List<NodeTemplate> getVfTypes() {
+ return vfTypes;
+ }
+
+ public void setVfTypes(List<NodeTemplate> vfTypes) {
+ this.vfTypes = vfTypes;
+ }
+
+ public AllottedResourceCustomization getCatalogResourceCustomization() {
+ return catalogResourceCustomization;
+ }
+
+ public void setCatalogResourceCustomization(AllottedResourceCustomization catalogResourceCustomization) {
+ this.catalogResourceCustomization = catalogResourceCustomization;
+ }
+
+ // Network Only
+ public NetworkResourceCustomization getCatalogNetworkResourceCustomization() {
+ return catalogNetworkResourceCustomization;
+ }
+
+ // Network Only
+ public void setCatalogNetworkResourceCustomization(
+ NetworkResourceCustomization catalogNetworkResourceCustomization) {
+ this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
+ }
+
+ public NetworkResource getCatalogNetworkResource() {
+ return catalogNetworkResource;
+ }
+
+ public void setCatalogNetworkResource(NetworkResource catalogNetworkResource) {
+ this.catalogNetworkResource = catalogNetworkResource;
+ }
+
+ public VfModule getCatalogVfModule() {
+ return vfModule;
+ }
+
+ public void setCatalogVfModule(VfModule vfModule) {
+ this.vfModule = vfModule;
+ }
+ /*
+ * public VnfResource getCatalogVnfResource() { return vnfResource; }
+ *
+ * public void setCatalogVnfResource(VnfResource vnfResource) { this.vnfResource = vnfResource; }
+ *
+ */
+
+ public VnfResourceCustomization getCatalogVnfResourceCustomization() {
+ return vnfResourceCustomization;
+ }
+
+ public void setCatalogVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) {
+ this.vnfResourceCustomization = vnfResourceCustomization;
+ }
+
+ public PnfResourceCustomization getPnfResourceCustomization() {
+ return pnfResourceCustomization;
+ }
+
+ public void setPnfResourceCustomization(PnfResourceCustomization pnfResourceCustomization) {
+ this.pnfResourceCustomization = pnfResourceCustomization;
+ }
+
+
+ public VfModuleCustomization getCatalogVfModuleCustomization() {
+ return vfModuleCustomization;
+ }
+
+ public void setCatalogVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
+ this.vfModuleCustomization = vfModuleCustomization;
+ }
+
+ public AllottedResource getAllottedResource() {
+ return allottedResource;
+ }
+
+ public void setAllottedResource(AllottedResource allottedResource) {
+ this.allottedResource = allottedResource;
+ }
+
+ public AllottedResourceCustomization getCatalogAllottedResourceCustomization() {
+ return allottedResourceCustomization;
+ }
+
+ public void setCatalogAllottedResourceCustomization(AllottedResourceCustomization allottedResourceCustomization) {
+ this.allottedResourceCustomization = allottedResourceCustomization;
+ }
+
+ public TempNetworkHeatTemplateLookup getCatalogTempNetworkHeatTemplateLookup() {
+ return tempNetworkHeatTemplateLookup;
+ }
+
+ public void setCatalogTempNetworkHeatTemplateLookup(TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
+ this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
+ }
+
+ public String getHeatFilesUUID() {
+ return heatFilesUUID;
+ }
+
+ public void setHeatFilesUUID(String heatFilesUUID) {
+ this.heatFilesUUID = heatFilesUUID;
+ }
+
+ public IArtifactInfo getToscaArtifact() {
+ return toscaArtifact;
+ }
+
+ public void setToscaArtifact(IArtifactInfo toscaArtifact) {
+ this.toscaArtifact = toscaArtifact;
+ }
+
+ public ToscaCsar getCatalogToscaCsar() {
+ return toscaCsar;
+ }
+
+ public void setCatalogToscaCsar(ToscaCsar toscaCsar) {
+ this.toscaCsar = toscaCsar;
+ }
+
+ public String getVolHeatTemplateUUID() {
+ return volHeatTemplateUUID;
+ }
+
+ public void setVolHeatTemplateUUID(String volHeatTemplateUUID) {
+ this.volHeatTemplateUUID = volHeatTemplateUUID;
+ }
+
+ public String getEnvHeatTemplateUUID() {
+ return envHeatTemplateUUID;
+ }
+
+ public void setEnvHeatTemplateUUID(String envHeatTemplateUUID) {
+ this.envHeatTemplateUUID = envHeatTemplateUUID;
+ }
+
+ public String getVolHeatEnvTemplateUUID() {
+ return volHeatEnvTemplateUUID;
+ }
+
+ public void setVolHeatEnvTemplateUUID(String volHeatEnvTemplateUUID) {
+ this.volHeatEnvTemplateUUID = volHeatEnvTemplateUUID;
+ }
+
+ public String getServiceVersion() {
+ return serviceVersion;
+ }
+
+ public void setServiceVersion(String serviceVersion) {
+ this.serviceVersion = serviceVersion;
+ }
+
+ public String getWorkloadPerformance() {
+ return workloadPerformance;
+ }
+
+ public void setWorkloadPerformance(String workloadPerformance) {
+ this.workloadPerformance = workloadPerformance;
+ }
+
+ public VfModule getVfModule() {
+ return vfModule;
+ }
+
+ public void setVfModule(VfModule vfModule) {
+ this.vfModule = vfModule;
+ }
+
+ public VfModuleCustomization getVfModuleCustomization() {
+ return vfModuleCustomization;
+ }
+
+ public void setVfModuleCustomization(VfModuleCustomization vfModuleCustomization) {
+ this.vfModuleCustomization = vfModuleCustomization;
+ }
+
+
+ public VnfResourceCustomization getVnfResourceCustomization() {
+ return vnfResourceCustomization;
+ }
+
+ public void setVnfResourceCustomization(VnfResourceCustomization vnfResourceCustomization) {
+ this.vnfResourceCustomization = vnfResourceCustomization;
+ }
+
+ public AllottedResourceCustomization getAllottedResourceCustomization() {
+ return allottedResourceCustomization;
+ }
+
+ public void setAllottedResourceCustomization(AllottedResourceCustomization allottedResourceCustomization) {
+ this.allottedResourceCustomization = allottedResourceCustomization;
+ }
+
+ public TempNetworkHeatTemplateLookup getTempNetworkHeatTemplateLookup() {
+ return tempNetworkHeatTemplateLookup;
+ }
+
+ public void setTempNetworkHeatTemplateLookup(TempNetworkHeatTemplateLookup tempNetworkHeatTemplateLookup) {
+ this.tempNetworkHeatTemplateLookup = tempNetworkHeatTemplateLookup;
+ }
+
+ public List<NetworkInstanceGroup> getCatalogNetworkInstanceGroup() {
+ return catalogNetworkInstanceGroup;
+ }
+
+ public void setCatalogNetworkInstanceGroup(List<NetworkInstanceGroup> catalogNetworkInstanceGroup) {
+ this.catalogNetworkInstanceGroup = catalogNetworkInstanceGroup;
+ }
+
+ public CollectionNetworkResourceCustomization getCatalogCollectionNetworkResourceCustomization() {
+ return catalogCollectionNetworkResourceCustomization;
+ }
+
+ public void setCatalogCollectionNetworkResourceCustomization(
+ CollectionNetworkResourceCustomization catalogCollectionNetworkResourceCustomization) {
+ this.catalogCollectionNetworkResourceCustomization = catalogCollectionNetworkResourceCustomization;
+ }
+
+ public CollectionResource getCatalogCollectionResource() {
+ return catalogCollectionResource;
+ }
+
+ public void setCatalogCollectionResource(CollectionResource catalogCollectionResource) {
+ this.catalogCollectionResource = catalogCollectionResource;
+ }
+
+ public CollectionResourceCustomization getCatalogCollectionResourceCustomization() {
+ return catalogCollectionResourceCustomization;
+ }
+
+ public void setCatalogCollectionResourceCustomization(
+ CollectionResourceCustomization catalogCollectionResourceCustomization) {
+ this.catalogCollectionResourceCustomization = catalogCollectionResourceCustomization;
+ }
+
+ public NetworkCollectionResourceCustomization getCatalogNetworkCollectionResourceCustomization() {
+ return catalogNetworkCollectionResourceCustomization;
+ }
+
+ public void setCatalogNetworkCollectionResourceCustomization(
+ NetworkCollectionResourceCustomization catalogNetworkCollectionResourceCustomization) {
+ this.catalogNetworkCollectionResourceCustomization = catalogNetworkCollectionResourceCustomization;
+ }
+
+ public ServiceProxyResourceCustomization getCatalogServiceProxyResourceCustomization() {
+ return catalogServiceProxyResourceCustomization;
+ }
+
+ public void setCatalogServiceProxyResourceCustomization(
+ ServiceProxyResourceCustomization catalogServiceProxyResourceCustomization) {
+ this.catalogServiceProxyResourceCustomization = catalogServiceProxyResourceCustomization;
+ }
+
+ public ConfigurationResource getCatalogConfigurationResource() {
+ return catalogConfigurationResource;
+ }
+
+ public void setCatalogConfigurationResource(ConfigurationResource catalogConfigurationResource) {
+ this.catalogConfigurationResource = catalogConfigurationResource;
+ }
+
+ public ConfigurationResourceCustomization getCatalogConfigurationResourceCustomization() {
+ return catalogConfigurationResourceCustomization;
+ }
+
+ public void setCatalogConfigurationResourceCustomization(
+ ConfigurationResourceCustomization catalogConfigurationResourceCustomization) {
+ this.catalogConfigurationResourceCustomization = catalogConfigurationResourceCustomization;
+ }
+
+ public ToscaCsar getToscaCsar() {
+ return toscaCsar;
+ }
+
+ public void setToscaCsar(ToscaCsar toscaCsar) {
+ this.toscaCsar = toscaCsar;
+ }
+
+ public boolean isDeployedSuccessfully() {
+ return isDeployedSuccessfully;
+ }
+
+ public void setSuccessfulDeployment() {
+ isDeployedSuccessfully = true;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
index cb4761c557..a3b074f557 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleArtifact.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.installer;
import java.io.UnsupportedEncodingException;
-
import org.onap.so.db.catalog.beans.HeatEnvironment;
import org.onap.so.db.catalog.beans.HeatFiles;
import org.onap.so.db.catalog.beans.HeatTemplate;
@@ -30,68 +29,70 @@ import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.results.IDistributionClientDownloadResult;
/**
- * The structure that contains the artifactInfo and its associated DownloadedResult.
+ * The structure that contains the artifactInfo and its associated DownloadedResult.
*
*/
public final class VfModuleArtifact {
- private final IArtifactInfo artifactInfo;
- private int deployedInDb=0;
- private final String result;
- private HeatFiles heatFiles;
- private HeatTemplate heatTemplate;
- private HeatEnvironment heatEnvironment;
-
- public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
- this(artifactinfo, clientResult, null);
- }
-
- public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate) throws UnsupportedEncodingException {
- artifactInfo=artifactinfo;
- if(modifiedHeatTemplate != null){
- result = modifiedHeatTemplate;
- }else{
- result = new String(clientResult.getArtifactPayload(), "UTF-8");
- }
- }
-
- public HeatFiles getHeatFiles() {
- return heatFiles;
- }
-
- public void setHeatFiles(HeatFiles heatFiles) {
- this.heatFiles = heatFiles;
- }
-
- public HeatTemplate getHeatTemplate() {
- return heatTemplate;
- }
-
- public void setHeatTemplate(HeatTemplate heatTemplate) {
- this.heatTemplate = heatTemplate;
- }
-
- public IArtifactInfo getArtifactInfo() {
- return artifactInfo;
- }
-
- public String getResult() {
- return result;
- }
-
- public int getDeployedInDb() {
- return deployedInDb;
- }
-
- public void incrementDeployedInDB() {
- ++deployedInDb;
- }
-
- public HeatEnvironment getHeatEnvironment() {
- return heatEnvironment;
- }
-
- public void setHeatEnvironment(HeatEnvironment heatEnvironment) {
- this.heatEnvironment=heatEnvironment;
- }
-
+ private final IArtifactInfo artifactInfo;
+ private int deployedInDb = 0;
+ private final String result;
+ private HeatFiles heatFiles;
+ private HeatTemplate heatTemplate;
+ private HeatEnvironment heatEnvironment;
+
+ public VfModuleArtifact(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult)
+ throws UnsupportedEncodingException {
+ this(artifactinfo, clientResult, null);
+ }
+
+ public VfModuleArtifact(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
+ String modifiedHeatTemplate) throws UnsupportedEncodingException {
+ artifactInfo = artifactinfo;
+ if (modifiedHeatTemplate != null) {
+ result = modifiedHeatTemplate;
+ } else {
+ result = new String(clientResult.getArtifactPayload(), "UTF-8");
+ }
+ }
+
+ public HeatFiles getHeatFiles() {
+ return heatFiles;
+ }
+
+ public void setHeatFiles(HeatFiles heatFiles) {
+ this.heatFiles = heatFiles;
+ }
+
+ public HeatTemplate getHeatTemplate() {
+ return heatTemplate;
+ }
+
+ public void setHeatTemplate(HeatTemplate heatTemplate) {
+ this.heatTemplate = heatTemplate;
+ }
+
+ public IArtifactInfo getArtifactInfo() {
+ return artifactInfo;
+ }
+
+ public String getResult() {
+ return result;
+ }
+
+ public int getDeployedInDb() {
+ return deployedInDb;
+ }
+
+ public void incrementDeployedInDB() {
+ ++deployedInDb;
+ }
+
+ public HeatEnvironment getHeatEnvironment() {
+ return heatEnvironment;
+ }
+
+ public void setHeatEnvironment(HeatEnvironment heatEnvironment) {
+ this.heatEnvironment = heatEnvironment;
+ }
+
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleMetaData.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleMetaData.java
index 11000bec98..40f32f648b 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleMetaData.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleMetaData.java
@@ -23,74 +23,73 @@ package org.onap.so.asdc.installer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
public class VfModuleMetaData implements IVfModuleData {
- @JsonProperty("artifacts")
- private List<String> artifacts;
+ @JsonProperty("artifacts")
+ private List<String> artifacts;
- @JsonProperty("properties")
- //private List<Map<String, Object>> properties = new ArrayList<>();
- private Map<String,String> properties = new HashMap<>();
+ @JsonProperty("properties")
+ // private List<Map<String, Object>> properties = new ArrayList<>();
+ private Map<String, String> properties = new HashMap<>();
- @JsonIgnore
- private Map<String,Object> attributesMap = new HashMap<>();
+ @JsonIgnore
+ private Map<String, Object> attributesMap = new HashMap<>();
- @Override
- public List<String> getArtifacts() {
- return artifacts;
- }
+ @Override
+ public List<String> getArtifacts() {
+ return artifacts;
+ }
- public Map<String, String> getProperties() {
- return properties;
- }
+ public Map<String, String> getProperties() {
+ return properties;
+ }
- @Override
- public String getVfModuleModelDescription() {
- return (String)attributesMap.get("vfModuleModelDescription");
- }
+ @Override
+ public String getVfModuleModelDescription() {
+ return (String) attributesMap.get("vfModuleModelDescription");
+ }
- @Override
- public String getVfModuleModelInvariantUUID() {
- return (String)attributesMap.get("vfModuleModelInvariantUUID");
- }
+ @Override
+ public String getVfModuleModelInvariantUUID() {
+ return (String) attributesMap.get("vfModuleModelInvariantUUID");
+ }
- public String getVfModuleModelCustomizationUUID() {
- return (String)attributesMap.get("vfModuleModelCustomizationUUID");
- }
+ public String getVfModuleModelCustomizationUUID() {
+ return (String) attributesMap.get("vfModuleModelCustomizationUUID");
+ }
- @Override
- public String getVfModuleModelName() {
- return (String)attributesMap.get("vfModuleModelName");
- }
+ @Override
+ public String getVfModuleModelName() {
+ return (String) attributesMap.get("vfModuleModelName");
+ }
- @Override
- public String getVfModuleModelUUID() {
- return (String)attributesMap.get("vfModuleModelUUID");
- }
+ @Override
+ public String getVfModuleModelUUID() {
+ return (String) attributesMap.get("vfModuleModelUUID");
+ }
- @Override
- public String getVfModuleModelVersion() {
- return (String)attributesMap.get("vfModuleModelVersion");
- }
+ @Override
+ public String getVfModuleModelVersion() {
+ return (String) attributesMap.get("vfModuleModelVersion");
+ }
- @Override
- public boolean isBase() {
- return (boolean)attributesMap.get("isBase");
- }
+ @Override
+ public boolean isBase() {
+ return (boolean) attributesMap.get("isBase");
+ }
- @SuppressWarnings("unused")
- @JsonAnySetter
- public final void setAttribute(String attrName, Object attrValue) {
- if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
- this.attributesMap.put(attrName,attrValue);
- }
- }
+ @SuppressWarnings("unused")
+ @JsonAnySetter
+ public final void setAttribute(String attrName, Object attrValue) {
+ if ((null != attrName) && (!attrName.isEmpty()) && (null != attrValue) && (null != attrValue.toString())) {
+ this.attributesMap.put(attrName, attrValue);
+ }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
index 9f0525db3d..36d6ab96c0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfModuleStructure.java
@@ -25,7 +25,6 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-
import org.onap.sdc.api.notification.IVfModuleMetadata;
import org.onap.so.asdc.client.ASDCConfiguration;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
@@ -33,82 +32,84 @@ import org.onap.so.db.catalog.beans.VfModule;
public final class VfModuleStructure {
- private final IVfModuleData vfModuleMetadata;
+ private final IVfModuleData vfModuleMetadata;
- private final VfResourceStructure parentVfResource;
+ private final VfResourceStructure parentVfResource;
- private VfModule catalogVfModule;
- /**
- * The list of artifact existing in this resource hashed by artifactType.
- */
- private final Map<String, List<VfModuleArtifact>> artifactsMap;
+ private VfModule catalogVfModule;
+ /**
+ * The list of artifact existing in this resource hashed by artifactType.
+ */
+ private final Map<String, List<VfModuleArtifact>> artifactsMap;
- public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleData vfmoduleMetadata) throws ArtifactInstallerException {
+ public VfModuleStructure(VfResourceStructure vfParentResource, IVfModuleData vfmoduleMetadata)
+ throws ArtifactInstallerException {
- vfModuleMetadata = vfmoduleMetadata;
- parentVfResource = vfParentResource;
+ vfModuleMetadata = vfmoduleMetadata;
+ parentVfResource = vfParentResource;
- artifactsMap = new HashMap<>();
+ artifactsMap = new HashMap<>();
- for (String artifactUUID:this.vfModuleMetadata.getArtifacts()) {
- if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) {
- this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID));
- } else {
- throw new ArtifactInstallerException("Artifact (UUID:"+artifactUUID+ ") referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment");
- }
- }
- }
+ for (String artifactUUID : this.vfModuleMetadata.getArtifacts()) {
+ if (vfParentResource.getArtifactsMapByUUID().containsKey(artifactUUID)) {
+ this.addToStructure(vfParentResource.getArtifactsMapByUUID().get(artifactUUID));
+ } else {
+ throw new ArtifactInstallerException("Artifact (UUID:" + artifactUUID
+ + ") referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment");
+ }
+ }
+ }
- private void addToStructure(VfModuleArtifact vfModuleArtifact) {
+ private void addToStructure(VfModuleArtifact vfModuleArtifact) {
- if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) {
- artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact);
+ if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) {
+ artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact);
- } else {
- List<VfModuleArtifact> nestedList = new LinkedList<>();
- nestedList.add(vfModuleArtifact);
+ } else {
+ List<VfModuleArtifact> nestedList = new LinkedList<>();
+ nestedList.add(vfModuleArtifact);
- artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList);
- }
- }
+ artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList);
+ }
+ }
- public List<VfModuleArtifact> getOrderedArtifactList() {
+ public List<VfModuleArtifact> getOrderedArtifactList() {
- List <VfModuleArtifact> artifactsList = new LinkedList<>();
+ List<VfModuleArtifact> artifactsList = new LinkedList<>();
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
+ artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT));
+ artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV));
+ artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED)));
+ artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_NESTED)));
- artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT)));
+ artifactsList.addAll((artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT)));
- artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
+ artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL));
- return null;
- }
+ return null;
+ }
- public IVfModuleData getVfModuleMetadata() {
- return vfModuleMetadata;
- }
+ public IVfModuleData getVfModuleMetadata() {
+ return vfModuleMetadata;
+ }
- public VfResourceStructure getParentVfResource() {
- return parentVfResource;
- }
+ public VfResourceStructure getParentVfResource() {
+ return parentVfResource;
+ }
- public Map<String, List<VfModuleArtifact>> getArtifactsMap() {
- return artifactsMap;
- }
+ public Map<String, List<VfModuleArtifact>> getArtifactsMap() {
+ return artifactsMap;
+ }
- public VfModule getCatalogVfModule() {
- return catalogVfModule;
- }
+ public VfModule getCatalogVfModule() {
+ return catalogVfModule;
+ }
- public void setCatalogVfModule(VfModule catalogVfModule) {
- this.catalogVfModule = catalogVfModule;
- }
+ public void setCatalogVfModule(VfModule catalogVfModule) {
+ this.catalogVfModule = catalogVfModule;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
index 402af160c1..62408be922 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/VfResourceStructure.java
@@ -83,13 +83,13 @@ public class VfResourceStructure extends ResourceStructure {
}
public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
+ IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException {
this.addArtifactToStructure(distributionClient, artifactinfo, clientResult, null);
}
public void addArtifactToStructure(IDistributionClient distributionClient, IArtifactInfo artifactinfo,
- IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate)
- throws UnsupportedEncodingException {
+ IDistributionClientDownloadResult clientResult, String modifiedHeatTemplate)
+ throws UnsupportedEncodingException {
VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo, clientResult, modifiedHeatTemplate);
addArtifactByType(artifactinfo, clientResult, vfModuleArtifact);
if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifactinfo.getArtifactType())) {
@@ -99,13 +99,13 @@ public class VfResourceStructure extends ResourceStructure {
}
protected void addArtifactByType(IArtifactInfo artifactinfo, IDistributionClientDownloadResult clientResult,
- VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
+ VfModuleArtifact vfModuleArtifact) throws UnsupportedEncodingException {
switch (artifactinfo.getArtifactType()) {
case ASDCConfiguration.HEAT:
case ASDCConfiguration.HEAT_ENV:
case ASDCConfiguration.HEAT_VOL:
- case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported
+ case ASDCConfiguration.HEAT_NESTED: // For 1607 only 1 level tree is supported
case ASDCConfiguration.HEAT_ARTIFACT:
case ASDCConfiguration.HEAT_NET:
case ASDCConfiguration.OTHER:
@@ -119,17 +119,16 @@ public class VfResourceStructure extends ResourceStructure {
}
}
- public void prepareInstall() throws ArtifactInstallerException{
+ public void prepareInstall() throws ArtifactInstallerException {
createVfModuleStructures();
}
public void createVfModuleStructures() throws ArtifactInstallerException {
- //for vender tosca VNF there is no VFModule in VF
+ // for vender tosca VNF there is no VFModule in VF
if (vfModulesMetadataList == null) {
logger.info("{} {} {} {}", MessageEnum.ASDC_GENERAL_INFO.toString(), "There is no VF mudules in the VF.",
- "ASDC",
- "createVfModuleStructures");
+ "ASDC", "createVfModuleStructures");
return;
}
for (IVfModuleData vfModuleMeta : vfModulesMetadataList) {
@@ -165,7 +164,7 @@ public class VfResourceStructure extends ResourceStructure {
// Network Only
public void setCatalogNetworkResourceCustomization(
- NetworkResourceCustomization catalogNetworkResourceCustomization) {
+ NetworkResourceCustomization catalogNetworkResourceCustomization) {
this.catalogNetworkResourceCustomization = catalogNetworkResourceCustomization;
}
@@ -173,8 +172,7 @@ public class VfResourceStructure extends ResourceStructure {
return catalogResourceCustomization;
}
- public void setCatalogResourceCustomization(
- AllottedResourceCustomization catalogResourceCustomization) {
+ public void setCatalogResourceCustomization(AllottedResourceCustomization catalogResourceCustomization) {
this.catalogResourceCustomization = catalogResourceCustomization;
}
@@ -188,9 +186,8 @@ public class VfResourceStructure extends ResourceStructure {
public List<IVfModuleData> decodeVfModuleArtifact(byte[] arg0) {
try {
- List<IVfModuleData> listVFModuleMetaData = new ObjectMapper()
- .readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {
- });
+ List<IVfModuleData> listVFModuleMetaData =
+ new ObjectMapper().readValue(arg0, new TypeReference<List<VfModuleMetaData>>() {});
return listVFModuleMetaData;
} catch (JsonParseException e) {
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
index 8daa708ee7..c98fb9b619 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/BpmnInstaller.java
@@ -55,59 +55,56 @@ import org.springframework.stereotype.Component;
@Component
public class BpmnInstaller {
- protected static final Logger logger = LoggerFactory.getLogger(BpmnInstaller.class);
- private static final String BPMN_SUFFIX = ".bpmn";
- private static final String CAMUNDA_URL = "mso.camundaURL";
- private static final String CREATE_DEPLOYMENT_PATH = "/sobpmnengine/deployment/create";
-
- @Autowired
- private Environment env;
-
- public void installBpmn(String csarFilePath) {
- logger.info("Deploying BPMN files from {}", csarFilePath);
- try {
- ZipInputStream csarFile = new ZipInputStream(new FileInputStream(Paths.get(csarFilePath).normalize().toString()));
- ZipEntry entry = csarFile.getNextEntry();
-
- while (entry != null) {
- String name = entry.getName();
- if (name.endsWith(BPMN_SUFFIX)) {
- logger.debug("Attempting to deploy BPMN file: {}", name);
- try {
- Path p = Paths.get(name);
- String fileName = p.getFileName().toString();
- extractBpmnFileFromCsar(csarFile, fileName);
- HttpResponse response = sendDeploymentRequest(fileName);
- logger.debug("Response status line: {}", response.getStatusLine());
- logger.debug("Response entity: {}", response.getEntity().toString());
- if (response.getStatusLine().getStatusCode() != 200) {
- logger.debug("Failed deploying BPMN {}", name);
- logger
- .error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name, fileName,
- Integer.toString(response.getStatusLine().getStatusCode()), ErrorCode.DataError.getValue(),
- "ASDC BPMN deploy failed");
- }
- else {
- logger.debug("Successfully deployed to Camunda: {}", name);
- }
- }
- catch (Exception e) {
- logger.debug("Exception :", e);
- logger
- .error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name, e.getMessage(),
- ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed");
- }
- }
- entry = csarFile.getNextEntry();
- }
- csarFile.close();
- } catch (IOException ex) {
- logger.debug("Exception :", ex);
- logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath,
- ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed");
- }
- return;
- }
+ protected static final Logger logger = LoggerFactory.getLogger(BpmnInstaller.class);
+ private static final String BPMN_SUFFIX = ".bpmn";
+ private static final String CAMUNDA_URL = "mso.camundaURL";
+ private static final String CREATE_DEPLOYMENT_PATH = "/sobpmnengine/deployment/create";
+
+ @Autowired
+ private Environment env;
+
+ public void installBpmn(String csarFilePath) {
+ logger.info("Deploying BPMN files from {}", csarFilePath);
+ try {
+ ZipInputStream csarFile =
+ new ZipInputStream(new FileInputStream(Paths.get(csarFilePath).normalize().toString()));
+ ZipEntry entry = csarFile.getNextEntry();
+
+ while (entry != null) {
+ String name = entry.getName();
+ if (name.endsWith(BPMN_SUFFIX)) {
+ logger.debug("Attempting to deploy BPMN file: {}", name);
+ try {
+ Path p = Paths.get(name);
+ String fileName = p.getFileName().toString();
+ extractBpmnFileFromCsar(csarFile, fileName);
+ HttpResponse response = sendDeploymentRequest(fileName);
+ logger.debug("Response status line: {}", response.getStatusLine());
+ logger.debug("Response entity: {}", response.getEntity().toString());
+ if (response.getStatusLine().getStatusCode() != 200) {
+ logger.debug("Failed deploying BPMN {}", name);
+ logger.error("{} {} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(),
+ name, fileName, Integer.toString(response.getStatusLine().getStatusCode()),
+ ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed");
+ } else {
+ logger.debug("Successfully deployed to Camunda: {}", name);
+ }
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), name,
+ e.getMessage(), ErrorCode.DataError.getValue(), "ASDC BPMN deploy failed");
+ }
+ }
+ entry = csarFile.getNextEntry();
+ }
+ csarFile.close();
+ } catch (IOException ex) {
+ logger.debug("Exception :", ex);
+ logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL.toString(), csarFilePath,
+ ex.getMessage(), ErrorCode.DataError.getValue(), "ASDC reading CSAR with workflows failed");
+ }
+ return;
+ }
public boolean containsWorkflows(String csarFilePath) {
boolean workflowsInCsar = false;
@@ -121,74 +118,79 @@ public class BpmnInstaller {
}
}
} catch (Exception e) {
- logger.debug("Exception :", e);
- logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, e.getMessage(),
- ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries");
- }
+ logger.debug("Exception :", e);
+ logger.error("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), csarFilePath, e.getMessage(),
+ ErrorCode.DataError.getValue(), "ASDC Unable to check CSAR entries");
+ }
return workflowsInCsar;
}
- protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception {
- HttpClient client = HttpClientBuilder.create().build();
- URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH);
- HttpPost post = new HttpPost(deploymentUri);
- RequestConfig requestConfig =
- RequestConfig.custom().setSocketTimeout(1000000).setConnectTimeout(1000).setConnectionRequestTimeout(1000).build();
- post.setConfig(requestConfig);
- HttpEntity requestEntity = buildMimeMultipart(bpmnFileName);
- post.setEntity(requestEntity);
- return client.execute(post);
- }
-
- protected HttpEntity buildMimeMultipart(String bpmnFileName) throws Exception {
- FileInputStream bpmnFileStream = new FileInputStream (Paths.get(System.getProperty("mso.config.path"),"ASDC", bpmnFileName).normalize().toString());
+ protected HttpResponse sendDeploymentRequest(String bpmnFileName) throws Exception {
+ HttpClient client = HttpClientBuilder.create().build();
+ URI deploymentUri = new URI(this.env.getProperty(CAMUNDA_URL) + CREATE_DEPLOYMENT_PATH);
+ HttpPost post = new HttpPost(deploymentUri);
+ RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(1000000).setConnectTimeout(1000)
+ .setConnectionRequestTimeout(1000).build();
+ post.setConfig(requestConfig);
+ HttpEntity requestEntity = buildMimeMultipart(bpmnFileName);
+ post.setEntity(requestEntity);
+ return client.execute(post);
+ }
+
+ protected HttpEntity buildMimeMultipart(String bpmnFileName) throws Exception {
+ FileInputStream bpmnFileStream = new FileInputStream(
+ Paths.get(System.getProperty("mso.config.path"), "ASDC", bpmnFileName).normalize().toString());
- byte[] bytesToSend = IOUtils.toByteArray(bpmnFileStream);
- HttpEntity requestEntity = MultipartEntityBuilder.create()
- .addPart(FormBodyPartBuilder.create()
- .setName("deployment-name")
- .setBody(new StringBody("MSO Sample 1", ContentType.TEXT_PLAIN))
- .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deployment-name"))
- .build())
- .addPart(FormBodyPartBuilder.create()
- .setName("enable-duplicate-filtering")
- .setBody(new StringBody("false", ContentType.TEXT_PLAIN))
- .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "enable-duplicate-filtering"))
- .build())
- .addPart(FormBodyPartBuilder.create()
- .setName("deplpy-changed-only")
- .setBody(new StringBody("false", ContentType.TEXT_PLAIN))
- .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deploy-changed-only"))
- .build())
- .addPart(FormBodyPartBuilder.create()
- .setName("deployment-source")
- .setBody(new StringBody("local", ContentType.TEXT_PLAIN))
- .setField("Content-Disposition", String.format("form-data; name=\"%s\"", "deployment-source"))
- .build())
- .addPart(FormBodyPartBuilder.create()
- .setName(bpmnFileName)
- .setBody(new ByteArrayBody(bytesToSend, ContentType.create("octet"), bpmnFileName))
- .setField("Content-Disposition", String.format("form-data; name=\"%s\"; filename=\"%s\"; size=%d", bpmnFileName, bpmnFileName, bytesToSend.length))
- .build())
- .build();
-
- IOUtils.closeQuietly(bpmnFileStream);
- return requestEntity;
- }
-
- /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */
- protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) {
- String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString();
- /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */
- try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))){
- byte[] bytesIn = new byte[4096];
- int read = 0;
- while ((read = zipIn.read(bytesIn)) != -1) {
- outputStream.write(bytesIn, 0, read);
- }
- /* outputStream.close(); */
- } catch (IOException e) {
- logger.error("Unable to open file.", e);
+ byte[] bytesToSend = IOUtils.toByteArray(bpmnFileStream);
+ HttpEntity requestEntity =
+ MultipartEntityBuilder.create()
+ .addPart(FormBodyPartBuilder.create().setName("deployment-name")
+ .setBody(new StringBody("MSO Sample 1", ContentType.TEXT_PLAIN))
+ .setField("Content-Disposition",
+ String.format("form-data; name=\"%s\"", "deployment-name"))
+ .build())
+ .addPart(FormBodyPartBuilder.create().setName("enable-duplicate-filtering")
+ .setBody(new StringBody("false", ContentType.TEXT_PLAIN))
+ .setField("Content-Disposition",
+ String.format("form-data; name=\"%s\"", "enable-duplicate-filtering"))
+ .build())
+ .addPart(FormBodyPartBuilder.create().setName("deplpy-changed-only")
+ .setBody(new StringBody("false", ContentType.TEXT_PLAIN))
+ .setField("Content-Disposition",
+ String.format("form-data; name=\"%s\"", "deploy-changed-only"))
+ .build())
+ .addPart(FormBodyPartBuilder.create().setName("deployment-source")
+ .setBody(new StringBody("local", ContentType.TEXT_PLAIN))
+ .setField("Content-Disposition",
+ String.format("form-data; name=\"%s\"", "deployment-source"))
+ .build())
+ .addPart(
+ FormBodyPartBuilder.create().setName(bpmnFileName)
+ .setBody(new ByteArrayBody(bytesToSend, ContentType.create("octet"),
+ bpmnFileName))
+ .setField("Content-Disposition",
+ String.format("form-data; name=\"%s\"; filename=\"%s\"; size=%d",
+ bpmnFileName, bpmnFileName, bytesToSend.length))
+ .build())
+ .build();
+
+ IOUtils.closeQuietly(bpmnFileStream);
+ return requestEntity;
+ }
+
+ /* protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) throws IOException */
+ protected void extractBpmnFileFromCsar(ZipInputStream zipIn, String fileName) {
+ String filePath = Paths.get(System.getProperty("mso.config.path"), "ASDC", fileName).normalize().toString();
+ /* BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath)); */
+ try (BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(filePath))) {
+ byte[] bytesIn = new byte[4096];
+ int read = 0;
+ while ((read = zipIn.read(bytesIn)) != -1) {
+ outputStream.write(bytesIn, 0, read);
+ }
+ /* outputStream.close(); */
+ } catch (IOException e) {
+ logger.error("Unable to open file.", e);
}
- }
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
index 04e3782bbe..0e30b77b01 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/heat/ToscaResourceInstaller.java
@@ -35,7 +35,6 @@ import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
-
import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.exception.LockAcquisitionException;
import org.onap.sdc.api.notification.IArtifactInfo;
@@ -141,2264 +140,2332 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
-
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
public class ToscaResourceInstaller {
- protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
-
- protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
-
- protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
-
- protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
-
- protected static final String SCALABLE = "scalable";
-
- protected static final String BASIC = "BASIC";
-
- protected static final String PROVIDER = "PROVIDER";
-
- protected static final String HEAT = "HEAT";
-
- protected static final String MANUAL_RECORD = "MANUAL_RECORD";
-
- protected static final String MSO = "SO";
-
- protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
-
- protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
-
- private static String CUSTOMIZATION_UUID = "customizationUUID";
-
- protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration";
-
- @Autowired
- protected ServiceRepository serviceRepo;
-
- @Autowired
- protected InstanceGroupRepository instanceGroupRepo;
-
- @Autowired
- protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
-
- @Autowired
- protected CollectionResourceRepository collectionRepo;
-
- @Autowired
- protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
-
- @Autowired
- protected ConfigurationResourceRepository configRepo;
-
- @Autowired
- protected VnfResourceRepository vnfRepo;
-
- @Autowired
- protected VFModuleRepository vfModuleRepo;
-
- @Autowired
- protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
-
- @Autowired
- protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
-
- @Autowired
- protected VnfcCustomizationRepository vnfcCustomizationRepo;
-
- @Autowired
- protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
-
- @Autowired
- protected AllottedResourceRepository allottedRepo;
-
- @Autowired
- protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
-
- @Autowired
- protected NetworkResourceRepository networkRepo;
-
- @Autowired
- protected HeatTemplateRepository heatRepo;
-
- @Autowired
- protected NetworkResourceCustomizationRepository networkCustomizationRepo;
-
- @Autowired
- protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
- @Autowired
- protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
- @Autowired
- protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
-
- @Autowired
- protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
-
- @Autowired
- protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
-
- @Autowired
- protected PnfResourceRepository pnfResourceRepository;
-
- @Autowired
- protected PnfCustomizationRepository pnfCustomizationRepository;
-
- protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
-
- public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
- boolean status = false;
- VfResourceStructure vfResourceStructure = vfResourceStruct;
- try {
- status = vfResourceStructure.isDeployedSuccessfully();
- } catch (RuntimeException e) {
- status = false;
- }
- try {
- Service existingService = serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
- if(existingService != null)
- status = true;
- if (status) {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.saveAndFlush(wdStatus);
- } else {
- logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
- vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
- vfResourceStructure.getNotification().getServiceName(),
- BigDecimalVersion.castAndCheckNotificationVersionToString(
- vfResourceStructure.getNotification().getServiceVersion()),
- vfResourceStructure.getNotification().getServiceUUID(),
- vfResourceStructure.getResourceInstance().getResourceName(), "", "");
- }
- return status;
- } catch (Exception e) {
- logger
- .error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
- "Exception - isResourceAlreadyDeployed");
- throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
- }
- }
-
- public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
- logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
- iStatus.getDistributionID(), iStatus.getComponentName());
-
- try {
- WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(iStatus.getDistributionID(),
- iStatus.getComponentName());
- cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
- watchdogCDStatusRepository.save(cdStatus);
-
- } catch (Exception e) {
- logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
- throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
- }
- }
-
- @Transactional(rollbackFor = {ArtifactInstallerException.class})
- public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
- throws ArtifactInstallerException {
- if (resourceStruct instanceof VfResourceStructure) {
- installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
- } else if (resourceStruct instanceof PnfResourceStructure) {
- installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
- } else {
- logger.warn("Unrecognized resource type");
- }
- }
-
- private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
- throws ArtifactInstallerException {
-
- // PCLO: in case of deployment failure, use a string that will represent
- // the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- try {
- createToscaCsar(toscaResourceStruct);
- Service service = createService(toscaResourceStruct, resourceStruct);
-
- processResourceSequence(toscaResourceStruct, service);
- processPnfResources(toscaResourceStruct, service, resourceStruct);
- serviceRepo.save(service);
-
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.save(status);
-
- toscaResourceStruct.setSuccessfulDeployment();
-
- } catch (Exception e) {
- logger.debug("Exception :", e);
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
- resourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
- watchdogCDStatusRepository.save(status);
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
- resourceStruct.getResourceInstance().getResourceName(),
- resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
- "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (!artifactListForLogging.isEmpty()
- ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
- : "No element listed");
- logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- ErrorCode.DataError.getValue(),
- "Exception caught during installation of " + resourceStruct.getResourceInstance()
- .getResourceName()
- + ". Transaction rollback", e);
- throw new ArtifactInstallerException("Exception caught during installation of "
- + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
- }
- }
- @Transactional(rollbackFor = { ArtifactInstallerException.class })
- public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
- throws ArtifactInstallerException {
- VfResourceStructure vfResourceStructure = vfResourceStruct;
- extractHeatInformation(toscaResourceStruct, vfResourceStructure);
-
- // PCLO: in case of deployment failure, use a string that will represent
- // the type of artifact that failed...
- List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
- try {
- createToscaCsar(toscaResourceStruct);
- Service service = createService(toscaResourceStruct, vfResourceStruct);
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
-
- Metadata metadata = nodeTemplate.getMetaData();
- String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
- String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
- }
-
- processResourceSequence(toscaResourceStruct, service);
- processVFResources(toscaResourceStruct, service, vfResourceStructure);
- List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
- processAllottedResources(toscaResourceStruct, service, allottedResourceList);
- processNetworks(toscaResourceStruct, service);
- // process Network Collections
- processNetworkCollections(toscaResourceStruct, service);
- // Process Service Proxy & Configuration
- processServiceProxyAndConfiguration(toscaResourceStruct, service);
-
- serviceRepo.save(service);
-
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
- watchdogCDStatusRepository.save(status);
-
- toscaResourceStruct.setSuccessfulDeployment();
-
- } catch (Exception e) {
- logger.debug("Exception :", e);
- WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(vfResourceStruct.getNotification().getDistributionID(), MSO);
- status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
- watchdogCDStatusRepository.save(status);
- Throwable dbExceptionToCapture = e;
- while (!(dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException)
- && (dbExceptionToCapture.getCause() != null)) {
- dbExceptionToCapture = dbExceptionToCapture.getCause();
- }
-
- if (dbExceptionToCapture instanceof ConstraintViolationException
- || dbExceptionToCapture instanceof LockAcquisitionException) {
- logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
- vfResourceStructure.getResourceInstance().getResourceName(),
- vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
- "Exception - ASCDC Artifact already deployed", e);
- } else {
- String elementToLog = (!artifactListForLogging.isEmpty()
- ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
- : "No element listed");
- logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
- ErrorCode.DataError.getValue(),
- "Exception caught during installation of " + vfResourceStructure.getResourceInstance().getResourceName()
- + ". Transaction rollback", e);
- throw new ArtifactInstallerException("Exception caught during installation of "
- + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
- }
- }
- }
-
-
- List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
- ISdcCsarHelper iSdcCsarHelper) {
-
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
- List<RequirementAssignment> reqAs = requirement.getAll();
- for (RequirementAssignment ra : reqAs) {
- String reqNode = ra.getNodeTemplateName();
- for (NodeTemplate rNode : resultList) {
- if (rNode.getName().equals(reqNode)) {
- if(!resultList.contains(nodeTemplate)) {
- resultList.add(nodeTemplate);
- }
- if(nodes.contains(nodeTemplate)) {
- nodes.remove(nodeTemplate);
- }
- break;
- }
- }
- }
- }
-
- if (!nodes.isEmpty()) {
- getRequirementList(resultList, nodes, iSdcCsarHelper);
- }
-
- return resultList;
- }
-
- // This method retrieve resource sequence from csar file
- void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
- List<String> resouceSequence = new ArrayList<String>();
- List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
-
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
- List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
- List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
- nodes.addAll(nodeTemplates);
-
- for (NodeTemplate nodeTemplate : nodeTemplates) {
- RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
-
- if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
- resultList.add(nodeTemplate);
- nodes.remove(nodeTemplate);
- }
- }
-
- resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
-
- for (NodeTemplate node : resultList) {
- String templateName = node.getMetaData().getValue("name");
- if (!resouceSequence.contains(templateName)) {
- resouceSequence.add(templateName);
- }
- }
-
- String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
- service.setResourceOrder(resourceSeqStr);
- logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
- }
-
- private static String getValue(Object value, List<Input> servInputs) {
- String output = null;
- if(value instanceof Map) {
- // currently this logic handles only one level of nesting.
- return ((LinkedHashMap) value).values().toArray()[0].toString();
- } else if(value instanceof GetInput) {
- String inputName = ((GetInput)value).getInputName();
-
- for(Input input : servInputs) {
- if(input.getName().equals(inputName)) {
- // keep both input name and default value
- // if service input does not supplies value the use default value
- String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
- output = inputName + "|" + defaultValue;// return default value
- }
- }
-
- } else {
- output = value != null ? value.toString() : "";
- }
- return output; // return property value
- }
-
- String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid) throws ArtifactInstallerException {
- Map<String, String> resouceRequest = new HashMap<>();
- ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
-
- List<Input> serInput = iSdcCsarHelper.getServiceInputs();
- Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
- .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid)).findFirst();
- if(nodeTemplateOpt.isPresent()) {
- NodeTemplate nodeTemplate = nodeTemplateOpt.get();
- LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
-
- for(String key : resourceProperties.keySet()) {
- Property property = resourceProperties.get(key);
-
- String value = getValue(property.getValue(), serInput);
- resouceRequest.put(key, value);
- }
- }
-
- try {
- ObjectMapper objectMapper = new ObjectMapper();
- String jsonStr = objectMapper.writeValueAsString(resouceRequest);
-
- jsonStr = jsonStr.replace("\"", "\\\"");
- logger.debug("resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
- return jsonStr;
- } catch (JsonProcessingException e) {
- logger.error("resource input could not be deserialized for resource customization id ("
- + resourceCustomizationUuid + ")");
- throw new ArtifactInstallerException("resource input could not be parsed", e);
- }
- }
-
- protected void processNetworks (ToscaResourceStructure toscaResourceStruct,
- Service service) throws ArtifactInstallerException {
- List <NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper ().getServiceVlList ();
-
- if (nodeTemplatesVLList != null) {
- for (NodeTemplate vlNode : nodeTemplatesVLList) {
- String networkResourceModelName = vlNode.getMetaData ().getValue (SdcPropertyNames.PROPERTY_NAME_NAME);
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp =
- tempNetworkLookupRepo.findFirstBynetworkResourceModelName (networkResourceModelName);
-
- if (tempNetworkLookUp != null) {
- HeatTemplate heatTemplate =
- heatRepo.findByArtifactUuid (tempNetworkLookUp.getHeatTemplateArtifactUuid ());
- if (heatTemplate != null) {
- NetworkResourceCustomization networkCustomization =
- createNetwork (vlNode,
- toscaResourceStruct,
- heatTemplate,
- tempNetworkLookUp.getAicVersionMax (),
- tempNetworkLookUp.getAicVersionMin (),
- service);
- service.getNetworkCustomizations ().add (networkCustomization);
- } else {
- throw new ArtifactInstallerException ("No HeatTemplate found for artifactUUID: "
- + tempNetworkLookUp.getHeatTemplateArtifactUuid ());
- }
- } else {
- NetworkResourceCustomization networkCustomization = createNetwork (vlNode,
- toscaResourceStruct,
- null,
- null,
- null,
- service);
- service.getNetworkCustomizations().add (networkCustomization);
- logger.debug ("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
- + networkResourceModelName);
- }
-
- }
- }
- }
-
- protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
- List<NodeTemplate> allottedResourceList) {
- if (allottedResourceList != null) {
- for (NodeTemplate allottedNode : allottedResourceList) {
- service.getAllottedCustomizations()
- .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
- }
- }
- }
-
-
- protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
- Metadata metadata = nodeTemplate.getMetaData();
- ConfigurationResource configResource = new ConfigurationResource();
- configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
- return configResource;
- }
-
- protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure,
- ServiceProxyResourceCustomization spResourceCustomization ) {
- Metadata metadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- configCustomizationResource.setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
-
- configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- configCustomizationResource.setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
-
- configCustomizationResource.setConfigurationResource(configResource);
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
- return configCustomizationResource;
- }
-
-
- protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(List<NodeTemplate> configurationNodeTemplatesList,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
- Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
- for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if(VLAN_NETWORK_RECEPTOR.equals(type)) {
- configurationResourceCust= Optional.of(getConfigurationResourceCustomization(nodeTemplate,
- toscaResourceStructure,spResourceCustomization));
- break;
- }
- }
-
- return configurationResourceCust;
- }
-
- protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> serviceProxyResourceList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
-
- List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
-
- List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
- List<ConfigurationResourceCustomization> configurationResourceList = new ArrayList<ConfigurationResourceCustomization>();
-
- ServiceProxyResourceCustomization serviceProxy = null;
-
- if (serviceProxyResourceList != null) {
- for (NodeTemplate spNode : serviceProxyResourceList) {
- serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
- serviceProxyList.add(serviceProxy);
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization = getVnrNodeTemplate(configurationNodeTemplatesList,toscaResourceStruct,serviceProxy);
-
- for (NodeTemplate configNode : configurationNodeTemplatesList) {
-
- List<RequirementAssignment> requirementsList = toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
- for (RequirementAssignment requirement : requirementsList) {
- if (requirement.getNodeTemplateName().equals(spNode.getName())) {
- ConfigurationResourceCustomization configurationResource = createConfiguration(configNode, toscaResourceStruct, serviceProxy, vnrResourceCustomization);
-
- Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList.stream()
- .filter(configurationResourceCustomization -> configNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID).equals(configurationResource.getModelCustomizationUUID()))
- .findFirst();
- if(!matchingObject.isPresent()){
- configurationResourceList.add(configurationResource);
- }
-
- break;
- }
- }
- }
-
- }
- }
-
- service.setConfigurationCustomizations(configurationResourceList);
- service.setServiceProxyCustomizations(serviceProxyList);
- }
-
- protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
-
- List<NodeTemplate> networkCollectionList = toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
-
- if (networkCollectionList != null) {
- for (NodeTemplate crNode : networkCollectionList) {
-
- createNetworkCollection(crNode, toscaResourceStruct, service);
- collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
-
- List<NetworkInstanceGroup> networkInstanceGroupList = toscaResourceStruct.getCatalogNetworkInstanceGroup();
- for(NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList){
- instanceGroupRepo.saveAndFlush(networkInstanceGroup);
- }
-
- }
- }
- service.getCollectionResourceCustomizations().add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
- }
-
-
- protected void processVFResources (ToscaResourceStructure toscaResourceStruct, Service service, VfResourceStructure vfResourceStructure)
- throws Exception{
- logger.debug("processVFResources");
-
- List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
-// String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
-// String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
-
- for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
- Metadata metadata = nodeTemplate.getMetaData();
- String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- // Do not treat Allotted Resources as VNF resources
- if(ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)){
- continue;
- }
-
- String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca
- // customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
- + vfCustomizationUUID);
-
- if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
- + " matches vfNotificationResource CustomizationUUID");
-
- processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
- vfCustomizationCategory);
- } else {
- logger.debug("Notification VF ResourceCustomizationUUID: "
- + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
- + "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
- }
-
- /**
- * This is used to process the PNF specific resource, including resource and resource_customization. {@link
- * IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for details.
- */
- protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
- PnfResourceStructure resourceStructure) throws Exception {
- logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
-
- ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
- EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
- TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
-
- List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
- for (IEntityDetails entityDetails : entityDetailsList) {
- Metadata metadata = entityDetails.getMetadata();
- String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
- String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
- if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
- logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
- customizationUUID, notifCustomizationUUID);
-
- if (checkExistingPnfResourceCutomization(customizationUUID)) {
- logger.info("Resource customization UUID: {} already deployed", customizationUUID);
- } else {
- PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
- if (pnfResource == null) {
- pnfResource = createPnfResource(entityDetails);
- }
- PnfResourceCustomization pnfResourceCustomization = createPnfResourceCustomization(entityDetails,
- pnfResource);
- pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
- toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
- service.getPnfCustomizations().add(pnfResourceCustomization);
- }
- } else {
- logger
- .warn("Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
- customizationUUID, notifCustomizationUUID);
- }
- }
- }
-
- private PnfResource findExistingPnfResource(Service service, String modelUuid) {
- PnfResource pnfResource = null;
- for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
- if (pnfResourceCustomization.getPnfResources() != null && pnfResourceCustomization.getPnfResources()
- .getModelUUID().equals(modelUuid)) {
- pnfResource = pnfResourceCustomization.getPnfResources();
- }
- }
- if (pnfResource == null) {
- pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
- }
- return pnfResource;
- }
-
- private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
- return pnfCustomizationRepository.findById(customizationUUID).isPresent();
- }
-
- /**
- * Construct the {@link PnfResource} from {@link IEntityDetails} object.
- */
- private PnfResource createPnfResource(IEntityDetails entity) {
- PnfResource pnfResource = new PnfResource();
- Metadata metadata = entity.getMetadata();
- pnfResource.setModelInvariantUUID(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- pnfResource.setModelVersion(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- pnfResource.setDescription(
- testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
- pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- pnfResource.setToscaNodeType(entity.getToscaType());
- return pnfResource;
- }
-
- /**
- * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
- */
- private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
- PnfResource pnfResource) {
-
- PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
- Metadata metadata = entityDetails.getMetadata();
- Map<String, Property> properties = entityDetails.getProperties();
- pnfResourceCustomization
- .setModelCustomizationUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
- pnfResourceCustomization
- .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
- pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
- pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
- pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
- pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
- pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
- pnfResourceCustomization.setPnfResources(pnfResource);
-
- return pnfResourceCustomization;
- }
-
- /**
- * Get value from {@link Property} and cast to boolean value. Return true if property is null.
- */
- private boolean getBooleanValue(Property property) {
- if (null == property) {
- return true;
- }
- Object value = property.getValue();
- return new Boolean(String.valueOf(value));
- }
-
- /**
- * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
- */
- private String getStringValue(Property property) {
- if (null == property) {
- return "";
- }
- Object value = property.getValue();
- return String.valueOf(value);
- }
-
- protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
- Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory) throws Exception {
-
- logger.debug("VF Category is : " + vfCustomizationCategory);
-
- if(vfResourceStructure.getVfModuleStructure() != null && !vfResourceStructure.getVfModuleStructure().isEmpty())
- {
-
- String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper()
- .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
-
- IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
-
- // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before comparing their VF Modules UUID's
- logger.debug("Checking if Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() +
- " matches Tosca VF Customization UUID: " + vfCustomizationUUID);
-
- if(vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())){
-
- logger.debug("vfCustomizationUUID: " + vfCustomizationUUID + " matches vfNotificationResource CustomizationUUID");
-
- VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
-
- Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
-
- for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
-
- logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
- List<org.onap.sdc.toscaparser.api.Group> vfGroups = toscaResourceStruct
- .getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
- IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
-
- logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : " + vfMetadata.getVfModuleModelCustomizationUUID());
-
- Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
- .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID " + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
- .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID").equals(vfMetadata.getVfModuleModelCustomizationUUID()))
- .findFirst();
- if(matchingObject.isPresent()){
- VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(), nodeTemplate, toscaResourceStruct,
- vfResourceStructure,vfMetadata, vnfResource, service, existingCvnfcSet, existingVnfcSet);
- vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
- }else
- throw new Exception("Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: " + vfMetadata.getVfModuleModelCustomizationUUID());
-
- }
-
-
- // Check for VNFC Instance Group info and add it if there is
- List<Group> groupList = toscaResourceStruct.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(nodeTemplate,
- "org.openecomp.groups.VfcInstanceGroup");
-
- for (Group group : groupList) {
- VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = createVNFCInstanceGroup(nodeTemplate, group, vnfResource, toscaResourceStruct);
- vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
- }
-
-
- service.getVnfCustomizations().add(vnfResource);
- } else{
- logger.debug("Notification VF ResourceCustomizationUUID: " + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match " +
- "Tosca VF Customization UUID: " + vfCustomizationUUID);
- }
- }
- }
-
- public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
- String consumerId) {
- WatchdogServiceModVerIdLookup modVerIdLookup = new WatchdogServiceModVerIdLookup(distributionId, servideUUID,
- distributionNotification, consumerId);
- watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
-
- try{
-
- WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
- watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
-
- } catch(ObjectOptimisticLockingFailureException e){
- logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
- throw e;
- }
- }
-
- protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
- VfResourceStructure vfResourceStructure) {
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
- case ASDCConfiguration.HEAT:
- case ASDCConfiguration.HEAT_NESTED:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_VOL:
- createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct,
- vfModuleArtifact);
- VfModuleArtifact envModuleArtifact = getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
- createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ENV:
- createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
- break;
- case ASDCConfiguration.HEAT_ARTIFACT:
- createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact,
- toscaResourceStruct);
- break;
- case ASDCConfiguration.HEAT_NET:
- case ASDCConfiguration.OTHER:
- logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
- vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:" + vfModuleArtifact.getArtifactInfo()
- .getArtifactName() + ")", ErrorCode.DataError.getValue(), "Artifact type not supported");
- break;
- default:
- break;
-
- }
- }
- }
-
- protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
- artifactName = artifactName.substring(0, artifactName.indexOf('.'));
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
- if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
- && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- return moduleArtifact;
- }
- }
- return null;
- }
-
- public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
- List<String> listTypes) {
- String newFileBody = filebody;
- for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
-
- newFileBody = verifyTheFilePrefixInString(newFileBody,
- moduleArtifact.getArtifactInfo().getArtifactName());
- }
- }
- return newFileBody;
- }
-
- public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
-
- String needlePrefix = "file:///";
- String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
-
- if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
- return body;
- }
-
- StringBuilder sb = new StringBuilder(body.length());
-
- int currentIndex = 0;
- int startIndex = 0;
-
- while (currentIndex != -1) {
- startIndex = currentIndex;
- currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
-
- if (currentIndex == -1) {
- break;
- }
- // We append from the startIndex up to currentIndex (start of File
- // Name)
- sb.append(body.substring(startIndex, currentIndex));
- sb.append(filenameToVerify);
-
- currentIndex += prefixedFilenameToVerify.length();
- }
-
- sb.append(body.substring(startIndex));
-
- return sb.toString();
- }
-
- protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
- ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
- HeatTemplate heatTemplate = new HeatTemplate();
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT_NESTED);
- typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
-
- heatTemplate.setTemplateBody(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
- heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
- } else {
- heatTemplate.setTimeoutMinutes(240);
- }
-
- heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatTemplate.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatTemplate.setArtifactChecksum(MANUAL_RECORD);
- }
-
- Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(
- vfModuleArtifact.getResult(), vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatTemplate.setParameters(heatParam);
- vfModuleArtifact.setHeatTemplate(heatTemplate);
- }
-
- protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact) {
- HeatEnvironment heatEnvironment = new HeatEnvironment();
- heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- List<String> typeList = new ArrayList<>();
- typeList.add(ASDCConfiguration.HEAT);
- typeList.add(ASDCConfiguration.HEAT_VOL);
- heatEnvironment.setEnvironment(
- verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
- heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatEnvironment.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
-
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatEnvironment(heatEnvironment);
- }
-
- protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
- VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
-
- HeatFiles heatFile = new HeatFiles();
- heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
- heatFile.setFileBody(vfModuleArtifact.getResult());
- heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
- heatFile.setVersion(BigDecimalVersion
- .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
- toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
- if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
- heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
- } else {
- heatFile.setArtifactChecksum(MANUAL_RECORD);
- }
- vfModuleArtifact.setHeatFiles(heatFile);
- }
-
- protected Service createService(ToscaResourceStructure toscaResourceStructure,
- ResourceStructure resourceStructure) {
-
- Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
-
- Service service = new Service();
-
- if (serviceMetadata != null) {
-
- if (toscaResourceStructure.getServiceVersion() != null) {
- service.setModelVersion(toscaResourceStructure.getServiceVersion());
- }
-
- service.setServiceType(serviceMetadata.getValue("serviceType"));
- service.setServiceRole(serviceMetadata.getValue("serviceRole"));
- service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
-
- service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
-
- if (resourceStructure != null)
- service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
-
- service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
- }
-
-
- toscaResourceStructure.setCatalogService(service);
- return service;
- }
-
- protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata spMetadata = nodeTemplate.getMetaData();
-
- ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
-
- Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
-
- spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- spCustomizationResource.setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- spCustomizationResource.setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
-
- String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
-
- Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
-
- spCustomizationResource.setSourceService(sourceService);
- spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
- serviceProxyCustomizationSet.add(spCustomizationResource);
-
-
- toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
-
- return spCustomizationResource;
- }
-
- protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
-
- ConfigurationResourceCustomization configCustomizationResource = getConfigurationResourceCustomization(nodeTemplate,
- toscaResourceStructure,spResourceCustomization);
-
- ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
-
- Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
-
- StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
- String type = entityType.getType();
-
- if(NODES_VRF_ENTRY.equals(type)) {
- configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
- }
-
- configCustomizationResource.setConfigurationResource(configResource);
-
- configResourceCustomizationSet.add(configCustomizationResource);
-
- configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
-
- toscaResourceStructure.setCatalogConfigurationResource(configResource);
-
- toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
-
- return configCustomizationResource;
- }
-
- protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata fabricMetadata = nodeTemplate.getMetaData();
-
- ConfigurationResource configResource = new ConfigurationResource();
-
- configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- configResource.setToscaNodeType(nodeTemplate.getType());
-
- return configResource;
- }
-
- protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
- ToscaCsar toscaCsar = new ToscaCsar();
- if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
- toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
- } else {
- toscaCsar.setArtifactChecksum(MANUAL_RECORD);
- }
- toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
- toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
- toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
- toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
- toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
-
- toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
- }
-
- protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
- VnfcCustomization vnfcCustomization = null;
- for(VnfcCustomization vnfcCustom : vnfcCustomizations){
- if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- vnfcCustomization = vnfcCustom;
- }
- }
-
- if(vnfcCustomization==null)
- vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
- //vnfcCustomization = new VnfcCustomization();
-
- return vnfcCustomization;
- }
-
- protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations, String customizationUUID) {
- CvnfcCustomization cvnfcCustomization = null;
- for(CvnfcCustomization cvnfcCustom : cvnfcCustomizations){
- if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
- cvnfcCustomization = cvnfcCustom;
- }
- }
-
- if(cvnfcCustomization==null)
- cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
-
- return cvnfcCustomization;
- }
-
- protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,Service service) {
-
- NetworkResourceCustomization networkResourceCustomization=networkCustomizationRepo.findOneByModelCustomizationUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- boolean networkUUIDsMatch = true;
- // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from the distribution.
- // If not we'll update the Customization record with latest from the distribution
- if(networkResourceCustomization != null){
- String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
- String latestNetworkModelUUID = networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
-
- if(!existingNetworkModelUUID.equals(latestNetworkModelUUID)){
- networkUUIDsMatch = false;
- }
-
- }
-
- if (networkResourceCustomization!=null && !networkUUIDsMatch){
-
- NetworkResource networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
-
- networkResourceCustomization.setNetworkResource(networkResource);
-
- networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
-
- }
- else if(networkResourceCustomization==null){
- networkResourceCustomization = createNetworkResourceCustomization(networkNodeTemplate,
- toscaResourceStructure);
-
- NetworkResource networkResource = findExistingNetworkResource(service,
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- if(networkResource == null)
- networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
- aicMax, aicMin);
-
- networkResource.addNetworkResourceCustomization(networkResourceCustomization);
- networkResourceCustomization.setNetworkResource(networkResource);
- }
-
- return networkResourceCustomization;
- }
-
- protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
- NetworkResource networkResource = null;
- for(NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()){
- if (networkCustom.getNetworkResource() != null
- && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
- networkResource = networkCustom.getNetworkResource();
- }
- }
- if(networkResource==null)
- networkResource = networkRepo.findResourceByModelUUID(modelUUID);
-
- return networkResource;
- }
-
- protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
- networkResourceCustomization.setModelInstanceName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- networkResourceCustomization.setModelCustomizationUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
-
- networkResourceCustomization.setNetworkTechnology(
- testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
- networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
- networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
- networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
- return networkResourceCustomization;
- }
-
- protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
- NetworkResource networkResource = new NetworkResource();
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource.setModelName(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
-
- networkResource.setModelInvariantUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- networkResource.setModelUUID(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- networkResource.setModelVersion(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
-
- networkResource.setAicVersionMax(aicMax);
- networkResource.setAicVersionMin(aicMin);
- networkResource.setToscaNodeType(networkNodeTemplate.getType());
- networkResource.setDescription(
- testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- networkResource.setOrchestrationMode(HEAT);
- networkResource.setHeatTemplate(heatTemplate);
- return networkResource;
- }
-
- protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
-
- CollectionNetworkResourceCustomization collectionNetworkResourceCustomization = new CollectionNetworkResourceCustomization();
-
- // **** Build Object to populate Collection_Resource table
- CollectionResource collectionResource = new CollectionResource();
-
- collectionResource
- .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- collectionResource.setModelInvariantUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- collectionResource
- .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- collectionResource
- .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- collectionResource
- .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- collectionResource.setToscaNodeType(networkNodeTemplate.getType());
-
- toscaResourceStructure.setCatalogCollectionResource(collectionResource);
-
- // **** Build object to populate Collection_Resource_Customization table
- NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
-
- ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_function"));
- ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_role"));
- ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- "cr_type"));
-
- ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- ncfc.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
- networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
-
- ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
-
- ncfc.setCollectionResource(collectionResource);
- toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
-
- //*** Build object to populate the Instance_Group table
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper()
- .getGroupsOfOriginOfNodeTemplateByToscaGroupType(networkNodeTemplate,
- "org.openecomp.groups.NetworkCollection");
-
- List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
-
- List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList = new ArrayList<CollectionResourceInstanceGroupCustomization>();
-
- for (Group group : groupList) {
-
- NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
- Metadata instanceMetadata = group.getMetadata();
- networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- networkInstanceGroup
- .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- networkInstanceGroup.setToscaNodeType(group.getType());
- networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
- // Role
- networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
- // type
- networkInstanceGroup.setCollectionResource(collectionResource);
-
- // ****Build object to populate
- // Collection_Resource_Instance_Group_Customization table
- CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization = new CollectionResourceInstanceGroupCustomization();
- crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
- crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- crInstanceGroupCustomization.setModelCustomizationUUID(
- networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- // Loop through the template policy to find the subinterface_network_quantity property name. Then extract the value for it.
- List<Policy> policyList = toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
-
- if(policyList != null){
- for(Policy policy : policyList){
- for(String policyNetworkCollection : policy.getTargets()){
-
- if(policyNetworkCollection.equalsIgnoreCase(group.getName())){
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if(propMap.get("quantity") != null){
-
- String quantity = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate, getPropertyInput(propMap.get("quantity").toString()));
-
- if(quantity != null){
- crInstanceGroupCustomization.setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
- }
-
- }
-
- }
- }
- }
- }
-
- crInstanceGroupCustomization.setDescription(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_description"));
- crInstanceGroupCustomization.setFunction(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
- instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
- + "_network_collection_function"));
- crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
- collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
-
- networkInstanceGroup
- .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
-
- networkInstanceGroupList.add(networkInstanceGroup);
-
-
- toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
-
- List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
-
- List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
-
- //*****Build object to populate the NetworkResource table
- NetworkResource networkResource = new NetworkResource();
-
- for(NodeTemplate vlNodeTemplate : vlNodeList){
-
- String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
- vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
-
- if ("true".equalsIgnoreCase(providerNetwork)) {
- networkResource.setNeutronNetworkType(PROVIDER);
- } else {
- networkResource.setNeutronNetworkType(BASIC);
- }
-
- networkResource.setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- networkResource.setModelInvariantUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- networkResource.setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- networkResource
- .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
-
- networkResource.setAicVersionMax(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
-
- TempNetworkHeatTemplateLookup tempNetworkLookUp = tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
-
- if (tempNetworkLookUp != null ) {
-
- HeatTemplate heatTemplate = heatRepo
- .findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
- networkResource.setHeatTemplate(heatTemplate);
-
- networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
-
- }
-
- networkResource.setToscaNodeType(vlNodeTemplate.getType());
- networkResource
- .setDescription(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- networkResource.setOrchestrationMode(HEAT);
-
- // Build object to populate the
- // Collection_Network_Resource_Customization table
- for (NodeTemplate memberNode : group.getMemberNodes()) {
- collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
- }
-
- collectionNetworkResourceCustomization.setModelCustomizationUUID(
- vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- collectionNetworkResourceCustomization.setNetworkTechnology(
- toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
- SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
- collectionNetworkResourceCustomization.setNetworkResource(networkResource);
- collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
-
- collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
- }
-
- }
-
- return collectionNetworkResourceCustomization;
- }
-
- protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
- VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
-
- Metadata instanceMetadata = group.getMetadata();
- // Populate InstanceGroup
- VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
-
- vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- vfcInstanceGroup.setToscaNodeType(group.getType());
- vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
- vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
-
- //Populate VNFCInstanceGroupCustomization
- VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
-
- vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
- vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
-
- vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
- vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
-
- vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
-
- String getInputName = null;
- String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group, "vfc_instance_group_function");
- if (groupProperty != null) {
- int getInputIndex = groupProperty.indexOf("{get_input=");
- if (getInputIndex > -1) {
- getInputName = groupProperty.substring(getInputIndex+11, groupProperty.length()-1);
- }
- }
- vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
- vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
-
-
- return vfcInstanceGroupCustom;
-
- }
-
- protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
- ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
- IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
- Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
-
- VfModuleCustomization vfModuleCustomization = findExistingVfModuleCustomization(vnfResource,
- vfModuleData.getVfModuleModelCustomizationUUID());
- if (vfModuleCustomization == null) {
- VfModule vfModule = findExistingVfModule(vnfResource,
- vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- Metadata vfMetadata = group.getMetadata();
- if (vfModule == null)
- vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
-
- vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
- vfModuleCustomization.setVnfCustomization(vnfResource);
- setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
- vfMetadata);
- vfModuleCustomization.setVfModule(vfModule);
- vfModule.getVfModuleCustomization().add(vfModuleCustomization);
- vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
- } else {
- vfResourceStructure.setAlreadyDeployed(true);
- }
-
- // ******************************************************************************************************************
- // * Extract VFC's and CVFC's then add them to VFModule
- // ******************************************************************************************************************
-
- Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations = new HashSet<CvnfcConfigurationCustomization>();
- Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
- Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
-
- // Only set the CVNFC if this vfModule group is a member of it.
- List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate,
- group);
- String vfModuleMemberName = null;
-
- for (NodeTemplate node : groupMembers) {
- vfModuleMemberName = node.getName();
- }
-
- // Extract CVFC lists
- List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate,
- SdcTypes.CVFC);
-
- for (NodeTemplate cvfcTemplate : cvfcList) {
- boolean cvnfcVfModuleNameMatch = false;
-
- for(NodeTemplate node : groupMembers){
- vfModuleMemberName = node.getName();
-
- if(vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())){
- cvnfcVfModuleNameMatch = true;
- break;
- }
- }
-
- if(vfModuleMemberName != null && cvnfcVfModuleNameMatch){
-
- // Extract associated VFC - Should always be just one
- List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
-
- for (NodeTemplate vfcTemplate : vfcList) {
-
- VnfcCustomization vnfcCustomization = new VnfcCustomization();
- VnfcCustomization existingVnfcCustomization = null;
-
- existingVnfcCustomization = findExistingVfc(existingVnfcSet,
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if (existingVnfcCustomization == null) {
- vnfcCustomization = new VnfcCustomization();
- } else {
- vnfcCustomization = existingVnfcCustomization;
- }
-
- // Only Add Abstract VNFC's to our DB, ignore all others
- if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
- .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
- vnfcCustomization.setModelCustomizationUUID(
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
- vnfcCustomization.setModelInvariantUUID(
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- vnfcCustomization
- .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- vnfcCustomization
- .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- vnfcCustomization.setModelVersion(
- testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfcCustomization.setDescription(testNull(
- vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
-
- vnfcCustomizations.add(vnfcCustomization);
- existingVnfcSet.add(vnfcCustomization);
- }
-
- // This check is needed incase the VFC subcategory is
- // something other than Abstract. In that case we want to
- // skip adding that record to our DB.
- if (vnfcCustomization.getModelCustomizationUUID() != null) {
- CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
- cvnfcCustomization.setModelCustomizationUUID(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
- cvnfcCustomization.setModelInvariantUUID(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- cvnfcCustomization
- .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- cvnfcCustomization
- .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- cvnfcCustomization.setModelVersion(
- testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- cvnfcCustomization.setDescription(testNull(
- cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
-
- if (existingVnfcCustomization != null) {
- cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
- } else {
- cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
- }
-
- cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
- cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
- cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
-
- cvnfcCustomizations.add(cvnfcCustomization);
- existingCvnfcSet.add(cvnfcCustomization);
-
- // *****************************************************************************************************************************************
- // * Extract Fabric Configuration
- // *****************************************************************************************************************************************
-
- List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
-
- for (NodeTemplate fabricTemplate : fabricConfigList) {
-
- ConfigurationResource fabricConfig = null;
-
- ConfigurationResource existingConfig = findExistingConfiguration(service,
- fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if (existingConfig == null) {
-
- fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
-
- } else {
- fabricConfig = existingConfig;
- }
-
- CvnfcConfigurationCustomization cvnfcConfigurationCustomization = createCvnfcConfigurationCustomization(
- fabricTemplate, toscaResourceStructure, vnfResource, vfModuleCustomization,
- cvnfcCustomization, fabricConfig, vfTemplate, vfModuleMemberName);
- cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
-
- fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
- }
- cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
- }
-
- }
-
- }
- }
- vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
-
- return vfModuleCustomization;
- }
-
- protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate, ToscaResourceStructure toscaResourceStruct,
- VnfResourceCustomization vnfResource, VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
+ protected static final String NODES_VRF_ENTRY = "org.openecomp.nodes.VRFEntry";
+
+ protected static final String VLAN_NETWORK_RECEPTOR = "org.openecomp.nodes.VLANNetworkReceptor";
+
+ protected static final String ALLOTTED_RESOURCE = "Allotted Resource";
+
+ protected static final String MULTI_STAGE_DESIGN = "multi_stage_design";
+
+ protected static final String SCALABLE = "scalable";
+
+ protected static final String BASIC = "BASIC";
+
+ protected static final String PROVIDER = "PROVIDER";
+
+ protected static final String HEAT = "HEAT";
+
+ protected static final String MANUAL_RECORD = "MANUAL_RECORD";
+
+ protected static final String MSO = "SO";
+
+ protected static final String SDNC_MODEL_NAME = "sdnc_model_name";
+
+ protected static final String SDNC_MODEL_VERSION = "sdnc_model_version";
+
+ private static String CUSTOMIZATION_UUID = "customizationUUID";
+
+ protected static final String SKIP_POST_INST_CONF = "skip_post_instantiation_configuration";
+
+ @Autowired
+ protected ServiceRepository serviceRepo;
+
+ @Autowired
+ protected InstanceGroupRepository instanceGroupRepo;
+
+ @Autowired
+ protected ServiceProxyResourceCustomizationRepository serviceProxyCustomizationRepo;
+
+ @Autowired
+ protected CollectionResourceRepository collectionRepo;
+
+ @Autowired
+ protected CollectionResourceCustomizationRepository collectionCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceCustomizationRepository configCustomizationRepo;
+
+ @Autowired
+ protected ConfigurationResourceRepository configRepo;
+
+ @Autowired
+ protected VnfResourceRepository vnfRepo;
+
+ @Autowired
+ protected VFModuleRepository vfModuleRepo;
+
+ @Autowired
+ protected VFModuleCustomizationRepository vfModuleCustomizationRepo;
+
+ @Autowired
+ protected VnfcInstanceGroupCustomizationRepository vnfcInstanceGroupCustomizationRepo;
+
+ @Autowired
+ protected VnfcCustomizationRepository vnfcCustomizationRepo;
+
+ @Autowired
+ protected CvnfcCustomizationRepository cvnfcCustomizationRepo;
+
+ @Autowired
+ protected AllottedResourceRepository allottedRepo;
+
+ @Autowired
+ protected AllottedResourceCustomizationRepository allottedCustomizationRepo;
+
+ @Autowired
+ protected NetworkResourceRepository networkRepo;
+
+ @Autowired
+ protected HeatTemplateRepository heatRepo;
+
+ @Autowired
+ protected NetworkResourceCustomizationRepository networkCustomizationRepo;
+
+ @Autowired
+ protected WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+ @Autowired
+ protected WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
+ @Autowired
+ protected WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
+
+ @Autowired
+ protected TempNetworkHeatTemplateRepository tempNetworkLookupRepo;
+
+ @Autowired
+ protected ExternalServiceToInternalServiceRepository externalServiceToInternalServiceRepository;
+
+ @Autowired
+ protected PnfResourceRepository pnfResourceRepository;
+
+ @Autowired
+ protected PnfCustomizationRepository pnfCustomizationRepository;
+
+ protected static final Logger logger = LoggerFactory.getLogger(ToscaResourceInstaller.class);
+
+ public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStruct) throws ArtifactInstallerException {
+ boolean status = false;
+ VfResourceStructure vfResourceStructure = vfResourceStruct;
+ try {
+ status = vfResourceStructure.isDeployedSuccessfully();
+ } catch (RuntimeException e) {
+ status = false;
+ }
+ try {
+ Service existingService =
+ serviceRepo.findOneByModelUUID(vfResourceStructure.getNotification().getServiceUUID());
+ if (existingService != null)
+ status = true;
+ if (status) {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ WatchdogComponentDistributionStatus wdStatus = new WatchdogComponentDistributionStatus(
+ vfResourceStruct.getNotification().getDistributionID(), MSO);
+ wdStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.saveAndFlush(wdStatus);
+ } else {
+ logger.info(vfResourceStructure.getResourceInstance().getResourceInstanceName(),
+ vfResourceStructure.getResourceInstance().getResourceCustomizationUUID(),
+ vfResourceStructure.getNotification().getServiceName(),
+ BigDecimalVersion.castAndCheckNotificationVersionToString(
+ vfResourceStructure.getNotification().getServiceVersion()),
+ vfResourceStructure.getNotification().getServiceUUID(),
+ vfResourceStructure.getResourceInstance().getResourceName(), "", "");
+ }
+ return status;
+ } catch (Exception e) {
+ logger.error("{} {} {}", MessageEnum.ASDC_ARTIFACT_CHECK_EXC.toString(), ErrorCode.SchemaError.getValue(),
+ "Exception - isResourceAlreadyDeployed");
+ throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e);
+ }
+ }
+
+ public void installTheComponentStatus(IStatusData iStatus) throws ArtifactInstallerException {
+ logger.debug("Entering installTheComponentStatus for distributionId {} and ComponentName {}",
+ iStatus.getDistributionID(), iStatus.getComponentName());
+
+ try {
+ WatchdogComponentDistributionStatus cdStatus =
+ new WatchdogComponentDistributionStatus(iStatus.getDistributionID(), iStatus.getComponentName());
+ cdStatus.setComponentDistributionStatus(iStatus.getStatus().toString());
+ watchdogCDStatusRepository.save(cdStatus);
+
+ } catch (Exception e) {
+ logger.debug("Exception caught in installTheComponentStatus {}", e.getMessage());
+ throw new ArtifactInstallerException("Exception caught in installTheComponentStatus " + e.getMessage());
+ }
+ }
+
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheResource(ToscaResourceStructure toscaResourceStruct, ResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+ if (resourceStruct instanceof VfResourceStructure) {
+ installTheVfResource(toscaResourceStruct, (VfResourceStructure) resourceStruct);
+ } else if (resourceStruct instanceof PnfResourceStructure) {
+ installPnfResource(toscaResourceStruct, (PnfResourceStructure) resourceStruct);
+ } else {
+ logger.warn("Unrecognized resource type");
+ }
+ }
+
+ private void installPnfResource(ToscaResourceStructure toscaResourceStruct, PnfResourceStructure resourceStruct)
+ throws ArtifactInstallerException {
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, resourceStruct);
+
+ processResourceSequence(toscaResourceStruct, service);
+ processPnfResources(toscaResourceStruct, service, resourceStruct);
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status =
+ new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status =
+ new WatchdogComponentDistributionStatus(resourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ resourceStruct.getResourceInstance().getResourceName(),
+ resourceStruct.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(), "Exception caught during installation of "
+ + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback",
+ e);
+ throw new ArtifactInstallerException(
+ "Exception caught during installation of "
+ + resourceStruct.getResourceInstance().getResourceName() + ". Transaction rollback.",
+ e);
+ }
+ }
+ }
+
+ @Transactional(rollbackFor = {ArtifactInstallerException.class})
+ public void installTheVfResource(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStruct)
+ throws ArtifactInstallerException {
+ VfResourceStructure vfResourceStructure = vfResourceStruct;
+ extractHeatInformation(toscaResourceStruct, vfResourceStructure);
+
+ // PCLO: in case of deployment failure, use a string that will represent
+ // the type of artifact that failed...
+ List<ASDCElementInfo> artifactListForLogging = new ArrayList<>();
+ try {
+ createToscaCsar(toscaResourceStruct);
+ Service service = createService(toscaResourceStruct, vfResourceStruct);
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+
+ Metadata metadata = nodeTemplate.getMetaData();
+ String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+ String vfCustomizationCategory = toscaResourceStruct.getSdcCsarHelper()
+ .getMetadataPropertyValue(metadata, SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ }
+
+ processResourceSequence(toscaResourceStruct, service);
+ processVFResources(toscaResourceStruct, service, vfResourceStructure);
+ List<NodeTemplate> allottedResourceList = toscaResourceStruct.getSdcCsarHelper().getAllottedResources();
+ processAllottedResources(toscaResourceStruct, service, allottedResourceList);
+ processNetworks(toscaResourceStruct, service);
+ // process Network Collections
+ processNetworkCollections(toscaResourceStruct, service);
+ // Process Service Proxy & Configuration
+ processServiceProxyAndConfiguration(toscaResourceStruct, service);
+
+ serviceRepo.save(service);
+
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ vfResourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+ watchdogCDStatusRepository.save(status);
+
+ toscaResourceStruct.setSuccessfulDeployment();
+
+ } catch (Exception e) {
+ logger.debug("Exception :", e);
+ WatchdogComponentDistributionStatus status = new WatchdogComponentDistributionStatus(
+ vfResourceStruct.getNotification().getDistributionID(), MSO);
+ status.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_ERROR.name());
+ watchdogCDStatusRepository.save(status);
+ Throwable dbExceptionToCapture = e;
+ while (!(dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException)
+ && (dbExceptionToCapture.getCause() != null)) {
+ dbExceptionToCapture = dbExceptionToCapture.getCause();
+ }
+
+ if (dbExceptionToCapture instanceof ConstraintViolationException
+ || dbExceptionToCapture instanceof LockAcquisitionException) {
+ logger.warn("{} {} {} {} {}", MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED.toString(),
+ vfResourceStructure.getResourceInstance().getResourceName(),
+ vfResourceStructure.getNotification().getServiceVersion(), ErrorCode.DataError.getValue(),
+ "Exception - ASCDC Artifact already deployed", e);
+ } else {
+ String elementToLog = (!artifactListForLogging.isEmpty()
+ ? artifactListForLogging.get(artifactListForLogging.size() - 1).toString()
+ : "No element listed");
+ logger.error("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_INSTALL_EXC.toString(), elementToLog,
+ ErrorCode.DataError.getValue(),
+ "Exception caught during installation of "
+ + vfResourceStructure.getResourceInstance().getResourceName()
+ + ". Transaction rollback",
+ e);
+ throw new ArtifactInstallerException("Exception caught during installation of "
+ + vfResourceStructure.getResourceInstance().getResourceName() + ". Transaction rollback.", e);
+ }
+ }
+ }
+
+
+ List<NodeTemplate> getRequirementList(List<NodeTemplate> resultList, List<NodeTemplate> nodeTemplates,
+ ISdcCsarHelper iSdcCsarHelper) {
+
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+ List<RequirementAssignment> reqAs = requirement.getAll();
+ for (RequirementAssignment ra : reqAs) {
+ String reqNode = ra.getNodeTemplateName();
+ for (NodeTemplate rNode : resultList) {
+ if (rNode.getName().equals(reqNode)) {
+ if (!resultList.contains(nodeTemplate)) {
+ resultList.add(nodeTemplate);
+ }
+ if (nodes.contains(nodeTemplate)) {
+ nodes.remove(nodeTemplate);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ if (!nodes.isEmpty()) {
+ getRequirementList(resultList, nodes, iSdcCsarHelper);
+ }
+
+ return resultList;
+ }
+
+ // This method retrieve resource sequence from csar file
+ void processResourceSequence(ToscaResourceStructure toscaResourceStructure, Service service) {
+ List<String> resouceSequence = new ArrayList<String>();
+ List<NodeTemplate> resultList = new ArrayList<NodeTemplate>();
+
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+ List<NodeTemplate> nodeTemplates = iSdcCsarHelper.getServiceNodeTemplates();
+ List<NodeTemplate> nodes = new ArrayList<NodeTemplate>();
+ nodes.addAll(nodeTemplates);
+
+ for (NodeTemplate nodeTemplate : nodeTemplates) {
+ RequirementAssignments requirement = iSdcCsarHelper.getRequirementsOf(nodeTemplate);
+
+ if (requirement == null || requirement.getAll() == null || requirement.getAll().isEmpty()) {
+ resultList.add(nodeTemplate);
+ nodes.remove(nodeTemplate);
+ }
+ }
+
+ resultList = getRequirementList(resultList, nodes, iSdcCsarHelper);
+
+ for (NodeTemplate node : resultList) {
+ String templateName = node.getMetaData().getValue("name");
+ if (!resouceSequence.contains(templateName)) {
+ resouceSequence.add(templateName);
+ }
+ }
+
+ String resourceSeqStr = resouceSequence.stream().collect(Collectors.joining(","));
+ service.setResourceOrder(resourceSeqStr);
+ logger.debug(" resourceSeq for service uuid(" + service.getModelUUID() + ") : " + resourceSeqStr);
+ }
+
+ private static String getValue(Object value, List<Input> servInputs) {
+ String output = null;
+ if (value instanceof Map) {
+ // currently this logic handles only one level of nesting.
+ return ((LinkedHashMap) value).values().toArray()[0].toString();
+ } else if (value instanceof GetInput) {
+ String inputName = ((GetInput) value).getInputName();
+
+ for (Input input : servInputs) {
+ if (input.getName().equals(inputName)) {
+ // keep both input name and default value
+ // if service input does not supplies value the use default value
+ String defaultValue = input.getDefault() != null ? (String) input.getDefault().toString() : "";
+ output = inputName + "|" + defaultValue;// return default value
+ }
+ }
+
+ } else {
+ output = value != null ? value.toString() : "";
+ }
+ return output; // return property value
+ }
+
+ String getResourceInput(ToscaResourceStructure toscaResourceStructure, String resourceCustomizationUuid)
+ throws ArtifactInstallerException {
+ Map<String, String> resouceRequest = new HashMap<>();
+ ISdcCsarHelper iSdcCsarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+ List<Input> serInput = iSdcCsarHelper.getServiceInputs();
+ Optional<NodeTemplate> nodeTemplateOpt = iSdcCsarHelper.getServiceNodeTemplates().stream()
+ .filter(e -> e.getMetaData().getValue(CUSTOMIZATION_UUID).equals(resourceCustomizationUuid))
+ .findFirst();
+ if (nodeTemplateOpt.isPresent()) {
+ NodeTemplate nodeTemplate = nodeTemplateOpt.get();
+ LinkedHashMap<String, Property> resourceProperties = nodeTemplate.getProperties();
+
+ for (String key : resourceProperties.keySet()) {
+ Property property = resourceProperties.get(key);
+
+ String value = getValue(property.getValue(), serInput);
+ resouceRequest.put(key, value);
+ }
+ }
+
+ try {
+ ObjectMapper objectMapper = new ObjectMapper();
+ String jsonStr = objectMapper.writeValueAsString(resouceRequest);
+
+ jsonStr = jsonStr.replace("\"", "\\\"");
+ logger.debug(
+ "resource request for resource customization id (" + resourceCustomizationUuid + ") : " + jsonStr);
+ return jsonStr;
+ } catch (JsonProcessingException e) {
+ logger.error("resource input could not be deserialized for resource customization id ("
+ + resourceCustomizationUuid + ")");
+ throw new ArtifactInstallerException("resource input could not be parsed", e);
+ }
+ }
+
+ protected void processNetworks(ToscaResourceStructure toscaResourceStruct, Service service)
+ throws ArtifactInstallerException {
+ List<NodeTemplate> nodeTemplatesVLList = toscaResourceStruct.getSdcCsarHelper().getServiceVlList();
+
+ if (nodeTemplatesVLList != null) {
+ for (NodeTemplate vlNode : nodeTemplatesVLList) {
+ String networkResourceModelName = vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp =
+ tempNetworkLookupRepo.findFirstBynetworkResourceModelName(networkResourceModelName);
+
+ if (tempNetworkLookUp != null) {
+ HeatTemplate heatTemplate =
+ heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ if (heatTemplate != null) {
+ NetworkResourceCustomization networkCustomization = createNetwork(vlNode, toscaResourceStruct,
+ heatTemplate, tempNetworkLookUp.getAicVersionMax(),
+ tempNetworkLookUp.getAicVersionMin(), service);
+ service.getNetworkCustomizations().add(networkCustomization);
+ } else {
+ throw new ArtifactInstallerException("No HeatTemplate found for artifactUUID: "
+ + tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ }
+ } else {
+ NetworkResourceCustomization networkCustomization =
+ createNetwork(vlNode, toscaResourceStruct, null, null, null, service);
+ service.getNetworkCustomizations().add(networkCustomization);
+ logger.debug("No NetworkResourceName found in TempNetworkHeatTemplateLookup for "
+ + networkResourceModelName);
+ }
+
+ }
+ }
+ }
+
+ protected void processAllottedResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ List<NodeTemplate> allottedResourceList) {
+ if (allottedResourceList != null) {
+ for (NodeTemplate allottedNode : allottedResourceList) {
+ service.getAllottedCustomizations()
+ .add(createAllottedResource(allottedNode, toscaResourceStruct, service));
+ }
+ }
+ }
+
+
+ protected ConfigurationResource getConfigurationResource(NodeTemplate nodeTemplate) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ ConfigurationResource configResource = new ConfigurationResource();
+ configResource.setModelName(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+ return configResource;
+ }
+
+ protected ConfigurationResourceCustomization getConfigurationResourceCustomization(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization) {
+ Metadata metadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ ConfigurationResourceCustomization configCustomizationResource = new ConfigurationResourceCustomization();
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ configCustomizationResource
+ .setModelCustomizationUUID(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ configCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+
+ configCustomizationResource.setNfFunction(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ configCustomizationResource.setNfRole(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ configCustomizationResource.setNfType(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ configCustomizationResource
+ .setServiceProxyResourceCustomizationUUID(spResourceCustomization.getModelCustomizationUUID());
+
+ configCustomizationResource.setConfigurationResource(configResource);
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+ return configCustomizationResource;
+ }
+
+
+ protected Optional<ConfigurationResourceCustomization> getVnrNodeTemplate(
+ List<NodeTemplate> configurationNodeTemplatesList, ToscaResourceStructure toscaResourceStructure,
+ ServiceProxyResourceCustomization spResourceCustomization) {
+ Optional<ConfigurationResourceCustomization> configurationResourceCust = Optional.empty();
+ for (NodeTemplate nodeTemplate : configurationNodeTemplatesList) {
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if (VLAN_NETWORK_RECEPTOR.equals(type)) {
+ configurationResourceCust = Optional.of(getConfigurationResourceCustomization(nodeTemplate,
+ toscaResourceStructure, spResourceCustomization));
+ break;
+ }
+ }
+
+ return configurationResourceCust;
+ }
+
+ protected void processServiceProxyAndConfiguration(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> serviceProxyResourceList =
+ toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+
+ List<NodeTemplate> configurationNodeTemplatesList =
+ toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+
+ List<ServiceProxyResourceCustomization> serviceProxyList = new ArrayList<ServiceProxyResourceCustomization>();
+ List<ConfigurationResourceCustomization> configurationResourceList =
+ new ArrayList<ConfigurationResourceCustomization>();
+
+ ServiceProxyResourceCustomization serviceProxy = null;
+
+ if (serviceProxyResourceList != null) {
+ for (NodeTemplate spNode : serviceProxyResourceList) {
+ serviceProxy = createServiceProxy(spNode, service, toscaResourceStruct);
+ serviceProxyList.add(serviceProxy);
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization =
+ getVnrNodeTemplate(configurationNodeTemplatesList, toscaResourceStruct, serviceProxy);
+
+ for (NodeTemplate configNode : configurationNodeTemplatesList) {
+
+ List<RequirementAssignment> requirementsList =
+ toscaResourceStruct.getSdcCsarHelper().getRequirementsOf(configNode).getAll();
+ for (RequirementAssignment requirement : requirementsList) {
+ if (requirement.getNodeTemplateName().equals(spNode.getName())) {
+ ConfigurationResourceCustomization configurationResource = createConfiguration(configNode,
+ toscaResourceStruct, serviceProxy, vnrResourceCustomization);
+
+ Optional<ConfigurationResourceCustomization> matchingObject = configurationResourceList
+ .stream()
+ .filter(configurationResourceCustomization -> configNode.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)
+ .equals(configurationResource.getModelCustomizationUUID()))
+ .findFirst();
+ if (!matchingObject.isPresent()) {
+ configurationResourceList.add(configurationResource);
+ }
+
+ break;
+ }
+ }
+ }
+
+ }
+ }
+
+ service.setConfigurationCustomizations(configurationResourceList);
+ service.setServiceProxyCustomizations(serviceProxyList);
+ }
+
+ protected void processNetworkCollections(ToscaResourceStructure toscaResourceStruct, Service service) {
+
+ List<NodeTemplate> networkCollectionList =
+ toscaResourceStruct.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
+
+ if (networkCollectionList != null) {
+ for (NodeTemplate crNode : networkCollectionList) {
+
+ createNetworkCollection(crNode, toscaResourceStruct, service);
+ collectionRepo.saveAndFlush(toscaResourceStruct.getCatalogCollectionResource());
+
+ List<NetworkInstanceGroup> networkInstanceGroupList =
+ toscaResourceStruct.getCatalogNetworkInstanceGroup();
+ for (NetworkInstanceGroup networkInstanceGroup : networkInstanceGroupList) {
+ instanceGroupRepo.saveAndFlush(networkInstanceGroup);
+ }
+
+ }
+ }
+ service.getCollectionResourceCustomizations()
+ .add(toscaResourceStruct.getCatalogCollectionResourceCustomization());
+ }
+
+
+ protected void processVFResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ VfResourceStructure vfResourceStructure) throws Exception {
+ logger.debug("processVFResources");
+
+ List<NodeTemplate> vfNodeTemplatesList = toscaResourceStruct.getSdcCsarHelper().getServiceVfList();
+ // String servicecategory = toscaResourceStruct.getCatalogService().getCategory();
+ // String serviceType = toscaResourceStruct.getCatalogService().getServiceType();
+
+ for (NodeTemplate nodeTemplate : vfNodeTemplatesList) {
+ Metadata metadata = nodeTemplate.getMetaData();
+ String vfCustomizationCategory = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY);
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ // Do not treat Allotted Resources as VNF resources
+ if (ALLOTTED_RESOURCE.equalsIgnoreCase(vfCustomizationCategory)) {
+ continue;
+ }
+
+ String vfCustomizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca
+ // customizations match before comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
+
+ processVfModules(toscaResourceStruct, vfResourceStructure, service, nodeTemplate, metadata,
+ vfCustomizationCategory);
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+ /**
+ * This is used to process the PNF specific resource, including resource and resource_customization.
+ * {@link IEntityDetails} based API is used to retrieve information. Please check {@link ISdcCsarHelper} for
+ * details.
+ */
+ protected void processPnfResources(ToscaResourceStructure toscaResourceStruct, Service service,
+ PnfResourceStructure resourceStructure) throws Exception {
+ logger.info("Processing PNF resource: {}", resourceStructure.getResourceInstance().getResourceUUID());
+
+ ISdcCsarHelper sdcCsarHelper = toscaResourceStruct.getSdcCsarHelper();
+ EntityQuery entityQuery = EntityQuery.newBuilder(SdcTypes.PNF).build();
+ TopologyTemplateQuery topologyTemplateQuery = TopologyTemplateQuery.newBuilder(SdcTypes.SERVICE).build();
+
+ List<IEntityDetails> entityDetailsList = sdcCsarHelper.getEntity(entityQuery, topologyTemplateQuery, false);
+ for (IEntityDetails entityDetails : entityDetailsList) {
+ Metadata metadata = entityDetails.getMetadata();
+ String customizationUUID = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ String modelUuid = metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ String notifCustomizationUUID = resourceStructure.getResourceInstance().getResourceCustomizationUUID();
+ if (customizationUUID != null && customizationUUID.equals(notifCustomizationUUID)) {
+ logger.info("Resource customization UUID: {} is the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+
+ if (checkExistingPnfResourceCutomization(customizationUUID)) {
+ logger.info("Resource customization UUID: {} already deployed", customizationUUID);
+ } else {
+ PnfResource pnfResource = findExistingPnfResource(service, modelUuid);
+ if (pnfResource == null) {
+ pnfResource = createPnfResource(entityDetails);
+ }
+ PnfResourceCustomization pnfResourceCustomization =
+ createPnfResourceCustomization(entityDetails, pnfResource);
+ pnfResource.getPnfResourceCustomizations().add(pnfResourceCustomization);
+ toscaResourceStruct.setPnfResourceCustomization(pnfResourceCustomization);
+ service.getPnfCustomizations().add(pnfResourceCustomization);
+ }
+ } else {
+ logger.warn(
+ "Resource customization UUID: {} is NOT the same as notified resource customizationUUID: {}",
+ customizationUUID, notifCustomizationUUID);
+ }
+ }
+ }
+
+ private PnfResource findExistingPnfResource(Service service, String modelUuid) {
+ PnfResource pnfResource = null;
+ for (PnfResourceCustomization pnfResourceCustomization : service.getPnfCustomizations()) {
+ if (pnfResourceCustomization.getPnfResources() != null
+ && pnfResourceCustomization.getPnfResources().getModelUUID().equals(modelUuid)) {
+ pnfResource = pnfResourceCustomization.getPnfResources();
+ }
+ }
+ if (pnfResource == null) {
+ pnfResource = pnfResourceRepository.findById(modelUuid).orElse(pnfResource);
+ }
+ return pnfResource;
+ }
+
+ private boolean checkExistingPnfResourceCutomization(String customizationUUID) {
+ return pnfCustomizationRepository.findById(customizationUUID).isPresent();
+ }
+
+ /**
+ * Construct the {@link PnfResource} from {@link IEntityDetails} object.
+ */
+ private PnfResource createPnfResource(IEntityDetails entity) {
+ PnfResource pnfResource = new PnfResource();
+ Metadata metadata = entity.getMetadata();
+ pnfResource.setModelInvariantUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ pnfResource.setModelName(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ pnfResource.setModelUUID(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ pnfResource.setModelVersion(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ pnfResource.setDescription(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ pnfResource.setCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+ pnfResource.setSubCategory(testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ pnfResource.setToscaNodeType(entity.getToscaType());
+ return pnfResource;
+ }
+
+ /**
+ * Construct the {@link PnfResourceCustomization} from {@link IEntityDetails} object.
+ */
+ private PnfResourceCustomization createPnfResourceCustomization(IEntityDetails entityDetails,
+ PnfResource pnfResource) {
+
+ PnfResourceCustomization pnfResourceCustomization = new PnfResourceCustomization();
+ Metadata metadata = entityDetails.getMetadata();
+ Map<String, Property> properties = entityDetails.getProperties();
+ pnfResourceCustomization.setModelCustomizationUUID(
+ testNull(metadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ pnfResourceCustomization.setModelInstanceName(entityDetails.getName());
+ pnfResourceCustomization
+ .setNfFunction(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ pnfResourceCustomization.setNfNamingCode(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFCODE)));
+ pnfResourceCustomization.setNfRole(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ pnfResourceCustomization.setNfType(getStringValue(properties.get(SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+ pnfResourceCustomization.setMultiStageDesign(getStringValue(properties.get(MULTI_STAGE_DESIGN)));
+ pnfResourceCustomization.setBlueprintName(getStringValue(properties.get(SDNC_MODEL_NAME)));
+ pnfResourceCustomization.setBlueprintVersion(getStringValue(properties.get(SDNC_MODEL_VERSION)));
+ pnfResourceCustomization.setSkipPostInstConf(getBooleanValue(properties.get(SKIP_POST_INST_CONF)));
+ pnfResourceCustomization.setPnfResources(pnfResource);
+
+ return pnfResourceCustomization;
+ }
+
+ /**
+ * Get value from {@link Property} and cast to boolean value. Return true if property is null.
+ */
+ private boolean getBooleanValue(Property property) {
+ if (null == property) {
+ return true;
+ }
+ Object value = property.getValue();
+ return new Boolean(String.valueOf(value));
+ }
+
+ /**
+ * Get value from {@link Property} and cast to String value. Return empty String if property is null value.
+ */
+ private String getStringValue(Property property) {
+ if (null == property) {
+ return "";
+ }
+ Object value = property.getValue();
+ return String.valueOf(value);
+ }
+
+ protected void processVfModules(ToscaResourceStructure toscaResourceStruct, VfResourceStructure vfResourceStructure,
+ Service service, NodeTemplate nodeTemplate, Metadata metadata, String vfCustomizationCategory)
+ throws Exception {
+
+ logger.debug("VF Category is : " + vfCustomizationCategory);
+
+ if (vfResourceStructure.getVfModuleStructure() != null
+ && !vfResourceStructure.getVfModuleStructure().isEmpty()) {
+
+ String vfCustomizationUUID = toscaResourceStruct.getSdcCsarHelper().getMetadataPropertyValue(metadata,
+ SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ logger.debug("VFCustomizationUUID=" + vfCustomizationUUID);
+
+ IResourceInstance vfNotificationResource = vfResourceStructure.getResourceInstance();
+
+ // Make sure the VF ResourceCustomizationUUID from the notification and tosca customizations match before
+ // comparing their VF Modules UUID's
+ logger.debug("Checking if Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " matches Tosca VF Customization UUID: "
+ + vfCustomizationUUID);
+
+ if (vfCustomizationUUID.equals(vfNotificationResource.getResourceCustomizationUUID())) {
+
+ logger.debug("vfCustomizationUUID: " + vfCustomizationUUID
+ + " matches vfNotificationResource CustomizationUUID");
+
+ VnfResourceCustomization vnfResource = createVnfResource(nodeTemplate, toscaResourceStruct, service);
+
+ Set<CvnfcCustomization> existingCvnfcSet = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> existingVnfcSet = new HashSet<VnfcCustomization>();
+
+ for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) {
+
+ logger.debug("vfModuleStructure:" + vfModuleStructure.toString());
+ List<org.onap.sdc.toscaparser.api.Group> vfGroups =
+ toscaResourceStruct.getSdcCsarHelper().getVfModulesByVf(vfCustomizationUUID);
+ IVfModuleData vfMetadata = vfModuleStructure.getVfModuleMetadata();
+
+ logger.debug("Comparing Vf_Modules_Metadata CustomizationUUID : "
+ + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ Optional<org.onap.sdc.toscaparser.api.Group> matchingObject = vfGroups.stream()
+ .peek(group -> logger.debug("To Csar Group VFModuleModelCustomizationUUID "
+ + group.getMetadata().getValue("vfModuleModelCustomizationUUID")))
+ .filter(group -> group.getMetadata().getValue("vfModuleModelCustomizationUUID")
+ .equals(vfMetadata.getVfModuleModelCustomizationUUID()))
+ .findFirst();
+ if (matchingObject.isPresent()) {
+ VfModuleCustomization vfModuleCustomization = createVFModuleResource(matchingObject.get(),
+ nodeTemplate, toscaResourceStruct, vfResourceStructure, vfMetadata, vnfResource,
+ service, existingCvnfcSet, existingVnfcSet);
+ vfModuleCustomization.getVfModule().setVnfResources(vnfResource.getVnfResources());
+ } else
+ throw new Exception(
+ "Cannot find matching VFModule Customization in Csar for Vf_Modules_Metadata: "
+ + vfMetadata.getVfModuleModelCustomizationUUID());
+
+ }
+
+
+ // Check for VNFC Instance Group info and add it if there is
+ List<Group> groupList =
+ toscaResourceStruct.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
+ nodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
+
+ for (Group group : groupList) {
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization =
+ createVNFCInstanceGroup(nodeTemplate, group, vnfResource, toscaResourceStruct);
+ vnfcInstanceGroupCustomizationRepo.saveAndFlush(vnfcInstanceGroupCustomization);
+ }
+
+
+ service.getVnfCustomizations().add(vnfResource);
+ } else {
+ logger.debug("Notification VF ResourceCustomizationUUID: "
+ + vfNotificationResource.getResourceCustomizationUUID() + " doesn't match "
+ + "Tosca VF Customization UUID: " + vfCustomizationUUID);
+ }
+ }
+ }
+
+ public void processWatchdog(String distributionId, String servideUUID, Optional<String> distributionNotification,
+ String consumerId) {
+ WatchdogServiceModVerIdLookup modVerIdLookup =
+ new WatchdogServiceModVerIdLookup(distributionId, servideUUID, distributionNotification, consumerId);
+ watchdogModVerIdLookupRepository.saveAndFlush(modVerIdLookup);
+
+ try {
+
+ WatchdogDistributionStatus distributionStatus = new WatchdogDistributionStatus(distributionId);
+ watchdogDistributionStatusRepository.saveAndFlush(distributionStatus);
+
+ } catch (ObjectOptimisticLockingFailureException e) {
+ logger.debug("ObjectOptimisticLockingFailureException in processWatchdog : " + e.toString());
+ throw e;
+ }
+ }
+
+ protected void extractHeatInformation(ToscaResourceStructure toscaResourceStruct,
+ VfResourceStructure vfResourceStructure) {
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) {
+ case ASDCConfiguration.HEAT:
+ case ASDCConfiguration.HEAT_NESTED:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_VOL:
+ createHeatTemplateFromArtifact(vfResourceStructure, toscaResourceStruct, vfModuleArtifact);
+ VfModuleArtifact envModuleArtifact =
+ getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
+ createHeatEnvFromArtifact(vfResourceStructure, envModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ENV:
+ createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact);
+ break;
+ case ASDCConfiguration.HEAT_ARTIFACT:
+ createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact, toscaResourceStruct);
+ break;
+ case ASDCConfiguration.HEAT_NET:
+ case ASDCConfiguration.OTHER:
+ logger.warn("{} {} {} {}", MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT.toString(),
+ vfModuleArtifact.getArtifactInfo().getArtifactType() + "(Artifact Name:"
+ + vfModuleArtifact.getArtifactInfo().getArtifactName() + ")",
+ ErrorCode.DataError.getValue(), "Artifact type not supported");
+ break;
+ default:
+ break;
+
+ }
+ }
+ }
+
+ protected VfModuleArtifact getHeatEnvArtifactFromGeneratedArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ String artifactName = vfModuleArtifact.getArtifactInfo().getArtifactName();
+ artifactName = artifactName.substring(0, artifactName.indexOf('.'));
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+ if (moduleArtifact.getArtifactInfo().getArtifactName().contains(artifactName)
+ && moduleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ return moduleArtifact;
+ }
+ }
+ return null;
+ }
+
+ public String verifyTheFilePrefixInArtifacts(String filebody, VfResourceStructure vfResourceStructure,
+ List<String> listTypes) {
+ String newFileBody = filebody;
+ for (VfModuleArtifact moduleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ if (listTypes.contains(moduleArtifact.getArtifactInfo().getArtifactType())) {
+
+ newFileBody =
+ verifyTheFilePrefixInString(newFileBody, moduleArtifact.getArtifactInfo().getArtifactName());
+ }
+ }
+ return newFileBody;
+ }
+
+ public String verifyTheFilePrefixInString(final String body, final String filenameToVerify) {
+
+ String needlePrefix = "file:///";
+ String prefixedFilenameToVerify = needlePrefix + filenameToVerify;
+
+ if ((body == null) || (body.length() == 0) || (filenameToVerify == null) || (filenameToVerify.length() == 0)) {
+ return body;
+ }
+
+ StringBuilder sb = new StringBuilder(body.length());
+
+ int currentIndex = 0;
+ int startIndex = 0;
+
+ while (currentIndex != -1) {
+ startIndex = currentIndex;
+ currentIndex = body.indexOf(prefixedFilenameToVerify, startIndex);
+
+ if (currentIndex == -1) {
+ break;
+ }
+ // We append from the startIndex up to currentIndex (start of File
+ // Name)
+ sb.append(body.substring(startIndex, currentIndex));
+ sb.append(filenameToVerify);
+
+ currentIndex += prefixedFilenameToVerify.length();
+ }
+
+ sb.append(body.substring(startIndex));
+
+ return sb.toString();
+ }
+
+ protected void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure,
+ ToscaResourceStructure toscaResourceStruct, VfModuleArtifact vfModuleArtifact) {
+ HeatTemplate heatTemplate = new HeatTemplate();
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT_NESTED);
+ typeList.add(ASDCConfiguration.HEAT_ARTIFACT);
+
+ heatTemplate.setTemplateBody(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatTemplate.setTemplateName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactTimeout() != null) {
+ heatTemplate.setTimeoutMinutes(vfModuleArtifact.getArtifactInfo().getArtifactTimeout());
+ } else {
+ heatTemplate.setTimeoutMinutes(240);
+ }
+
+ heatTemplate.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatTemplate.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatTemplate.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatTemplate.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatTemplate.setArtifactChecksum(MANUAL_RECORD);
+ }
+
+ Set<HeatTemplateParam> heatParam = extractHeatTemplateParameters(vfModuleArtifact.getResult(),
+ vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatTemplate.setParameters(heatParam);
+ vfModuleArtifact.setHeatTemplate(heatTemplate);
+ }
+
+ protected void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact) {
+ HeatEnvironment heatEnvironment = new HeatEnvironment();
+ heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ List<String> typeList = new ArrayList<>();
+ typeList.add(ASDCConfiguration.HEAT);
+ typeList.add(ASDCConfiguration.HEAT_VOL);
+ heatEnvironment.setEnvironment(
+ verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(), vfResourceStructure, typeList));
+ heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatEnvironment.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ heatEnvironment.setArtifactUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatEnvironment.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatEnvironment.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatEnvironment(heatEnvironment);
+ }
+
+ protected void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure,
+ VfModuleArtifact vfModuleArtifact, ToscaResourceStructure toscaResourceStruct) {
+
+ HeatFiles heatFile = new HeatFiles();
+ heatFile.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ heatFile.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription());
+ heatFile.setFileBody(vfModuleArtifact.getResult());
+ heatFile.setFileName(vfModuleArtifact.getArtifactInfo().getArtifactName());
+ heatFile.setVersion(BigDecimalVersion
+ .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion()));
+ toscaResourceStruct.setHeatFilesUUID(vfModuleArtifact.getArtifactInfo().getArtifactUUID());
+ if (vfModuleArtifact.getArtifactInfo().getArtifactChecksum() != null) {
+ heatFile.setArtifactChecksum(vfModuleArtifact.getArtifactInfo().getArtifactChecksum());
+ } else {
+ heatFile.setArtifactChecksum(MANUAL_RECORD);
+ }
+ vfModuleArtifact.setHeatFiles(heatFile);
+ }
+
+ protected Service createService(ToscaResourceStructure toscaResourceStructure,
+ ResourceStructure resourceStructure) {
+
+ Metadata serviceMetadata = toscaResourceStructure.getServiceMetadata();
+
+ Service service = new Service();
+
+ if (serviceMetadata != null) {
+
+ if (toscaResourceStructure.getServiceVersion() != null) {
+ service.setModelVersion(toscaResourceStructure.getServiceVersion());
+ }
+
+ service.setServiceType(serviceMetadata.getValue("serviceType"));
+ service.setServiceRole(serviceMetadata.getValue("serviceRole"));
+ service.setCategory(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+
+ service.setDescription(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ service.setModelName(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ service.setModelUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ service.setEnvironmentContext(serviceMetadata.getValue("environmentContext"));
+
+ if (resourceStructure != null)
+ service.setWorkloadContext(resourceStructure.getNotification().getWorkloadContext());
+
+ service.setModelInvariantUUID(serviceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ service.setCsar(toscaResourceStructure.getCatalogToscaCsar());
+ }
+
+
+ toscaResourceStructure.setCatalogService(service);
+ return service;
+ }
+
+ protected ServiceProxyResourceCustomization createServiceProxy(NodeTemplate nodeTemplate, Service service,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata spMetadata = nodeTemplate.getMetaData();
+
+ ServiceProxyResourceCustomization spCustomizationResource = new ServiceProxyResourceCustomization();
+
+ Set<ServiceProxyResourceCustomization> serviceProxyCustomizationSet = new HashSet<>();
+
+ spCustomizationResource.setModelName(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ spCustomizationResource
+ .setModelInvariantUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ spCustomizationResource.setModelUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ spCustomizationResource.setModelVersion(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ spCustomizationResource.setDescription(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ spCustomizationResource
+ .setModelCustomizationUUID(spMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ spCustomizationResource.setModelInstanceName(nodeTemplate.getName());
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+
+ String sourceServiceUUID = spMetadata.getValue("sourceModelUuid");
+
+ Service sourceService = serviceRepo.findOneByModelUUID(sourceServiceUUID);
+
+ spCustomizationResource.setSourceService(sourceService);
+ spCustomizationResource.setToscaNodeType(nodeTemplate.getType());
+ serviceProxyCustomizationSet.add(spCustomizationResource);
+
+
+ toscaResourceStructure.setCatalogServiceProxyResourceCustomization(spCustomizationResource);
+
+ return spCustomizationResource;
+ }
+
+ protected ConfigurationResourceCustomization createConfiguration(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, ServiceProxyResourceCustomization spResourceCustomization,
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization) {
+
+ ConfigurationResourceCustomization configCustomizationResource =
+ getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure, spResourceCustomization);
+
+ ConfigurationResource configResource = getConfigurationResource(nodeTemplate);
+
+ Set<ConfigurationResourceCustomization> configResourceCustomizationSet = new HashSet<>();
+
+ StatefulEntityType entityType = nodeTemplate.getTypeDefinition();
+ String type = entityType.getType();
+
+ if (NODES_VRF_ENTRY.equals(type)) {
+ configCustomizationResource.setConfigResourceCustomization(vnrResourceCustomization.orElse(null));
+ }
+
+ configCustomizationResource.setConfigurationResource(configResource);
+
+ configResourceCustomizationSet.add(configCustomizationResource);
+
+ configResource.setConfigurationResourceCustomization(configResourceCustomizationSet);
+
+ toscaResourceStructure.setCatalogConfigurationResource(configResource);
+
+ toscaResourceStructure.setCatalogConfigurationResourceCustomization(configCustomizationResource);
+
+ return configCustomizationResource;
+ }
+
+ protected ConfigurationResource createFabricConfiguration(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata fabricMetadata = nodeTemplate.getMetaData();
+
+ ConfigurationResource configResource = new ConfigurationResource();
+
+ configResource.setModelName(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ configResource.setModelInvariantUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ configResource.setModelUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ configResource.setModelVersion(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ configResource.setDescription(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ configResource.setToscaNodeType(nodeTemplate.getType());
+
+ return configResource;
+ }
+
+ protected void createToscaCsar(ToscaResourceStructure toscaResourceStructure) {
+ ToscaCsar toscaCsar = new ToscaCsar();
+ if (toscaResourceStructure.getToscaArtifact().getArtifactChecksum() != null) {
+ toscaCsar.setArtifactChecksum(toscaResourceStructure.getToscaArtifact().getArtifactChecksum());
+ } else {
+ toscaCsar.setArtifactChecksum(MANUAL_RECORD);
+ }
+ toscaCsar.setArtifactUUID(toscaResourceStructure.getToscaArtifact().getArtifactUUID());
+ toscaCsar.setName(toscaResourceStructure.getToscaArtifact().getArtifactName());
+ toscaCsar.setVersion(toscaResourceStructure.getToscaArtifact().getArtifactVersion());
+ toscaCsar.setDescription(toscaResourceStructure.getToscaArtifact().getArtifactDescription());
+ toscaCsar.setUrl(toscaResourceStructure.getToscaArtifact().getArtifactURL());
+
+ toscaResourceStructure.setCatalogToscaCsar(toscaCsar);
+ }
+
+ protected VnfcCustomization findExistingVfc(Set<VnfcCustomization> vnfcCustomizations, String customizationUUID) {
+ VnfcCustomization vnfcCustomization = null;
+ for (VnfcCustomization vnfcCustom : vnfcCustomizations) {
+ if (vnfcCustom != null && vnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ vnfcCustomization = vnfcCustom;
+ }
+ }
+
+ if (vnfcCustomization == null)
+ vnfcCustomization = vnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+ // vnfcCustomization = new VnfcCustomization();
+
+ return vnfcCustomization;
+ }
+
+ protected CvnfcCustomization findExistingCvfc(Set<CvnfcCustomization> cvnfcCustomizations,
+ String customizationUUID) {
+ CvnfcCustomization cvnfcCustomization = null;
+ for (CvnfcCustomization cvnfcCustom : cvnfcCustomizations) {
+ if (cvnfcCustom != null && cvnfcCustom.getModelCustomizationUUID().equals(customizationUUID)) {
+ cvnfcCustomization = cvnfcCustom;
+ }
+ }
+
+ if (cvnfcCustomization == null)
+ cvnfcCustomization = cvnfcCustomizationRepo.findOneByModelCustomizationUUID(customizationUUID);
+
+ return cvnfcCustomization;
+ }
+
+ protected NetworkResourceCustomization createNetwork(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin,
+ Service service) {
+
+ NetworkResourceCustomization networkResourceCustomization =
+ networkCustomizationRepo.findOneByModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ boolean networkUUIDsMatch = true;
+ // Check to make sure the NetworkResourceUUID on the Customization record matches the NetworkResourceUUID from
+ // the distribution.
+ // If not we'll update the Customization record with latest from the distribution
+ if (networkResourceCustomization != null) {
+ String existingNetworkModelUUID = networkResourceCustomization.getNetworkResource().getModelUUID();
+ String latestNetworkModelUUID =
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+
+ if (!existingNetworkModelUUID.equals(latestNetworkModelUUID)) {
+ networkUUIDsMatch = false;
+ }
+
+ }
+
+ if (networkResourceCustomization != null && !networkUUIDsMatch) {
+
+ NetworkResource networkResource =
+ createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate, aicMax, aicMin);
+
+ networkResourceCustomization.setNetworkResource(networkResource);
+
+ networkCustomizationRepo.saveAndFlush(networkResourceCustomization);
+
+ } else if (networkResourceCustomization == null) {
+ networkResourceCustomization =
+ createNetworkResourceCustomization(networkNodeTemplate, toscaResourceStructure);
+
+ NetworkResource networkResource = findExistingNetworkResource(service,
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ if (networkResource == null)
+ networkResource = createNetworkResource(networkNodeTemplate, toscaResourceStructure, heatTemplate,
+ aicMax, aicMin);
+
+ networkResource.addNetworkResourceCustomization(networkResourceCustomization);
+ networkResourceCustomization.setNetworkResource(networkResource);
+ }
+
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource findExistingNetworkResource(Service service, String modelUUID) {
+ NetworkResource networkResource = null;
+ for (NetworkResourceCustomization networkCustom : service.getNetworkCustomizations()) {
+ if (networkCustom.getNetworkResource() != null
+ && networkCustom.getNetworkResource().getModelUUID().equals(modelUUID)) {
+ networkResource = networkCustom.getNetworkResource();
+ }
+ }
+ if (networkResource == null)
+ networkResource = networkRepo.findResourceByModelUUID(modelUUID);
+
+ return networkResource;
+ }
+
+ protected NetworkResourceCustomization createNetworkResourceCustomization(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ NetworkResourceCustomization networkResourceCustomization = new NetworkResourceCustomization();
+ networkResourceCustomization.setModelInstanceName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ networkResourceCustomization.setModelCustomizationUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+
+ networkResourceCustomization.setNetworkTechnology(
+ testNull(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY)));
+ networkResourceCustomization.setNetworkType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE)));
+ networkResourceCustomization.setNetworkRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE)));
+ networkResourceCustomization.setNetworkScope(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE)));
+ return networkResourceCustomization;
+ }
+
+ protected NetworkResource createNetworkResource(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, HeatTemplate heatTemplate, String aicMax, String aicMin) {
+ NetworkResource networkResource = new NetworkResource();
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ networkNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource.setModelName(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+
+ networkResource.setModelInvariantUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ networkResource.setModelUUID(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ networkResource.setModelVersion(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+
+ networkResource.setAicVersionMax(aicMax);
+ networkResource.setAicVersionMin(aicMin);
+ networkResource.setToscaNodeType(networkNodeTemplate.getType());
+ networkResource.setDescription(
+ testNull(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ networkResource.setOrchestrationMode(HEAT);
+ networkResource.setHeatTemplate(heatTemplate);
+ return networkResource;
+ }
+
+ protected CollectionNetworkResourceCustomization createNetworkCollection(NodeTemplate networkNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+
+ CollectionNetworkResourceCustomization collectionNetworkResourceCustomization =
+ new CollectionNetworkResourceCustomization();
+
+ // **** Build Object to populate Collection_Resource table
+ CollectionResource collectionResource = new CollectionResource();
+
+ collectionResource
+ .setModelName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ collectionResource.setModelInvariantUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ collectionResource
+ .setModelUUID(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ collectionResource
+ .setModelVersion(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ collectionResource
+ .setDescription(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ collectionResource.setToscaNodeType(networkNodeTemplate.getType());
+
+ toscaResourceStructure.setCatalogCollectionResource(collectionResource);
+
+ // **** Build object to populate Collection_Resource_Customization table
+ NetworkCollectionResourceCustomization ncfc = new NetworkCollectionResourceCustomization();
+
+ ncfc.setFunction(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_function"));
+ ncfc.setRole(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_role"));
+ ncfc.setType(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ "cr_type"));
+
+ ncfc.setModelInstanceName(networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ ncfc.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ Set<CollectionNetworkResourceCustomization> networkResourceCustomizationSet = new HashSet<>();
+ networkResourceCustomizationSet.add(collectionNetworkResourceCustomization);
+
+ ncfc.setNetworkResourceCustomization(networkResourceCustomizationSet);
+
+ ncfc.setCollectionResource(collectionResource);
+ toscaResourceStructure.setCatalogCollectionResourceCustomization(ncfc);
+
+ // *** Build object to populate the Instance_Group table
+ List<Group> groupList =
+ toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
+ networkNodeTemplate, "org.openecomp.groups.NetworkCollection");
+
+ List<NetworkInstanceGroup> networkInstanceGroupList = new ArrayList<>();
+
+ List<CollectionResourceInstanceGroupCustomization> collectionResourceInstanceGroupCustomizationList =
+ new ArrayList<CollectionResourceInstanceGroupCustomization>();
+
+ for (Group group : groupList) {
+
+ NetworkInstanceGroup networkInstanceGroup = new NetworkInstanceGroup();
+ Metadata instanceMetadata = group.getMetadata();
+ networkInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ networkInstanceGroup
+ .setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ networkInstanceGroup.setToscaNodeType(group.getType());
+ networkInstanceGroup.setRole(SubType.SUB_INTERFACE.toString()); // Set
+ // Role
+ networkInstanceGroup.setType(InstanceGroupType.L3_NETWORK); // Set
+ // type
+ networkInstanceGroup.setCollectionResource(collectionResource);
+
+ // ****Build object to populate
+ // Collection_Resource_Instance_Group_Customization table
+ CollectionResourceInstanceGroupCustomization crInstanceGroupCustomization =
+ new CollectionResourceInstanceGroupCustomization();
+ crInstanceGroupCustomization.setInstanceGroup(networkInstanceGroup);
+ crInstanceGroupCustomization.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ crInstanceGroupCustomization.setModelCustomizationUUID(
+ networkNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ // Loop through the template policy to find the subinterface_network_quantity property name. Then extract
+ // the value for it.
+ List<Policy> policyList =
+ toscaResourceStructure.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(
+ networkNodeTemplate, "org.openecomp.policies.scaling.Fixed");
+
+ if (policyList != null) {
+ for (Policy policy : policyList) {
+ for (String policyNetworkCollection : policy.getTargets()) {
+
+ if (policyNetworkCollection.equalsIgnoreCase(group.getName())) {
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if (propMap.get("quantity") != null) {
+
+ String quantity = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ getPropertyInput(propMap.get("quantity").toString()));
+
+ if (quantity != null) {
+ crInstanceGroupCustomization
+ .setSubInterfaceNetworkQuantity(Integer.parseInt(quantity));
+ }
+
+ }
+
+ }
+ }
+ }
+ }
+
+ crInstanceGroupCustomization.setDescription(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_description"));
+ crInstanceGroupCustomization.setFunction(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(networkNodeTemplate,
+ instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME)
+ + "_network_collection_function"));
+ crInstanceGroupCustomization.setCollectionResourceCust(ncfc);
+ collectionResourceInstanceGroupCustomizationList.add(crInstanceGroupCustomization);
+
+ networkInstanceGroup
+ .setCollectionInstanceGroupCustomizations(collectionResourceInstanceGroupCustomizationList);
+
+ networkInstanceGroupList.add(networkInstanceGroup);
+
+
+ toscaResourceStructure.setCatalogNetworkInstanceGroup(networkInstanceGroupList);
+
+ List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(networkNodeTemplate, SdcTypes.VL);
+
+ List<CollectionNetworkResourceCustomization> collectionNetworkResourceCustomizationList = new ArrayList<>();
+
+ // *****Build object to populate the NetworkResource table
+ NetworkResource networkResource = new NetworkResource();
+
+ for (NodeTemplate vlNodeTemplate : vlNodeList) {
+
+ String providerNetwork = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_PROVIDERNETWORK_ISPROVIDERNETWORK);
+
+ if ("true".equalsIgnoreCase(providerNetwork)) {
+ networkResource.setNeutronNetworkType(PROVIDER);
+ } else {
+ networkResource.setNeutronNetworkType(BASIC);
+ }
+
+ networkResource
+ .setModelName(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ networkResource.setModelInvariantUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ networkResource
+ .setModelUUID(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ networkResource
+ .setModelVersion(vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+
+ networkResource.setAicVersionMax(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+
+ TempNetworkHeatTemplateLookup tempNetworkLookUp =
+ tempNetworkLookupRepo.findFirstBynetworkResourceModelName(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+
+ if (tempNetworkLookUp != null) {
+
+ HeatTemplate heatTemplate =
+ heatRepo.findByArtifactUuid(tempNetworkLookUp.getHeatTemplateArtifactUuid());
+ networkResource.setHeatTemplate(heatTemplate);
+
+ networkResource.setAicVersionMin(tempNetworkLookUp.getAicVersionMin());
+
+ }
+
+ networkResource.setToscaNodeType(vlNodeTemplate.getType());
+ networkResource.setDescription(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ networkResource.setOrchestrationMode(HEAT);
+
+ // Build object to populate the
+ // Collection_Network_Resource_Customization table
+ for (NodeTemplate memberNode : group.getMemberNodes()) {
+ collectionNetworkResourceCustomization.setModelInstanceName(memberNode.getName());
+ }
+
+ collectionNetworkResourceCustomization.setModelCustomizationUUID(
+ vlNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ collectionNetworkResourceCustomization.setNetworkTechnology(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ collectionNetworkResourceCustomization.setNetworkType(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ collectionNetworkResourceCustomization.setNetworkRole(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ collectionNetworkResourceCustomization.setNetworkScope(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vlNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ collectionNetworkResourceCustomization.setInstanceGroup(networkInstanceGroup);
+ collectionNetworkResourceCustomization.setNetworkResource(networkResource);
+ collectionNetworkResourceCustomization.setNetworkResourceCustomization(ncfc);
+
+ collectionNetworkResourceCustomizationList.add(collectionNetworkResourceCustomization);
+ }
+
+ }
+
+ return collectionNetworkResourceCustomization;
+ }
+
+ protected VnfcInstanceGroupCustomization createVNFCInstanceGroup(NodeTemplate vnfcNodeTemplate, Group group,
+ VnfResourceCustomization vnfResourceCustomization, ToscaResourceStructure toscaResourceStructure) {
+
+ Metadata instanceMetadata = group.getMetadata();
+ // Populate InstanceGroup
+ VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+
+ vfcInstanceGroup.setModelName(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vfcInstanceGroup.setModelInvariantUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vfcInstanceGroup.setModelUUID(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ vfcInstanceGroup.setModelVersion(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ vfcInstanceGroup.setToscaNodeType(group.getType());
+ vfcInstanceGroup.setRole("SUB-INTERFACE"); // Set Role
+ vfcInstanceGroup.setType(InstanceGroupType.VNFC); // Set type
+
+ // Populate VNFCInstanceGroupCustomization
+ VnfcInstanceGroupCustomization vfcInstanceGroupCustom = new VnfcInstanceGroupCustomization();
+
+ vfcInstanceGroupCustom.setVnfResourceCust(vnfResourceCustomization);
+ vnfResourceCustomization.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
+
+ vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
+ vfcInstanceGroup.getVnfcInstanceGroupCustomizations().add(vfcInstanceGroupCustom);
+
+ vfcInstanceGroupCustom.setDescription(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+
+ String getInputName = null;
+ String groupProperty = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ "vfc_instance_group_function");
+ if (groupProperty != null) {
+ int getInputIndex = groupProperty.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ getInputName = groupProperty.substring(getInputIndex + 11, groupProperty.length() - 1);
+ }
+ }
+ vfcInstanceGroupCustom.setFunction(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vnfcNodeTemplate, getInputName));
+ vfcInstanceGroupCustom.setInstanceGroup(vfcInstanceGroup);
+
+
+ return vfcInstanceGroupCustom;
+
+ }
+
+ protected VfModuleCustomization createVFModuleResource(Group group, NodeTemplate vfTemplate,
+ ToscaResourceStructure toscaResourceStructure, VfResourceStructure vfResourceStructure,
+ IVfModuleData vfModuleData, VnfResourceCustomization vnfResource, Service service,
+ Set<CvnfcCustomization> existingCvnfcSet, Set<VnfcCustomization> existingVnfcSet) {
+
+ VfModuleCustomization vfModuleCustomization =
+ findExistingVfModuleCustomization(vnfResource, vfModuleData.getVfModuleModelCustomizationUUID());
+ if (vfModuleCustomization == null) {
+ VfModule vfModule = findExistingVfModule(vnfResource,
+ vfTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ Metadata vfMetadata = group.getMetadata();
+ if (vfModule == null)
+ vfModule = createVfModule(group, toscaResourceStructure, vfModuleData, vfMetadata);
+
+ vfModuleCustomization = createVfModuleCustomization(group, toscaResourceStructure, vfModule, vfModuleData);
+ vfModuleCustomization.setVnfCustomization(vnfResource);
+ setHeatInformationForVfModule(toscaResourceStructure, vfResourceStructure, vfModule, vfModuleCustomization,
+ vfMetadata);
+ vfModuleCustomization.setVfModule(vfModule);
+ vfModule.getVfModuleCustomization().add(vfModuleCustomization);
+ vnfResource.getVfModuleCustomizations().add(vfModuleCustomization);
+ } else {
+ vfResourceStructure.setAlreadyDeployed(true);
+ }
+
+ // ******************************************************************************************************************
+ // * Extract VFC's and CVFC's then add them to VFModule
+ // ******************************************************************************************************************
+
+ Set<CvnfcConfigurationCustomization> cvnfcConfigurationCustomizations =
+ new HashSet<CvnfcConfigurationCustomization>();
+ Set<CvnfcCustomization> cvnfcCustomizations = new HashSet<CvnfcCustomization>();
+ Set<VnfcCustomization> vnfcCustomizations = new HashSet<VnfcCustomization>();
+
+ // Only set the CVNFC if this vfModule group is a member of it.
+ List<NodeTemplate> groupMembers =
+ toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfTemplate, group);
+ String vfModuleMemberName = null;
+
+ for (NodeTemplate node : groupMembers) {
+ vfModuleMemberName = node.getName();
+ }
+
+ // Extract CVFC lists
+ List<NodeTemplate> cvfcList =
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfTemplate, SdcTypes.CVFC);
+
+ for (NodeTemplate cvfcTemplate : cvfcList) {
+ boolean cvnfcVfModuleNameMatch = false;
+
+ for (NodeTemplate node : groupMembers) {
+ vfModuleMemberName = node.getName();
+
+ if (vfModuleMemberName.equalsIgnoreCase(cvfcTemplate.getName())) {
+ cvnfcVfModuleNameMatch = true;
+ break;
+ }
+ }
+
+ if (vfModuleMemberName != null && cvnfcVfModuleNameMatch) {
+
+ // Extract associated VFC - Should always be just one
+ List<NodeTemplate> vfcList =
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+ for (NodeTemplate vfcTemplate : vfcList) {
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ VnfcCustomization existingVnfcCustomization = null;
+
+ existingVnfcCustomization = findExistingVfc(existingVnfcSet,
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (existingVnfcCustomization == null) {
+ vnfcCustomization = new VnfcCustomization();
+ } else {
+ vnfcCustomization = existingVnfcCustomization;
+ }
+
+ // Only Add Abstract VNFC's to our DB, ignore all others
+ if (existingVnfcCustomization == null && vfcTemplate.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY).equalsIgnoreCase("Abstract")) {
+ vnfcCustomization.setModelCustomizationUUID(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ vnfcCustomization.setModelInstanceName(vfcTemplate.getName());
+ vnfcCustomization.setModelInvariantUUID(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ vnfcCustomization
+ .setModelName(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ vnfcCustomization
+ .setModelUUID(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ vnfcCustomization.setModelVersion(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfcCustomization.setDescription(testNull(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfcCustomization.setToscaNodeType(testNull(vfcTemplate.getType()));
+
+ vnfcCustomizations.add(vnfcCustomization);
+ existingVnfcSet.add(vnfcCustomization);
+ }
+
+ // This check is needed incase the VFC subcategory is
+ // something other than Abstract. In that case we want to
+ // skip adding that record to our DB.
+ if (vnfcCustomization.getModelCustomizationUUID() != null) {
+ CvnfcCustomization cvnfcCustomization = new CvnfcCustomization();
+ cvnfcCustomization.setModelCustomizationUUID(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcCustomization.setModelInstanceName(cvfcTemplate.getName());
+ cvnfcCustomization.setModelInvariantUUID(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ cvnfcCustomization
+ .setModelName(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ cvnfcCustomization
+ .setModelUUID(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ cvnfcCustomization.setModelVersion(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ cvnfcCustomization.setDescription(testNull(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ cvnfcCustomization.setToscaNodeType(testNull(cvfcTemplate.getType()));
+
+ if (existingVnfcCustomization != null) {
+ cvnfcCustomization.setVnfcCustomization(existingVnfcCustomization);
+ } else {
+ cvnfcCustomization.setVnfcCustomization(vnfcCustomization);
+ }
+
+ cvnfcCustomization.setNfcFunction(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_function"));
+ cvnfcCustomization.setNfcNamingCode(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(cvfcTemplate, "nfc_naming_code"));
+ cvnfcCustomization.setVfModuleCustomization(vfModuleCustomization);
+
+ cvnfcCustomizations.add(cvnfcCustomization);
+ existingCvnfcSet.add(cvnfcCustomization);
+
+ // *****************************************************************************************************************************************
+ // * Extract Fabric Configuration
+ // *****************************************************************************************************************************************
+
+ List<NodeTemplate> fabricConfigList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(vfTemplate, SdcTypes.CONFIGURATION);
+
+ for (NodeTemplate fabricTemplate : fabricConfigList) {
+
+ ConfigurationResource fabricConfig = null;
+
+ ConfigurationResource existingConfig = findExistingConfiguration(service,
+ fabricTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (existingConfig == null) {
+
+ fabricConfig = createFabricConfiguration(fabricTemplate, toscaResourceStructure);
+
+ } else {
+ fabricConfig = existingConfig;
+ }
+
+ CvnfcConfigurationCustomization cvnfcConfigurationCustomization =
+ createCvnfcConfigurationCustomization(fabricTemplate, toscaResourceStructure,
+ vnfResource, vfModuleCustomization, cvnfcCustomization, fabricConfig,
+ vfTemplate, vfModuleMemberName);
+ cvnfcConfigurationCustomizations.add(cvnfcConfigurationCustomization);
+
+ fabricConfig.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
+ }
+ cvnfcCustomization.setCvnfcConfigurationCustomization(cvnfcConfigurationCustomizations);
+ }
+
+ }
+
+ }
+ }
+ vfModuleCustomization.setCvnfcCustomization(cvnfcCustomizations);
+
+ return vfModuleCustomization;
+ }
+
+ protected CvnfcConfigurationCustomization createCvnfcConfigurationCustomization(NodeTemplate fabricTemplate,
+ ToscaResourceStructure toscaResourceStruct, VnfResourceCustomization vnfResource,
+ VfModuleCustomization vfModuleCustomization, CvnfcCustomization cvnfcCustomization,
ConfigurationResource configResource, NodeTemplate vfTemplate, String vfModuleMemberName) {
- Metadata fabricMetadata = fabricTemplate.getMetaData();
-
- CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
-
- cvnfcConfigurationCustomization.setConfigurationResource(configResource);
-
- cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
-
- cvnfcConfigurationCustomization.setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
-
- List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper().getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
-
- if(policyList != null){
- for(Policy policy : policyList){
-
- for(String policyCvfcTarget : policy.getTargets()){
-
- if(policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)){
-
- Map<String, Object> propMap = policy.getPolicyProperties();
-
- if(propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")){
- cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
- }
- }
- }
- }
- }
-
- cvnfcConfigurationCustomization.setConfigurationFunction(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
- cvnfcConfigurationCustomization.setConfigurationRole(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
- cvnfcConfigurationCustomization.setConfigurationType(toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
-
- return cvnfcConfigurationCustomization;
- }
-
- protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
- ConfigurationResource configResource = null;
- for(ConfigurationResourceCustomization configurationResourceCustom : service.getConfigurationCustomizations()){
- if (configurationResourceCustom.getConfigurationResource() != null
- && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
- configResource = configurationResourceCustom.getConfigurationResource();
- }
- }
-
- return configResource;
- }
-
- protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
- String vfModuleModelCustomizationUUID) {
- VfModuleCustomization vfModuleCustomization = null;
- for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
- if(vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)){
- vfModuleCustomization = vfModuleCustom;
- }
- }
- return vfModuleCustomization;
- }
-
- protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
- VfModule vfModule = null;
- for(VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()){
- if(vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)){
- vfModule = vfModuleCustom.getVfModule();
- }
- }
- if(vfModule==null)
- vfModule = vfModuleRepo.findByModelUUID(modelUUID);
-
- return vfModule;
- }
-
- protected VfModuleCustomization createVfModuleCustomization(Group group,
- ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
- VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
-
- vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
-
- vfModuleCustomization.setVfModule(vfModule);
-
- String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
- if (initialCount != null && initialCount.length() > 0) {
- vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
- }
-
- vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
- .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
-
- String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
- if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
- vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
- }
-
- vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
-
- String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
- if (maxInstances != null && maxInstances.length() > 0) {
- vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
- }
-
- String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
- if (minInstances != null && minInstances.length() > 0) {
- vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
- }
- return vfModuleCustomization;
- }
-
- protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
- IVfModuleData vfModuleData, Metadata vfMetadata) {
- VfModule vfModule = new VfModule();
- String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
-
- if(vfModuleModelUUID == null) {
- vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
- } else if (vfModuleModelUUID.indexOf('.') > -1) {
- vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
- }
-
- vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
- vfModule.setModelUUID(vfModuleModelUUID);
- vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
-
- String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
- SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
- if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
- vfModule.setIsBase(true);
- } else {
- vfModule.setIsBase(false);
- }
- return vfModule;
- }
-
- protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
- VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- Metadata vfMetadata) {
-
- Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
- .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
- .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
- SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
- .findFirst();
-
- if (matchingObject.isPresent()) {
- List<HeatFiles> heatFilesList = new ArrayList<>();
- List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
- List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
- HeatTemplate parentHeatTemplate = new HeatTemplate();
- String parentArtifactType = null;
- Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
- for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
-
- List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
-
- if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
- checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
- childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
- }
-
- if(vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)){
- parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
-
- if(!childNestedHeatTemplates.isEmpty()){
-
- if (parentArtifactType != null && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
- volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
- } else {
- heatChildTemplates.add(childNestedHeatTemplates.get(0));
- }
- }
- }
-
- }
- if(!heatFilesList.isEmpty()){
- vfModule.setHeatFiles(heatFilesList);
- }
-
-
- // Set all Child Templates related to HEAT_VOLUME
- if(!volumeHeatChildTemplates.isEmpty()){
- if(vfModule.getVolumeHeatTemplate() != null){
- vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
- }else{
- logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
-
- // Set all Child Templates related to HEAT
- if(!heatChildTemplates.isEmpty()){
- if(vfModule.getModuleHeatTemplate() != null){
- vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
- }else{
- logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
- }
- }
- }
- }
-
- protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
- List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
- HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
- if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
- vfModuleArtifact.incrementDeployedInDB();
- vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
- vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
- VfModuleArtifact volVfModuleArtifact = this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
- vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
- if(vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
- vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
- } else {
- vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
- }
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
- heatFilesList.add(vfModuleArtifact.getHeatFiles());
- vfModuleArtifact.incrementDeployedInDB();
- } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
- nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
- vfModuleArtifact.incrementDeployedInDB();
- }
- }
-
- protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- VnfResourceCustomization vnfResourceCustomization = null;
- if(vnfResourceCustomization == null){
- VnfResource vnfResource = findExistingVnfResource(service,
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if(vnfResource==null)
- vnfResource=createVnfResource(vfNodeTemplate);
-
- vnfResourceCustomization = createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure,
- vnfResource);
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResourceCustomization.setService(service);
- vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
-
- }
- return vnfResourceCustomization;
- }
-
- protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
- VnfResource vnfResource = null;
- for(VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()){
- if (vnfResourceCustom.getVnfResources() != null
- && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
- vnfResource = vnfResourceCustom.getVnfResources();
- }
- }
- if(vnfResource==null)
- vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
-
- return vnfResource;
- }
-
- protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
- ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
- VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
- vnfResourceCustomization.setModelCustomizationUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
-
- vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
- vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
-
- vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
-
- vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
-
- String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
- if (skipPostInstConfText != null){
- vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
- }
-
- vnfResourceCustomization.setVnfResources(vnfResource);
- vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
- vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
-
- CapabilityAssignments vnfCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(vfNodeTemplate);
-
- if (vnfCustomizationCapability != null) {
- CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
- .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
-
- }
-
- toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
-
- return vnfResourceCustomization;
- }
-
- protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
- VnfResource vnfResource = new VnfResource();
- vnfResource.setModelInvariantUUID(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
-
- vnfResource.setModelVersion(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- vnfResource.setDescription(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- vnfResource.setOrchestrationMode(HEAT);
- vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
- vnfResource.setAicVersionMax(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- vnfResource.setAicVersionMin(
- testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
- vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
-
- return vnfResource;
- }
-
- protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure, Service service) {
- AllottedResourceCustomization allottedResourceCustomization = allottedCustomizationRepo
- .findOneByModelCustomizationUUID(
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
-
- if(allottedResourceCustomization == null){
- AllottedResource allottedResource = findExistingAllottedResource(service,
- nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
-
- if(allottedResource==null)
- allottedResource=createAR(nodeTemplate);
-
- toscaResourceStructure.setAllottedResource(allottedResource);
- allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
- allottedResourceCustomization.setAllottedResource(allottedResource);
- allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
- AllottedResource allottedResource = null;
- for(AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()){
- if (allottedResourceCustom.getAllottedResource() != null
- && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
- allottedResource = allottedResourceCustom.getAllottedResource();
- }
- }
- if(allottedResource==null)
- allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
-
- return allottedResource;
- }
-
- protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
- ToscaResourceStructure toscaResourceStructure) {
- AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
- allottedResourceCustomization.setModelCustomizationUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
-
-
- allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
- allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
- allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
- allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
- .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
-
- List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper().getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
-
- if(vfcNodes != null){
- for(NodeTemplate vfcNode : vfcNodes){
-
- allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
- allottedResourceCustomization.setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
- allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
- }
- }
-
-
- CapabilityAssignments arCustomizationCapability = toscaResourceStructure.getSdcCsarHelper()
- .getCapabilitiesOf(nodeTemplate);
-
- if (arCustomizationCapability != null) {
- CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
-
- if (capAssign != null) {
- allottedResourceCustomization.setMinInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- allottedResourceCustomization.setMaxInstances(
- Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
- capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- }
- }
- return allottedResourceCustomization;
- }
-
- protected AllottedResource createAR(NodeTemplate nodeTemplate) {
- AllottedResource allottedResource = new AllottedResource();
- allottedResource
- .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- allottedResource.setModelInvariantUUID(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- allottedResource
- .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- allottedResource
- .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
- allottedResource.setSubcategory(
- testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- allottedResource
- .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- return allottedResource;
- }
-
- protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
- // Scan the payload downloadResult and extract the HeatTemplate
- // parameters
- YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
- return yamlEditor.getParameterList(artifactUUID);
- }
-
- protected String testNull(Object object) {
-
- if (object == null) {
- return null;
- } else if (object.equals("NULL")) {
- return null;
- } else if (object instanceof Integer) {
- return object.toString();
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return "Type not recognized";
- }
- }
-
- protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
- VfModuleArtifact heatNestedArtifact) {
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
- .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
- .getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT;
- }
-
- }
- }
-
- if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
- && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
- .getRelatedArtifacts() != null) {
- for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
- .get(0).getArtifactInfo().getRelatedArtifacts()) {
- if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
- return ASDCConfiguration.HEAT_VOL;
- }
-
- }
- }
-
- // Does not belong to anything
- return null;
-
- }
-
- protected static String createVNFName(VfResourceStructure vfResourceStructure) {
-
- return vfResourceStructure.getNotification().getServiceName() + "/"
- + vfResourceStructure.getResourceInstance().getResourceInstanceName();
- }
-
- protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
-
- return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
- + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
- }
-
- protected String getPropertyInput(String propertyName){
-
- String inputName = new String();
-
- if (propertyName != null) {
- int getInputIndex = propertyName.indexOf("{get_input=");
- if (getInputIndex > -1) {
- inputName = propertyName.substring(getInputIndex+11, propertyName.length()-1);
- }
- }
-
- return inputName;
- }
-
-
- protected static Timestamp getCurrentTimeStamp() {
-
- return new Timestamp(new Date().getTime());
- }
+ Metadata fabricMetadata = fabricTemplate.getMetaData();
+
+ CvnfcConfigurationCustomization cvnfcConfigurationCustomization = new CvnfcConfigurationCustomization();
+
+ cvnfcConfigurationCustomization.setConfigurationResource(configResource);
+
+ cvnfcConfigurationCustomization.setCvnfcCustomization(cvnfcCustomization);
+
+ cvnfcConfigurationCustomization
+ .setModelCustomizationUUID(fabricMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ cvnfcConfigurationCustomization.setModelInstanceName(fabricTemplate.getName());
+
+ List<Policy> policyList = toscaResourceStruct.getSdcCsarHelper()
+ .getPoliciesOfOriginOfNodeTemplateByToscaPolicyType(vfTemplate, "org.openecomp.policies.External");
+
+ if (policyList != null) {
+ for (Policy policy : policyList) {
+
+ for (String policyCvfcTarget : policy.getTargets()) {
+
+ if (policyCvfcTarget.equalsIgnoreCase(vfModuleMemberName)) {
+
+ Map<String, Object> propMap = policy.getPolicyProperties();
+
+ if (propMap.get("type").toString().equalsIgnoreCase("Fabric Policy")) {
+ cvnfcConfigurationCustomization.setPolicyName(propMap.get("name").toString());
+ }
+ }
+ }
+ }
+ }
+
+ cvnfcConfigurationCustomization.setConfigurationFunction(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "function"));
+ cvnfcConfigurationCustomization.setConfigurationRole(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "role"));
+ cvnfcConfigurationCustomization.setConfigurationType(
+ toscaResourceStruct.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(fabricTemplate, "type"));
+
+ return cvnfcConfigurationCustomization;
+ }
+
+ protected ConfigurationResource findExistingConfiguration(Service service, String modelUUID) {
+ ConfigurationResource configResource = null;
+ for (ConfigurationResourceCustomization configurationResourceCustom : service
+ .getConfigurationCustomizations()) {
+ if (configurationResourceCustom.getConfigurationResource() != null
+ && configurationResourceCustom.getConfigurationResource().getModelUUID().equals(modelUUID)) {
+ configResource = configurationResourceCustom.getConfigurationResource();
+ }
+ }
+
+ return configResource;
+ }
+
+ protected VfModuleCustomization findExistingVfModuleCustomization(VnfResourceCustomization vnfResource,
+ String vfModuleModelCustomizationUUID) {
+ VfModuleCustomization vfModuleCustomization = null;
+ for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
+ if (vfModuleCustom.getModelCustomizationUUID().equalsIgnoreCase(vfModuleModelCustomizationUUID)) {
+ vfModuleCustomization = vfModuleCustom;
+ }
+ }
+ return vfModuleCustomization;
+ }
+
+ protected VfModule findExistingVfModule(VnfResourceCustomization vnfResource, String modelUUID) {
+ VfModule vfModule = null;
+ for (VfModuleCustomization vfModuleCustom : vnfResource.getVfModuleCustomizations()) {
+ if (vfModuleCustom.getVfModule() != null && vfModuleCustom.getVfModule().getModelUUID().equals(modelUUID)) {
+ vfModule = vfModuleCustom.getVfModule();
+ }
+ }
+ if (vfModule == null)
+ vfModule = vfModuleRepo.findByModelUUID(modelUUID);
+
+ return vfModule;
+ }
+
+ protected VfModuleCustomization createVfModuleCustomization(Group group,
+ ToscaResourceStructure toscaResourceStructure, VfModule vfModule, IVfModuleData vfModuleData) {
+ VfModuleCustomization vfModuleCustomization = new VfModuleCustomization();
+
+ vfModuleCustomization.setModelCustomizationUUID(vfModuleData.getVfModuleModelCustomizationUUID());
+
+ vfModuleCustomization.setVfModule(vfModule);
+
+ String initialCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT);
+ if (initialCount != null && initialCount.length() > 0) {
+ vfModuleCustomization.setInitialCount(Integer.valueOf(initialCount));
+ }
+
+ vfModuleCustomization.setInitialCount(Integer.valueOf(toscaResourceStructure.getSdcCsarHelper()
+ .getGroupPropertyLeafValue(group, SdcPropertyNames.PROPERTY_NAME_INITIALCOUNT)));
+
+ String availabilityZoneCount = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT);
+ if (availabilityZoneCount != null && availabilityZoneCount.length() > 0) {
+ vfModuleCustomization.setAvailabilityZoneCount(Integer.valueOf(availabilityZoneCount));
+ }
+
+ vfModuleCustomization.setLabel(toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULELABEL));
+
+ String maxInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MAXVFMODULEINSTANCES);
+ if (maxInstances != null && maxInstances.length() > 0) {
+ vfModuleCustomization.setMaxInstances(Integer.valueOf(maxInstances));
+ }
+
+ String minInstances = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_MINVFMODULEINSTANCES);
+ if (minInstances != null && minInstances.length() > 0) {
+ vfModuleCustomization.setMinInstances(Integer.valueOf(minInstances));
+ }
+ return vfModuleCustomization;
+ }
+
+ protected VfModule createVfModule(Group group, ToscaResourceStructure toscaResourceStructure,
+ IVfModuleData vfModuleData, Metadata vfMetadata) {
+ VfModule vfModule = new VfModule();
+ String vfModuleModelUUID = vfModuleData.getVfModuleModelUUID();
+
+ if (vfModuleModelUUID == null) {
+ vfModuleModelUUID = testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID));
+ } else if (vfModuleModelUUID.indexOf('.') > -1) {
+ vfModuleModelUUID = vfModuleModelUUID.substring(0, vfModuleModelUUID.indexOf('.'));
+ }
+
+ vfModule.setModelInvariantUUID(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
+ vfModule.setModelName(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ vfModule.setModelUUID(vfModuleModelUUID);
+ vfModule.setModelVersion(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
+ vfModule.setDescription(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+
+ String vfModuleType = toscaResourceStructure.getSdcCsarHelper().getGroupPropertyLeafValue(group,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULETYPE);
+ if (vfModuleType != null && "Base".equalsIgnoreCase(vfModuleType)) {
+ vfModule.setIsBase(true);
+ } else {
+ vfModule.setIsBase(false);
+ }
+ return vfModule;
+ }
+
+ protected void setHeatInformationForVfModule(ToscaResourceStructure toscaResourceStructure,
+ VfResourceStructure vfResourceStructure, VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ Metadata vfMetadata) {
+
+ Optional<VfModuleStructure> matchingObject = vfResourceStructure.getVfModuleStructure().stream()
+ .filter(vfModuleStruct -> vfModuleStruct.getVfModuleMetadata().getVfModuleModelUUID()
+ .equalsIgnoreCase(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)))
+ .findFirst();
+
+ if (matchingObject.isPresent()) {
+ List<HeatFiles> heatFilesList = new ArrayList<>();
+ List<HeatTemplate> volumeHeatChildTemplates = new ArrayList<HeatTemplate>();
+ List<HeatTemplate> heatChildTemplates = new ArrayList<HeatTemplate>();
+ HeatTemplate parentHeatTemplate = new HeatTemplate();
+ String parentArtifactType = null;
+ Set<String> artifacts = new HashSet<>(matchingObject.get().getVfModuleMetadata().getArtifacts());
+ for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) {
+
+ List<HeatTemplate> childNestedHeatTemplates = new ArrayList<HeatTemplate>();
+
+ if (artifacts.contains(vfModuleArtifact.getArtifactInfo().getArtifactUUID())) {
+ checkVfModuleArtifactType(vfModule, vfModuleCustomization, heatFilesList, vfModuleArtifact,
+ childNestedHeatTemplates, parentHeatTemplate, vfResourceStructure);
+ }
+
+ if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
+ parentArtifactType = identifyParentOfNestedTemplate(matchingObject.get(), vfModuleArtifact);
+
+ if (!childNestedHeatTemplates.isEmpty()) {
+
+ if (parentArtifactType != null
+ && parentArtifactType.equalsIgnoreCase(ASDCConfiguration.HEAT_VOL)) {
+ volumeHeatChildTemplates.add(childNestedHeatTemplates.get(0));
+ } else {
+ heatChildTemplates.add(childNestedHeatTemplates.get(0));
+ }
+ }
+ }
+
+ }
+ if (!heatFilesList.isEmpty()) {
+ vfModule.setHeatFiles(heatFilesList);
+ }
+
+
+ // Set all Child Templates related to HEAT_VOLUME
+ if (!volumeHeatChildTemplates.isEmpty()) {
+ if (vfModule.getVolumeHeatTemplate() != null) {
+ vfModule.getVolumeHeatTemplate().setChildTemplates(volumeHeatChildTemplates);
+ } else {
+ logger.debug("VolumeHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+
+ // Set all Child Templates related to HEAT
+ if (!heatChildTemplates.isEmpty()) {
+ if (vfModule.getModuleHeatTemplate() != null) {
+ vfModule.getModuleHeatTemplate().setChildTemplates(heatChildTemplates);
+ } else {
+ logger.debug("ModuleHeatTemplate not set in setHeatInformationForVfModule()");
+ }
+ }
+ }
+ }
+
+ protected void checkVfModuleArtifactType(VfModule vfModule, VfModuleCustomization vfModuleCustomization,
+ List<HeatFiles> heatFilesList, VfModuleArtifact vfModuleArtifact, List<HeatTemplate> nestedHeatTemplates,
+ HeatTemplate parentHeatTemplate, VfResourceStructure vfResourceStructure) {
+ if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT)) {
+ vfModuleArtifact.incrementDeployedInDB();
+ vfModule.setModuleHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_VOL)) {
+ vfModule.setVolumeHeatTemplate(vfModuleArtifact.getHeatTemplate());
+ VfModuleArtifact volVfModuleArtifact =
+ this.getHeatEnvArtifactFromGeneratedArtifact(vfResourceStructure, vfModuleArtifact);
+ vfModuleCustomization.setVolumeHeatEnv(volVfModuleArtifact.getHeatEnvironment());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ENV)) {
+ if (vfModuleArtifact.getHeatEnvironment().getName().contains("volume")) {
+ vfModuleCustomization.setVolumeHeatEnv(vfModuleArtifact.getHeatEnvironment());
+ } else {
+ vfModuleCustomization.setHeatEnvironment(vfModuleArtifact.getHeatEnvironment());
+ }
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_ARTIFACT)) {
+ heatFilesList.add(vfModuleArtifact.getHeatFiles());
+ vfModuleArtifact.incrementDeployedInDB();
+ } else if (vfModuleArtifact.getArtifactInfo().getArtifactType().equals(ASDCConfiguration.HEAT_NESTED)) {
+ nestedHeatTemplates.add(vfModuleArtifact.getHeatTemplate());
+ vfModuleArtifact.incrementDeployedInDB();
+ }
+ }
+
+ protected VnfResourceCustomization createVnfResource(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ VnfResourceCustomization vnfResourceCustomization = null;
+ if (vnfResourceCustomization == null) {
+ VnfResource vnfResource = findExistingVnfResource(service,
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (vnfResource == null)
+ vnfResource = createVnfResource(vfNodeTemplate);
+
+ vnfResourceCustomization =
+ createVnfResourceCustomization(vfNodeTemplate, toscaResourceStructure, vnfResource);
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResourceCustomization.setService(service);
+ vnfResource.getVnfResourceCustomizations().add(vnfResourceCustomization);
+
+ }
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource findExistingVnfResource(Service service, String modelUUID) {
+ VnfResource vnfResource = null;
+ for (VnfResourceCustomization vnfResourceCustom : service.getVnfCustomizations()) {
+ if (vnfResourceCustom.getVnfResources() != null
+ && vnfResourceCustom.getVnfResources().getModelUUID().equals(modelUUID)) {
+ vnfResource = vnfResourceCustom.getVnfResources();
+ }
+ }
+ if (vnfResource == null)
+ vnfResource = vnfRepo.findResourceByModelUUID(modelUUID);
+
+ return vnfResource;
+ }
+
+ protected VnfResourceCustomization createVnfResourceCustomization(NodeTemplate vfNodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, VnfResource vnfResource) {
+ VnfResourceCustomization vnfResourceCustomization = new VnfResourceCustomization();
+ vnfResourceCustomization.setModelCustomizationUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ vnfResourceCustomization.setModelInstanceName(vfNodeTemplate.getName());
+
+ vnfResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ vnfResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code")));
+ vnfResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ vnfResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ vnfResourceCustomization.setMultiStageDesign(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, MULTI_STAGE_DESIGN));
+
+ vnfResourceCustomization.setBlueprintName(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_NAME)));
+
+ vnfResourceCustomization.setBlueprintVersion(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SDNC_MODEL_VERSION)));
+
+ String skipPostInstConfText = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfNodeTemplate, SKIP_POST_INST_CONF);
+ if (skipPostInstConfText != null) {
+ vnfResourceCustomization.setSkipPostInstConf(Boolean.parseBoolean(skipPostInstConfText));
+ }
+
+ vnfResourceCustomization.setVnfResources(vnfResource);
+ vnfResourceCustomization.setAvailabilityZoneMaxCount(Integer.getInteger(
+ vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_AVAILABILITYZONECOUNT)));
+
+ CapabilityAssignments vnfCustomizationCapability =
+ toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(vfNodeTemplate);
+
+ if (vnfCustomizationCapability != null) {
+ CapabilityAssignment capAssign = vnfCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ vnfResourceCustomization.setMinInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResourceCustomization.setMaxInstances(Integer.getInteger(toscaResourceStructure.getSdcCsarHelper()
+ .getCapabilityPropertyLeafValue(capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+
+ }
+
+ toscaResourceStructure.setCatalogVnfResourceCustomization(vnfResourceCustomization);
+
+ return vnfResourceCustomization;
+ }
+
+ protected VnfResource createVnfResource(NodeTemplate vfNodeTemplate) {
+ VnfResource vnfResource = new VnfResource();
+ vnfResource.setModelInvariantUUID(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ vnfResource.setModelName(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ vnfResource.setModelUUID(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+
+ vnfResource.setModelVersion(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ vnfResource.setDescription(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ vnfResource.setOrchestrationMode(HEAT);
+ vnfResource.setToscaNodeType(testNull(vfNodeTemplate.getType()));
+ vnfResource.setAicVersionMax(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ vnfResource.setAicVersionMin(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ vnfResource.setCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY));
+ vnfResource.setSubCategory(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
+
+ return vnfResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResource(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure, Service service) {
+ AllottedResourceCustomization allottedResourceCustomization =
+ allottedCustomizationRepo.findOneByModelCustomizationUUID(
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+
+ if (allottedResourceCustomization == null) {
+ AllottedResource allottedResource = findExistingAllottedResource(service,
+ nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+
+ if (allottedResource == null)
+ allottedResource = createAR(nodeTemplate);
+
+ toscaResourceStructure.setAllottedResource(allottedResource);
+ allottedResourceCustomization = createAllottedResourceCustomization(nodeTemplate, toscaResourceStructure);
+ allottedResourceCustomization.setAllottedResource(allottedResource);
+ allottedResource.getAllotedResourceCustomization().add(allottedResourceCustomization);
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource findExistingAllottedResource(Service service, String modelUUID) {
+ AllottedResource allottedResource = null;
+ for (AllottedResourceCustomization allottedResourceCustom : service.getAllottedCustomizations()) {
+ if (allottedResourceCustom.getAllottedResource() != null
+ && allottedResourceCustom.getAllottedResource().getModelUUID().equals(modelUUID)) {
+ allottedResource = allottedResourceCustom.getAllottedResource();
+ }
+ }
+ if (allottedResource == null)
+ allottedResource = allottedRepo.findResourceByModelUUID(modelUUID);
+
+ return allottedResource;
+ }
+
+ protected AllottedResourceCustomization createAllottedResourceCustomization(NodeTemplate nodeTemplate,
+ ToscaResourceStructure toscaResourceStructure) {
+ AllottedResourceCustomization allottedResourceCustomization = new AllottedResourceCustomization();
+ allottedResourceCustomization.setModelCustomizationUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ allottedResourceCustomization.setModelInstanceName(nodeTemplate.getName());
+
+
+ allottedResourceCustomization.setNfFunction(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION)));
+ allottedResourceCustomization.setNfNamingCode(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, "nf_naming_code")));
+ allottedResourceCustomization.setNfRole(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE)));
+ allottedResourceCustomization.setNfType(testNull(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE)));
+
+ List<NodeTemplate> vfcNodes = toscaResourceStructure.getSdcCsarHelper()
+ .getVfcListByVf(allottedResourceCustomization.getModelCustomizationUUID());
+
+ if (vfcNodes != null) {
+ for (NodeTemplate vfcNode : vfcNodes) {
+
+ allottedResourceCustomization.setProvidingServiceModelUUID(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_uuid"));
+ allottedResourceCustomization
+ .setProvidingServiceModelInvariantUUID(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_invariant_uuid"));
+ allottedResourceCustomization.setProvidingServiceModelName(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(vfcNode, "providing_service_name"));
+ }
+ }
+
+
+ CapabilityAssignments arCustomizationCapability =
+ toscaResourceStructure.getSdcCsarHelper().getCapabilitiesOf(nodeTemplate);
+
+ if (arCustomizationCapability != null) {
+ CapabilityAssignment capAssign = arCustomizationCapability.getCapabilityByName(SCALABLE);
+
+ if (capAssign != null) {
+ allottedResourceCustomization.setMinInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ allottedResourceCustomization.setMaxInstances(
+ Integer.getInteger(toscaResourceStructure.getSdcCsarHelper().getCapabilityPropertyLeafValue(
+ capAssign, SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ }
+ }
+ return allottedResourceCustomization;
+ }
+
+ protected AllottedResource createAR(NodeTemplate nodeTemplate) {
+ AllottedResource allottedResource = new AllottedResource();
+ allottedResource
+ .setModelUUID(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ allottedResource.setModelInvariantUUID(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ allottedResource
+ .setModelName(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ allottedResource
+ .setModelVersion(testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ allottedResource.setToscaNodeType(testNull(nodeTemplate.getType()));
+ allottedResource.setSubcategory(
+ testNull(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ allottedResource
+ .setDescription(nodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ return allottedResource;
+ }
+
+ protected Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile, String artifactUUID) {
+ // Scan the payload downloadResult and extract the HeatTemplate
+ // parameters
+ YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes());
+ return yamlEditor.getParameterList(artifactUUID);
+ }
+
+ protected String testNull(Object object) {
+
+ if (object == null) {
+ return null;
+ } else if (object.equals("NULL")) {
+ return null;
+ } else if (object instanceof Integer) {
+ return object.toString();
+ } else if (object instanceof String) {
+ return (String) object;
+ } else {
+ return "Type not recognized";
+ }
+ }
+
+ protected static String identifyParentOfNestedTemplate(VfModuleStructure vfModuleStructure,
+ VfModuleArtifact heatNestedArtifact) {
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) != null && vfModuleStructure
+ .getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo().getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0)
+ .getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT;
+ }
+
+ }
+ }
+
+ if (vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL) != null
+ && vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo()
+ .getRelatedArtifacts() != null) {
+ for (IArtifactInfo unknownArtifact : vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL)
+ .get(0).getArtifactInfo().getRelatedArtifacts()) {
+ if (heatNestedArtifact.getArtifactInfo().getArtifactUUID().equals(unknownArtifact.getArtifactUUID())) {
+ return ASDCConfiguration.HEAT_VOL;
+ }
+
+ }
+ }
+
+ // Does not belong to anything
+ return null;
+
+ }
+
+ protected static String createVNFName(VfResourceStructure vfResourceStructure) {
+
+ return vfResourceStructure.getNotification().getServiceName() + "/"
+ + vfResourceStructure.getResourceInstance().getResourceInstanceName();
+ }
+
+ protected static String createVfModuleName(VfModuleStructure vfModuleStructure) {
+
+ return createVNFName(vfModuleStructure.getParentVfResource()) + "::"
+ + vfModuleStructure.getVfModuleMetadata().getVfModuleModelName();
+ }
+
+ protected String getPropertyInput(String propertyName) {
+
+ String inputName = new String();
+
+ if (propertyName != null) {
+ int getInputIndex = propertyName.indexOf("{get_input=");
+ if (getInputIndex > -1) {
+ inputName = propertyName.substring(getInputIndex + 11, propertyName.length() - 1);
+ }
+ }
+
+ return inputName;
+ }
+
+
+ protected static Timestamp getCurrentTimeStamp() {
+
+ return new Timestamp(new Date().getTime());
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java
index 7b769bd532..6ca97c7c67 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImpl.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.tenantIsolation;
import java.net.MalformedURLException;
import java.net.URL;
-
import org.onap.so.client.aai.AAIProperties;
import org.onap.so.client.aai.AAIVersion;
import org.onap.so.spring.SpringContextHelper;
@@ -30,42 +29,42 @@ import org.springframework.context.ApplicationContext;
public class AaiClientPropertiesImpl implements AAIProperties {
- private String aaiEndpoint;
- private String auth;
- private String key;
- private static final String SYSTEM_NAME = "MSO";
-
- public AaiClientPropertiesImpl() {
- ApplicationContext context = SpringContextHelper.getAppContext();
- aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
- this.auth = context.getEnvironment().getProperty("aai.auth");
- this.key = context.getEnvironment().getProperty("mso.msoKey");
- }
+ private String aaiEndpoint;
+ private String auth;
+ private String key;
+ private static final String SYSTEM_NAME = "MSO";
+
+ public AaiClientPropertiesImpl() {
+ ApplicationContext context = SpringContextHelper.getAppContext();
+ aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
+ this.auth = context.getEnvironment().getProperty("aai.auth");
+ this.key = context.getEnvironment().getProperty("mso.msoKey");
+ }
+
+ @Override
+ public URL getEndpoint() throws MalformedURLException {
+ ApplicationContext context = SpringContextHelper.getAppContext();
+ aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
+ return new URL(aaiEndpoint);
+ }
+
+ @Override
+ public String getSystemName() {
+ return SYSTEM_NAME;
+ }
- @Override
- public URL getEndpoint() throws MalformedURLException {
- ApplicationContext context = SpringContextHelper.getAppContext();
- aaiEndpoint = context.getEnvironment().getProperty("mso.aai.endpoint");
- return new URL(aaiEndpoint);
- }
+ @Override
+ public AAIVersion getDefaultVersion() {
+ return AAIVersion.LATEST;
+ }
- @Override
- public String getSystemName() {
- return SYSTEM_NAME;
- }
-
- @Override
- public AAIVersion getDefaultVersion() {
- return AAIVersion.LATEST;
- }
-
- @Override
- public String getAuth() {
- return this.auth;
- }
+ @Override
+ public String getAuth() {
+ return this.auth;
+ }
- @Override
- public String getKey() {
- return this.key;
- }
+ @Override
+ public String getKey() {
+ return this.key;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/DistributionStatus.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/DistributionStatus.java
index d092712a8b..7be29718c0 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/DistributionStatus.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/DistributionStatus.java
@@ -22,8 +22,5 @@ package org.onap.so.asdc.tenantIsolation;
public enum DistributionStatus {
- SUCCESS,
- FAILURE,
- TIMEOUT,
- INCOMPLETE
+ SUCCESS, FAILURE, TIMEOUT, INCOMPLETE
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
index c95d701cb2..3659ceed12 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/tenantIsolation/WatchdogDistribution.java
@@ -25,7 +25,6 @@ package org.onap.so.asdc.tenantIsolation;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.AAIResourcesClient;
import org.onap.so.client.aai.entities.uri.AAIResourceUri;
@@ -47,157 +46,166 @@ import org.springframework.stereotype.Component;
@Component
public class WatchdogDistribution {
- private static final Logger logger = LoggerFactory.getLogger(WatchdogDistribution.class);
-
- private AAIResourcesClient aaiClient;
-
- @Autowired
- private WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
-
- @Autowired
- private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
-
- @Autowired
- private WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
-
- @Autowired
- private ServiceRepository serviceRepo;
-
- @Value("${mso.asdc.config.components.componentNames}")
- private String[] componentNames;
-
- public String getOverallDistributionStatus(String distributionId) throws Exception {
- logger.debug("Entered getOverallDistributionStatus method for distrubutionId: {}", distributionId);
-
- String status = null;
- try {
- WatchdogDistributionStatus watchdogDistributionStatus = watchdogDistributionStatusRepository.findById(distributionId)
- .orElseGet( () -> null);
- if(watchdogDistributionStatus == null){
- watchdogDistributionStatus = new WatchdogDistributionStatus();
- watchdogDistributionStatus.setDistributionId(distributionId);
- watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
- }
- String distributionStatus = watchdogDistributionStatus.getDistributionIdStatus();
-
- if(DistributionStatus.TIMEOUT.name().equalsIgnoreCase(distributionStatus)) {
- logger.debug("Ignoring to update WatchdogDistributionStatus as distributionId: {} status is set to: {}",
- distributionId, distributionStatus);
- return DistributionStatus.TIMEOUT.name();
- } else {
- List<WatchdogComponentDistributionStatus> results = watchdogCDStatusRepository.findByDistributionId(distributionId);
- logger.debug("Executed RequestDB getWatchdogComponentDistributionStatus for distrubutionId: {}",
- distributionId);
-
- //*************************************************************************************************************************************************
- //**** Compare config values verse DB watchdog component names to see if every component has reported status before returning final result back to ASDC
- //**************************************************************************************************************************************************
-
- List<WatchdogComponentDistributionStatus> cdStatuses = watchdogCDStatusRepository.findByDistributionId(distributionId);
-
- boolean allComponentsComplete = true;
-
- for(String name : componentNames ) {
-
- boolean match = false;
-
- for(WatchdogComponentDistributionStatus cdStatus: cdStatuses){
- if(name.equals(cdStatus.getComponentName())){
- logger.debug("Found componentName {} in the WatchDog Component DB", name);
- match = true;
- break;
- }
- }
- if(!match){
- logger.debug("{} has not be updated in the the WatchDog Component DB yet, so ending the loop", name);
- allComponentsComplete = false;
- break;
- }
- }
-
-
- if(allComponentsComplete) {
- logger.debug("Components Size matched with the WatchdogComponentDistributionStatus results.");
-
- for(WatchdogComponentDistributionStatus componentDist : results) {
- String componentDistributionStatus = componentDist.getComponentDistributionStatus();
- logger.debug("Component status: {} on componentName: ", componentDistributionStatus, componentDist
- .getComponentName());
- if(componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_ERROR")) {
- status = DistributionStatus.FAILURE.name();
- break;
- } else if(componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_OK")) {
- status = DistributionStatus.SUCCESS.name();
- } else {
- throw new Exception("Invalid Component distribution status: " + componentDistributionStatus);
- }
- }
-
- logger.debug("Updating overall DistributionStatus to: {} for distributionId: ", status, distributionId);
-
- watchdogDistributionStatus.setDistributionIdStatus(status);
- watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
- } else {
- logger.debug("Components Size Didn't match with the WatchdogComponentDistributionStatus results.");
- status = DistributionStatus.INCOMPLETE.name();
- return status;
- }
- }
- }catch (Exception e) {
- logger.debug("Exception occurred on getOverallDistributionStatus : {}", e.getMessage());
- logger.error("Exception occurred", e);
- throw new Exception(e);
- }
- logger.debug("Exiting getOverallDistributionStatus method in WatchdogDistribution");
- return status;
- }
-
- public void executePatchAAI(String distributionId, String serviceModelInvariantUUID, String distributionStatus) throws Exception {
- logger.debug("Entered executePatchAAI method with distrubutionId: {} and distributionStatus: ", distributionId,
- distributionStatus);
-
- try {
- WatchdogServiceModVerIdLookup lookup = watchdogModVerIdLookupRepository.findOneByDistributionId(distributionId);
- String serviceModelVersionId = "";
-
- if(lookup != null) {
- serviceModelVersionId = lookup.getServiceModelVersionId();
- }
-
- logger.debug("Executed RequestDB getWatchdogServiceModVerIdLookup with distributionId: {} "
- + "and serviceModelVersionId: {}", distributionId, serviceModelVersionId);
- logger.debug("ASDC Notification ServiceModelInvariantUUID : {}", serviceModelInvariantUUID);
-
- if(serviceModelInvariantUUID == null || "".equals(serviceModelVersionId)) {
- String error = "No Service found with serviceModelInvariantUUID: " + serviceModelInvariantUUID;
- logger.debug(error);
- throw new Exception(error);
- }
-
- AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID, serviceModelVersionId);
- aaiUri.depth(Depth.ZERO); //Do not return relationships if any
- logger.debug("Target A&AI Resource URI: {}", aaiUri.build().toString());
-
- Map<String, String> payload = new HashMap<>();
- payload.put("distribution-status", distributionStatus);
- getAaiClient().update(aaiUri, payload);
-
- logger.debug("A&AI UPDATE MODEL Version is success!");
- } catch (Exception e) {
- logger.debug("Exception occurred on executePatchAAI : {}", e.getMessage());
- logger.error("Exception occurred", e);
- throw new Exception(e);
- }
- }
-
- public AAIResourcesClient getAaiClient() {
- if(aaiClient == null) {
- aaiClient = new AAIResourcesClient();
- }
- return aaiClient;
- }
-
- public void setAaiClient(AAIResourcesClient aaiClient) {
- this.aaiClient = aaiClient;
- }
+ private static final Logger logger = LoggerFactory.getLogger(WatchdogDistribution.class);
+
+ private AAIResourcesClient aaiClient;
+
+ @Autowired
+ private WatchdogDistributionStatusRepository watchdogDistributionStatusRepository;
+
+ @Autowired
+ private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+
+ @Autowired
+ private WatchdogServiceModVerIdLookupRepository watchdogModVerIdLookupRepository;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Value("${mso.asdc.config.components.componentNames}")
+ private String[] componentNames;
+
+ public String getOverallDistributionStatus(String distributionId) throws Exception {
+ logger.debug("Entered getOverallDistributionStatus method for distrubutionId: {}", distributionId);
+
+ String status = null;
+ try {
+ WatchdogDistributionStatus watchdogDistributionStatus =
+ watchdogDistributionStatusRepository.findById(distributionId).orElseGet(() -> null);
+ if (watchdogDistributionStatus == null) {
+ watchdogDistributionStatus = new WatchdogDistributionStatus();
+ watchdogDistributionStatus.setDistributionId(distributionId);
+ watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
+ }
+ String distributionStatus = watchdogDistributionStatus.getDistributionIdStatus();
+
+ if (DistributionStatus.TIMEOUT.name().equalsIgnoreCase(distributionStatus)) {
+ logger.debug("Ignoring to update WatchdogDistributionStatus as distributionId: {} status is set to: {}",
+ distributionId, distributionStatus);
+ return DistributionStatus.TIMEOUT.name();
+ } else {
+ List<WatchdogComponentDistributionStatus> results =
+ watchdogCDStatusRepository.findByDistributionId(distributionId);
+ logger.debug("Executed RequestDB getWatchdogComponentDistributionStatus for distrubutionId: {}",
+ distributionId);
+
+ // *************************************************************************************************************************************************
+ // **** Compare config values verse DB watchdog component names to see if every component has reported
+ // status before returning final result back to ASDC
+ // **************************************************************************************************************************************************
+
+ List<WatchdogComponentDistributionStatus> cdStatuses =
+ watchdogCDStatusRepository.findByDistributionId(distributionId);
+
+ boolean allComponentsComplete = true;
+
+ for (String name : componentNames) {
+
+ boolean match = false;
+
+ for (WatchdogComponentDistributionStatus cdStatus : cdStatuses) {
+ if (name.equals(cdStatus.getComponentName())) {
+ logger.debug("Found componentName {} in the WatchDog Component DB", name);
+ match = true;
+ break;
+ }
+ }
+ if (!match) {
+ logger.debug("{} has not be updated in the the WatchDog Component DB yet, so ending the loop",
+ name);
+ allComponentsComplete = false;
+ break;
+ }
+ }
+
+
+ if (allComponentsComplete) {
+ logger.debug("Components Size matched with the WatchdogComponentDistributionStatus results.");
+
+ for (WatchdogComponentDistributionStatus componentDist : results) {
+ String componentDistributionStatus = componentDist.getComponentDistributionStatus();
+ logger.debug("Component status: {} on componentName: ", componentDistributionStatus,
+ componentDist.getComponentName());
+ if (componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_ERROR")) {
+ status = DistributionStatus.FAILURE.name();
+ break;
+ } else if (componentDistributionStatus.equalsIgnoreCase("COMPONENT_DONE_OK")) {
+ status = DistributionStatus.SUCCESS.name();
+ } else {
+ throw new Exception(
+ "Invalid Component distribution status: " + componentDistributionStatus);
+ }
+ }
+
+ logger.debug("Updating overall DistributionStatus to: {} for distributionId: ", status,
+ distributionId);
+
+ watchdogDistributionStatus.setDistributionIdStatus(status);
+ watchdogDistributionStatusRepository.save(watchdogDistributionStatus);
+ } else {
+ logger.debug("Components Size Didn't match with the WatchdogComponentDistributionStatus results.");
+ status = DistributionStatus.INCOMPLETE.name();
+ return status;
+ }
+ }
+ } catch (Exception e) {
+ logger.debug("Exception occurred on getOverallDistributionStatus : {}", e.getMessage());
+ logger.error("Exception occurred", e);
+ throw new Exception(e);
+ }
+ logger.debug("Exiting getOverallDistributionStatus method in WatchdogDistribution");
+ return status;
+ }
+
+ public void executePatchAAI(String distributionId, String serviceModelInvariantUUID, String distributionStatus)
+ throws Exception {
+ logger.debug("Entered executePatchAAI method with distrubutionId: {} and distributionStatus: ", distributionId,
+ distributionStatus);
+
+ try {
+ WatchdogServiceModVerIdLookup lookup =
+ watchdogModVerIdLookupRepository.findOneByDistributionId(distributionId);
+ String serviceModelVersionId = "";
+
+ if (lookup != null) {
+ serviceModelVersionId = lookup.getServiceModelVersionId();
+ }
+
+ logger.debug("Executed RequestDB getWatchdogServiceModVerIdLookup with distributionId: {} "
+ + "and serviceModelVersionId: {}", distributionId, serviceModelVersionId);
+ logger.debug("ASDC Notification ServiceModelInvariantUUID : {}", serviceModelInvariantUUID);
+
+ if (serviceModelInvariantUUID == null || "".equals(serviceModelVersionId)) {
+ String error = "No Service found with serviceModelInvariantUUID: " + serviceModelInvariantUUID;
+ logger.debug(error);
+ throw new Exception(error);
+ }
+
+ AAIResourceUri aaiUri = AAIUriFactory.createResourceUri(AAIObjectType.MODEL_VER, serviceModelInvariantUUID,
+ serviceModelVersionId);
+ aaiUri.depth(Depth.ZERO); // Do not return relationships if any
+ logger.debug("Target A&AI Resource URI: {}", aaiUri.build().toString());
+
+ Map<String, String> payload = new HashMap<>();
+ payload.put("distribution-status", distributionStatus);
+ getAaiClient().update(aaiUri, payload);
+
+ logger.debug("A&AI UPDATE MODEL Version is success!");
+ } catch (Exception e) {
+ logger.debug("Exception occurred on executePatchAAI : {}", e.getMessage());
+ logger.error("Exception occurred", e);
+ throw new Exception(e);
+ }
+ }
+
+ public AAIResourcesClient getAaiClient() {
+ if (aaiClient == null) {
+ aaiClient = new AAIResourcesClient();
+ }
+ return aaiClient;
+ }
+
+ public void setAaiClient(AAIResourcesClient aaiClient) {
+ this.aaiClient = aaiClient;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
index 0d75c56c58..a154734690 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ASDCNotificationLogging.java
@@ -23,7 +23,6 @@ package org.onap.so.asdc.util;
import java.util.List;
import java.util.Map;
-
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
import org.onap.sdc.api.notification.IResourceInstance;
@@ -39,905 +38,974 @@ import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
public class ASDCNotificationLogging {
- public static String dumpASDCNotification(INotificationData asdcNotification) {
-
- if (asdcNotification == null) {
- return "NULL";
- }
- return "ASDC Notification:" + System.lineSeparator() +
- "DistributionID:" + testNull(asdcNotification.getDistributionID()) + System.lineSeparator() +
- "ServiceName:" + testNull(asdcNotification.getServiceName()) + System.lineSeparator() +
- "ServiceVersion:" + testNull(asdcNotification.getServiceVersion()) + System.lineSeparator() +
- "ServiceUUID:" + testNull(asdcNotification.getServiceUUID()) + System.lineSeparator() +
- "ServiceInvariantUUID:" + testNull(asdcNotification.getServiceInvariantUUID()) + System.lineSeparator() +
- "ServiceDescription:" + testNull(asdcNotification.getServiceDescription()) + System.lineSeparator() +
- "Service Artifacts List:" + System.lineSeparator() + testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts())) + System.lineSeparator() +
- "Resource Instances List:" + System.lineSeparator() + testNull(dumpASDCResourcesList(asdcNotification)) + System.lineSeparator();
- }
-
- public static String dumpCSARNotification(INotificationData asdcNotification, ToscaResourceStructure toscaResourceStructure) {
-
- if (asdcNotification == null) {
- return "NULL";
- }
-
-
- StringBuilder buffer = new StringBuilder("CSAR Notification:");
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
-
-
- ISdcCsarHelper csarHelper = toscaResourceStructure.getSdcCsarHelper();
-
-
- buffer.append("Service Level Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Name:");
- buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Model Version:");
- buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Model InvariantUuid:");
- buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Service Type:");
- buffer.append(csarHelper.getServiceMetadata().getValue("serviceType"));
- buffer.append(System.lineSeparator());
- buffer.append("Service Role:");
- buffer.append(csarHelper.getServiceMetadata().getValue("serviceRole"));
- buffer.append(System.lineSeparator());
- buffer.append("WorkLoad Context:");
- buffer.append(asdcNotification.getWorkloadContext());
- buffer.append(System.lineSeparator());
- buffer.append("Environment Context:");
- buffer.append(csarHelper.getServiceMetadata().getValue("environmentContext"));
- buffer.append(System.lineSeparator());
-
-
- List<NodeTemplate> serviceProxyResourceList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
-
- if(serviceProxyResourceList != null){
-
- for (NodeTemplate serviceProxyNodeTemplate : serviceProxyResourceList) {
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Service Proxy Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Model Name:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Service Proxy Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Customization UUID:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Model Instance Name:");
- buffer.append(serviceProxyNodeTemplate.getName());
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(serviceProxyNodeTemplate.getType());
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
-
- }
- }
-
- List<NodeTemplate> configurationNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
-
- if(configurationNodeTemplatesList != null){
- for (NodeTemplate configNodeTemplate : configurationNodeTemplatesList) {
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Configuration Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Name:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(configNodeTemplate.getType());
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Configuration Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Customization UUID:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Model Instance Name:");
- buffer.append(configNodeTemplate.getName());
- buffer.append(System.lineSeparator());
- buffer.append("NFFunction:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- buffer.append(System.lineSeparator());
- buffer.append("NFRole:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- buffer.append(System.lineSeparator());
- buffer.append("NFType:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- buffer.append(System.lineSeparator());
-
- }
- }
-
+ public static String dumpASDCNotification(INotificationData asdcNotification) {
+
+ if (asdcNotification == null) {
+ return "NULL";
+ }
+ return "ASDC Notification:" + System.lineSeparator() + "DistributionID:"
+ + testNull(asdcNotification.getDistributionID()) + System.lineSeparator() + "ServiceName:"
+ + testNull(asdcNotification.getServiceName()) + System.lineSeparator() + "ServiceVersion:"
+ + testNull(asdcNotification.getServiceVersion()) + System.lineSeparator() + "ServiceUUID:"
+ + testNull(asdcNotification.getServiceUUID()) + System.lineSeparator() + "ServiceInvariantUUID:"
+ + testNull(asdcNotification.getServiceInvariantUUID()) + System.lineSeparator() + "ServiceDescription:"
+ + testNull(asdcNotification.getServiceDescription()) + System.lineSeparator()
+ + "Service Artifacts List:" + System.lineSeparator()
+ + testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts())) + System.lineSeparator()
+ + "Resource Instances List:" + System.lineSeparator()
+ + testNull(dumpASDCResourcesList(asdcNotification)) + System.lineSeparator();
+ }
+
+ public static String dumpCSARNotification(INotificationData asdcNotification,
+ ToscaResourceStructure toscaResourceStructure) {
+
+ if (asdcNotification == null) {
+ return "NULL";
+ }
+
+
+ StringBuilder buffer = new StringBuilder("CSAR Notification:");
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+
+
+ ISdcCsarHelper csarHelper = toscaResourceStructure.getSdcCsarHelper();
+
+
+ buffer.append("Service Level Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Name:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(testNull(csarHelper.getServiceMetadata().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Service Type:");
+ buffer.append(csarHelper.getServiceMetadata().getValue("serviceType"));
+ buffer.append(System.lineSeparator());
+ buffer.append("Service Role:");
+ buffer.append(csarHelper.getServiceMetadata().getValue("serviceRole"));
+ buffer.append(System.lineSeparator());
+ buffer.append("WorkLoad Context:");
+ buffer.append(asdcNotification.getWorkloadContext());
+ buffer.append(System.lineSeparator());
+ buffer.append("Environment Context:");
+ buffer.append(csarHelper.getServiceMetadata().getValue("environmentContext"));
+ buffer.append(System.lineSeparator());
+
+
+ List<NodeTemplate> serviceProxyResourceList =
+ toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.SERVICE_PROXY);
+
+ if (serviceProxyResourceList != null) {
+
+ for (NodeTemplate serviceProxyNodeTemplate : serviceProxyResourceList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Service Proxy Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(
+ serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(
+ serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Service Proxy Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Customization UUID:");
+ buffer.append(serviceProxyNodeTemplate.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Instance Name:");
+ buffer.append(serviceProxyNodeTemplate.getName());
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(serviceProxyNodeTemplate.getType());
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(
+ serviceProxyNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+
+ }
+ }
+
+ List<NodeTemplate> configurationNodeTemplatesList =
+ toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CONFIGURATION);
+
+ if (configurationNodeTemplatesList != null) {
+ for (NodeTemplate configNodeTemplate : configurationNodeTemplatesList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Configuration Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Name:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(configNodeTemplate.getType());
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Configuration Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Customization UUID:");
+ buffer.append(
+ configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Instance Name:");
+ buffer.append(configNodeTemplate.getName());
+ buffer.append(System.lineSeparator());
+ buffer.append("NFFunction:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFRole:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFType:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ buffer.append(System.lineSeparator());
+
+ }
+ }
+
List<NodeTemplate> vfNodeTemplatesList = toscaResourceStructure.getSdcCsarHelper().getServiceVfList();
- for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) {
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("VNF Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Model Name:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Type:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)));
- buffer.append(System.lineSeparator());
- buffer.append("Category:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Max Instances:");
- buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
- buffer.append(System.lineSeparator());
- buffer.append("Min Instances:");
- buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES));
- buffer.append(System.lineSeparator());
-
- buffer.append(System.lineSeparator());
- buffer.append("VNF Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Customization UUID:");
- buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("NFFunction:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- buffer.append(System.lineSeparator());
- buffer.append("NFCode:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, "nf_naming_code"));
- buffer.append(System.lineSeparator());
- buffer.append("NFRole:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- buffer.append(System.lineSeparator());
- buffer.append("NFType:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- buffer.append(System.lineSeparator());
- buffer.append("MultiStageDesign:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate, "multi_stage_design"));
- buffer.append(System.lineSeparator());
-
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(vfNodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
-
- if(groupList != null){
- for (Group group : groupList) {
- Metadata instanceMetadata = group.getMetadata();
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("VNFC Instance Group Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Name:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("Type:");
- buffer.append(vfNodeTemplate.getType());
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- }
-
- }
-
-
- List<Group> vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
-
- for(Group group : vfGroups){
-
- Metadata vfMetadata = group.getMetadata();
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("VF Module Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("ModelInvariantUuid:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelName:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelUuid:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelVersion:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
-
- List<NodeTemplate> groupMembers = toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfNodeTemplate, group);
-
- for(NodeTemplate node : groupMembers){
- buffer.append("Member Name:");
- buffer.append(testNull(node.getName()));
- buffer.append(System.lineSeparator());
- }
-
- buffer.append(System.lineSeparator());
- buffer.append("VF Module Customization Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Model Customization UUID:");
- buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata, SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID)));
- buffer.append(System.lineSeparator());
-
- }
-
- List<NodeTemplate> vfConfigList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CONFIGURATION);
-
- if(vfConfigList != null){
- for (NodeTemplate configNodeTemplate : vfConfigList) {
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Fabric Configuration Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Name:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(configNodeTemplate.getType());
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Fabric Configuration Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Customization UUID:");
- buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Model Instance Name:");
- buffer.append(configNodeTemplate.getName());
- buffer.append(System.lineSeparator());
- buffer.append("NFFunction:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- buffer.append(System.lineSeparator());
- buffer.append("NFRole:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- buffer.append(System.lineSeparator());
- buffer.append("NFType:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- buffer.append(System.lineSeparator());
-
- }
- }
-
- List<NodeTemplate> cvfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC);
-
- for(NodeTemplate cvfcTemplate : cvfcList) {
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("CVNFC Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("ModelCustomizationUuid:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelInvariantUuid:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelName:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelUuid:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelVersion:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
- buffer.append("Template Name:");
- buffer.append(testNull(cvfcTemplate.getName()));
- buffer.append(System.lineSeparator());
-
-
- List<NodeTemplate> vfcList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
-
- for(NodeTemplate vfcTemplate : vfcList) {
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("VNFC Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("ModelCustomizationUuid:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelInvariantUuid:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelName:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelUuid:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("ModelVersion:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
- buffer.append("Sub Category:");
- buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
- buffer.append(System.lineSeparator());
-
- }
-
- }
-
- }
-
-
-
- List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList();
-
- if(nodeTemplatesVLList != null){
-
- for(NodeTemplate vlNode : nodeTemplatesVLList){
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("NETWORK Level Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Model Name:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("Model InvariantUuid:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Model Version:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("AIC Max Version:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
- buffer.append(System.lineSeparator());
- buffer.append("AIC Min Version:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
- buffer.append(System.lineSeparator());
-
-
- buffer.append(System.lineSeparator());
- buffer.append("NETWORK Customization Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("CustomizationUUID:");
- buffer.append(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Network Technology:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- buffer.append(System.lineSeparator());
- buffer.append("Network Type:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- buffer.append(System.lineSeparator());
- buffer.append("Network Role:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- buffer.append(System.lineSeparator());
- buffer.append("Network Scope:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- buffer.append(System.lineSeparator());
-
- }
-
- }
-
-
- List<NodeTemplate> networkCollectionList = toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
-
- if (networkCollectionList != null) {
- for (NodeTemplate crNode : networkCollectionList) {
- buffer.append(System.lineSeparator());
- buffer.append("Network Collection Properties:");
- buffer.append(System.lineSeparator());
- buffer.append("Model Name:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(crNode.getType());
- buffer.append(System.lineSeparator());
- buffer.append("CR Function:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_function"));
- buffer.append(System.lineSeparator());
- buffer.append("CR Role:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_role"));
- buffer.append(System.lineSeparator());
- buffer.append("CR Type:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_type"));
- buffer.append(System.lineSeparator());
-
- List<NodeTemplate> vlNodeList = toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(crNode, SdcTypes.VL);
-
- for(NodeTemplate vlNodeTemplate : vlNodeList){
-
- Metadata vlMetadata = vlNodeTemplate.getMetaData();
-
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Network CR VL Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Name:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- buffer.append("AIC Max Version:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
- buffer.append(System.lineSeparator());
- buffer.append("Description:");
- buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
- buffer.append("Tosca Node Type:");
- buffer.append(vlNodeTemplate.getType());
- buffer.append(System.lineSeparator());
-
- }
-
-
- List<Group> groupList = toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(crNode, "org.openecomp.groups.NetworkCollection");
-
- if(groupList != null){
- for (Group group : groupList) {
- Metadata instanceMetadata = group.getMetadata();
- buffer.append(System.lineSeparator());
- buffer.append(System.lineSeparator());
- buffer.append("Network Instance Group Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Name:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
- buffer.append(System.lineSeparator());
- buffer.append("InvariantUuid:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Version:");
- buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
- buffer.append(System.lineSeparator());
- }
-
- }
-
- buffer.append(System.lineSeparator());
- buffer.append("Network Collection Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Customization UUID:");
- buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
- buffer.append(System.lineSeparator());
- buffer.append("Model Instance Name:");
- buffer.append(crNode.getName());
- buffer.append(System.lineSeparator());
- buffer.append("Network Scope:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
- buffer.append(System.lineSeparator());
- buffer.append("Network Role:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
- buffer.append(System.lineSeparator());
- buffer.append("Network Type:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
- buffer.append(System.lineSeparator());
- buffer.append("Network Technology:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
- buffer.append(System.lineSeparator());
-
- }
- }
-
+ for (NodeTemplate vfNodeTemplate : vfNodeTemplatesList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("VNF Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Type:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Category:");
+ buffer.append(testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CATEGORY)));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Max Instances:");
+ buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+ buffer.append(System.lineSeparator());
+ buffer.append("Min Instances:");
+ buffer.append(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES));
+ buffer.append(System.lineSeparator());
+
+ buffer.append(System.lineSeparator());
+ buffer.append("VNF Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Customization UUID:");
+ buffer.append(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFFunction:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFCode:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate,
+ "nf_naming_code"));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFRole:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFType:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ buffer.append(System.lineSeparator());
+ buffer.append("MultiStageDesign:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vfNodeTemplate,
+ "multi_stage_design"));
+ buffer.append(System.lineSeparator());
+
+ List<Group> groupList =
+ toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
+ vfNodeTemplate, "org.openecomp.groups.VfcInstanceGroup");
+
+ if (groupList != null) {
+ for (Group group : groupList) {
+ Metadata instanceMetadata = group.getMetadata();
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("VNFC Instance Group Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Name:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Type:");
+ buffer.append(vfNodeTemplate.getType());
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ }
+
+ }
+
+
+ List<Group> vfGroups = toscaResourceStructure.getSdcCsarHelper().getVfModulesByVf(
+ testNull(vfNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+
+ for (Group group : vfGroups) {
+
+ Metadata vfMetadata = group.getMetadata();
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("VF Module Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelInvariantUuid:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELINVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelName:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELNAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelUuid:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelVersion:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULEMODELVERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+
+ List<NodeTemplate> groupMembers =
+ toscaResourceStructure.getSdcCsarHelper().getMembersOfVfModule(vfNodeTemplate, group);
+
+ for (NodeTemplate node : groupMembers) {
+ buffer.append("Member Name:");
+ buffer.append(testNull(node.getName()));
+ buffer.append(System.lineSeparator());
+ }
+
+ buffer.append(System.lineSeparator());
+ buffer.append("VF Module Customization Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Customization UUID:");
+ buffer.append(testNull(toscaResourceStructure.getSdcCsarHelper().getMetadataPropertyValue(vfMetadata,
+ SdcPropertyNames.PROPERTY_NAME_VFMODULECUSTOMIZATIONUUID)));
+ buffer.append(System.lineSeparator());
+
+ }
+
+ List<NodeTemplate> vfConfigList = toscaResourceStructure.getSdcCsarHelper()
+ .getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CONFIGURATION);
+
+ if (vfConfigList != null) {
+ for (NodeTemplate configNodeTemplate : vfConfigList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Fabric Configuration Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Name:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(
+ configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(
+ configNodeTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(configNodeTemplate.getType());
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Fabric Configuration Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Customization UUID:");
+ buffer.append(configNodeTemplate.getMetaData()
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Instance Name:");
+ buffer.append(configNodeTemplate.getName());
+ buffer.append(System.lineSeparator());
+ buffer.append("NFFunction:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFRole:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFType:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(
+ configNodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ buffer.append(System.lineSeparator());
+
+ }
+ }
+
+ List<NodeTemplate> cvfcList =
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(vfNodeTemplate, SdcTypes.CVFC);
+
+ for (NodeTemplate cvfcTemplate : cvfcList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("CVNFC Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelCustomizationUuid:");
+ buffer.append(testNull(
+ cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelInvariantUuid:");
+ buffer.append(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelName:");
+ buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelUuid:");
+ buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelVersion:");
+ buffer.append(testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(
+ testNull(cvfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Template Name:");
+ buffer.append(testNull(cvfcTemplate.getName()));
+ buffer.append(System.lineSeparator());
+
+
+ List<NodeTemplate> vfcList =
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(cvfcTemplate, SdcTypes.VFC);
+
+ for (NodeTemplate vfcTemplate : vfcList) {
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("VNFC Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelCustomizationUuid:");
+ buffer.append(testNull(
+ vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelInvariantUuid:");
+ buffer.append(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelName:");
+ buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelUuid:");
+ buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("ModelVersion:");
+ buffer.append(testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Sub Category:");
+ buffer.append(
+ testNull(vfcTemplate.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY)));
+ buffer.append(System.lineSeparator());
+
+ }
+
+ }
+
+ }
+
+
+
+ List<NodeTemplate> nodeTemplatesVLList = toscaResourceStructure.getSdcCsarHelper().getServiceVlList();
+
+ if (nodeTemplatesVLList != null) {
+
+ for (NodeTemplate vlNode : nodeTemplatesVLList) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("NETWORK Level Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("AIC Max Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES)));
+ buffer.append(System.lineSeparator());
+ buffer.append("AIC Min Version:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_MININSTANCES)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_TYPE)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(testNull(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION)));
+ buffer.append(System.lineSeparator());
+
+
+ buffer.append(System.lineSeparator());
+ buffer.append("NETWORK Customization Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("CustomizationUUID:");
+ buffer.append(vlNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Technology:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Type:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Role:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Scope:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(vlNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ buffer.append(System.lineSeparator());
+
+ }
+
+ }
+
+
+ List<NodeTemplate> networkCollectionList =
+ toscaResourceStructure.getSdcCsarHelper().getServiceNodeTemplateBySdcType(SdcTypes.CR);
+
+ if (networkCollectionList != null) {
+ for (NodeTemplate crNode : networkCollectionList) {
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Collection Properties:");
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(crNode.getType());
+ buffer.append(System.lineSeparator());
+ buffer.append("CR Function:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode,
+ "cr_function"));
+ buffer.append(System.lineSeparator());
+ buffer.append("CR Role:");
+ buffer.append(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_role"));
+ buffer.append(System.lineSeparator());
+ buffer.append("CR Type:");
+ buffer.append(
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode, "cr_type"));
+ buffer.append(System.lineSeparator());
+
+ List<NodeTemplate> vlNodeList =
+ toscaResourceStructure.getSdcCsarHelper().getNodeTemplateBySdcType(crNode, SdcTypes.VL);
+
+ for (NodeTemplate vlNodeTemplate : vlNodeList) {
+
+ Metadata vlMetadata = vlNodeTemplate.getMetaData();
+
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Network CR VL Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Name:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ buffer.append("AIC Max Version:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_MAXINSTANCES));
+ buffer.append(System.lineSeparator());
+ buffer.append("Description:");
+ buffer.append(vlMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("Tosca Node Type:");
+ buffer.append(vlNodeTemplate.getType());
+ buffer.append(System.lineSeparator());
+
+ }
+
+
+ List<Group> groupList =
+ toscaResourceStructure.getSdcCsarHelper().getGroupsOfOriginOfNodeTemplateByToscaGroupType(
+ crNode, "org.openecomp.groups.NetworkCollection");
+
+ if (groupList != null) {
+ for (Group group : groupList) {
+ Metadata instanceMetadata = group.getMetadata();
+ buffer.append(System.lineSeparator());
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Instance Group Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Name:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_NAME));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_UUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("InvariantUuid:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Version:");
+ buffer.append(instanceMetadata.getValue(SdcPropertyNames.PROPERTY_NAME_VERSION));
+ buffer.append(System.lineSeparator());
+ }
+
+ }
+
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Collection Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Customization UUID:");
+ buffer.append(crNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Instance Name:");
+ buffer.append(crNode.getName());
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Scope:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKSCOPE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Role:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Type:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTYPE));
+ buffer.append(System.lineSeparator());
+ buffer.append("Network Technology:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(crNode,
+ SdcPropertyNames.PROPERTY_NAME_NETWORKTECHNOLOGY));
+ buffer.append(System.lineSeparator());
+
+ }
+ }
+
List<NodeTemplate> allottedResourceList = toscaResourceStructure.getSdcCsarHelper().getAllottedResources();
-
- if(allottedResourceList != null){
-
- buffer.append(System.lineSeparator());
- buffer.append("Allotted Resource Properties:");
- buffer.append(System.lineSeparator());
-
- for(NodeTemplate allottedNode : allottedResourceList){
-
- buffer.append("Model Name:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("Model Name:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
- buffer.append(System.lineSeparator());
- buffer.append("Model InvariantUuid:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Model Version:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
- buffer.append(System.lineSeparator());
- buffer.append("Model UUID:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
- buffer.append(System.lineSeparator());
- buffer.append("Model Subcategory:");
- buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
- buffer.append(System.lineSeparator());
- buffer.append("Model Description:");
- buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
- buffer.append(System.lineSeparator());
-
-
- buffer.append("Allotted Resource Customization Properties:");
- buffer.append(System.lineSeparator());
-
- buffer.append("Model Cutomization UUID:");
- buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
- buffer.append(System.lineSeparator());
- buffer.append("NFFunction:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
- buffer.append(System.lineSeparator());
- buffer.append("NFCode:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, "nf_naming_code"));
- buffer.append(System.lineSeparator());
- buffer.append("NFRole:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, SdcPropertyNames.PROPERTY_NAME_NFROLE));
- buffer.append(System.lineSeparator());
- buffer.append("NFType:");
- buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode, SdcPropertyNames.PROPERTY_NAME_NFTYPE));
- buffer.append(System.lineSeparator());
-
-
- }
- }
-
-
- return buffer.toString();
- }
-
- public static String dumpVfModuleMetaDataList(List<IVfModuleData> moduleMetaDataList) {
- if (moduleMetaDataList == null ) {
- return null;
- }
-
- StringBuilder buffer = new StringBuilder("VfModuleMetaData List:");
- buffer.append(System.lineSeparator());
-
- buffer.append("{");
-
- for (IVfModuleData moduleMetaData:moduleMetaDataList) {
- buffer.append(System.lineSeparator());
- buffer.append(testNull(dumpVfModuleMetaData(moduleMetaData)));
- buffer.append(System.lineSeparator());
- buffer.append(",");
-
- }
- buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
- buffer.append("}");
- buffer.append(System.lineSeparator());
-
- return buffer.toString();
- }
-
- private static String dumpVfModuleMetaData(IVfModuleData moduleMetaData) {
-
- if (moduleMetaData == null ) {
- return "NULL";
- }
-
- StringBuilder stringBuilder = new StringBuilder("VfModuleMetaData:");
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("VfModuleModelName:");
- stringBuilder.append(testNull(moduleMetaData.getVfModuleModelName()));
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("VfModuleModelVersion:");
- stringBuilder.append(testNull(moduleMetaData.getVfModuleModelVersion()));
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("VfModuleModelUUID:");
- stringBuilder.append(testNull(moduleMetaData.getVfModuleModelUUID()));
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("VfModuleModelInvariantUUID:");
- stringBuilder.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID()));
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("VfModuleModelDescription:");
- stringBuilder.append(testNull(moduleMetaData.getVfModuleModelDescription()));
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("Artifacts UUID List:");
-
- if (moduleMetaData.getArtifacts() != null) {
- stringBuilder.append("{");
-
- for (String artifactUUID:moduleMetaData.getArtifacts()) {
- stringBuilder.append(System.lineSeparator());
- stringBuilder.append(testNull(artifactUUID));
- stringBuilder.append(System.lineSeparator());
- stringBuilder.append(",");
- }
- stringBuilder.replace(stringBuilder.length()-1,stringBuilder.length(), System.lineSeparator());
- stringBuilder.append("}");
- stringBuilder.append(System.lineSeparator());
- } else {
- stringBuilder.append("NULL");
- }
-
- if (moduleMetaData.getProperties() != null) {
- Map<String, String> vfModuleMap = moduleMetaData.getProperties();
- stringBuilder.append("Properties List:");
- stringBuilder.append("{");
-
- for (Map.Entry<String, String> entry : vfModuleMap.entrySet()) {
- stringBuilder.append(System.lineSeparator());
- stringBuilder.append(" ").append(entry.getKey()).append(" : ").append(entry.getValue());
- }
- stringBuilder.replace(stringBuilder.length()-1,stringBuilder.length(), System.lineSeparator());
- stringBuilder.append("}");
- stringBuilder.append(System.lineSeparator());
- } else {
- stringBuilder.append("NULL");
- }
-
-
- stringBuilder.append(System.lineSeparator());
-
- stringBuilder.append("isBase:");
- stringBuilder.append(moduleMetaData.isBase());
- stringBuilder.append(System.lineSeparator());
-
- return stringBuilder.toString();
- }
-
- private static String testNull(Object object) {
- if (object == null) {
- return "NULL";
- } else if (object instanceof Integer) {
- return object.toString();
- } else if (object instanceof String) {
- return (String)object;
- } else {
- return "Type not recognized";
- }
- }
-
- private static String dumpASDCResourcesList(INotificationData asdcNotification) {
- if (asdcNotification == null || asdcNotification.getResources() == null) {
- return null;
- }
-
- StringBuilder buffer = new StringBuilder();
- buffer.append("{");
-
- for (IResourceInstance resourceInstanceElem:asdcNotification.getResources()) {
- buffer.append(System.lineSeparator());
- buffer.append(testNull(dumpASDCResourceInstance(resourceInstanceElem)));
- buffer.append(System.lineSeparator());
- buffer.append(",");
- }
- buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
- buffer.append("}");
- buffer.append(System.lineSeparator());
-
- return buffer.toString();
-
- }
-
- private static String dumpASDCResourceInstance(IResourceInstance resourceInstance) {
-
- if (resourceInstance == null) {
- return null;
- }
-
- return "Resource Instance Info:" + System.lineSeparator() +
- "ResourceInstanceName:" + testNull(resourceInstance.getResourceInstanceName()) + System.lineSeparator() +
- "ResourceCustomizationUUID:" + testNull(resourceInstance.getResourceCustomizationUUID()) + System.lineSeparator() +
- "ResourceInvariantUUID:" + testNull(resourceInstance.getResourceInvariantUUID()) + System.lineSeparator() +
- "ResourceName:" + testNull(resourceInstance.getResourceName()) + System.lineSeparator() +
- "ResourceType:" + testNull(resourceInstance.getResourceType()) + System.lineSeparator() +
- "ResourceUUID:" + testNull(resourceInstance.getResourceUUID()) + System.lineSeparator() +
- "ResourceVersion:" + testNull(resourceInstance.getResourceVersion()) + System.lineSeparator() +
- "Category:" + testNull(resourceInstance.getCategory()) + System.lineSeparator() +
- "SubCategory:" + testNull(resourceInstance.getSubcategory()) + System.lineSeparator() +
- "Resource Artifacts List:" + System.lineSeparator() + testNull(dumpArtifactInfoList(resourceInstance.getArtifacts())) + System.lineSeparator();
- }
-
-
- private static String dumpArtifactInfoList(List<IArtifactInfo> artifactsList) {
-
- if (artifactsList == null || artifactsList.isEmpty()) {
- return null;
- }
-
- StringBuilder buffer = new StringBuilder();
- buffer.append("{");
- for (IArtifactInfo artifactInfoElem:artifactsList) {
- buffer.append(System.lineSeparator());
- buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
- buffer.append(System.lineSeparator());
- buffer.append(",");
-
- }
- buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
- buffer.append("}");
- buffer.append(System.lineSeparator());
-
- return buffer.toString();
- }
-
- private static String dumpASDCArtifactInfo(IArtifactInfo artifactInfo) {
-
- if (artifactInfo == null) {
- return null;
- }
-
- StringBuilder buffer = new StringBuilder("Service Artifacts Info:");
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactName:");
- buffer.append(testNull(artifactInfo.getArtifactName()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactVersion:");
- buffer.append(testNull(artifactInfo.getArtifactVersion()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactType:");
- buffer.append(testNull(artifactInfo.getArtifactType()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactDescription:");
- buffer.append(testNull(artifactInfo.getArtifactDescription()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactTimeout:");
- buffer.append(testNull(artifactInfo.getArtifactTimeout()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactURL:");
- buffer.append(testNull(artifactInfo.getArtifactURL()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactUUID:");
- buffer.append(testNull(artifactInfo.getArtifactUUID()));
- buffer.append(System.lineSeparator());
-
- buffer.append("ArtifactChecksum:");
- buffer.append(testNull(artifactInfo.getArtifactChecksum()));
- buffer.append(System.lineSeparator());
-
- buffer.append("GeneratedArtifact:");
- buffer.append("{");
- buffer.append(testNull(dumpASDCArtifactInfo(artifactInfo.getGeneratedArtifact())));
- buffer.append(System.lineSeparator());
- buffer.append("}");
- buffer.append(System.lineSeparator());
-
- buffer.append("RelatedArtifacts:");
+ if (allottedResourceList != null) {
+
+ buffer.append(System.lineSeparator());
+ buffer.append("Allotted Resource Properties:");
+ buffer.append(System.lineSeparator());
+
+ for (NodeTemplate allottedNode : allottedResourceList) {
+
+ buffer.append("Model Name:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Name:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_NAME)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model InvariantUuid:");
+ buffer.append(
+ testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Version:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_VERSION)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model UUID:");
+ buffer.append(testNull(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_UUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Subcategory:");
+ buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_SUBCATEGORY));
+ buffer.append(System.lineSeparator());
+ buffer.append("Model Description:");
+ buffer.append(allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION));
+ buffer.append(System.lineSeparator());
+
+
+ buffer.append("Allotted Resource Customization Properties:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("Model Cutomization UUID:");
+ buffer.append(testNull(
+ allottedNode.getMetaData().getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID)));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFFunction:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode,
+ SdcPropertyNames.PROPERTY_NAME_NFFUNCTION));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFCode:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode,
+ "nf_naming_code"));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFRole:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode,
+ SdcPropertyNames.PROPERTY_NAME_NFROLE));
+ buffer.append(System.lineSeparator());
+ buffer.append("NFType:");
+ buffer.append(toscaResourceStructure.getSdcCsarHelper().getNodeTemplatePropertyLeafValue(allottedNode,
+ SdcPropertyNames.PROPERTY_NAME_NFTYPE));
+ buffer.append(System.lineSeparator());
+
+
+ }
+ }
+
+
+ return buffer.toString();
+ }
+
+ public static String dumpVfModuleMetaDataList(List<IVfModuleData> moduleMetaDataList) {
+ if (moduleMetaDataList == null) {
+ return null;
+ }
+
+ StringBuilder buffer = new StringBuilder("VfModuleMetaData List:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("{");
+
+ for (IVfModuleData moduleMetaData : moduleMetaDataList) {
+ buffer.append(System.lineSeparator());
+ buffer.append(testNull(dumpVfModuleMetaData(moduleMetaData)));
+ buffer.append(System.lineSeparator());
+ buffer.append(",");
+
+ }
+ buffer.replace(buffer.length() - 1, buffer.length(), System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+
+ return buffer.toString();
+ }
+
+ private static String dumpVfModuleMetaData(IVfModuleData moduleMetaData) {
+
+ if (moduleMetaData == null) {
+ return "NULL";
+ }
+
+ StringBuilder stringBuilder = new StringBuilder("VfModuleMetaData:");
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("VfModuleModelName:");
+ stringBuilder.append(testNull(moduleMetaData.getVfModuleModelName()));
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("VfModuleModelVersion:");
+ stringBuilder.append(testNull(moduleMetaData.getVfModuleModelVersion()));
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("VfModuleModelUUID:");
+ stringBuilder.append(testNull(moduleMetaData.getVfModuleModelUUID()));
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("VfModuleModelInvariantUUID:");
+ stringBuilder.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID()));
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("VfModuleModelDescription:");
+ stringBuilder.append(testNull(moduleMetaData.getVfModuleModelDescription()));
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("Artifacts UUID List:");
+
+ if (moduleMetaData.getArtifacts() != null) {
+ stringBuilder.append("{");
+
+ for (String artifactUUID : moduleMetaData.getArtifacts()) {
+ stringBuilder.append(System.lineSeparator());
+ stringBuilder.append(testNull(artifactUUID));
+ stringBuilder.append(System.lineSeparator());
+ stringBuilder.append(",");
+ }
+ stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), System.lineSeparator());
+ stringBuilder.append("}");
+ stringBuilder.append(System.lineSeparator());
+ } else {
+ stringBuilder.append("NULL");
+ }
+
+ if (moduleMetaData.getProperties() != null) {
+ Map<String, String> vfModuleMap = moduleMetaData.getProperties();
+ stringBuilder.append("Properties List:");
+ stringBuilder.append("{");
+
+ for (Map.Entry<String, String> entry : vfModuleMap.entrySet()) {
+ stringBuilder.append(System.lineSeparator());
+ stringBuilder.append(" ").append(entry.getKey()).append(" : ").append(entry.getValue());
+ }
+ stringBuilder.replace(stringBuilder.length() - 1, stringBuilder.length(), System.lineSeparator());
+ stringBuilder.append("}");
+ stringBuilder.append(System.lineSeparator());
+ } else {
+ stringBuilder.append("NULL");
+ }
+
+
+ stringBuilder.append(System.lineSeparator());
+
+ stringBuilder.append("isBase:");
+ stringBuilder.append(moduleMetaData.isBase());
+ stringBuilder.append(System.lineSeparator());
+
+ return stringBuilder.toString();
+ }
+
+ private static String testNull(Object object) {
+ if (object == null) {
+ return "NULL";
+ } else if (object instanceof Integer) {
+ return object.toString();
+ } else if (object instanceof String) {
+ return (String) object;
+ } else {
+ return "Type not recognized";
+ }
+ }
+
+ private static String dumpASDCResourcesList(INotificationData asdcNotification) {
+ if (asdcNotification == null || asdcNotification.getResources() == null) {
+ return null;
+ }
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("{");
+
+ for (IResourceInstance resourceInstanceElem : asdcNotification.getResources()) {
+ buffer.append(System.lineSeparator());
+ buffer.append(testNull(dumpASDCResourceInstance(resourceInstanceElem)));
+ buffer.append(System.lineSeparator());
+ buffer.append(",");
+ }
+ buffer.replace(buffer.length() - 1, buffer.length(), System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+
+ return buffer.toString();
+
+ }
+
+ private static String dumpASDCResourceInstance(IResourceInstance resourceInstance) {
+
+ if (resourceInstance == null) {
+ return null;
+ }
+
+ return "Resource Instance Info:" + System.lineSeparator() + "ResourceInstanceName:"
+ + testNull(resourceInstance.getResourceInstanceName()) + System.lineSeparator()
+ + "ResourceCustomizationUUID:" + testNull(resourceInstance.getResourceCustomizationUUID())
+ + System.lineSeparator() + "ResourceInvariantUUID:"
+ + testNull(resourceInstance.getResourceInvariantUUID()) + System.lineSeparator() + "ResourceName:"
+ + testNull(resourceInstance.getResourceName()) + System.lineSeparator() + "ResourceType:"
+ + testNull(resourceInstance.getResourceType()) + System.lineSeparator() + "ResourceUUID:"
+ + testNull(resourceInstance.getResourceUUID()) + System.lineSeparator() + "ResourceVersion:"
+ + testNull(resourceInstance.getResourceVersion()) + System.lineSeparator() + "Category:"
+ + testNull(resourceInstance.getCategory()) + System.lineSeparator() + "SubCategory:"
+ + testNull(resourceInstance.getSubcategory()) + System.lineSeparator() + "Resource Artifacts List:"
+ + System.lineSeparator() + testNull(dumpArtifactInfoList(resourceInstance.getArtifacts()))
+ + System.lineSeparator();
+ }
+
+
+ private static String dumpArtifactInfoList(List<IArtifactInfo> artifactsList) {
+
+ if (artifactsList == null || artifactsList.isEmpty()) {
+ return null;
+ }
+
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("{");
+ for (IArtifactInfo artifactInfoElem : artifactsList) {
+ buffer.append(System.lineSeparator());
+ buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
+ buffer.append(System.lineSeparator());
+ buffer.append(",");
+
+ }
+ buffer.replace(buffer.length() - 1, buffer.length(), System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+
+ return buffer.toString();
+ }
+
+ private static String dumpASDCArtifactInfo(IArtifactInfo artifactInfo) {
+
+ if (artifactInfo == null) {
+ return null;
+ }
+
+ StringBuilder buffer = new StringBuilder("Service Artifacts Info:");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactName:");
+ buffer.append(testNull(artifactInfo.getArtifactName()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactVersion:");
+ buffer.append(testNull(artifactInfo.getArtifactVersion()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactType:");
+ buffer.append(testNull(artifactInfo.getArtifactType()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactDescription:");
+ buffer.append(testNull(artifactInfo.getArtifactDescription()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactTimeout:");
+ buffer.append(testNull(artifactInfo.getArtifactTimeout()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactURL:");
+ buffer.append(testNull(artifactInfo.getArtifactURL()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactUUID:");
+ buffer.append(testNull(artifactInfo.getArtifactUUID()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("ArtifactChecksum:");
+ buffer.append(testNull(artifactInfo.getArtifactChecksum()));
+ buffer.append(System.lineSeparator());
+
+ buffer.append("GeneratedArtifact:");
+ buffer.append("{");
+ buffer.append(testNull(dumpASDCArtifactInfo(artifactInfo.getGeneratedArtifact())));
+ buffer.append(System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+
+ buffer.append("RelatedArtifacts:");
- if (artifactInfo.getRelatedArtifacts() != null) {
- buffer.append("{");
- buffer.append(System.lineSeparator());
- for (IArtifactInfo artifactInfoElem:artifactInfo.getRelatedArtifacts()) {
- buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
- buffer.append(System.lineSeparator());
- buffer.append(",");
-
- }
- buffer.replace(buffer.length()-1,buffer.length(), System.lineSeparator());
- buffer.append("}");
- buffer.append(System.lineSeparator());
- } else {
- buffer.append("NULL");
- }
-
- buffer.append(System.lineSeparator());
+ if (artifactInfo.getRelatedArtifacts() != null) {
+ buffer.append("{");
+ buffer.append(System.lineSeparator());
+ for (IArtifactInfo artifactInfoElem : artifactInfo.getRelatedArtifacts()) {
+
+ buffer.append(testNull(dumpASDCArtifactInfo(artifactInfoElem)));
+ buffer.append(System.lineSeparator());
+ buffer.append(",");
+
+ }
+ buffer.replace(buffer.length() - 1, buffer.length(), System.lineSeparator());
+ buffer.append("}");
+ buffer.append(System.lineSeparator());
+ } else {
+ buffer.append("NULL");
+ }
+
+ buffer.append(System.lineSeparator());
- return buffer.toString();
- }
+ return buffer.toString();
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/NotificationLogging.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/NotificationLogging.java
index fae1da374a..d2e5b07a07 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/NotificationLogging.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/NotificationLogging.java
@@ -35,138 +35,133 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.onap.sdc.api.notification.INotificationData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class NotificationLogging implements InvocationHandler {
-
- private static Map<Object, List<Method>> objectMethodsToLog = new HashMap<>();
-
- protected static final Logger logger = LoggerFactory.getLogger(NotificationLogging.class);
-
- private static InvocationHandler handler = (arg0, arg1, arg2) -> {
- List<Method> methods = objectMethodsToLog.get(arg0);
- if ((methods == null) || (methods.isEmpty())) {
- // Do nothing for now...
- return null;
- }
- methods.add(arg1);
- return arg1.invoke(arg0, arg2);
- };
-
- public static InvocationHandler getHandler() {
- return handler;
- }
-
- /**
- *
- */
- private NotificationLogging() {}
-
- private static final String[] GETTER_PREFIXES = { "get", "is" };
-
- public static String logNotification(INotificationData iNotif) {
- if (iNotif == null) {
- return "NULL";
- }
-
- Class<? extends INotificationData> clazz = iNotif.getClass();
-
- Method[] declaredMethods = clazz.getDeclaredMethods();
-
- if (declaredMethods == null || declaredMethods.length == 0) {
- return "EMPTY"; // No declared methods in this class !!!
- }
-
- StringBuilder buffer = new StringBuilder("ASDC Notification:");
- buffer.append(System.lineSeparator());
-
- for (Method m : declaredMethods) {
- if ((m != null) && isGetter(m)) {
- for (String prefix : GETTER_PREFIXES) {
- if (m.getName().startsWith(prefix)) {
- buffer.append(m.getName().substring(prefix.length()));
- break;
- }
- }
- try {
- buffer.append(testNull(m.invoke(iNotif, (Object[])null)));
- } catch (IllegalAccessException | IllegalArgumentException
- | InvocationTargetException e) {
- logger.debug("Exception", e);
- buffer.append("UNREADABLE");
- }
- buffer.append(System.lineSeparator());
- }
- }
-
- return buffer.toString();
- }
-
- private static boolean isGetter(Method method) {
-
- // Must start with a valid (and known) prefix
- boolean prefixFound = false;
- for (String prefix : GETTER_PREFIXES) {
- if (method.getName().startsWith(prefix)) {
- prefixFound = true;
- break;
- }
- }
- if (!prefixFound) {
- return false;
- }
-
- // Must not take any input arguments
- if (method.getParameterTypes().length != 0) {
- return false;
- }
-
- // Must not have return type 'void'
- if (void.class.equals(method.getReturnType())) {
- return false;
- }
-
- // Must be public
- if (!Modifier.isPublic(method.getModifiers())) {
- return false;
- }
-
- return true;
- }
-
- private static String testNull(Object object) {
- if (object == null) {
- return "NULL";
- } else if (object instanceof Integer) {
- return object.toString();
- } else if (object instanceof String) {
- return (String) object;
- } else {
- return "Type not recognized";
- }
- }
-
- private static void registerForLog(INotificationData objectToLog) {
- INotificationData proxy = (INotificationData) Proxy.newProxyInstance(
- INotificationData.class.getClassLoader(),
- new Class[] { INotificationData.class },
- NotificationLogging.getHandler());
- objectMethodsToLog.put(proxy, new ArrayList<>());
- }
-
- private static <T> void methodToLog(T methodCall) {
- //
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args)
- throws Throwable {
- // TODO Auto-generated method stub
- return null;
- }
+
+ private static Map<Object, List<Method>> objectMethodsToLog = new HashMap<>();
+
+ protected static final Logger logger = LoggerFactory.getLogger(NotificationLogging.class);
+
+ private static InvocationHandler handler = (arg0, arg1, arg2) -> {
+ List<Method> methods = objectMethodsToLog.get(arg0);
+ if ((methods == null) || (methods.isEmpty())) {
+ // Do nothing for now...
+ return null;
+ }
+ methods.add(arg1);
+ return arg1.invoke(arg0, arg2);
+ };
+
+ public static InvocationHandler getHandler() {
+ return handler;
+ }
+
+ /**
+ *
+ */
+ private NotificationLogging() {}
+
+ private static final String[] GETTER_PREFIXES = {"get", "is"};
+
+ public static String logNotification(INotificationData iNotif) {
+ if (iNotif == null) {
+ return "NULL";
+ }
+
+ Class<? extends INotificationData> clazz = iNotif.getClass();
+
+ Method[] declaredMethods = clazz.getDeclaredMethods();
+
+ if (declaredMethods == null || declaredMethods.length == 0) {
+ return "EMPTY"; // No declared methods in this class !!!
+ }
+
+ StringBuilder buffer = new StringBuilder("ASDC Notification:");
+ buffer.append(System.lineSeparator());
+
+ for (Method m : declaredMethods) {
+ if ((m != null) && isGetter(m)) {
+ for (String prefix : GETTER_PREFIXES) {
+ if (m.getName().startsWith(prefix)) {
+ buffer.append(m.getName().substring(prefix.length()));
+ break;
+ }
+ }
+ try {
+ buffer.append(testNull(m.invoke(iNotif, (Object[]) null)));
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
+ logger.debug("Exception", e);
+ buffer.append("UNREADABLE");
+ }
+ buffer.append(System.lineSeparator());
+ }
+ }
+
+ return buffer.toString();
+ }
+
+ private static boolean isGetter(Method method) {
+
+ // Must start with a valid (and known) prefix
+ boolean prefixFound = false;
+ for (String prefix : GETTER_PREFIXES) {
+ if (method.getName().startsWith(prefix)) {
+ prefixFound = true;
+ break;
+ }
+ }
+ if (!prefixFound) {
+ return false;
+ }
+
+ // Must not take any input arguments
+ if (method.getParameterTypes().length != 0) {
+ return false;
+ }
+
+ // Must not have return type 'void'
+ if (void.class.equals(method.getReturnType())) {
+ return false;
+ }
+
+ // Must be public
+ if (!Modifier.isPublic(method.getModifiers())) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private static String testNull(Object object) {
+ if (object == null) {
+ return "NULL";
+ } else if (object instanceof Integer) {
+ return object.toString();
+ } else if (object instanceof String) {
+ return (String) object;
+ } else {
+ return "Type not recognized";
+ }
+ }
+
+ private static void registerForLog(INotificationData objectToLog) {
+ INotificationData proxy = (INotificationData) Proxy.newProxyInstance(INotificationData.class.getClassLoader(),
+ new Class[] {INotificationData.class}, NotificationLogging.getHandler());
+ objectMethodsToLog.put(proxy, new ArrayList<>());
+ }
+
+ private static <T> void methodToLog(T methodCall) {
+ //
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/ToLog.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/ToLog.java
index 1f67b9cd91..b69158d426 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/ToLog.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/ToLog.java
@@ -23,7 +23,6 @@ package org.onap.so.asdc.util;
-
public @interface ToLog {
}
diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
index 3418ee3295..acafaacd11 100644
--- a/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
+++ b/asdc-controller/src/main/java/org/onap/so/asdc/util/YamlEditor.java
@@ -32,76 +32,74 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-
import org.yaml.snakeyaml.Yaml;
-
import org.onap.so.db.catalog.beans.HeatTemplateParam;
public class YamlEditor {
protected static final String REFER_PATTERN = "file:///";
- protected Map <String, Object> yml;
- protected Yaml yaml = new Yaml ();
+ protected Map<String, Object> yml;
+ protected Yaml yaml = new Yaml();
- public YamlEditor () {
+ public YamlEditor() {
}
- public YamlEditor (byte[] body) {
- init (body);
+ public YamlEditor(byte[] body) {
+ init(body);
}
-
- public YamlEditor (Yaml yaml) {
- this.yaml = yaml;
+
+ public YamlEditor(Yaml yaml) {
+ this.yaml = yaml;
}
@SuppressWarnings("unchecked")
- protected synchronized void init (byte[] body) {
- InputStream input = new ByteArrayInputStream (body);
- yml = (Map <String, Object>) yaml.load (input);
+ protected synchronized void init(byte[] body) {
+ InputStream input = new ByteArrayInputStream(body);
+ yml = (Map<String, Object>) yaml.load(input);
}
- public synchronized List <String> getYamlNestedFileResourceTypeList () {
- List <String> typeList = new ArrayList<>();
+ public synchronized List<String> getYamlNestedFileResourceTypeList() {
+ List<String> typeList = new ArrayList<>();
@SuppressWarnings("unchecked")
- Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("resources");
- Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator ();
- while (it.hasNext ()) {
- Map.Entry <String, Object> pair = it.next ();
+ Map<String, Object> resourceMap = (Map<String, Object>) yml.get("resources");
+ Iterator<Entry<String, Object>> it = resourceMap.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry<String, Object> pair = it.next();
@SuppressWarnings("unchecked")
- Map <String, String> resourceEntry = (Map <String, String>) pair.getValue ();
- String type = resourceEntry.get ("type");
+ Map<String, String> resourceEntry = (Map<String, String>) pair.getValue();
+ String type = resourceEntry.get("type");
- if (type.contains (REFER_PATTERN)) {
- typeList.add (type);
+ if (type.contains(REFER_PATTERN)) {
+ typeList.add(type);
}
- it.remove (); // avoids a ConcurrentModificationException
+ it.remove(); // avoids a ConcurrentModificationException
}
return typeList;
}
-
- public synchronized List <String> getYamlResourceTypeList () {
- List <String> typeList = new ArrayList<>();
+
+ public synchronized List<String> getYamlResourceTypeList() {
+ List<String> typeList = new ArrayList<>();
@SuppressWarnings("unchecked")
- Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("resources");
+ Map<String, Object> resourceMap = (Map<String, Object>) yml.get("resources");
for (Entry<String, Object> pair : resourceMap.entrySet()) {
@SuppressWarnings("unchecked")
Map<String, String> resourceEntry = (Map<String, String>) pair.getValue();
typeList.add(resourceEntry.get("type"));
}
return typeList;
- }
+ }
// Generate the parameter list based on the Heat Template
// Based on the email from Ella Kvetny:
// Within Heat Template, under parameters catalog, it might indicate the default value of the parameter
// If default value exist, the parameter is not mandatory, otherwise its value should be set
- public synchronized Set <HeatTemplateParam> getParameterList (String artifactUUID) {
- Set <HeatTemplateParam> paramSet = new HashSet<>();
+ public synchronized Set<HeatTemplateParam> getParameterList(String artifactUUID) {
+ Set<HeatTemplateParam> paramSet = new HashSet<>();
@SuppressWarnings("unchecked")
- Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters");
+ Map<String, Object> resourceMap = (Map<String, Object>) yml.get("parameters");
for (Entry<String, Object> stringObjectEntry : resourceMap.entrySet()) {
HeatTemplateParam param = new HeatTemplateParam();
@@ -129,42 +127,42 @@ public class YamlEditor {
}
- public synchronized void addParameterList (Set <HeatTemplateParam> heatSet) {
+ public synchronized void addParameterList(Set<HeatTemplateParam> heatSet) {
@SuppressWarnings("unchecked")
- Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters");
+ Map<String, Object> resourceMap = (Map<String, Object>) yml.get("parameters");
if (resourceMap == null) {
resourceMap = new LinkedHashMap<>();
- this.yml.put ("parameters", resourceMap);
+ this.yml.put("parameters", resourceMap);
}
for (HeatTemplateParam heatParam : heatSet) {
- Map <String, Object> paramInfo = new HashMap<>();
- paramInfo.put ("type", heatParam.getParamType ());
+ Map<String, Object> paramInfo = new HashMap<>();
+ paramInfo.put("type", heatParam.getParamType());
- resourceMap.put (heatParam.getParamName (), paramInfo);
+ resourceMap.put(heatParam.getParamName(), paramInfo);
}
// this.yml.put("parameters", resourceMap);
}
- public boolean isParentTemplate (String templateBody) {
- return templateBody.contains (REFER_PATTERN);
+ public boolean isParentTemplate(String templateBody) {
+ return templateBody.contains(REFER_PATTERN);
}
- public boolean verifyTemplate () {
+ public boolean verifyTemplate() {
// Verify whether the heat template is for Vnf Resource
// We don't support other template installation yet
return true;
}
- public String encode (Map <String, Object> content) {
- return yaml.dump (content);
+ public String encode(Map<String, Object> content) {
+ return yaml.dump(content);
}
- public synchronized String encode () {
- return this.yaml.dump (this.yml);
+ public synchronized String encode() {
+ return this.yaml.dump(this.yml);
}
/**
@@ -172,9 +170,9 @@ public class YamlEditor {
*
*/
@Override
- public String toString () {
+ public String toString() {
- return encode ();
+ return encode();
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
index 354b6dac3c..dc51d46888 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/ASDCPojoTest.java
@@ -29,7 +29,6 @@ import org.onap.so.asdc.client.test.emulators.JsonVfModuleMetaData;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
import org.onap.so.asdc.client.test.emulators.ResourceInfoImpl;
import org.onap.so.asdc.installer.VfResourceStructure;
-
import com.openpojo.reflection.PojoClass;
import com.openpojo.reflection.impl.PojoClassFactory;
import com.openpojo.validation.Validator;
@@ -38,23 +37,20 @@ import com.openpojo.validation.test.impl.GetterTester;
import com.openpojo.validation.test.impl.SetterTester;
public class ASDCPojoTest {
- @Test
- public void pojoStructure() {
- test(PojoClassFactory.getPojoClass(FinalDistributionStatusMessage.class));
- test(PojoClassFactory.getPojoClass(ArtifactInfoImpl.class));
- test(PojoClassFactory.getPojoClass(NotificationDataImpl.class));
- test(PojoClassFactory.getPojoClass(JsonVfModuleMetaData.class));
- test(PojoClassFactory.getPojoClass(ResourceInfoImpl.class));
- test(PojoClassFactory.getPojoClass(DistributionClientEmulator.class));
- test(PojoClassFactory.getPojoClass(JsonStatusData.class));
- test(PojoClassFactory.getPojoClass(VfResourceStructure.class));
- }
-
- private void test(PojoClass pojoClass) {
- Validator validator = ValidatorBuilder.create()
- .with(new SetterTester())
- .with(new GetterTester())
- .build();
- validator.validate(pojoClass);
- }
+ @Test
+ public void pojoStructure() {
+ test(PojoClassFactory.getPojoClass(FinalDistributionStatusMessage.class));
+ test(PojoClassFactory.getPojoClass(ArtifactInfoImpl.class));
+ test(PojoClassFactory.getPojoClass(NotificationDataImpl.class));
+ test(PojoClassFactory.getPojoClass(JsonVfModuleMetaData.class));
+ test(PojoClassFactory.getPojoClass(ResourceInfoImpl.class));
+ test(PojoClassFactory.getPojoClass(DistributionClientEmulator.class));
+ test(PojoClassFactory.getPojoClass(JsonStatusData.class));
+ test(PojoClassFactory.getPojoClass(VfResourceStructure.class));
+ }
+
+ private void test(PojoClass pojoClass) {
+ Validator validator = ValidatorBuilder.create().with(new SetterTester()).with(new GetterTester()).build();
+ validator.validate(pojoClass);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
index a100f26d5a..fb8e5bbc2f 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/AllTestsTestSuite.java
@@ -19,14 +19,14 @@
*/
package org.onap.so.asdc;
-import org.junit.runner.RunWith;
+import org.junit.runner.RunWith;
import com.googlecode.junittoolbox.SuiteClasses;
import com.googlecode.junittoolbox.WildcardPatternSuite;
@RunWith(WildcardPatternSuite.class)
@SuiteClasses("**/*Test.class")
public class AllTestsTestSuite {
- // the class remains empty,
- // used only as a holder for the above annotations
+ // the class remains empty,
+ // used only as a holder for the above annotations
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
index 83d60aefea..0fcf9b0559 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/BaseTest.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc;
import static org.mockito.Mockito.reset;
-
import org.junit.After;
import org.junit.runner.RunWith;
import org.onap.so.asdc.installer.ToscaResourceStructure;
@@ -39,7 +38,6 @@ import org.springframework.cloud.contract.wiremock.AutoConfigureWireMock;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
-
import com.github.tomakehurst.wiremock.WireMockServer;
@RunWith(SpringRunner.class)
@@ -48,23 +46,23 @@ import com.github.tomakehurst.wiremock.WireMockServer;
@ContextConfiguration(classes = SpringContextHelper.class, initializers = ConfigFileApplicationContextInitializer.class)
@AutoConfigureWireMock(port = 0)
public abstract class BaseTest {
- @MockBean
- protected VfResourceStructure vfResourceStructure;
- @MockBean
- protected ToscaResourceStructure toscaResourceStruct;
- @SpyBean
- protected WatchdogDistribution watchdogDistributionSpy;
- @SpyBean
- protected ToscaResourceInstaller toscaInstaller;
- @Autowired
- protected WireMockServer wireMockServer;
-
- @Value("${wiremock.server.port}")
+ @MockBean
+ protected VfResourceStructure vfResourceStructure;
+ @MockBean
+ protected ToscaResourceStructure toscaResourceStruct;
+ @SpyBean
+ protected WatchdogDistribution watchdogDistributionSpy;
+ @SpyBean
+ protected ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ protected WireMockServer wireMockServer;
+
+ @Value("${wiremock.server.port}")
protected String wireMockPort;
- @After
- public void after() {
- reset(vfResourceStructure);
- reset(toscaResourceStruct);
- }
+ @After
+ public void after() {
+ reset(vfResourceStructure);
+ reset(toscaResourceStruct);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
index 27b6c0ab53..e81a318e68 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedCatalogDbConfig.java
@@ -19,10 +19,10 @@
*/
package org.onap.so.asdc;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -36,17 +36,14 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@Profile({"test"})
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "entityManagerFactory",
- basePackages = {"org.onap.so.db.catalog.data.repository"}
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "entityManagerFactory",
+ basePackages = {"org.onap.so.db.catalog.data.repository"})
public class EmbeddedCatalogDbConfig {
@Bean
@@ -54,49 +51,36 @@ public class EmbeddedCatalogDbConfig {
return new MariaDB4jSpringService();
}
- @Primary
- @Bean(name = "dataSource")
+ @Primary
+ @Bean(name = "dataSource")
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
-
- @Primary
- @Bean(name = "entityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("dataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.catalog.beans")
- .persistenceUnit("catalogDB")
- .build();
- }
- @Primary
- @Bean(name = "transactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("entityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Primary
+ @Bean(name = "entityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("dataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.catalog.beans").persistenceUnit("catalogDB")
+ .build();
+ }
+
+ @Primary
+ @Bean(name = "transactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("entityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
index 2827f8721e..e60b8fe238 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/EmbeddedRequestDbConfig.java
@@ -19,10 +19,10 @@
*/
package org.onap.so.asdc;
+
import ch.vorburger.exec.ManagedProcessException;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;
import ch.vorburger.mariadb4j.springframework.MariaDB4jSpringService;
-
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
@@ -37,17 +37,14 @@ import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
-
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@Profile({"test"})
@EnableTransactionManagement
-@EnableJpaRepositories(
- entityManagerFactoryRef = "requestEntityManagerFactory",transactionManagerRef = "requestTransactionManager",
- basePackages = { "org.onap.so.db.request.data.repository" }
- )
+@EnableJpaRepositories(entityManagerFactoryRef = "requestEntityManagerFactory",
+ transactionManagerRef = "requestTransactionManager", basePackages = {"org.onap.so.db.request.data.repository"})
public class EmbeddedRequestDbConfig {
@Bean
@@ -56,47 +53,34 @@ public class EmbeddedRequestDbConfig {
}
- @Bean(name = "requestDataSource")
- @ConfigurationProperties(prefix = "request.datasource")
+ @Bean(name = "requestDataSource")
+ @ConfigurationProperties(prefix = "request.datasource")
DataSource dataSource(MariaDB4jSpringService mariaDB4jSpringService,
- @Value("${mariaDB4j.databaseName2}") String databaseName,
- @Value("${spring.datasource.username}") String datasourceUsername,
- @Value("${spring.datasource.password}") String datasourcePassword,
- @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
- //Create our database with default root user and no password
+ @Value("${mariaDB4j.databaseName2}") String databaseName,
+ @Value("${spring.datasource.username}") String datasourceUsername,
+ @Value("${spring.datasource.password}") String datasourcePassword,
+ @Value("${spring.datasource.driver-class-name}") String datasourceDriver) throws ManagedProcessException {
+ // Create our database with default root user and no password
mariaDB4jSpringService.getDB().createDB(databaseName);
DBConfigurationBuilder config = mariaDB4jSpringService.getConfiguration();
- return DataSourceBuilder
- .create()
- .username(datasourceUsername)
- .password(datasourcePassword)
- .url(config.getURL(databaseName))
- .driverClassName(datasourceDriver)
- .build();
+ return DataSourceBuilder.create().username(datasourceUsername).password(datasourcePassword)
+ .url(config.getURL(databaseName)).driverClassName(datasourceDriver).build();
}
- @Bean(name = "requestEntityManagerFactory")
- public LocalContainerEntityManagerFactoryBean
- entityManagerFactory(
- EntityManagerFactoryBuilder builder,
- @Qualifier("requestDataSource") DataSource dataSource
- ) {
- return builder
- .dataSource(dataSource)
- .packages("org.onap.so.db.request.beans")
- .persistenceUnit("requestDB")
- .build();
- }
+ @Bean(name = "requestEntityManagerFactory")
+ public LocalContainerEntityManagerFactoryBean entityManagerFactory(EntityManagerFactoryBuilder builder,
+ @Qualifier("requestDataSource") DataSource dataSource) {
+ return builder.dataSource(dataSource).packages("org.onap.so.db.request.beans").persistenceUnit("requestDB")
+ .build();
+ }
- @Bean(name = "requestTransactionManager")
- public PlatformTransactionManager transactionManager(
- @Qualifier("requestEntityManagerFactory") EntityManagerFactory
- entityManagerFactory
- ) {
- return new JpaTransactionManager(entityManagerFactory);
- }
+ @Bean(name = "requestTransactionManager")
+ public PlatformTransactionManager transactionManager(
+ @Qualifier("requestEntityManagerFactory") EntityManagerFactory entityManagerFactory) {
+ return new JpaTransactionManager(entityManagerFactory);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
index 4298f9c5b5..c35e8e34d6 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/TestApplication.java
@@ -31,15 +31,15 @@ import org.springframework.context.annotation.Profile;
@SpringBootApplication
@Profile("test")
-@ComponentScan(basePackages = {"org.onap.so.asdc"}, excludeFilters = {
- @Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
- @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class) })
+@ComponentScan(basePackages = {"org.onap.so.asdc"},
+ excludeFilters = {@Filter(type = FilterType.ANNOTATION, classes = SpringBootApplication.class),
+ @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = RequestsDBHelper.class),
+ @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = InfraActiveRequestsRepositoryImpl.class)})
public class TestApplication {
- public static void main(String... args) {
- SpringApplication.run(TestApplication.class, args);
- System.getProperties().setProperty("mso.db", "MARIADB");
- System.getProperties().setProperty("server.name", "Springboot");
- System.getProperties().setProperty("mso.config.path", "src/test/resources/");
- }
+ public static void main(String... args) {
+ SpringApplication.run(TestApplication.class, args);
+ System.getProperties().setProperty("mso.db", "MARIADB");
+ System.getProperties().setProperty("server.name", "Springboot");
+ System.getProperties().setProperty("mso.config.path", "src/test/resources/");
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
index 16bd97b409..40c403fd72 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCConfigurationTest.java
@@ -23,9 +23,7 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.assertTrue;
-
import javax.transaction.Transactional;
-
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
@@ -36,24 +34,24 @@ import org.springframework.beans.factory.annotation.Autowired;
*
*/
public class ASDCConfigurationTest extends BaseTest {
-
+
@Autowired
private ASDCConfiguration config;
-
+
@Test
- @Transactional
- public void testInitASDCConfiguration() throws Exception {
- assertTrue("msopreist".equals(config.getUser()));
- assertTrue("msoasdc-id-local".equals(config.getConsumerGroup()));
- assertTrue("msoasdc-id-local".equals(config.getConsumerID()));
- assertTrue("Pre-IST".equals(config.getEnvironmentName()));
- assertTrue("localhost:8443".equals(config.getAsdcAddress()));
- assertTrue("msopreist".equals(config.getPassword()));
- assertTrue(config.getPollingInterval() == 30);
- assertTrue(config.getPollingTimeout() == 30);
- assertTrue(config.getRelevantArtifactTypes().size() == config.SUPPORTED_ARTIFACT_TYPES_LIST.size());
- assertTrue(config.getWatchDogTimeout() == 1);
- assertTrue(config.isUseHttpsWithDmaap() == true);
+ @Transactional
+ public void testInitASDCConfiguration() throws Exception {
+ assertTrue("msopreist".equals(config.getUser()));
+ assertTrue("msoasdc-id-local".equals(config.getConsumerGroup()));
+ assertTrue("msoasdc-id-local".equals(config.getConsumerID()));
+ assertTrue("Pre-IST".equals(config.getEnvironmentName()));
+ assertTrue("localhost:8443".equals(config.getAsdcAddress()));
+ assertTrue("msopreist".equals(config.getPassword()));
+ assertTrue(config.getPollingInterval() == 30);
+ assertTrue(config.getPollingTimeout() == 30);
+ assertTrue(config.getRelevantArtifactTypes().size() == config.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+ assertTrue(config.getWatchDogTimeout() == 1);
+ assertTrue(config.isUseHttpsWithDmaap() == true);
}
-
+
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
index 51559c2ffe..0681cd8aed 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerITTest.java
@@ -1,20 +1,15 @@
/*
- * ============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
+ * ============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.
+ * 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=========================================================
+ * SPDX-License-Identifier: Apache-2.0 ============LICENSE_END=========================================================
*/
package org.onap.so.asdc.client;
@@ -26,15 +21,12 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.fail;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
-
import javax.persistence.EntityNotFoundException;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
@@ -120,7 +112,7 @@ public class ASDCControllerITTest extends BaseTest {
distributionId = UUID.randomUUID().toString();
artifactUuid = UUID.randomUUID().toString();
logger.info("Using distributionId: {}, artifactUUID: {} for testcase: {}", distributionId, artifactUuid,
- testName.getMethodName());
+ testName.getMethodName());
distributionClient = new DistributionClientEmulator();
distributionClient.setResourcePath("src/test/resources");
@@ -148,7 +140,7 @@ public class ASDCControllerITTest extends BaseTest {
*/
private void initMockAaiServer(final String serviceUuid, final String serviceInvariantUuid) {
String modelEndpoint = "/aai/v15/service-design-and-creation/models/model/" + serviceInvariantUuid
- + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
+ + "/model-vers/model-ver/" + serviceUuid + "?depth=0";
wireMockServer.stubFor(post(urlEqualTo(modelEndpoint)).willReturn(ok()));
}
@@ -191,7 +183,7 @@ public class ASDCControllerITTest extends BaseTest {
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
- .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Testservice140-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
@@ -200,17 +192,18 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("toscar csar URL", "/download/service-Testservice140-csar.csar", toscaCsar.getUrl());
/**
- * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ * Check the service entity, it should be the same as global metadata information in
+ * service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid)
- .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", "efaea486-561f-4159-9191-a8d3cb346728", service.getModelUUID());
assertEquals("model name", "TestService140", service.getModelName());
assertEquals("model invariantUUID", "f2edfbf4-bb0a-4fe7-a57a-71362d4b0b23",
- service.getModelInvariantUUID());
+ service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
assertEquals("description", "Test Service for extended attributes of PNF resource",
- service.getDescription().trim());
+ service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "Network", service.getServiceType());
assertEquals("service role", "nfv", service.getServiceRole());
@@ -220,18 +213,17 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource order", "Test140PNF", service.getResourceOrder());
/**
- * Check PNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Test140pnf-template.yml
+ * Check PNF resource, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
*/
String pnfResourceKey = "9c54e269-122b-4e8a-8b2a-6eac849b441a";
PnfResource pnfResource = pnfResourceRepository.findById(pnfResourceKey)
- .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("PNF resource:" + pnfResourceKey + " not found"));
assertNull("orchestration mode", pnfResource.getOrchestrationMode());
assertEquals("Description", "Oracle", pnfResource.getDescription().trim());
assertEquals("model UUID", pnfResourceKey, pnfResource.getModelUUID());
assertEquals("model invariant UUID", "d832a027-75f3-455d-9de4-f02fcdee7e7e",
- pnfResource.getModelInvariantUUID());
+ pnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", pnfResource.getModelVersion());
assertEquals("model name", "Test140PNF", pnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.pnf.Test140pnf", pnfResource.getToscaNodeType());
@@ -239,15 +231,13 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource sub category", "Call Control", pnfResource.getSubCategory());
/**
- * Check PNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Test140pnf-template.yml
+ * Check PNF resource customization, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Test140pnf-template.yml
*/
String pnfCustomizationKey = "428a3d73-f962-4cc2-ba62-2483c45d6b12";
- PnfResourceCustomization pnfCustomization = pnfCustomizationRepository
- .findById(pnfCustomizationKey).orElseThrow(
- () -> new EntityNotFoundException(
- "PNF resource customization: " + pnfCustomizationKey + " not found"));
+ PnfResourceCustomization pnfCustomization = pnfCustomizationRepository.findById(pnfCustomizationKey)
+ .orElseThrow(() -> new EntityNotFoundException(
+ "PNF resource customization: " + pnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", pnfCustomizationKey, pnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "Test140PNF 0", pnfCustomization.getModelInstanceName());
assertEquals("NF type", "", pnfCustomization.getNfType());
@@ -258,9 +248,9 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("Multi stage design", "", pnfCustomization.getMultiStageDesign());
assertNull("resource input", pnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", pnfCustomization.getBlueprintName(),
- pnfCustomization.getBlueprintName());
+ pnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", pnfCustomization.getBlueprintVersion(),
- pnfCustomization.getBlueprintVersion());
+ pnfCustomization.getBlueprintVersion());
/**
* Check the pnf resource customization with service mapping
@@ -272,8 +262,8 @@ public class ASDCControllerITTest extends BaseTest {
/**
* Check the watchdog for component distribution status
*/
- List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository
- .findByDistributionId(this.distributionId);
+ List<WatchdogComponentDistributionStatus> distributionList =
+ watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
@@ -353,7 +343,7 @@ public class ASDCControllerITTest extends BaseTest {
* Check the tosca csar entity, it should be the same as provided from NotficationData.
*/
ToscaCsar toscaCsar = toscaCsarRepository.findById(artifactUuid)
- .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Tosca csar: " + artifactUuid + " not found"));
assertEquals("tosca csar UUID", artifactUuid, toscaCsar.getArtifactUUID());
assertEquals("tosca csar name", "service-Svc140-VF-csar.csar", toscaCsar.getName());
assertEquals("tosca csar version", "1.0", toscaCsar.getVersion());
@@ -362,17 +352,16 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("toscar csar URL", "/download/service-Svc140-VF-csar.csar", toscaCsar.getUrl());
/**
- * Check the service entity, it should be the same as global metadata information in service-Testservice140-template.yml inside csar.
+ * Check the service entity, it should be the same as global metadata information in
+ * service-Testservice140-template.yml inside csar.
*/
Service service = serviceRepository.findById(serviceUuid)
- .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("Service: " + serviceUuid + " not found"));
assertEquals("model UUID", serviceUuid, service.getModelUUID());
assertEquals("model name", "SVC140", service.getModelName());
- assertEquals("model invariantUUID", serviceInvariantUuid,
- service.getModelInvariantUUID());
+ assertEquals("model invariantUUID", serviceInvariantUuid, service.getModelInvariantUUID());
assertEquals("model version", "1.0", service.getModelVersion());
- assertEquals("description", "SVC140",
- service.getDescription().trim());
+ assertEquals("description", "SVC140", service.getDescription().trim());
assertEquals("tosca csar artifact UUID", artifactUuid, service.getCsar().getArtifactUUID());
assertEquals("service type", "ST", service.getServiceType());
assertEquals("service role", "Sr", service.getServiceRole());
@@ -382,18 +371,17 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource order", "TestVF140", service.getResourceOrder());
/**
- * Check VNF resource, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Testservice140-template.yml
+ * Check VNF resource, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfResourceKey = "d20d3ea9-2f54-4071-8b5c-fd746dde245e";
VnfResource vnfResource = vnfResourceRepository.findById(vnfResourceKey)
- .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
+ .orElseThrow(() -> new EntityNotFoundException("VNF resource:" + vnfResourceKey + " not found"));
assertEquals("orchestration mode", "HEAT", vnfResource.getOrchestrationMode());
assertEquals("Description", "TestPNF140", vnfResource.getDescription().trim());
assertEquals("model UUID", vnfResourceKey, vnfResource.getModelUUID());
assertEquals("model invariant UUID", "7a4bffa2-fac5-4b8b-b348-0bdf313a1aeb",
- vnfResource.getModelInvariantUUID());
+ vnfResource.getModelInvariantUUID());
assertEquals("model version", "1.0", vnfResource.getModelVersion());
assertEquals("model name", "TestVF140", vnfResource.getModelName());
assertEquals("tosca node type", "org.openecomp.resource.vf.Testvf140", vnfResource.getToscaNodeType());
@@ -401,15 +389,14 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("resource sub category", "Database", vnfResource.getSubCategory());
/**
- * Check VNF resource customization, it should be the same as metadata in the topology template in service-Testservice140-template.yml
- * OR
- * global metadata in the resource-Testservice140-template.yml
+ * Check VNF resource customization, it should be the same as metadata in the topology template in
+ * service-Testservice140-template.yml OR global metadata in the resource-Testservice140-template.yml
*/
String vnfCustomizationKey = "ca1c8455-8ce2-4a76-a037-3f4cf01cffa0";
- VnfResourceCustomization vnfCustomization = Optional.ofNullable(vnfCustomizationRepository
- .findOneByModelCustomizationUUID(vnfCustomizationKey)).orElseThrow(
- () -> new EntityNotFoundException(
- "VNF resource customization: " + vnfCustomizationKey + " not found"));
+ VnfResourceCustomization vnfCustomization =
+ Optional.ofNullable(vnfCustomizationRepository.findOneByModelCustomizationUUID(vnfCustomizationKey))
+ .orElseThrow(() -> new EntityNotFoundException(
+ "VNF resource customization: " + vnfCustomizationKey + " not found"));
assertEquals("model customizationUUID", vnfCustomizationKey, vnfCustomization.getModelCustomizationUUID());
assertEquals("model instance name", "TestVF140 0", vnfCustomization.getModelInstanceName());
assertNull("NF type", vnfCustomization.getNfType());
@@ -420,9 +407,9 @@ public class ASDCControllerITTest extends BaseTest {
assertEquals("Multi stage design", "false", vnfCustomization.getMultiStageDesign());
assertNull("resource input", vnfCustomization.getResourceInput());
assertEquals("cds blueprint name(sdnc_model_name property)", vnfCustomization.getBlueprintName(),
- vnfCustomization.getBlueprintName());
+ vnfCustomization.getBlueprintName());
assertEquals("cds blueprint version(sdnc_model_version property)", vnfCustomization.getBlueprintVersion(),
- vnfCustomization.getBlueprintVersion());
+ vnfCustomization.getBlueprintVersion());
/**
* Check the vnf resource customization with service mapping
*/
@@ -433,8 +420,8 @@ public class ASDCControllerITTest extends BaseTest {
/**
* Check the watchdog for component distribution status
*/
- List<WatchdogComponentDistributionStatus> distributionList = watchdogCDStatusRepository
- .findByDistributionId(this.distributionId);
+ List<WatchdogComponentDistributionStatus> distributionList =
+ watchdogCDStatusRepository.findByDistributionId(this.distributionId);
assertNotNull(distributionList);
assertEquals(1, distributionList.size());
WatchdogComponentDistributionStatus distributionStatus = distributionList.get(0);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
index 580220aabb..104eed7c90 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCControllerTest.java
@@ -28,21 +28,21 @@ import org.onap.so.asdc.client.exceptions.ASDCControllerException;
import org.springframework.beans.factory.annotation.Autowired;
public class ASDCControllerTest extends BaseTest {
- @Autowired
- private ASDCController asdcController;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void initASDCExceptionTest() throws Exception {
- expectedException.expect(ASDCControllerException.class);
-
- asdcController.changeControllerStatus(ASDCControllerStatus.IDLE);
-
- try {
- asdcController.initASDC();
- } finally {
- asdcController.closeASDC();
- }
- }
+ @Autowired
+ private ASDCController asdcController;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void initASDCExceptionTest() throws Exception {
+ expectedException.expect(ASDCControllerException.class);
+
+ asdcController.changeControllerStatus(ASDCControllerStatus.IDLE);
+
+ try {
+ asdcController.initASDC();
+ } finally {
+ asdcController.closeASDC();
+ }
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
index fec3ae6362..6196691807 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCElementInfoTest.java
@@ -27,10 +27,8 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-
import java.util.Collections;
import java.util.UUID;
-
import org.junit.Test;
import org.mockito.Mockito;
import org.onap.sdc.api.notification.IArtifactInfo;
@@ -46,129 +44,132 @@ import org.onap.so.asdc.installer.IVfModuleData;
public class ASDCElementInfoTest {
- @Test
- public void createASDCElementInfoWithNullParameterTest() {
- ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);
- ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);
- ASDCElementInfo elementInfoFromNullVfResourceStructure = ASDCElementInfo.createElementFromVfResourceStructure(null);
+ @Test
+ public void createASDCElementInfoWithNullParameterTest() {
+ ASDCElementInfo elementInfoFromNullVfArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(null);
+ ASDCElementInfo elementInfoFromNullVfModuleStructure = ASDCElementInfo.createElementFromVfModuleStructure(null);
+ ASDCElementInfo elementInfoFromNullVfResourceStructure =
+ ASDCElementInfo.createElementFromVfResourceStructure(null);
- elementInfoFromNullVfArtifact.addElementInfo(null, null);
- elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");
- elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);
+ elementInfoFromNullVfArtifact.addElementInfo(null, null);
+ elementInfoFromNullVfModuleStructure.addElementInfo(null, "someValue");
+ elementInfoFromNullVfResourceStructure.addElementInfo("someKey", null);
- assertEquals(elementInfoFromNullVfArtifact.toString(), "");
- assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
- assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
+ assertEquals(elementInfoFromNullVfArtifact.toString(), "");
+ assertEquals(elementInfoFromNullVfModuleStructure.toString(), "");
+ assertEquals(elementInfoFromNullVfResourceStructure.toString(), "");
- assertNotNull(elementInfoFromNullVfArtifact);
- assertNotNull(elementInfoFromNullVfModuleStructure);
- assertNotNull(elementInfoFromNullVfResourceStructure);
+ assertNotNull(elementInfoFromNullVfArtifact);
+ assertNotNull(elementInfoFromNullVfModuleStructure);
+ assertNotNull(elementInfoFromNullVfResourceStructure);
- assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
+ assertNotNull(ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(elementInfoFromNullVfResourceStructure, ASDCElementInfo.EMPTY_INSTANCE);
+ assertEquals(elementInfoFromNullVfArtifact, ASDCElementInfo.EMPTY_INSTANCE);
+ assertEquals(elementInfoFromNullVfModuleStructure, ASDCElementInfo.EMPTY_INSTANCE);
+ assertEquals(elementInfoFromNullVfResourceStructure, ASDCElementInfo.EMPTY_INSTANCE);
- assertEquals(ASDCElementInfo.EMPTY_INSTANCE.getType(), "");
- assertEquals(ASDCElementInfo.EMPTY_INSTANCE.toString(), "");
+ assertEquals(ASDCElementInfo.EMPTY_INSTANCE.getType(), "");
+ assertEquals(ASDCElementInfo.EMPTY_INSTANCE.toString(), "");
- assertEquals(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
- assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
- assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
- }
+ assertEquals(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType());
+ }
- @Test
- public void createASDCElementInfoFromVfResourceTest() {
+ @Test
+ public void createASDCElementInfoFromVfResourceTest() {
- String resourceInstanceName = "Resource 1";
+ String resourceInstanceName = "Resource 1";
- UUID generatedUUID = UUID.randomUUID();
+ UUID generatedUUID = UUID.randomUUID();
- INotificationData notificationData = Mockito.mock(INotificationData.class);
- IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+ INotificationData notificationData = Mockito.mock(INotificationData.class);
+ IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
- Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
- Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
- VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
- ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
+ ASDCElementInfo elementInfoFromVfResource =
+ ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure);
- assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));
- assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));
+ assertTrue(elementInfoFromVfResource.toString().contains(resourceInstanceName));
+ assertTrue(elementInfoFromVfResource.toString().contains(generatedUUID.toString()));
- assertFalse(ASDCConfiguration.VF_MODULES_METADATA.equals(elementInfoFromVfResource.getType()));
- assertEquals(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name(), elementInfoFromVfResource.getType());
+ assertFalse(ASDCConfiguration.VF_MODULES_METADATA.equals(elementInfoFromVfResource.getType()));
+ assertEquals(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name(), elementInfoFromVfResource.getType());
- assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
- elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");
- assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
- }
+ assertFalse(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue");
+ assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue"));
+ }
- @Test
- public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
+ @Test
+ public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException {
- String resourceInstanceName = "Resource 1";
+ String resourceInstanceName = "Resource 1";
- UUID generatedUUID = UUID.randomUUID();
+ UUID generatedUUID = UUID.randomUUID();
- INotificationData notificationData = Mockito.mock(INotificationData.class);
- IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
+ INotificationData notificationData = Mockito.mock(INotificationData.class);
+ IResourceInstance resourceInstance = Mockito.mock(IResourceInstance.class);
- Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
- Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
+ Mockito.when(resourceInstance.getResourceInstanceName()).thenReturn(resourceInstanceName);
+ Mockito.when(resourceInstance.getResourceInvariantUUID()).thenReturn(generatedUUID.toString());
- VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
+ VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance);
- // Create module structure now
+ // Create module structure now
- String vfModuleModelName = "Module Model XYZ";
+ String vfModuleModelName = "Module Model XYZ";
- UUID generatedUUIDForModule = UUID.randomUUID();
+ UUID generatedUUIDForModule = UUID.randomUUID();
- IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
- Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
- Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
- Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String> emptyList());
+ IVfModuleData moduleMetadata = Mockito.mock(IVfModuleData.class);
+ Mockito.when(moduleMetadata.getVfModuleModelName()).thenReturn(vfModuleModelName);
+ Mockito.when(moduleMetadata.getVfModuleModelInvariantUUID()).thenReturn(generatedUUIDForModule.toString());
+ Mockito.when(moduleMetadata.getArtifacts()).thenReturn(Collections.<String>emptyList());
- VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
+ VfModuleStructure vfModuleStructure = new VfModuleStructure(vfResourceStructure, moduleMetadata);
- ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
+ ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure);
- assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
- assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
+ assertTrue(elementInfoFromVfModule.toString().contains(vfModuleModelName));
+ assertTrue(elementInfoFromVfModule.toString().contains(generatedUUIDForModule.toString()));
- assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
- assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
+ assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromVfModule.getType()));
+ assertEquals(ASDCConfiguration.VF_MODULES_METADATA, elementInfoFromVfModule.getType());
- assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
- elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
- assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
- }
+ assertFalse(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
+ elementInfoFromVfModule.addElementInfo("MyInfo2", "someValue");
+ assertTrue(elementInfoFromVfModule.toString().contains("MyInfo2: someValue"));
+ }
- @Test
- public void createASDCElementInfoFromArtifact() {
- for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {
- String generatedArtifactName = eVal + " 1";
- UUID generatedUUIDForArtifact = UUID.randomUUID();
+ @Test
+ public void createASDCElementInfoFromArtifact() {
+ for (String eVal : ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST) {
+ String generatedArtifactName = eVal + " 1";
+ UUID generatedUUIDForArtifact = UUID.randomUUID();
- IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);
- Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);
- Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);
- Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());
+ IArtifactInfo artifactInfo = Mockito.mock(IArtifactInfo.class);
+ Mockito.when(artifactInfo.getArtifactType()).thenReturn(eVal);
+ Mockito.when(artifactInfo.getArtifactName()).thenReturn(generatedArtifactName);
+ Mockito.when(artifactInfo.getArtifactUUID()).thenReturn(generatedUUIDForArtifact.toString());
- ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
+ ASDCElementInfo elementInfoFromArtifact = ASDCElementInfo.createElementFromVfArtifactInfo(artifactInfo);
- assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
- assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
+ assertTrue(elementInfoFromArtifact.toString().contains(generatedArtifactName));
+ assertTrue(elementInfoFromArtifact.toString().contains(generatedUUIDForArtifact.toString()));
- assertFalse(ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));
- assertEquals(eVal, elementInfoFromArtifact.getType());
+ assertFalse(
+ ASDCElementInfo.ASDCElementTypeEnum.VNF_RESOURCE.name().equals(elementInfoFromArtifact.getType()));
+ assertEquals(eVal, elementInfoFromArtifact.getType());
- assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
- elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");
- assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
- }
- }
+ assertFalse(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
+ elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue");
+ assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue"));
+ }
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
index ba95a6ea24..24b1736fad 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/ASDCStatusCallBackTest.java
@@ -27,7 +27,6 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -41,51 +40,52 @@ import org.onap.so.asdc.client.test.emulators.JsonStatusData;
import org.springframework.beans.factory.annotation.Autowired;
public class ASDCStatusCallBackTest extends BaseTest {
- @Autowired
- private ASDCStatusCallBack statusCallback;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void activateCallbackTest() throws Exception {
- JsonStatusData statusData = new JsonStatusData();
-
- doNothing().when(toscaInstaller).installTheComponentStatus(isA(JsonStatusData.class));
-
- statusCallback.activateCallback(statusData);
-
- verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
- }
-
- @Test
- public void activateCallbackDoneErrorStatusTest() throws Exception {
- IStatusData statusData = mock(IStatusData.class);
-
- doReturn("distributionId").when(statusData).getDistributionID();
- doReturn("componentName").when(statusData).getComponentName();
- doReturn(DistributionStatusEnum.COMPONENT_DONE_ERROR).when(statusData).getStatus();
- doNothing().when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
-
- statusCallback.activateCallback(statusData);
-
- verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
- }
-
- @Test
- public void activateCallbackExceptionTest() throws Exception {
- IStatusData statusData = mock(IStatusData.class);
-
- doReturn("distributionId").when(statusData).getDistributionID();
- doReturn("componentName").when(statusData).getComponentName();
- doReturn(DistributionStatusEnum.COMPONENT_DONE_OK).when(statusData).getStatus();
- doThrow(ArtifactInstallerException.class).when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
-
- statusCallback.activateCallback(statusData);
- }
+ @Autowired
+ private ASDCStatusCallBack statusCallback;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void activateCallbackTest() throws Exception {
+ JsonStatusData statusData = new JsonStatusData();
+
+ doNothing().when(toscaInstaller).installTheComponentStatus(isA(JsonStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+
+ verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void activateCallbackDoneErrorStatusTest() throws Exception {
+ IStatusData statusData = mock(IStatusData.class);
+
+ doReturn("distributionId").when(statusData).getDistributionID();
+ doReturn("componentName").when(statusData).getComponentName();
+ doReturn(DistributionStatusEnum.COMPONENT_DONE_ERROR).when(statusData).getStatus();
+ doNothing().when(toscaInstaller).installTheComponentStatus(isA(IStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+
+ verify(toscaInstaller, times(1)).installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void activateCallbackExceptionTest() throws Exception {
+ IStatusData statusData = mock(IStatusData.class);
+
+ doReturn("distributionId").when(statusData).getDistributionID();
+ doReturn("componentName").when(statusData).getComponentName();
+ doReturn(DistributionStatusEnum.COMPONENT_DONE_OK).when(statusData).getStatus();
+ doThrow(ArtifactInstallerException.class).when(toscaInstaller)
+ .installTheComponentStatus(isA(IStatusData.class));
+
+ statusCallback.activateCallback(statusData);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
index 4eb9ed5619..090f2e8968 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/BigDecimalVersionTest.java
@@ -24,30 +24,29 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.assertTrue;
import java.math.BigDecimal;
import org.junit.Test;
-
import org.onap.so.asdc.installer.BigDecimalVersion;
public class BigDecimalVersionTest {
@Test
- public final void versionCastTest () {
+ public final void versionCastTest() {
- BigDecimal versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0");
- assertTrue(versionDecimal.equals(new BigDecimal("12.0")));
- assertTrue("12.0".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0")));
+ BigDecimal versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0");
+ assertTrue(versionDecimal.equals(new BigDecimal("12.0")));
+ assertTrue("12.0".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0")));
- versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0.2");
- assertTrue(versionDecimal.equals(new BigDecimal("12.02")));
- assertTrue("12.02".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0.2")));
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("12.0.2");
+ assertTrue(versionDecimal.equals(new BigDecimal("12.02")));
+ assertTrue("12.02".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("12.0.2")));
- versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10");
- assertTrue(versionDecimal.equals(new BigDecimal("10")));
- assertTrue("10".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10")));
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10");
+ assertTrue(versionDecimal.equals(new BigDecimal("10")));
+ assertTrue("10".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10")));
- versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10.1.2.6");
- assertTrue(versionDecimal.equals(new BigDecimal("10.126")));
- assertTrue("10.126".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10.1.2.6")));
+ versionDecimal = BigDecimalVersion.castAndCheckNotificationVersion("10.1.2.6");
+ assertTrue(versionDecimal.equals(new BigDecimal("10.126")));
+ assertTrue("10.126".equals(BigDecimalVersion.castAndCheckNotificationVersionToString("10.1.2.6")));
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
index 0c6476ddef..9c8929b76a 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/DistributionStatusMessageTest.java
@@ -21,25 +21,24 @@
package org.onap.so.asdc.client;
import static org.junit.Assert.assertEquals;
-
import org.junit.Test;
import org.onap.sdc.utils.DistributionStatusEnum;
public class DistributionStatusMessageTest {
-
- @Test
- public void distributionStatusMessageTest() {
- String artifactUrl = "artifactUrl";
- String consumerId = "consumerId";
- String distributionId = "distributionId";
- Long timestamp = 123L;
- DistributionStatusMessage distributionStatusMessage = new DistributionStatusMessage(
- artifactUrl, consumerId, distributionId, DistributionStatusEnum.DEPLOY_OK, timestamp);
-
- assertEquals(artifactUrl, distributionStatusMessage.getArtifactURL());
- assertEquals(consumerId, distributionStatusMessage.getConsumerID());
- assertEquals(distributionId, distributionStatusMessage.getDistributionID());
- assertEquals(DistributionStatusEnum.DEPLOY_OK, distributionStatusMessage.getStatus());
- assertEquals(123L, distributionStatusMessage.getTimestamp());
- }
+
+ @Test
+ public void distributionStatusMessageTest() {
+ String artifactUrl = "artifactUrl";
+ String consumerId = "consumerId";
+ String distributionId = "distributionId";
+ Long timestamp = 123L;
+ DistributionStatusMessage distributionStatusMessage = new DistributionStatusMessage(artifactUrl, consumerId,
+ distributionId, DistributionStatusEnum.DEPLOY_OK, timestamp);
+
+ assertEquals(artifactUrl, distributionStatusMessage.getArtifactURL());
+ assertEquals(consumerId, distributionStatusMessage.getConsumerID());
+ assertEquals(distributionId, distributionStatusMessage.getDistributionID());
+ assertEquals(DistributionStatusEnum.DEPLOY_OK, distributionStatusMessage.getStatus());
+ assertEquals(123L, distributionStatusMessage.getTimestamp());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
index ed761c7f4d..d7316e57bd 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/YamlTest.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.client;
import static org.junit.Assert.*;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -36,118 +35,123 @@ import org.onap.so.db.catalog.beans.HeatTemplateParam;
public class YamlTest {
- @Test
- public void getYamlResourceTypeTestList() throws Exception {
-
- InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
- YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
- List<String> typeList = decoder.getYamlNestedFileResourceTypeList();
-
- assertTrue(typeList.size() == 1 && typeList.get(0).equals("file:///my_test.yaml"));
- }
-
- @Test
- public void getParameterListTest() throws Exception {
-
- InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
- YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
- Set <HeatTemplateParam> paramSet = decoder.getParameterList("123456");
-
- assertTrue(paramSet.size() == 5);
-
- for (HeatTemplateParam param : paramSet) {
- if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
-
- assertTrue(param.isRequired()==false);
- } else {
-
- assertTrue(param.isRequired()==true);
- }
-
- assertTrue("string".equals(param.getParamType()));
- }
- }
-
- @Test
- public void addParameterListWhenEmptyTest() throws Exception {
-
- InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml"));
- YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
-
- Set <HeatTemplateParam> newParamSet = new HashSet<>();
-
- HeatTemplateParam heatParam1 = new HeatTemplateParam();
- heatParam1.setHeatTemplateArtifactUuid("1");
- heatParam1.setParamName("testos1");
- heatParam1.setParamType("string");
-
- HeatTemplateParam heatParam2 = new HeatTemplateParam();
- heatParam2.setHeatTemplateArtifactUuid("2");
- heatParam2.setParamName("testos2");
- heatParam2.setParamType("number");
-
- newParamSet.add(heatParam1);
- newParamSet.add(heatParam2);
-
- decoder.addParameterList(newParamSet);
-
- Set <HeatTemplateParam> paramSet = decoder.getParameterList("123456");
- assertTrue(paramSet.size() == 2);
-
- assertTrue(decoder.encode().contains("testos1"));
- assertTrue(decoder.encode().contains("string"));
- assertTrue(decoder.encode().contains("testos2"));
- assertTrue(decoder.encode().contains("number"));
- }
-
- @Test
- public void addParameterListTest() throws Exception {
-
- InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
- YamlEditor decoder = new YamlEditor (IOUtils.toByteArray(input));
-
- Set <HeatTemplateParam> newParamSet = new HashSet<>();
-
- HeatTemplateParam heatParam1 = new HeatTemplateParam();
- heatParam1.setHeatTemplateArtifactUuid("1");
- heatParam1.setParamName("testos1");
- heatParam1.setParamType("string");
-
- HeatTemplateParam heatParam2 = new HeatTemplateParam();
- heatParam2.setHeatTemplateArtifactUuid("2");
- heatParam2.setParamName("testos2");
- heatParam2.setParamType("number");
-
- newParamSet.add(heatParam1);
- newParamSet.add(heatParam2);
-
- decoder.addParameterList(newParamSet);
-
- Set <HeatTemplateParam> paramSet = decoder.getParameterList("123456");
-
- assertTrue(paramSet.size() == 7);
-
- Boolean check1 = Boolean.FALSE;
- Boolean check2 = Boolean.FALSE;
-
- for (HeatTemplateParam param : paramSet) {
- if ("ip_port_snmp_manager".equals(param.getParamName()) || "cor_direct_net_name".equals(param.getParamName()) || "cor_direct_net_RT".equals(param.getParamName())) {
- assertFalse(param.isRequired());
- } else {
- assertTrue(param.isRequired());
- }
-
- if ("testos1".equals(param.getParamName()) && "string".equals(param.getParamType())) {
- check1=Boolean.TRUE;
- }
-
- if ("testos2".equals(param.getParamName()) && "number".equals(param.getParamType())) {
- check2=Boolean.TRUE;
- }
-
- }
-
- assertTrue(check1);
- assertTrue(check2);
- }
+ @Test
+ public void getYamlResourceTypeTestList() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
+ List<String> typeList = decoder.getYamlNestedFileResourceTypeList();
+
+ assertTrue(typeList.size() == 1 && typeList.get(0).equals("file:///my_test.yaml"));
+ }
+
+ @Test
+ public void getParameterListTest() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
+ Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
+
+ assertTrue(paramSet.size() == 5);
+
+ for (HeatTemplateParam param : paramSet) {
+ if ("ip_port_snmp_manager".equals(param.getParamName())
+ || "cor_direct_net_name".equals(param.getParamName())
+ || "cor_direct_net_RT".equals(param.getParamName())) {
+
+ assertTrue(param.isRequired() == false);
+ } else {
+
+ assertTrue(param.isRequired() == true);
+ }
+
+ assertTrue("string".equals(param.getParamType()));
+ }
+ }
+
+ @Test
+ public void addParameterListWhenEmptyTest() throws Exception {
+
+ InputStream input =
+ new FileInputStream(new File("src/test/resources/resource-examples/simpleTestWithoutParam.yaml"));
+ YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
+
+ Set<HeatTemplateParam> newParamSet = new HashSet<>();
+
+ HeatTemplateParam heatParam1 = new HeatTemplateParam();
+ heatParam1.setHeatTemplateArtifactUuid("1");
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setHeatTemplateArtifactUuid("2");
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
+ assertTrue(paramSet.size() == 2);
+
+ assertTrue(decoder.encode().contains("testos1"));
+ assertTrue(decoder.encode().contains("string"));
+ assertTrue(decoder.encode().contains("testos2"));
+ assertTrue(decoder.encode().contains("number"));
+ }
+
+ @Test
+ public void addParameterListTest() throws Exception {
+
+ InputStream input = new FileInputStream(new File("src/test/resources/resource-examples/simpleTest.yaml"));
+ YamlEditor decoder = new YamlEditor(IOUtils.toByteArray(input));
+
+ Set<HeatTemplateParam> newParamSet = new HashSet<>();
+
+ HeatTemplateParam heatParam1 = new HeatTemplateParam();
+ heatParam1.setHeatTemplateArtifactUuid("1");
+ heatParam1.setParamName("testos1");
+ heatParam1.setParamType("string");
+
+ HeatTemplateParam heatParam2 = new HeatTemplateParam();
+ heatParam2.setHeatTemplateArtifactUuid("2");
+ heatParam2.setParamName("testos2");
+ heatParam2.setParamType("number");
+
+ newParamSet.add(heatParam1);
+ newParamSet.add(heatParam2);
+
+ decoder.addParameterList(newParamSet);
+
+ Set<HeatTemplateParam> paramSet = decoder.getParameterList("123456");
+
+ assertTrue(paramSet.size() == 7);
+
+ Boolean check1 = Boolean.FALSE;
+ Boolean check2 = Boolean.FALSE;
+
+ for (HeatTemplateParam param : paramSet) {
+ if ("ip_port_snmp_manager".equals(param.getParamName())
+ || "cor_direct_net_name".equals(param.getParamName())
+ || "cor_direct_net_RT".equals(param.getParamName())) {
+ assertFalse(param.isRequired());
+ } else {
+ assertTrue(param.isRequired());
+ }
+
+ if ("testos1".equals(param.getParamName()) && "string".equals(param.getParamType())) {
+ check1 = Boolean.TRUE;
+ }
+
+ if ("testos2".equals(param.getParamName()) && "number".equals(param.getParamType())) {
+ check2 = Boolean.TRUE;
+ }
+
+ }
+
+ assertTrue(check1);
+ assertTrue(check2);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
index e2aee6080e..927779c485 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCControllerExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCControllerExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCControllerException asdcDownloadException = new ASDCControllerException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
index 98deb52a08..b022ed91d7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCDownloadExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCDownloadExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcDownloadExceptionTest() {
- ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcDownloadExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcDownloadExceptionTest() {
+ ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcDownloadExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCDownloadException asdcDownloadException = new ASDCDownloadException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
index bac05bd47c..2b4a0c956e 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ASDCParametersExceptionTest.java
@@ -22,29 +22,28 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ASDCParametersExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ASDCParametersException asdcDownloadException = new ASDCParametersException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
index f2227908f5..3e0dd27d07 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/exceptions/ArtifactInstallerExceptionTest.java
@@ -22,29 +22,29 @@ package org.onap.so.asdc.client.exceptions;
import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
-
import org.junit.Test;
public class ArtifactInstallerExceptionTest {
- private String exceptionMessage = "test message for exception";
- private String throwableMessage = "separate throwable that caused asdcDownloadException";
-
- @Test
- public void asdcParametersExceptionTest() {
- ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage);
-
- Exception expectedException = new Exception(exceptionMessage);
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
-
- @Test
- public void asdcParametersExceptionThrowableTest() {
- Throwable throwableCause = new Throwable(throwableMessage);
- ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage, throwableCause);
-
- Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
-
- assertThat(asdcDownloadException, sameBeanAs(expectedException));
- }
+ private String exceptionMessage = "test message for exception";
+ private String throwableMessage = "separate throwable that caused asdcDownloadException";
+
+ @Test
+ public void asdcParametersExceptionTest() {
+ ArtifactInstallerException asdcDownloadException = new ArtifactInstallerException(exceptionMessage);
+
+ Exception expectedException = new Exception(exceptionMessage);
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
+
+ @Test
+ public void asdcParametersExceptionThrowableTest() {
+ Throwable throwableCause = new Throwable(throwableMessage);
+ ArtifactInstallerException asdcDownloadException =
+ new ArtifactInstallerException(exceptionMessage, throwableCause);
+
+ Exception expectedException = new Exception(exceptionMessage, new Throwable(throwableMessage));
+
+ assertThat(asdcDownloadException, sameBeanAs(expectedException));
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
index 3dc323559d..69d3fd103d 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ArtifactInfoImplTest.java
@@ -22,28 +22,26 @@ package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.so.asdc.BaseTest;
-public class ArtifactInfoImplTest extends BaseTest {
- @Mock
- private IArtifactInfo iArtifactInfo;
-
- @Test
- public void convertToArtifactInfoImplTest() {
- List<IArtifactInfo> list = new ArrayList<IArtifactInfo>();
- list.add(iArtifactInfo);
- assertEquals(1, ArtifactInfoImpl.convertToArtifactInfoImpl(list).size());
- }
-
- @Test
- public void convertToArtifactInfoImplNullListTest() {
- assertTrue(ArtifactInfoImpl.convertToArtifactInfoImpl(null).isEmpty());
- }
+public class ArtifactInfoImplTest extends BaseTest {
+ @Mock
+ private IArtifactInfo iArtifactInfo;
+
+ @Test
+ public void convertToArtifactInfoImplTest() {
+ List<IArtifactInfo> list = new ArrayList<IArtifactInfo>();
+ list.add(iArtifactInfo);
+ assertEquals(1, ArtifactInfoImpl.convertToArtifactInfoImpl(list).size());
+ }
+
+ @Test
+ public void convertToArtifactInfoImplNullListTest() {
+ assertTrue(ArtifactInfoImpl.convertToArtifactInfoImpl(null).isEmpty());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
index 38c2564241..cfbf7724cc 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/DistributionClientEmulatorTest.java
@@ -21,13 +21,11 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.LinkedList;
import java.util.List;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.sdc.api.consumer.IDistributionStatusMessage;
@@ -43,136 +41,156 @@ import org.onap.so.asdc.client.ASDCStatusCallBack;
import org.onap.so.asdc.client.DistributionStatusMessage;
public class DistributionClientEmulatorTest {
-
- private DistributionClientEmulator distClientEmulator;
-
- @Before
- public void before() {
- distClientEmulator = new DistributionClientEmulator();
- }
-
- @Test
- public void getDistributionMessageReceived() {
- List<IDistributionStatusMessage> receivedMessages = distClientEmulator.getDistributionMessageReceived();
- assertEquals(new LinkedList<>(), receivedMessages);
-
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- distClientEmulator.sendDeploymentStatus(message);
- assertEquals(message, receivedMessages.get(0));
-
- IDistributionStatusMessage message2 = new DistributionStatusMessage("testArtifactUrl2", "testConsumerId2", "testDistributionId2", DistributionStatusEnum.DOWNLOAD_OK, 1234567);
- distClientEmulator.sendDeploymentStatus(message2);
- assertEquals(message2, receivedMessages.get(1));
- }
-
- @Test
- public void sendDeploymentStatusPrimary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message);
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDeploymentStatusSecondary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message, "test");
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDownloadStatusPrimary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message);
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void sendDownloadStatusSecondary() {
- IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId", "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
- IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message, "test");
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void initPrimary() {
- IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void initSecondary() {
- IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack(), new ASDCStatusCallBack());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void start() {
- IDistributionClientResult result = distClientEmulator.start();
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void stop() {
- IDistributionClientResult result = distClientEmulator.stop();
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void updateConfiguration() {
- IDistributionClientResult result = distClientEmulator.updateConfiguration(new ASDCConfiguration());
- IDistributionClientResult expectedResult = new DistributionClientResultImpl(DistributionActionResultEnum.SUCCESS,DistributionActionResultEnum.SUCCESS.name());
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
-
- @Test
- public void getResourcePath() {
- String testResourcePath = "testResourcePath";
- distClientEmulator = new DistributionClientEmulator(testResourcePath);
- assertEquals(testResourcePath, distClientEmulator.getResourcePath());
- }
-
- @Test
- public void setResourcePath() {
- String testResourcePath = "testResourcePath";
- distClientEmulator.setResourcePath(testResourcePath);
- assertEquals(testResourcePath, distClientEmulator.getResourcePath());
- }
-
- @Test
- public void downloadSuccess() throws IOException {
- ArtifactInfoImpl info = new ArtifactInfoImpl();
- info.setArtifactURL("mso.json");
- info.setArtifactName("testArtifactName");
-
- distClientEmulator.setResourcePath("src/test/resources/");
-
- IDistributionClientDownloadResult result = distClientEmulator.download(info);
-
- byte[] expectedInputStream = Files.readAllBytes(Paths.get(distClientEmulator.getResourcePath() + info.getArtifactURL()));
- IDistributionClientDownloadResult expectedResult = new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name(), info.getArtifactName(), expectedInputStream);
-
- assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
- assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
- }
+
+ private DistributionClientEmulator distClientEmulator;
+
+ @Before
+ public void before() {
+ distClientEmulator = new DistributionClientEmulator();
+ }
+
+ @Test
+ public void getDistributionMessageReceived() {
+ List<IDistributionStatusMessage> receivedMessages = distClientEmulator.getDistributionMessageReceived();
+ assertEquals(new LinkedList<>(), receivedMessages);
+
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ distClientEmulator.sendDeploymentStatus(message);
+ assertEquals(message, receivedMessages.get(0));
+
+ IDistributionStatusMessage message2 = new DistributionStatusMessage("testArtifactUrl2", "testConsumerId2",
+ "testDistributionId2", DistributionStatusEnum.DOWNLOAD_OK, 1234567);
+ distClientEmulator.sendDeploymentStatus(message2);
+ assertEquals(message2, receivedMessages.get(1));
+ }
+
+ @Test
+ public void sendDeploymentStatusPrimary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message);
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDeploymentStatusSecondary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDeploymentStatus(message, "test");
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDownloadStatusPrimary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message);
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void sendDownloadStatusSecondary() {
+ IDistributionStatusMessage message = new DistributionStatusMessage("testArtifactUrl", "testConsumerId",
+ "testDistributionId", DistributionStatusEnum.DOWNLOAD_OK, 123456);
+ IDistributionClientResult result = distClientEmulator.sendDownloadStatus(message, "test");
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(message, distClientEmulator.getDistributionMessageReceived().get(0));
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void initPrimary() {
+ IDistributionClientResult result =
+ distClientEmulator.init(new ASDCConfiguration(), new ASDCNotificationCallBack());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void initSecondary() {
+ IDistributionClientResult result = distClientEmulator.init(new ASDCConfiguration(),
+ new ASDCNotificationCallBack(), new ASDCStatusCallBack());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void start() {
+ IDistributionClientResult result = distClientEmulator.start();
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void stop() {
+ IDistributionClientResult result = distClientEmulator.stop();
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void updateConfiguration() {
+ IDistributionClientResult result = distClientEmulator.updateConfiguration(new ASDCConfiguration());
+ IDistributionClientResult expectedResult = new DistributionClientResultImpl(
+ DistributionActionResultEnum.SUCCESS, DistributionActionResultEnum.SUCCESS.name());
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
+
+ @Test
+ public void getResourcePath() {
+ String testResourcePath = "testResourcePath";
+ distClientEmulator = new DistributionClientEmulator(testResourcePath);
+ assertEquals(testResourcePath, distClientEmulator.getResourcePath());
+ }
+
+ @Test
+ public void setResourcePath() {
+ String testResourcePath = "testResourcePath";
+ distClientEmulator.setResourcePath(testResourcePath);
+ assertEquals(testResourcePath, distClientEmulator.getResourcePath());
+ }
+
+ @Test
+ public void downloadSuccess() throws IOException {
+ ArtifactInfoImpl info = new ArtifactInfoImpl();
+ info.setArtifactURL("mso.json");
+ info.setArtifactName("testArtifactName");
+
+ distClientEmulator.setResourcePath("src/test/resources/");
+
+ IDistributionClientDownloadResult result = distClientEmulator.download(info);
+
+ byte[] expectedInputStream =
+ Files.readAllBytes(Paths.get(distClientEmulator.getResourcePath() + info.getArtifactURL()));
+ IDistributionClientDownloadResult expectedResult =
+ new DistributionClientDownloadResultImpl(DistributionActionResultEnum.SUCCESS,
+ DistributionActionResultEnum.SUCCESS.name(), info.getArtifactName(), expectedInputStream);
+
+ assertEquals(expectedResult.getDistributionActionResult(), result.getDistributionActionResult());
+ assertEquals(expectedResult.getDistributionMessageResult(), result.getDistributionMessageResult());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
index 5e2f1ad828..cf54656271 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonStatusDataTest.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc.client.test.emulators;
import org.junit.Test;
-
import static org.junit.Assert.assertEquals;
public class JsonStatusDataTest {
@@ -39,17 +38,16 @@ public class JsonStatusDataTest {
}
@Test
- public void setGetAttributes()
- {
+ public void setGetAttributes() {
JsonStatusData jsonStatusData = new JsonStatusData();
- jsonStatusData.setAttribute("test","test");
+ jsonStatusData.setAttribute("test", "test");
jsonStatusData.getStatus();
jsonStatusData.getTimestamp();
jsonStatusData.getComponentName();
jsonStatusData.getConsumerID();
jsonStatusData.getDistributionID();
String errReason = jsonStatusData.getErrorReason();
- assertEquals(errReason,"MSO FAILURE");
+ assertEquals(errReason, "MSO FAILURE");
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
index 6da3a2c18c..bcef94336b 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/JsonVfModuleMetaDataTest.java
@@ -21,32 +21,30 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.util.HashMap;
-
import org.junit.Test;
public class JsonVfModuleMetaDataTest {
-
- @Test
- public void attributesMapTest() {
- JsonVfModuleMetaData vfModuleMetadata = new JsonVfModuleMetaData();
- vfModuleMetadata.setAttribute("vfModuleModelDescription", "vfModuleModelDescription");
- vfModuleMetadata.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID");
- vfModuleMetadata.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID");
- vfModuleMetadata.setAttribute("vfModuleModelName", "vfModuleModelName");
- vfModuleMetadata.setAttribute("vfModuleModelUUID", "vfModuleModelUUID");
- vfModuleMetadata.setAttribute("vfModuleModelVersion", "vfModuleModelVersion");
- vfModuleMetadata.setAttribute("isBase", true);
-
- assertEquals("vfModuleModelDescription", vfModuleMetadata.getVfModuleModelDescription());
- assertEquals("vfModuleModelInvariantUUID", vfModuleMetadata.getVfModuleModelInvariantUUID());
- assertEquals("vfModuleModelCustomizationUUID", vfModuleMetadata.getVfModuleModelCustomizationUUID());
- assertEquals("vfModuleModelName", vfModuleMetadata.getVfModuleModelName());
- assertEquals("vfModuleModelUUID", vfModuleMetadata.getVfModuleModelUUID());
- assertEquals("vfModuleModelVersion", vfModuleMetadata.getVfModuleModelVersion());
- assertEquals(true, vfModuleMetadata.isBase());
- assertEquals(null, vfModuleMetadata.getArtifacts());
- assertEquals(new HashMap<String, String>(), vfModuleMetadata.getProperties());
- }
+
+ @Test
+ public void attributesMapTest() {
+ JsonVfModuleMetaData vfModuleMetadata = new JsonVfModuleMetaData();
+ vfModuleMetadata.setAttribute("vfModuleModelDescription", "vfModuleModelDescription");
+ vfModuleMetadata.setAttribute("vfModuleModelInvariantUUID", "vfModuleModelInvariantUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelCustomizationUUID", "vfModuleModelCustomizationUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelName", "vfModuleModelName");
+ vfModuleMetadata.setAttribute("vfModuleModelUUID", "vfModuleModelUUID");
+ vfModuleMetadata.setAttribute("vfModuleModelVersion", "vfModuleModelVersion");
+ vfModuleMetadata.setAttribute("isBase", true);
+
+ assertEquals("vfModuleModelDescription", vfModuleMetadata.getVfModuleModelDescription());
+ assertEquals("vfModuleModelInvariantUUID", vfModuleMetadata.getVfModuleModelInvariantUUID());
+ assertEquals("vfModuleModelCustomizationUUID", vfModuleMetadata.getVfModuleModelCustomizationUUID());
+ assertEquals("vfModuleModelName", vfModuleMetadata.getVfModuleModelName());
+ assertEquals("vfModuleModelUUID", vfModuleMetadata.getVfModuleModelUUID());
+ assertEquals("vfModuleModelVersion", vfModuleMetadata.getVfModuleModelVersion());
+ assertEquals(true, vfModuleMetadata.isBase());
+ assertEquals(null, vfModuleMetadata.getArtifacts());
+ assertEquals(new HashMap<String, String>(), vfModuleMetadata.getProperties());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
index b1524e015f..94ba54db29 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/NotificationDataImplTest.java
@@ -21,39 +21,38 @@
package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.so.asdc.BaseTest;
import org.springframework.beans.factory.annotation.Autowired;
public class NotificationDataImplTest extends BaseTest {
- @Autowired
- private NotificationDataImpl notificationDataImpl;
-
- @Mock
- private ArtifactInfoImpl artifactInfoImpl;
-
- private static final String NOTIFICATION_DATA_IMPL_STRING = "NotificationDataImpl [distributionID=distributionID, serviceName=serviceName, "
- + "serviceVersion=serviceVersion, serviceUUID=serviceUUID, serviceDescription=serviceDescription, "
- + "serviceInvariantUUID=serviceInvariantUUID, resources=null, serviceArtifacts=[artifactInfoImpl], workloadContext=workloadContext]";
-
- @Test
- public void toStringTest() {
- List<ArtifactInfoImpl> relevantServiceArtifacts = new ArrayList<ArtifactInfoImpl>();
- relevantServiceArtifacts.add(artifactInfoImpl);
- notificationDataImpl.setDistributionID("distributionID");
- notificationDataImpl.setServiceName("serviceName");
- notificationDataImpl.setServiceVersion("serviceVersion");
- notificationDataImpl.setServiceDescription("serviceDescription");
- notificationDataImpl.setServiceUUID("serviceUUID");
- notificationDataImpl.setServiceInvariantUUID("serviceInvariantUUID");
- notificationDataImpl.setWorkloadContext("workloadContext");
- notificationDataImpl.setServiceArtifacts(relevantServiceArtifacts);
-
- assertEquals(NOTIFICATION_DATA_IMPL_STRING, notificationDataImpl.toString());
- }
+ @Autowired
+ private NotificationDataImpl notificationDataImpl;
+
+ @Mock
+ private ArtifactInfoImpl artifactInfoImpl;
+
+ private static final String NOTIFICATION_DATA_IMPL_STRING =
+ "NotificationDataImpl [distributionID=distributionID, serviceName=serviceName, "
+ + "serviceVersion=serviceVersion, serviceUUID=serviceUUID, serviceDescription=serviceDescription, "
+ + "serviceInvariantUUID=serviceInvariantUUID, resources=null, serviceArtifacts=[artifactInfoImpl], workloadContext=workloadContext]";
+
+ @Test
+ public void toStringTest() {
+ List<ArtifactInfoImpl> relevantServiceArtifacts = new ArrayList<ArtifactInfoImpl>();
+ relevantServiceArtifacts.add(artifactInfoImpl);
+ notificationDataImpl.setDistributionID("distributionID");
+ notificationDataImpl.setServiceName("serviceName");
+ notificationDataImpl.setServiceVersion("serviceVersion");
+ notificationDataImpl.setServiceDescription("serviceDescription");
+ notificationDataImpl.setServiceUUID("serviceUUID");
+ notificationDataImpl.setServiceInvariantUUID("serviceInvariantUUID");
+ notificationDataImpl.setWorkloadContext("workloadContext");
+ notificationDataImpl.setServiceArtifacts(relevantServiceArtifacts);
+
+ assertEquals(NOTIFICATION_DATA_IMPL_STRING, notificationDataImpl.toString());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
index 423661770b..47662daab7 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/emulators/ResourceInfoImplTest.java
@@ -22,30 +22,28 @@ package org.onap.so.asdc.client.test.emulators;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.mockito.Mock;
import org.onap.sdc.api.notification.IResourceInstance;
import org.onap.so.asdc.BaseTest;
public class ResourceInfoImplTest extends BaseTest {
- @Mock
- private IResourceInstance iResourceInstance;
-
- @Test
- public void convertToJsonContainerTest() {
- List<IResourceInstance> resources = new ArrayList<IResourceInstance>();
- resources.add(iResourceInstance);
- ResourceInfoImpl.convertToJsonContainer(resources);
-
- assertEquals(1, ResourceInfoImpl.convertToJsonContainer(resources).size());
- }
-
- @Test
- public void convertToJsonContainerNullListTest() {
- assertTrue(ResourceInfoImpl.convertToJsonContainer(null).isEmpty());
- }
+ @Mock
+ private IResourceInstance iResourceInstance;
+
+ @Test
+ public void convertToJsonContainerTest() {
+ List<IResourceInstance> resources = new ArrayList<IResourceInstance>();
+ resources.add(iResourceInstance);
+ ResourceInfoImpl.convertToJsonContainer(resources);
+
+ assertEquals(1, ResourceInfoImpl.convertToJsonContainer(resources).size());
+ }
+
+ @Test
+ public void convertToJsonContainerNullListTest() {
+ assertTrue(ResourceInfoImpl.convertToJsonContainer(null).isEmpty());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
index 947da4f492..815f419c40 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/ASDCRestInterfaceTest.java
@@ -27,14 +27,11 @@ import static com.shazam.shazamcrest.MatcherAssert.assertThat;
import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
-
import java.io.File;
import java.util.HashSet;
import java.util.Set;
-
import javax.transaction.Transactional;
import javax.ws.rs.core.Response;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -55,105 +52,103 @@ import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
-
import com.fasterxml.jackson.databind.ObjectMapper;
public class ASDCRestInterfaceTest extends BaseTest {
- @Autowired
- private AllottedResourceRepository allottedRepo;
-
- @Autowired
- private ServiceRepository serviceRepo;
-
- @Autowired
- private NetworkResourceRepository networkRepo;
-
- @Autowired
- private ASDCRestInterface asdcRestInterface;
-
- private TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
-
- private HttpHeaders headers = new HttpHeaders();
-
- @Spy
- DistributionClientEmulator spyClient = new DistributionClientEmulator();
-
- @LocalServerPort
- private int port;
-
-
- @Rule
- public TemporaryFolder folder= new TemporaryFolder();
-
-
- @Before
- public void setUp() {
- //ASDC Controller writes to this path
- System.setProperty("mso.config.path", folder.getRoot().toString());
- }
-
- @Test
- @Transactional
- public void testAllottedResourceService() throws Exception {
-
- wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
- .willReturn(aResponse()
- .withStatus(200)
- .withHeader("Content-Type", "application/json")));
-
- ObjectMapper mapper = new ObjectMapper();
- NotificationDataImpl request = mapper.readValue(new File("src/test/resources/resource-examples/allottedresource/notif-portm.json"), NotificationDataImpl.class);
- headers.add("resource-location", "src/test/resources/resource-examples/allottedresource/");
- HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
-
- ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"), HttpMethod.POST,
- entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
-
- AllottedResource expectedService = new AllottedResource();
- expectedService.setDescription("rege1802pnf");
- expectedService.setModelInvariantUUID("b8f83c3f-077c-4e2c-b489-c66382060436");
- expectedService.setModelName("rege1802pnf");
- expectedService.setModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
- expectedService.setModelVersion("1.0");
- expectedService.setSubcategory("Contrail Route");
- expectedService.setToscaNodeType("org.openecomp.resource.pnf.Rege1802pnf");
- Set<AllottedResourceCustomization> arCustomizationSet = new HashSet<AllottedResourceCustomization>();
- AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
- arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
- arCustomization.setModelInstanceName("rege1802pnf 0");
- arCustomizationSet.add(arCustomization);
-
- arCustomization.setAllottedResource(expectedService);
-
-
- expectedService.setAllotedResourceCustomization(arCustomizationSet);
-
- AllottedResource actualResponse = allottedRepo.findResourceByModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
-
-
- if(actualResponse == null)
- throw new Exception("No Allotted Resource Written to database");
-
-
- assertThat(actualResponse, sameBeanAs(expectedService).ignoring("0x1.created").ignoring("0x1.allotedResourceCustomization.created"));
- }
-
- @Test
- public void invokeASDCStatusDataNullTest() {
- String request = "";
- Response response = asdcRestInterface.invokeASDCStatusData(request);
- assertNull(response);
-
- }
-
-
-
-
-
- protected String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ @Autowired
+ private AllottedResourceRepository allottedRepo;
+
+ @Autowired
+ private ServiceRepository serviceRepo;
+
+ @Autowired
+ private NetworkResourceRepository networkRepo;
+
+ @Autowired
+ private ASDCRestInterface asdcRestInterface;
+
+ private TestRestTemplate restTemplate = new TestRestTemplate("test", "test");
+
+ private HttpHeaders headers = new HttpHeaders();
+
+ @Spy
+ DistributionClientEmulator spyClient = new DistributionClientEmulator();
+
+ @LocalServerPort
+ private int port;
+
+
+ @Rule
+ public TemporaryFolder folder = new TemporaryFolder();
+
+
+ @Before
+ public void setUp() {
+ // ASDC Controller writes to this path
+ System.setProperty("mso.config.path", folder.getRoot().toString());
+ }
+
+ @Test
+ @Transactional
+ public void testAllottedResourceService() throws Exception {
+
+ wireMockServer.stubFor(post(urlPathMatching("/aai/.*"))
+ .willReturn(aResponse().withStatus(200).withHeader("Content-Type", "application/json")));
+
+ ObjectMapper mapper = new ObjectMapper();
+ NotificationDataImpl request =
+ mapper.readValue(new File("src/test/resources/resource-examples/allottedresource/notif-portm.json"),
+ NotificationDataImpl.class);
+ headers.add("resource-location", "src/test/resources/resource-examples/allottedresource/");
+ HttpEntity<NotificationDataImpl> entity = new HttpEntity<NotificationDataImpl>(request, headers);
+
+ ResponseEntity<String> response = restTemplate.exchange(createURLWithPort("test/treatNotification/v1"),
+ HttpMethod.POST, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+
+ AllottedResource expectedService = new AllottedResource();
+ expectedService.setDescription("rege1802pnf");
+ expectedService.setModelInvariantUUID("b8f83c3f-077c-4e2c-b489-c66382060436");
+ expectedService.setModelName("rege1802pnf");
+ expectedService.setModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
+ expectedService.setModelVersion("1.0");
+ expectedService.setSubcategory("Contrail Route");
+ expectedService.setToscaNodeType("org.openecomp.resource.pnf.Rege1802pnf");
+ Set<AllottedResourceCustomization> arCustomizationSet = new HashSet<AllottedResourceCustomization>();
+ AllottedResourceCustomization arCustomization = new AllottedResourceCustomization();
+ arCustomization.setModelCustomizationUUID("f62bb612-c5d4-4406-865c-0abec30631ba");
+ arCustomization.setModelInstanceName("rege1802pnf 0");
+ arCustomizationSet.add(arCustomization);
+
+ arCustomization.setAllottedResource(expectedService);
+
+
+ expectedService.setAllotedResourceCustomization(arCustomizationSet);
+
+ AllottedResource actualResponse = allottedRepo.findResourceByModelUUID("5b18c75e-2d08-4bf2-ad58-4ea704ec648d");
+
+
+ if (actualResponse == null)
+ throw new Exception("No Allotted Resource Written to database");
+
+
+ assertThat(actualResponse, sameBeanAs(expectedService).ignoring("0x1.created")
+ .ignoring("0x1.allotedResourceCustomization.created"));
+ }
+
+ @Test
+ public void invokeASDCStatusDataNullTest() {
+ String request = "";
+ Response response = asdcRestInterface.invokeASDCStatusData(request);
+ assertNull(response);
+
+ }
+
+
+
+ protected String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
index cd2c3ee7e6..adc55937b6 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/test/rest/HealthCheckTest.java
@@ -38,28 +38,27 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
public class HealthCheckTest extends BaseTest {
-
- @LocalServerPort
- private int port;
- TestRestTemplate restTemplate = new TestRestTemplate();
+ @LocalServerPort
+ private int port;
- HttpHeaders headers = new HttpHeaders();
-
- @Test
- public void testHealthcheck() throws JSONException {
+ TestRestTemplate restTemplate = new TestRestTemplate();
- HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+ HttpHeaders headers = new HttpHeaders();
- ResponseEntity<String> response = restTemplate.exchange(
- createURLWithPort("/manage/health"),
- HttpMethod.GET, entity, String.class);
-
- assertEquals(Response.Status.OK.getStatusCode(),response.getStatusCode().value());
- }
-
- private String createURLWithPort(String uri) {
- return "http://localhost:" + port + uri;
- }
+ @Test
+ public void testHealthcheck() throws JSONException {
+
+ HttpEntity<String> entity = new HttpEntity<String>(null, headers);
+
+ ResponseEntity<String> response =
+ restTemplate.exchange(createURLWithPort("/manage/health"), HttpMethod.GET, entity, String.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ }
+
+ private String createURLWithPort(String uri) {
+ return "http://localhost:" + port + uri;
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
index db797cff29..992d495369 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/client/tests/ASDCConfigurationTest.java
@@ -24,12 +24,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import javax.transaction.Transactional;
-
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.onap.so.asdc.client.ASDCConfiguration;
@@ -42,111 +39,111 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
@Transactional
public class ASDCConfigurationTest extends BaseTest {
-
+
@Autowired
private ASDCConfiguration config;
-
+
private List<String> msgBusAddressList = new ArrayList<String>();
-
+
private static final String MSO_PRE_IST = "msopreist";
private static final String MSO_ASDC_ID_LOCAL = "msoasdc-id-local";
private static final String PRE_IST = "Pre-IST";
private static final String ASDC_ADDRESS = "localhost:8443";
-
+
@Test
public void isUseHttpsWithDmaapTest() {
- assertTrue(config.isUseHttpsWithDmaap());
+ assertTrue(config.isUseHttpsWithDmaap());
}
-
+
@Test
public void isConsumeProduceStatusTopicTest() {
- assertTrue(config.isConsumeProduceStatusTopic());
+ assertTrue(config.isConsumeProduceStatusTopic());
}
-
+
@Test
public void getUserTest() {
- assertTrue(MSO_PRE_IST.equals(config.getUser()));
+ assertTrue(MSO_PRE_IST.equals(config.getUser()));
}
-
+
@Test
public void getConsumerGroupTest() {
- assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerGroup()));
+ assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerGroup()));
}
-
+
@Test
public void getConsumerIDTest() {
- assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerID()));
+ assertTrue(MSO_ASDC_ID_LOCAL.equals(config.getConsumerID()));
}
-
+
@Test
public void getEnvironmentNameTest() {
- assertTrue(PRE_IST.equals(config.getEnvironmentName()));
+ assertTrue(PRE_IST.equals(config.getEnvironmentName()));
}
-
+
@Test
public void getAsdcAddress() {
- assertTrue(ASDC_ADDRESS.equals(config.getAsdcAddress()));
+ assertTrue(ASDC_ADDRESS.equals(config.getAsdcAddress()));
}
-
+
@Test
public void getPasswordTest() {
- assertTrue(MSO_PRE_IST.equals(config.getPassword()));
+ assertTrue(MSO_PRE_IST.equals(config.getPassword()));
}
-
+
@Test
public void getPollingIntervalTest() {
- assertTrue(config.getPollingInterval() == 30);
+ assertTrue(config.getPollingInterval() == 30);
}
-
+
@Test
public void getPollingTimeoutTest() {
- assertTrue(config.getPollingTimeout() == 30);
+ assertTrue(config.getPollingTimeout() == 30);
}
-
+
@Test
public void getRelevantArtifactTypesTest() {
- assertTrue(config.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
+ assertTrue(config.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size());
}
-
+
@Test
public void getWatchDogTimeoutTest() {
- assertTrue(config.getWatchDogTimeout() == 1);
+ assertTrue(config.getWatchDogTimeout() == 1);
}
-
+
@Test
public void activateServerTLSAuthTest() {
- assertFalse(config.activateServerTLSAuth());
+ assertFalse(config.activateServerTLSAuth());
}
-
+
@Test
public void getKeyStorePasswordTest() {
- assertNull(config.getKeyStorePassword());
+ assertNull(config.getKeyStorePassword());
}
-
+
@Test
public void getKeyStorePathTest() {
- assertNull(config.getKeyStorePath());
+ assertNull(config.getKeyStorePath());
}
-
+
@Test
public void isFilterInEmptyResourcesTest() {
- assertTrue(config.isFilterInEmptyResources());
+ assertTrue(config.isFilterInEmptyResources());
}
-
+
@Test
public void setGetAsdcControllerNameTest() {
- String asdcControllerName = "testAsdcControllerName";
- config.setAsdcControllerName(asdcControllerName);
- String actualAsdcControllerName = config.getAsdcControllerName();
- assertEquals(asdcControllerName, actualAsdcControllerName);
+ String asdcControllerName = "testAsdcControllerName";
+ config.setAsdcControllerName(asdcControllerName);
+ String actualAsdcControllerName = config.getAsdcControllerName();
+ assertEquals(asdcControllerName, actualAsdcControllerName);
}
-
+
@Test
public void getMsgBusAddressTest() {
- msgBusAddressList.add("localhost");
- msgBusAddressList.add("localhost");
-
- List<String> actualMsgBusAddress = config.getMsgBusAddress();
- assertEquals(msgBusAddressList, actualMsgBusAddress);
+ msgBusAddressList.add("localhost");
+ msgBusAddressList.add("localhost");
+
+ List<String> actualMsgBusAddress = config.getMsgBusAddress();
+ assertEquals(msgBusAddressList, actualMsgBusAddress);
}
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
index 1e8b72d145..d3990b9e7d 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/ToscaResourceStructureTest.java
@@ -26,10 +26,8 @@ import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
-
import java.util.ArrayList;
import java.util.HashMap;
-
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
@@ -50,84 +48,89 @@ import org.onap.so.db.catalog.beans.VfModuleCustomization;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
public class ToscaResourceStructureTest {
- private ArtifactInfoImpl artifactInfo;
- private SdcCsarHelperImpl sdcCsarHelper;
-
- private ToscaResourceStructure toscaResourceStructure;
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Test
- public void toscaResourceStructureBeanTest() {
- artifactInfo = mock(ArtifactInfoImpl.class);
- sdcCsarHelper = mock(SdcCsarHelperImpl.class);
-
- toscaResourceStructure = new ToscaResourceStructure();
- toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
- toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
- toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
- toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
- toscaResourceStructure.setCatalogService(new Service());
- toscaResourceStructure.setNetworkTypes(new ArrayList<>());
- toscaResourceStructure.setVfTypes(new ArrayList<>());
- toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
- toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
- toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
- toscaResourceStructure.setCatalogVfModule(new VfModule());
- toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
- toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
- toscaResourceStructure.setAllottedResource(new AllottedResource());
- toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
- toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
- toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
- toscaResourceStructure.setToscaArtifact(artifactInfo);
- toscaResourceStructure.setToscaCsar(new ToscaCsar());
- toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
- toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
- toscaResourceStructure.setServiceVersion("serviceVersion");
- toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
- toscaResourceStructure.setVfModule(new VfModule());
- toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
- toscaResourceStructure.setSuccessfulDeployment();
-
- assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
- assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
- assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
- assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
- assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
- assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
- assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
- assertThat(toscaResourceStructure.getCatalogResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(), sameBeanAs(new NetworkResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
- assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
- assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
- assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
- assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
- assertThat(toscaResourceStructure.getAllottedResourceCustomization(), sameBeanAs(new AllottedResourceCustomization()));
- assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
- assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
- assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
- assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
- assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
- assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
- assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
- assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
- assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
- assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(), sameBeanAs(new TempNetworkHeatTemplateLookup()));
- assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
- }
-
- @Test
- public void updateResourceStructureExceptionTest() throws Exception {
- expectedException.expect(ASDCDownloadException.class);
-
- artifactInfo = mock(ArtifactInfoImpl.class);
- toscaResourceStructure = new ToscaResourceStructure();
+ private ArtifactInfoImpl artifactInfo;
+ private SdcCsarHelperImpl sdcCsarHelper;
+
+ private ToscaResourceStructure toscaResourceStructure;
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Test
+ public void toscaResourceStructureBeanTest() {
+ artifactInfo = mock(ArtifactInfoImpl.class);
+ sdcCsarHelper = mock(SdcCsarHelperImpl.class);
+
+ toscaResourceStructure = new ToscaResourceStructure();
+ toscaResourceStructure.setHeatTemplateUUID("heatTemplateUUID");
+ toscaResourceStructure.setAllottedList(new ArrayList<NodeTemplate>());
+ toscaResourceStructure.setSdcCsarHelper(sdcCsarHelper);
+ toscaResourceStructure.setServiceMetadata(new Metadata(new HashMap<>()));
+ toscaResourceStructure.setCatalogService(new Service());
+ toscaResourceStructure.setNetworkTypes(new ArrayList<>());
+ toscaResourceStructure.setVfTypes(new ArrayList<>());
+ toscaResourceStructure.setCatalogResourceCustomization(new AllottedResourceCustomization());
+ toscaResourceStructure.setCatalogNetworkResourceCustomization(new NetworkResourceCustomization());
+ toscaResourceStructure.setCatalogNetworkResource(new NetworkResource());
+ toscaResourceStructure.setCatalogVfModule(new VfModule());
+ toscaResourceStructure.setVnfResourceCustomization(new VnfResourceCustomization());
+ toscaResourceStructure.setVfModuleCustomization(new VfModuleCustomization());
+ toscaResourceStructure.setAllottedResource(new AllottedResource());
+ toscaResourceStructure.setAllottedResourceCustomization(new AllottedResourceCustomization());
+ toscaResourceStructure.setCatalogTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ toscaResourceStructure.setHeatFilesUUID("heatFilesUUID");
+ toscaResourceStructure.setToscaArtifact(artifactInfo);
+ toscaResourceStructure.setToscaCsar(new ToscaCsar());
+ toscaResourceStructure.setVolHeatTemplateUUID("volHeatTemplateUUID");
+ toscaResourceStructure.setEnvHeatTemplateUUID("envHeatTemplateUUID");
+ toscaResourceStructure.setServiceVersion("serviceVersion");
+ toscaResourceStructure.setWorkloadPerformance("workloadPerformance");
+ toscaResourceStructure.setVfModule(new VfModule());
+ toscaResourceStructure.setTempNetworkHeatTemplateLookup(new TempNetworkHeatTemplateLookup());
+ toscaResourceStructure.setSuccessfulDeployment();
+
+ assertEquals("heatTemplateUUID", toscaResourceStructure.getHeatTemplateUUID());
+ assertThat(toscaResourceStructure.getAllottedList(), sameBeanAs(new ArrayList<NodeTemplate>()));
+ assertEquals(sdcCsarHelper, toscaResourceStructure.getSdcCsarHelper());
+ assertThat(toscaResourceStructure.getServiceMetadata(), sameBeanAs(new Metadata(new HashMap<>())));
+ assertThat(toscaResourceStructure.getCatalogService(), sameBeanAs(new Service()));
+ assertThat(toscaResourceStructure.getNetworkTypes(), sameBeanAs(new ArrayList<>()));
+ assertThat(toscaResourceStructure.getVfTypes(), sameBeanAs(new ArrayList<>()));
+ assertThat(toscaResourceStructure.getCatalogResourceCustomization(),
+ sameBeanAs(new AllottedResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogNetworkResourceCustomization(),
+ sameBeanAs(new NetworkResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogNetworkResource(), sameBeanAs(new NetworkResource()));
+ assertThat(toscaResourceStructure.getCatalogVfModule(), sameBeanAs(new VfModule()));
+ assertThat(toscaResourceStructure.getVnfResourceCustomization(), sameBeanAs(new VnfResourceCustomization()));
+ assertThat(toscaResourceStructure.getVfModuleCustomization(), sameBeanAs(new VfModuleCustomization()));
+ assertThat(toscaResourceStructure.getAllottedResource(), sameBeanAs(new AllottedResource()));
+ assertThat(toscaResourceStructure.getAllottedResourceCustomization(),
+ sameBeanAs(new AllottedResourceCustomization()));
+ assertThat(toscaResourceStructure.getCatalogTempNetworkHeatTemplateLookup(),
+ sameBeanAs(new TempNetworkHeatTemplateLookup()));
+ assertEquals("heatFilesUUID", toscaResourceStructure.getHeatFilesUUID());
+ assertEquals(artifactInfo, toscaResourceStructure.getToscaArtifact());
+ assertThat(toscaResourceStructure.getToscaCsar(), sameBeanAs(new ToscaCsar()));
+ assertEquals("volHeatTemplateUUID", toscaResourceStructure.getVolHeatTemplateUUID());
+ assertEquals("envHeatTemplateUUID", toscaResourceStructure.getEnvHeatTemplateUUID());
+ assertEquals("serviceVersion", toscaResourceStructure.getServiceVersion());
+ assertEquals("workloadPerformance", toscaResourceStructure.getWorkloadPerformance());
+ assertThat(toscaResourceStructure.getVfModule(), sameBeanAs(new VfModule()));
+ assertThat(toscaResourceStructure.getTempNetworkHeatTemplateLookup(),
+ sameBeanAs(new TempNetworkHeatTemplateLookup()));
+ assertEquals(true, toscaResourceStructure.isDeployedSuccessfully());
+ }
+
+ @Test
+ public void updateResourceStructureExceptionTest() throws Exception {
+ expectedException.expect(ASDCDownloadException.class);
+
+ artifactInfo = mock(ArtifactInfoImpl.class);
+ toscaResourceStructure = new ToscaResourceStructure();
+
+ doReturn("artifactName").when(artifactInfo).getArtifactName();
- doReturn("artifactName").when(artifactInfo).getArtifactName();
-
- toscaResourceStructure.updateResourceStructure(artifactInfo);
- }
+ toscaResourceStructure.updateResourceStructure(artifactInfo);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
index e780a259ea..6efb04fc35 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/bpmn/BpmnInstallerTest.java
@@ -32,7 +32,6 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
@@ -77,27 +76,26 @@ public class BpmnInstallerTest {
public static void cleanup() {
System.clearProperty("mso.config.path");
}
-
+
@Test
public void buildMimeMultiPart_Test() throws Exception {
- Path tempFilePath = Paths.get(tempDirectoryPath.toAbsolutePath().toString(), "TestBB.bpmn");
- Files.createFile(tempFilePath);
- HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn");
- String mimeMultipartBodyFilePath = "src/test/resources" + "/mime-multipart-body.txt";
-
- File mimeMultipartBody = new File(mimeMultipartBodyFilePath);
- InputStream expectedContent = new FileInputStream(mimeMultipartBody);
-
- assertThat(IOUtils.contentEquals(expectedContent, entity.getContent()));
-
- IOUtils.closeQuietly(expectedContent);
+ Path tempFilePath = Paths.get(tempDirectoryPath.toAbsolutePath().toString(), "TestBB.bpmn");
+ Files.createFile(tempFilePath);
+ HttpEntity entity = bpmnInstaller.buildMimeMultipart("TestBB.bpmn");
+ String mimeMultipartBodyFilePath = "src/test/resources" + "/mime-multipart-body.txt";
+
+ File mimeMultipartBody = new File(mimeMultipartBodyFilePath);
+ InputStream expectedContent = new FileInputStream(mimeMultipartBody);
+
+ assertThat(IOUtils.contentEquals(expectedContent, entity.getContent()));
+
+ IOUtils.closeQuietly(expectedContent);
}
@Test
public void installBpmn_Test() throws Exception {
BpmnInstaller bpmnInstallerSpy = spy(bpmnInstaller);
- HttpResponse response = new BasicHttpResponse(
- new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
+ HttpResponse response = new BasicHttpResponse(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, ""));
HttpClient httpClient = mock(HttpClient.class);
doReturn(response).when(httpClient).execute(any(HttpPost.class));
bpmnInstallerSpy.installBpmn(TEST_CSAR);
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
index bc9275bb51..844adeede2 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInputTest.java
@@ -33,12 +33,10 @@ import org.onap.sdc.toscaparser.api.parameters.Input;
import org.onap.so.asdc.client.exceptions.ArtifactInstallerException;
import org.onap.so.asdc.installer.ToscaResourceStructure;
import org.onap.so.db.catalog.beans.Service;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
index e4eb09782a..99833da3a3 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/installer/heat/ToscaResourceInstallerTest.java
@@ -30,11 +30,9 @@ import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
-
import org.hibernate.exception.LockAcquisitionException;
import org.junit.Before;
import org.junit.Rule;
@@ -69,310 +67,319 @@ import org.onap.so.db.request.data.repository.WatchdogComponentDistributionStatu
import org.springframework.beans.factory.annotation.Autowired;
public class ToscaResourceInstallerTest extends BaseTest {
- @Autowired
- private ToscaResourceInstaller toscaInstaller;
- @Autowired
- private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
- @Autowired
- private AllottedResourceRepository allottedRepo;
- @Autowired
- private AllottedResourceCustomizationRepository allottedCustomizationRepo;
- @Autowired
- private ServiceRepository serviceRepo;
- @Mock
- private SdcCsarHelperImpl sdcCsarHelper;
- @Mock
- private Metadata metadata;
- @Mock
- private ArtifactInfoImpl artifactInfo;
- @Mock
- private List<Group> vfGroups;
- @Mock
- private IResourceInstance resourceInstance;
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Mock
- private NodeTemplate nodeTemplate;
- @Mock
- private ToscaResourceStructure toscaResourceStructure;
- @Mock
- private ServiceProxyResourceCustomization spResourceCustomization;
- @Mock
- private ISdcCsarHelper csarHelper;
- @Mock
- private StatefulEntityType entityType;
-
- private NotificationDataImpl notificationData;
- private JsonStatusData statusData;
- private static final String MSO = "SO";
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
-
- notificationData = new NotificationDataImpl();
- statusData = new JsonStatusData();
- }
-
- @Test
- public void isResourceAlreadyDeployedTest() throws Exception {
- notificationData.setServiceName("serviceName");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setDistributionID("testStatusSuccessTosca");
-
- WatchdogComponentDistributionStatus expectedComponentDistributionStatus =
- new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
- expectedComponentDistributionStatus.setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
-
- doReturn(true).when(vfResourceStructure).isDeployedSuccessfully();
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
- doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
- doReturn("resourceName").when(resourceInstance).getResourceName();
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
-
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
-
- verify(vfResourceStructure, times(3)).getResourceInstance();
- verify(vfResourceStructure, times(5)).getNotification();
- assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedComponentDistributionStatus)
- .ignoring("createTime")
- .ignoring("modifyTime"));
- }
-
- @Test
- public void isResourceAlreadyDeployedFalseTest() throws Exception {
- notificationData.setServiceName("serviceName");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setDistributionID("testStatusSuccess");
-
- doThrow(RuntimeException.class).when(vfResourceStructure).isDeployedSuccessfully();
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
- doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
- doReturn("resourceName").when(resourceInstance).getResourceName();
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
-
- verify(vfResourceStructure, times(3)).getResourceInstance();
- verify(vfResourceStructure, times(4)).getNotification();
- }
-
- @Test
- public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
- expectedException.expect(ArtifactInstallerException.class);
-
- toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
- }
-
- @Test
- public void installTheComponentStatusTest() throws Exception {
- String distributionId = "testStatusSuccessTosca";
- String componentName = "testComponentName";
-
- statusData = spy(JsonStatusData.class);
- doReturn(distributionId).when(statusData).getDistributionID();
- doReturn(componentName).when(statusData).getComponentName();
-
- WatchdogComponentDistributionStatus expectedWatchdogComponentDistributionStatus =
- new WatchdogComponentDistributionStatus(distributionId, componentName);
- expectedWatchdogComponentDistributionStatus.setComponentDistributionStatus(statusData.getStatus().toString());
-
- WatchdogComponentDistributionStatus cdStatus = new WatchdogComponentDistributionStatus(statusData.getDistributionID(),
- statusData.getComponentName());
-
- toscaInstaller.installTheComponentStatus(statusData);
-
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId("testStatusSuccessTosca"), statusData.getComponentName());
-
- assertEquals(statusData.getDistributionID(), cdStatus.getDistributionId());
- assertEquals(statusData.getComponentName(), cdStatus.getComponentName());
- assertThat(actualWatchdogComponentDistributionStatus, sameBeanAs(expectedWatchdogComponentDistributionStatus)
- .ignoring("createTime")
- .ignoring("modifyTime"));
- }
-
- @Test
- public void installTheComponentStatusExceptionTest() throws ArtifactInstallerException {
- expectedException.expect(ArtifactInstallerException.class);
-
- statusData = spy(JsonStatusData.class);
- doReturn(null).when(statusData).getStatus();
-
- toscaInstaller.installTheComponentStatus(statusData);
- }
-
- @Test
- public void installTheResourceExceptionTest() throws Exception {
- expectedException.expect(ArtifactInstallerException.class);
-
- notificationData.setDistributionID("testStatusFailureTosca");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
-
- toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
- }
-
- @Test
- public void installTheResourceDBExceptionTest() throws Exception {
- notificationData.setDistributionID("testStatusSuccessTosca");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- doReturn(notificationData).when(vfResourceStructure).getNotification();
- doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
- doThrow(LockAcquisitionException.class).when(toscaResourceStruct).getToscaArtifact();
-
- toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
- }
-
- @Test
- public void verifyTheFilePrefixInStringTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = "testfile.txt";
- String expectedFileBody = "abcabcabctestfile.txtabcbabacbcabc";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(expectedFileBody, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringNullBodyTest() {
- String body = null;
- String filenameToVerify = "testfile.txt";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringEmptyBodyTest() {
- String body = "";
- String filenameToVerify = "testfile.txt";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringNullFilenameTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = null;
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- @Test
- public void verifyTheFilePrefixInStringEmptyFilenameTest() {
- String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
- String filenameToVerify = "";
-
- String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
-
- assertEquals(body, newFileBody);
- }
-
- private WatchdogComponentDistributionStatus getWatchdogCDStatusWithName(List<WatchdogComponentDistributionStatus> watchdogComponentDistributionStatuses, String componentName) {
- WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = new WatchdogComponentDistributionStatus();
- for(WatchdogComponentDistributionStatus watchdogComponentDistributionStatus : watchdogComponentDistributionStatuses) {
- if(componentName.equals(watchdogComponentDistributionStatus.getComponentName())) {
- actualWatchdogComponentDistributionStatus = watchdogComponentDistributionStatus;
- break;
- }
- }
- return actualWatchdogComponentDistributionStatus;
- }
-
-
-
-
- private void prepareConfigurationResource() {
- doReturn(metadata).when(nodeTemplate).getMetaData();
- doReturn(MockConstants.TEMPLATE_TYPE).when(nodeTemplate).getType();
-
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- doReturn(MockConstants.MODEL_INVARIANT_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
- doReturn(MockConstants.MODEL_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
- doReturn(MockConstants.MODEL_VERSION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
- doReturn(MockConstants.MODEL_DESCRIPTION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
- }
-
- @Test
- public void getConfigurationResourceTest() {
- prepareConfigurationResource();
-
- ConfigurationResource configResource=toscaInstaller.getConfigurationResource(nodeTemplate);
-
- assertNotNull(configResource);
- assertEquals(MockConstants.MODEL_NAME, configResource.getModelName());
- assertEquals(MockConstants.MODEL_INVARIANT_UUID, configResource.getModelInvariantUUID());
- assertEquals(MockConstants.MODEL_UUID, configResource.getModelUUID());
- assertEquals(MockConstants.MODEL_VERSION, configResource.getModelVersion());
- assertEquals(MockConstants.MODEL_DESCRIPTION, configResource.getDescription());
- assertEquals(MockConstants.TEMPLATE_TYPE, nodeTemplate.getType());
- }
-
- private void prepareConfigurationResourceCustomization() {
- prepareConfigurationResource();
- doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
- doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFROLE);
- doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate, SdcPropertyNames.PROPERTY_NAME_NFTYPE);
- doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(spResourceCustomization).getModelCustomizationUUID();
- }
-
-
- @Test
- public void getConfigurationResourceCustomizationTest() {
- prepareConfigurationResourceCustomization();
-
- ConfigurationResourceCustomization configurationResourceCustomization = toscaInstaller.getConfigurationResourceCustomization(
- nodeTemplate, toscaResourceStructure, spResourceCustomization);
- assertNotNull(configurationResourceCustomization);
- assertNotNull(configurationResourceCustomization.getConfigurationResource());
- assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID, configurationResourceCustomization.getServiceProxyResourceCustomizationUUID());
- }
-
- @Test
- public void getVnrNodeTemplateTest() {
- prepareConfigurationResourceCustomization();
- List<NodeTemplate> nodeTemplateList = new ArrayList<>();
- doReturn(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR).when(entityType).getType();
- doReturn(entityType).when(nodeTemplate).getTypeDefinition();
- nodeTemplateList.add(nodeTemplate);
- Optional<ConfigurationResourceCustomization> vnrResourceCustomization=
- toscaInstaller.getVnrNodeTemplate(nodeTemplateList, toscaResourceStructure, spResourceCustomization);
- assertTrue(vnrResourceCustomization.isPresent());
- assertEquals(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR, entityType.getType());
- }
-
- class MockConstants{
- public final static String MODEL_NAME = "VLAN Network Receptor Configuration";
- public final static String MODEL_INVARIANT_UUID = "1608eef4-de53-4334-a8d2-ba79cab4bde0";
- public final static String MODEL_UUID = "212ca27b-554c-474c-96b9-ddc2f1b1ddba";
- public final static String MODEL_VERSION = "30.0";
- public final static String MODEL_DESCRIPTION = "VLAN network receptor configuration object";
- public final static String MODEL_CUSTOMIZATIONUUID = "2db953e8-679d-437b-bff7-cb262638a8cd";
- public final static String TEMPLATE_TYPE = "org.openecomp.nodes.VLANNetworkReceptor";
- public final static String TEMPLATE_NAME = "VLAN Network Receptor Configuration 0";
-
- }
+ @Autowired
+ private ToscaResourceInstaller toscaInstaller;
+ @Autowired
+ private WatchdogComponentDistributionStatusRepository watchdogCDStatusRepository;
+ @Autowired
+ private AllottedResourceRepository allottedRepo;
+ @Autowired
+ private AllottedResourceCustomizationRepository allottedCustomizationRepo;
+ @Autowired
+ private ServiceRepository serviceRepo;
+ @Mock
+ private SdcCsarHelperImpl sdcCsarHelper;
+ @Mock
+ private Metadata metadata;
+ @Mock
+ private ArtifactInfoImpl artifactInfo;
+ @Mock
+ private List<Group> vfGroups;
+ @Mock
+ private IResourceInstance resourceInstance;
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+ @Mock
+ private NodeTemplate nodeTemplate;
+ @Mock
+ private ToscaResourceStructure toscaResourceStructure;
+ @Mock
+ private ServiceProxyResourceCustomization spResourceCustomization;
+ @Mock
+ private ISdcCsarHelper csarHelper;
+ @Mock
+ private StatefulEntityType entityType;
+
+ private NotificationDataImpl notificationData;
+ private JsonStatusData statusData;
+ private static final String MSO = "SO";
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+
+ notificationData = new NotificationDataImpl();
+ statusData = new JsonStatusData();
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedTest() throws Exception {
+ notificationData.setServiceName("serviceName");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setDistributionID("testStatusSuccessTosca");
+
+ WatchdogComponentDistributionStatus expectedComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus(notificationData.getDistributionID(), MSO);
+ expectedComponentDistributionStatus
+ .setComponentDistributionStatus(DistributionStatusEnum.COMPONENT_DONE_OK.name());
+
+ doReturn(true).when(vfResourceStructure).isDeployedSuccessfully();
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
+ doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
+ doReturn("resourceName").when(resourceInstance).getResourceName();
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus = getWatchdogCDStatusWithName(
+ watchdogCDStatusRepository.findByDistributionId(notificationData.getDistributionID()), MSO);
+
+ verify(vfResourceStructure, times(3)).getResourceInstance();
+ verify(vfResourceStructure, times(5)).getNotification();
+ assertThat(actualWatchdogComponentDistributionStatus,
+ sameBeanAs(expectedComponentDistributionStatus).ignoring("createTime").ignoring("modifyTime"));
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedFalseTest() throws Exception {
+ notificationData.setServiceName("serviceName");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setDistributionID("testStatusSuccess");
+
+ doThrow(RuntimeException.class).when(vfResourceStructure).isDeployedSuccessfully();
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doReturn("resourceInstanceName").when(resourceInstance).getResourceInstanceName();
+ doReturn("resourceCustomizationUUID").when(resourceInstance).getResourceCustomizationUUID();
+ doReturn("resourceName").when(resourceInstance).getResourceName();
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+
+ verify(vfResourceStructure, times(3)).getResourceInstance();
+ verify(vfResourceStructure, times(4)).getNotification();
+ }
+
+ @Test
+ public void isResourceAlreadyDeployedExceptionTest() throws ArtifactInstallerException {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ toscaInstaller.isResourceAlreadyDeployed(vfResourceStructure);
+ }
+
+ @Test
+ public void installTheComponentStatusTest() throws Exception {
+ String distributionId = "testStatusSuccessTosca";
+ String componentName = "testComponentName";
+
+ statusData = spy(JsonStatusData.class);
+ doReturn(distributionId).when(statusData).getDistributionID();
+ doReturn(componentName).when(statusData).getComponentName();
+
+ WatchdogComponentDistributionStatus expectedWatchdogComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus(distributionId, componentName);
+ expectedWatchdogComponentDistributionStatus.setComponentDistributionStatus(statusData.getStatus().toString());
+
+ WatchdogComponentDistributionStatus cdStatus =
+ new WatchdogComponentDistributionStatus(statusData.getDistributionID(), statusData.getComponentName());
+
+ toscaInstaller.installTheComponentStatus(statusData);
+
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus =
+ getWatchdogCDStatusWithName(watchdogCDStatusRepository.findByDistributionId("testStatusSuccessTosca"),
+ statusData.getComponentName());
+
+ assertEquals(statusData.getDistributionID(), cdStatus.getDistributionId());
+ assertEquals(statusData.getComponentName(), cdStatus.getComponentName());
+ assertThat(actualWatchdogComponentDistributionStatus,
+ sameBeanAs(expectedWatchdogComponentDistributionStatus).ignoring("createTime").ignoring("modifyTime"));
+ }
+
+ @Test
+ public void installTheComponentStatusExceptionTest() throws ArtifactInstallerException {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ statusData = spy(JsonStatusData.class);
+ doReturn(null).when(statusData).getStatus();
+
+ toscaInstaller.installTheComponentStatus(statusData);
+ }
+
+ @Test
+ public void installTheResourceExceptionTest() throws Exception {
+ expectedException.expect(ArtifactInstallerException.class);
+
+ notificationData.setDistributionID("testStatusFailureTosca");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+
+ toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
+ }
+
+ @Test
+ public void installTheResourceDBExceptionTest() throws Exception {
+ notificationData.setDistributionID("testStatusSuccessTosca");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ doReturn(notificationData).when(vfResourceStructure).getNotification();
+ doReturn(resourceInstance).when(vfResourceStructure).getResourceInstance();
+ doThrow(LockAcquisitionException.class).when(toscaResourceStruct).getToscaArtifact();
+
+ toscaInstaller.installTheResource(toscaResourceStruct, vfResourceStructure);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = "testfile.txt";
+ String expectedFileBody = "abcabcabctestfile.txtabcbabacbcabc";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(expectedFileBody, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringNullBodyTest() {
+ String body = null;
+ String filenameToVerify = "testfile.txt";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringEmptyBodyTest() {
+ String body = "";
+ String filenameToVerify = "testfile.txt";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringNullFilenameTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = null;
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ @Test
+ public void verifyTheFilePrefixInStringEmptyFilenameTest() {
+ String body = "abcabcabcfile:///testfile.txtabcbabacbcabc";
+ String filenameToVerify = "";
+
+ String newFileBody = toscaInstaller.verifyTheFilePrefixInString(body, filenameToVerify);
+
+ assertEquals(body, newFileBody);
+ }
+
+ private WatchdogComponentDistributionStatus getWatchdogCDStatusWithName(
+ List<WatchdogComponentDistributionStatus> watchdogComponentDistributionStatuses, String componentName) {
+ WatchdogComponentDistributionStatus actualWatchdogComponentDistributionStatus =
+ new WatchdogComponentDistributionStatus();
+ for (WatchdogComponentDistributionStatus watchdogComponentDistributionStatus : watchdogComponentDistributionStatuses) {
+ if (componentName.equals(watchdogComponentDistributionStatus.getComponentName())) {
+ actualWatchdogComponentDistributionStatus = watchdogComponentDistributionStatus;
+ break;
+ }
+ }
+ return actualWatchdogComponentDistributionStatus;
+ }
+
+
+
+ private void prepareConfigurationResource() {
+ doReturn(metadata).when(nodeTemplate).getMetaData();
+ doReturn(MockConstants.TEMPLATE_TYPE).when(nodeTemplate).getType();
+
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ doReturn(MockConstants.MODEL_INVARIANT_UUID).when(metadata)
+ .getValue(SdcPropertyNames.PROPERTY_NAME_INVARIANTUUID);
+ doReturn(MockConstants.MODEL_UUID).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_UUID);
+ doReturn(MockConstants.MODEL_VERSION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_VERSION);
+ doReturn(MockConstants.MODEL_DESCRIPTION).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_DESCRIPTION);
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ doReturn(MockConstants.MODEL_NAME).when(metadata).getValue(SdcPropertyNames.PROPERTY_NAME_NAME);
+ }
+
+ @Test
+ public void getConfigurationResourceTest() {
+ prepareConfigurationResource();
+
+ ConfigurationResource configResource = toscaInstaller.getConfigurationResource(nodeTemplate);
+
+ assertNotNull(configResource);
+ assertEquals(MockConstants.MODEL_NAME, configResource.getModelName());
+ assertEquals(MockConstants.MODEL_INVARIANT_UUID, configResource.getModelInvariantUUID());
+ assertEquals(MockConstants.MODEL_UUID, configResource.getModelUUID());
+ assertEquals(MockConstants.MODEL_VERSION, configResource.getModelVersion());
+ assertEquals(MockConstants.MODEL_DESCRIPTION, configResource.getDescription());
+ assertEquals(MockConstants.TEMPLATE_TYPE, nodeTemplate.getType());
+ }
+
+ private void prepareConfigurationResourceCustomization() {
+ prepareConfigurationResource();
+ doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(metadata)
+ .getValue(SdcPropertyNames.PROPERTY_NAME_CUSTOMIZATIONUUID);
+ doReturn(csarHelper).when(toscaResourceStructure).getSdcCsarHelper();
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFFUNCTION);
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFROLE);
+ doReturn(null).when(csarHelper).getNodeTemplatePropertyLeafValue(nodeTemplate,
+ SdcPropertyNames.PROPERTY_NAME_NFTYPE);
+ doReturn(MockConstants.MODEL_CUSTOMIZATIONUUID).when(spResourceCustomization).getModelCustomizationUUID();
+ }
+
+
+ @Test
+ public void getConfigurationResourceCustomizationTest() {
+ prepareConfigurationResourceCustomization();
+
+ ConfigurationResourceCustomization configurationResourceCustomization = toscaInstaller
+ .getConfigurationResourceCustomization(nodeTemplate, toscaResourceStructure, spResourceCustomization);
+ assertNotNull(configurationResourceCustomization);
+ assertNotNull(configurationResourceCustomization.getConfigurationResource());
+ assertEquals(MockConstants.MODEL_CUSTOMIZATIONUUID,
+ configurationResourceCustomization.getServiceProxyResourceCustomizationUUID());
+ }
+
+ @Test
+ public void getVnrNodeTemplateTest() {
+ prepareConfigurationResourceCustomization();
+ List<NodeTemplate> nodeTemplateList = new ArrayList<>();
+ doReturn(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR).when(entityType).getType();
+ doReturn(entityType).when(nodeTemplate).getTypeDefinition();
+ nodeTemplateList.add(nodeTemplate);
+ Optional<ConfigurationResourceCustomization> vnrResourceCustomization =
+ toscaInstaller.getVnrNodeTemplate(nodeTemplateList, toscaResourceStructure, spResourceCustomization);
+ assertTrue(vnrResourceCustomization.isPresent());
+ assertEquals(ToscaResourceInstaller.VLAN_NETWORK_RECEPTOR, entityType.getType());
+ }
+
+ class MockConstants {
+ public final static String MODEL_NAME = "VLAN Network Receptor Configuration";
+ public final static String MODEL_INVARIANT_UUID = "1608eef4-de53-4334-a8d2-ba79cab4bde0";
+ public final static String MODEL_UUID = "212ca27b-554c-474c-96b9-ddc2f1b1ddba";
+ public final static String MODEL_VERSION = "30.0";
+ public final static String MODEL_DESCRIPTION = "VLAN network receptor configuration object";
+ public final static String MODEL_CUSTOMIZATIONUUID = "2db953e8-679d-437b-bff7-cb262638a8cd";
+ public final static String TEMPLATE_TYPE = "org.openecomp.nodes.VLANNetworkReceptor";
+ public final static String TEMPLATE_NAME = "VLAN Network Receptor Configuration 0";
+
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
index a20f6de579..9aad96cbc4 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/AaiClientPropertiesImplTest.java
@@ -21,38 +21,37 @@
package org.onap.so.asdc.tenantIsolation;
import static org.junit.Assert.assertEquals;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.so.asdc.BaseTest;
import org.onap.so.client.aai.AAIVersion;
public class AaiClientPropertiesImplTest extends BaseTest {
-
- private static final String SYSTEM_NAME = "MSO";
- private static final String LOCAL_HOST = "http://localhost:";
-
- @BeforeClass
- public static void setup() throws Exception {
- System.setProperty("mso.config.path", "src/test/resources");
- }
-
- @Test
- public void getEndpointTest() throws Exception {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- String aaiEndpoint = aaiClientPropertiesImpl.getEndpoint().toString();
- assertEquals(LOCAL_HOST + wireMockPort, aaiEndpoint);
- }
-
- @Test
- public void getSystemNameTest() {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- assertEquals(SYSTEM_NAME, aaiClientPropertiesImpl.getSystemName());
- }
-
- @Test
- public void getDefaultVersionTest() {
- AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
- assertEquals(AAIVersion.LATEST, aaiClientPropertiesImpl.getDefaultVersion());
- }
+
+ private static final String SYSTEM_NAME = "MSO";
+ private static final String LOCAL_HOST = "http://localhost:";
+
+ @BeforeClass
+ public static void setup() throws Exception {
+ System.setProperty("mso.config.path", "src/test/resources");
+ }
+
+ @Test
+ public void getEndpointTest() throws Exception {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ String aaiEndpoint = aaiClientPropertiesImpl.getEndpoint().toString();
+ assertEquals(LOCAL_HOST + wireMockPort, aaiEndpoint);
+ }
+
+ @Test
+ public void getSystemNameTest() {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ assertEquals(SYSTEM_NAME, aaiClientPropertiesImpl.getSystemName());
+ }
+
+ @Test
+ public void getDefaultVersionTest() {
+ AaiClientPropertiesImpl aaiClientPropertiesImpl = new AaiClientPropertiesImpl();
+ assertEquals(AAIVersion.LATEST, aaiClientPropertiesImpl.getDefaultVersion());
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
index cfce0f6a17..9ef41c7cbf 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/tenantIsolation/WatchdogDistributionTest.java
@@ -27,9 +27,7 @@ import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-
import java.util.HashMap;
-
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -43,99 +41,100 @@ import org.onap.so.db.catalog.beans.Service;
import org.springframework.beans.factory.annotation.Autowired;
public class WatchdogDistributionTest extends BaseTest {
- @Autowired
- private WatchdogDistribution watchdogDistribution;
-
- @Mock
- private AAIResourcesClient aaiResourceClient;
-
- private static final String SUCCESS_TEST = "watchdogTestStatusSuccess";
- private static final String FAILURE_TEST = "watchdogTestStatusFailure";
- private static final String TIMEOUT_TEST = "watchdogTestStatusTimeout";
- private static final String INCOMPLETE_TEST = "watchdogTestStatusIncomplete";
- private static final String EXCEPTION_TEST = "watchdogTestStatusException";
- private static final String NULL_TEST = "watchdogTestStatusNull";
-
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void before() {
- MockitoAnnotations.initMocks(this);
- }
-
- @Test
- public void getOverallDistributionStatusTimeoutTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(TIMEOUT_TEST);
- assertEquals(DistributionStatus.TIMEOUT.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusSuccessTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(SUCCESS_TEST);
- assertEquals(DistributionStatus.SUCCESS.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusFailureTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(FAILURE_TEST);
- assertEquals(DistributionStatus.FAILURE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusIncompleteTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus(INCOMPLETE_TEST);
- assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusInvalidComponentExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.getOverallDistributionStatus(EXCEPTION_TEST);
- }
-
- @Test
- public void getOverallDistributionStatusNewStatusTest() throws Exception {
- String status = watchdogDistribution.getOverallDistributionStatus("newDistrubutionStatus");
- assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
- }
-
- @Test
- public void getOverallDistributionStatusExceptionTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.getOverallDistributionStatus(null);
- }
-
- @Test
- public void executePatchAAITest() throws Exception {
- Service service = new Service();
- service.setModelInvariantUUID("9647dfc4-2083-11e7-93ae-92361f002671");
-
- doReturn(aaiResourceClient).when(watchdogDistributionSpy).getAaiClient();
- doNothing().when(aaiResourceClient).update(isA(AAIResourceUri.class), isA(HashMap.class));
-
- watchdogDistribution.executePatchAAI(SUCCESS_TEST, service.getModelInvariantUUID(), DistributionStatus.SUCCESS.toString());
-
- verify(aaiResourceClient, times(1)).update(any(AAIResourceUri.class), any(HashMap.class));
- }
-
- @Test
- public void executePatchAAINullDistrubutionIdTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.executePatchAAI(null, "", DistributionStatus.SUCCESS.toString());
- }
-
- @Test
- public void executePatchAAINullServiceTest() throws Exception {
- expectedException.expect(Exception.class);
- watchdogDistribution.executePatchAAI(NULL_TEST, null, DistributionStatus.SUCCESS.toString());
- }
-
- @Test
- public void getSetAaiClientTest() {
- aaiResourceClient = watchdogDistribution.getAaiClient();
- watchdogDistribution.setAaiClient(aaiResourceClient);
- AAIResourcesClient aaiResourceClient2 = watchdogDistribution.getAaiClient();
- assertEquals(aaiResourceClient, aaiResourceClient2);
- }
+ @Autowired
+ private WatchdogDistribution watchdogDistribution;
+
+ @Mock
+ private AAIResourcesClient aaiResourceClient;
+
+ private static final String SUCCESS_TEST = "watchdogTestStatusSuccess";
+ private static final String FAILURE_TEST = "watchdogTestStatusFailure";
+ private static final String TIMEOUT_TEST = "watchdogTestStatusTimeout";
+ private static final String INCOMPLETE_TEST = "watchdogTestStatusIncomplete";
+ private static final String EXCEPTION_TEST = "watchdogTestStatusException";
+ private static final String NULL_TEST = "watchdogTestStatusNull";
+
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
+ @Before
+ public void before() {
+ MockitoAnnotations.initMocks(this);
+ }
+
+ @Test
+ public void getOverallDistributionStatusTimeoutTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(TIMEOUT_TEST);
+ assertEquals(DistributionStatus.TIMEOUT.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusSuccessTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(SUCCESS_TEST);
+ assertEquals(DistributionStatus.SUCCESS.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusFailureTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(FAILURE_TEST);
+ assertEquals(DistributionStatus.FAILURE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusIncompleteTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus(INCOMPLETE_TEST);
+ assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusInvalidComponentExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.getOverallDistributionStatus(EXCEPTION_TEST);
+ }
+
+ @Test
+ public void getOverallDistributionStatusNewStatusTest() throws Exception {
+ String status = watchdogDistribution.getOverallDistributionStatus("newDistrubutionStatus");
+ assertEquals(DistributionStatus.INCOMPLETE.toString(), status);
+ }
+
+ @Test
+ public void getOverallDistributionStatusExceptionTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.getOverallDistributionStatus(null);
+ }
+
+ @Test
+ public void executePatchAAITest() throws Exception {
+ Service service = new Service();
+ service.setModelInvariantUUID("9647dfc4-2083-11e7-93ae-92361f002671");
+
+ doReturn(aaiResourceClient).when(watchdogDistributionSpy).getAaiClient();
+ doNothing().when(aaiResourceClient).update(isA(AAIResourceUri.class), isA(HashMap.class));
+
+ watchdogDistribution.executePatchAAI(SUCCESS_TEST, service.getModelInvariantUUID(),
+ DistributionStatus.SUCCESS.toString());
+
+ verify(aaiResourceClient, times(1)).update(any(AAIResourceUri.class), any(HashMap.class));
+ }
+
+ @Test
+ public void executePatchAAINullDistrubutionIdTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.executePatchAAI(null, "", DistributionStatus.SUCCESS.toString());
+ }
+
+ @Test
+ public void executePatchAAINullServiceTest() throws Exception {
+ expectedException.expect(Exception.class);
+ watchdogDistribution.executePatchAAI(NULL_TEST, null, DistributionStatus.SUCCESS.toString());
+ }
+
+ @Test
+ public void getSetAaiClientTest() {
+ aaiResourceClient = watchdogDistribution.getAaiClient();
+ watchdogDistribution.setAaiClient(aaiResourceClient);
+ AAIResourcesClient aaiResourceClient2 = watchdogDistribution.getAaiClient();
+ assertEquals(aaiResourceClient, aaiResourceClient2);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
index 3abc2e7a62..6fd853915e 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/util/ASDCNotificationLoggingTest.java
@@ -21,10 +21,8 @@
package org.onap.so.asdc.util;
import static org.junit.Assert.assertTrue;
-
import java.util.ArrayList;
import java.util.List;
-
import org.junit.Test;
import org.onap.sdc.api.notification.IArtifactInfo;
import org.onap.sdc.api.notification.INotificationData;
@@ -34,153 +32,153 @@ import org.onap.so.asdc.installer.VfModuleMetaData;
import org.onap.so.asdc.util.ASDCNotificationLogging;
public class ASDCNotificationLoggingTest {
- @Test
- public void dumpASDCNotificationTestForNull() throws Exception {
- INotificationData asdcNotification = iNotificationDataObject();
-
- String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
-
- assertTrue(!result.equalsIgnoreCase("NULL"));
- }
-
- private INotificationData iNotificationDataObject() {
- INotificationData iNotification = new INotificationData() {
-
- @Override
- public String getServiceVersion() {
- return "DistributionID";
- }
-
- @Override
- public String getServiceUUID() {
- return "12343254";
- }
-
- @Override
- public String getServiceName() {
- return "servername";
- }
-
- @Override
- public String getServiceInvariantUUID() {
- return "ServiceInvariantUUID";
- }
-
- @Override
- public String getServiceDescription() {
- return "Description";
- }
-
- @Override
- public List<IArtifactInfo> getServiceArtifacts() {
- return new ArrayList();
- }
-
- @Override
- public List<IResourceInstance> getResources() {
- return new ArrayList();
- }
-
- @Override
- public String getDistributionID() {
- return "23434";
- }
-
- @Override
- public IArtifactInfo getArtifactMetadataByUUID(String arg0) {
- return null;
- }
-
- @Override
- public String getWorkloadContext() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public void setWorkloadContext(String arg0) {
- // TODO Auto-generated method stub
-
- }
- };
- return iNotification;
- }
-
- @Test
- public void dumpASDCNotificationTest() throws Exception {
- INotificationData asdcNotification = iNotificationDataObject();
- String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
-
- assertTrue(!result.equalsIgnoreCase("NULL"));
- }
-
- @Test
- public void dumpVfModuleMetaDataListTest() {
- INotificationData asdcNotification = iNotificationDataObject();
- List<IVfModuleData> list = new ArrayList<>();
- list.add(new VfModuleMetaData());
- String result = null;
- try {
- result = ASDCNotificationLogging.dumpVfModuleMetaDataList(list);
- } catch (Exception e) {
- }
-
- assertTrue(result == null);
-
- }
-
- public IArtifactInfo getIArtifactInfo() {
- return new IArtifactInfo() {
-
- @Override
- public List<IArtifactInfo> getRelatedArtifacts() {
- return null;
- }
-
- @Override
- public IArtifactInfo getGeneratedArtifact() {
- return null;
- }
-
- @Override
- public String getArtifactVersion() {
- return "version";
- }
-
- @Override
- public String getArtifactUUID() {
- return "123";
- }
-
- @Override
- public String getArtifactURL() {
- return "url";
- }
-
- @Override
- public String getArtifactType() {
- return "type";
- }
-
- @Override
- public Integer getArtifactTimeout() {
- return 12;
- }
-
- @Override
- public String getArtifactName() {
- return "name";
- }
-
- @Override
- public String getArtifactDescription() {
- return "desc";
- }
-
- @Override
- public String getArtifactChecksum() {
- return "true";
- }
- };
- }
+ @Test
+ public void dumpASDCNotificationTestForNull() throws Exception {
+ INotificationData asdcNotification = iNotificationDataObject();
+
+ String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
+
+ assertTrue(!result.equalsIgnoreCase("NULL"));
+ }
+
+ private INotificationData iNotificationDataObject() {
+ INotificationData iNotification = new INotificationData() {
+
+ @Override
+ public String getServiceVersion() {
+ return "DistributionID";
+ }
+
+ @Override
+ public String getServiceUUID() {
+ return "12343254";
+ }
+
+ @Override
+ public String getServiceName() {
+ return "servername";
+ }
+
+ @Override
+ public String getServiceInvariantUUID() {
+ return "ServiceInvariantUUID";
+ }
+
+ @Override
+ public String getServiceDescription() {
+ return "Description";
+ }
+
+ @Override
+ public List<IArtifactInfo> getServiceArtifacts() {
+ return new ArrayList();
+ }
+
+ @Override
+ public List<IResourceInstance> getResources() {
+ return new ArrayList();
+ }
+
+ @Override
+ public String getDistributionID() {
+ return "23434";
+ }
+
+ @Override
+ public IArtifactInfo getArtifactMetadataByUUID(String arg0) {
+ return null;
+ }
+
+ @Override
+ public String getWorkloadContext() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setWorkloadContext(String arg0) {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ return iNotification;
+ }
+
+ @Test
+ public void dumpASDCNotificationTest() throws Exception {
+ INotificationData asdcNotification = iNotificationDataObject();
+ String result = ASDCNotificationLogging.dumpASDCNotification(asdcNotification);
+
+ assertTrue(!result.equalsIgnoreCase("NULL"));
+ }
+
+ @Test
+ public void dumpVfModuleMetaDataListTest() {
+ INotificationData asdcNotification = iNotificationDataObject();
+ List<IVfModuleData> list = new ArrayList<>();
+ list.add(new VfModuleMetaData());
+ String result = null;
+ try {
+ result = ASDCNotificationLogging.dumpVfModuleMetaDataList(list);
+ } catch (Exception e) {
+ }
+
+ assertTrue(result == null);
+
+ }
+
+ public IArtifactInfo getIArtifactInfo() {
+ return new IArtifactInfo() {
+
+ @Override
+ public List<IArtifactInfo> getRelatedArtifacts() {
+ return null;
+ }
+
+ @Override
+ public IArtifactInfo getGeneratedArtifact() {
+ return null;
+ }
+
+ @Override
+ public String getArtifactVersion() {
+ return "version";
+ }
+
+ @Override
+ public String getArtifactUUID() {
+ return "123";
+ }
+
+ @Override
+ public String getArtifactURL() {
+ return "url";
+ }
+
+ @Override
+ public String getArtifactType() {
+ return "type";
+ }
+
+ @Override
+ public Integer getArtifactTimeout() {
+ return 12;
+ }
+
+ @Override
+ public String getArtifactName() {
+ return "name";
+ }
+
+ @Override
+ public String getArtifactDescription() {
+ return "desc";
+ }
+
+ @Override
+ public String getArtifactChecksum() {
+ return "true";
+ }
+ };
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java b/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
index 8bd11d9f52..0bdb3a8bab 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/util/NotificationLoggingTest.java
@@ -22,46 +22,45 @@ package org.onap.so.asdc.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
-
import org.junit.Before;
import org.junit.Test;
import org.onap.so.asdc.client.test.emulators.NotificationDataImpl;
public class NotificationLoggingTest {
- private NotificationDataImpl notificationData;
-
- @Before
- public void before() {
- notificationData = new NotificationDataImpl();
- }
-
- @Test
- public void logNotificationTest() {
- notificationData.setDistributionID("distributionID");
- notificationData.setServiceVersion("123456");
- notificationData.setServiceUUID("serviceUUID");
- notificationData.setWorkloadContext("workloadContext");
-
- String response = NotificationLogging.logNotification(notificationData);
+ private NotificationDataImpl notificationData;
+
+ @Before
+ public void before() {
+ notificationData = new NotificationDataImpl();
+ }
+
+ @Test
+ public void logNotificationTest() {
+ notificationData.setDistributionID("distributionID");
+ notificationData.setServiceVersion("123456");
+ notificationData.setServiceUUID("serviceUUID");
+ notificationData.setWorkloadContext("workloadContext");
+
+ String response = NotificationLogging.logNotification(notificationData);
+
+ assertTrue(response.contains("ASDC Notification"));
+ assertTrue(response.contains("ResourcesType not recognized"));
+ assertTrue(response.contains("ServiceNameNULL"));
+ assertTrue(response.contains("ServiceUUIDserviceUUID"));
+ assertTrue(response.contains("ResourcesImplNULL"));
+ assertTrue(response.contains("ServiceArtifactsType not recognized"));
+ assertTrue(response.contains("ServiceDescriptionNULL"));
+ assertTrue(response.contains("DistributionIDdistributionID"));
+ assertTrue(response.contains("ServiceInvariantUUIDNULL"));
+ assertTrue(response.contains("WorkloadContextworkloadContext"));
+ }
+
+ @Test
+ public void logNotificationNullTest() {
+ notificationData = null;
+
+ String response = NotificationLogging.logNotification(notificationData);
- assertTrue(response.contains("ASDC Notification"));
- assertTrue(response.contains("ResourcesType not recognized"));
- assertTrue(response.contains("ServiceNameNULL"));
- assertTrue(response.contains("ServiceUUIDserviceUUID"));
- assertTrue(response.contains("ResourcesImplNULL"));
- assertTrue(response.contains("ServiceArtifactsType not recognized"));
- assertTrue(response.contains("ServiceDescriptionNULL"));
- assertTrue(response.contains("DistributionIDdistributionID"));
- assertTrue(response.contains("ServiceInvariantUUIDNULL"));
- assertTrue(response.contains("WorkloadContextworkloadContext"));
- }
-
- @Test
- public void logNotificationNullTest() {
- notificationData = null;
-
- String response = NotificationLogging.logNotification(notificationData);
-
- assertEquals("NULL", response);
- }
+ assertEquals("NULL", response);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
index 2a77664714..b344f6230a 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingRunner.java
@@ -22,35 +22,31 @@ package org.onap.so.asdc.utils;
import java.nio.file.Files;
import java.nio.file.Paths;
-
import org.antlr.v4.runtime.CharStreams;
import org.antlr.v4.runtime.CommonTokenStream;
import org.antlr.v4.runtime.tree.ParseTree;
-
import com.fasterxml.jackson.databind.JsonNode;
-public class ASDCLoggingRunner
-{
- public static void main( String[] args) throws Exception
- {
+public class ASDCLoggingRunner {
+ public static void main(String[] args) throws Exception {
String content = new String(Files.readAllBytes(Paths.get("src/test/resources/Heat_Nested_Notification.txt")));
ASDCLoggingLexer lexer = new ASDCLoggingLexer(CharStreams.fromString(content));
- CommonTokenStream tokens = new CommonTokenStream(lexer);
+ CommonTokenStream tokens = new CommonTokenStream(lexer);
+
+ ASDCLoggingParser parser = new ASDCLoggingParser(tokens);
+
+ ParseTree tree = parser.doc();
+
+ System.out.println(TreeUtils.printTree(tree, parser)); // print LISP-style tree
+
+ ASDCLoggingVisitorImpl v = new ASDCLoggingVisitorImpl();
- ASDCLoggingParser parser = new ASDCLoggingParser(tokens);
-
- ParseTree tree = parser.doc();
+ JsonNode node = v.visit(tree);
- System.out.println(TreeUtils.printTree(tree, parser)); // print LISP-style tree
-
- ASDCLoggingVisitorImpl v = new ASDCLoggingVisitorImpl();
-
- JsonNode node = v.visit(tree);
-
- System.out.println(node.toString());
+ System.out.println(node.toString());
- }
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
index 51036e2a18..53d163a5bc 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/ASDCLoggingVisitorImpl.java
@@ -22,7 +22,6 @@ package org.onap.so.asdc.utils;
import java.util.ArrayDeque;
import java.util.Deque;
-
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ContainerNode;
@@ -32,73 +31,74 @@ import com.google.common.base.CaseFormat;
public class ASDCLoggingVisitorImpl extends ASDCLoggingBaseVisitor<ContainerNode> {
- private final ObjectMapper mapper = new ObjectMapper();
- private ObjectNode doc;
- private Deque<ContainerNode> nodeStore = new ArrayDeque<>();
-
- @Override
- public ContainerNode visitDoc(ASDCLoggingParser.DocContext ctx) {
- doc = mapper.createObjectNode();
- nodeStore.addFirst(doc);
- this.visitChildren(ctx);
- return doc;
- }
-
- @Override
- public ContainerNode visitValue(ASDCLoggingParser.ValueContext ctx) {
-
- return this.visitChildren(ctx);
-
- }
- @Override
- public ContainerNode visitSimplePair(ASDCLoggingParser.SimplePairContext ctx) {
- ObjectNode node = mapper.createObjectNode();
- ((ObjectNode)nodeStore.peekFirst()).put(this.toLowerCamel(ctx.key().getText()), ctx.keyValue().getText());
-
- return node;
- }
-
- @Override
- public ContainerNode visitComplexPair(ASDCLoggingParser.ComplexPairContext ctx) {
- ContainerNode container = nodeStore.peekFirst();
- if (container.isArray()) {
- ArrayNode array = (ArrayNode) container;
- ObjectNode node = mapper.createObjectNode();
- array.add(node);
- nodeStore.addFirst(node);
- } else {
- nodeStore.addFirst(((ObjectNode)nodeStore.peekFirst()).putObject(this.toLowerCamel(ctx.key().getText())));
- }
- this.visitChildren(ctx);
- return nodeStore.removeFirst();
-
-
- }
-
- @Override
- public ContainerNode visitList(ASDCLoggingParser.ListContext ctx) {
- nodeStore.addFirst(((ObjectNode)nodeStore.peekFirst()).putArray(this.keyMapper(ctx.listName().getText())));
- this.visitChildren(ctx);
- return nodeStore.removeFirst();
- }
-
- private String keyMapper(String key) {
- if ("Service Artifacts List".equals(key)) {
- return "serviceArtifacts";
- } else if ("Resource Instances List".equals(key)) {
- return "resources";
- } else if ("Resource Artifacts List".equals(key)) {
- return "artifacts";
- } else {
- return key;
- }
- }
-
- private String toLowerCamel(String key) {
- String result = key.replaceAll("\\s", "");
- if ("ServiceArtifactsInfo".equals(result)) {
- return "artifactInfo";
- }
- return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, result);
- }
+ private final ObjectMapper mapper = new ObjectMapper();
+ private ObjectNode doc;
+ private Deque<ContainerNode> nodeStore = new ArrayDeque<>();
+
+ @Override
+ public ContainerNode visitDoc(ASDCLoggingParser.DocContext ctx) {
+ doc = mapper.createObjectNode();
+ nodeStore.addFirst(doc);
+ this.visitChildren(ctx);
+ return doc;
+ }
+
+ @Override
+ public ContainerNode visitValue(ASDCLoggingParser.ValueContext ctx) {
+
+ return this.visitChildren(ctx);
+
+ }
+
+ @Override
+ public ContainerNode visitSimplePair(ASDCLoggingParser.SimplePairContext ctx) {
+ ObjectNode node = mapper.createObjectNode();
+ ((ObjectNode) nodeStore.peekFirst()).put(this.toLowerCamel(ctx.key().getText()), ctx.keyValue().getText());
+
+ return node;
+ }
+
+ @Override
+ public ContainerNode visitComplexPair(ASDCLoggingParser.ComplexPairContext ctx) {
+ ContainerNode container = nodeStore.peekFirst();
+ if (container.isArray()) {
+ ArrayNode array = (ArrayNode) container;
+ ObjectNode node = mapper.createObjectNode();
+ array.add(node);
+ nodeStore.addFirst(node);
+ } else {
+ nodeStore.addFirst(((ObjectNode) nodeStore.peekFirst()).putObject(this.toLowerCamel(ctx.key().getText())));
+ }
+ this.visitChildren(ctx);
+ return nodeStore.removeFirst();
+
+
+ }
+
+ @Override
+ public ContainerNode visitList(ASDCLoggingParser.ListContext ctx) {
+ nodeStore.addFirst(((ObjectNode) nodeStore.peekFirst()).putArray(this.keyMapper(ctx.listName().getText())));
+ this.visitChildren(ctx);
+ return nodeStore.removeFirst();
+ }
+
+ private String keyMapper(String key) {
+ if ("Service Artifacts List".equals(key)) {
+ return "serviceArtifacts";
+ } else if ("Resource Instances List".equals(key)) {
+ return "resources";
+ } else if ("Resource Artifacts List".equals(key)) {
+ return "artifacts";
+ } else {
+ return key;
+ }
+ }
+
+ private String toLowerCamel(String key) {
+ String result = key.replaceAll("\\s", "");
+ if ("ServiceArtifactsInfo".equals(result)) {
+ return "artifactInfo";
+ }
+ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, result);
+ }
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
index c4a84c0540..39119c7dca 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreePrinterListener.java
@@ -25,7 +25,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.RuleContext;
@@ -38,7 +37,7 @@ import org.antlr.v4.runtime.tree.Trees;
public class TreePrinterListener implements ParseTreeListener {
private final List<String> ruleNames;
private final StringBuilder builder = new StringBuilder();
- Map<RuleContext,ArrayList<String>> stack = new HashMap<RuleContext,ArrayList<String>>();
+ Map<RuleContext, ArrayList<String>> stack = new HashMap<RuleContext, ArrayList<String>>();
public TreePrinterListener(Parser parser) {
this.ruleNames = Arrays.asList(parser.getRuleNames());
@@ -50,10 +49,10 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void visitTerminal(TerminalNode node) {
- String text = Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false);
- if(text.startsWith(" ") || text.endsWith(" ")){
- text = "'" + text + "'";
- }
+ String text = Utils.escapeWhitespace(Trees.getNodeText(node, ruleNames), false);
+ if (text.startsWith(" ") || text.endsWith(" ")) {
+ text = "'" + text + "'";
+ }
stack.get(node.getParent()).add(text);
}
@@ -64,20 +63,19 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void enterEveryRule(ParserRuleContext ctx) {
- if(!stack.containsKey(ctx.parent)){
- stack.put(ctx.parent, new ArrayList<String>());
- }
- if(!stack.containsKey(ctx)){
- stack.put(ctx, new ArrayList<String>());
- }
+ if (!stack.containsKey(ctx.parent)) {
+ stack.put(ctx.parent, new ArrayList<String>());
+ }
+ if (!stack.containsKey(ctx)) {
+ stack.put(ctx, new ArrayList<String>());
+ }
- final StringBuilder sb = new StringBuilder();
- int ruleIndex = ctx.getRuleIndex();
+ final StringBuilder sb = new StringBuilder();
+ int ruleIndex = ctx.getRuleIndex();
String ruleName;
if (ruleIndex >= 0 && ruleIndex < ruleNames.size()) {
ruleName = ruleNames.get(ruleIndex);
- }
- else {
+ } else {
ruleName = Integer.toString(ruleIndex);
}
sb.append(ruleName);
@@ -86,52 +84,52 @@ public class TreePrinterListener implements ParseTreeListener {
@Override
public void exitEveryRule(ParserRuleContext ctx) {
- ArrayList<String> ruleStack = stack.remove(ctx);
- StringBuilder sb = new StringBuilder();
- boolean brackit =ruleStack.size()>1;
- if(brackit){
- sb.append("(");
- }
- sb.append(ruleStack.get(0));
- for(int i=1; i<ruleStack.size(); i++){
- sb.append(" ");
- sb.append(ruleStack.get(i));
- }
- if(brackit){
- sb.append(")");
- }
- if(sb.length() < 80){
- stack.get(ctx.parent).add(sb.toString());
- }else{
- // Current line is too long, regenerate it using 1 line per item.
- sb.setLength(0);
- if(brackit){
- sb.append("(");
- }
- if(!ruleStack.isEmpty()){
- sb.append(ruleStack.remove(0)).append("\r\n");
- }
- while(!ruleStack.isEmpty()){
- sb.append(indent(ruleStack.remove(0))).append("\r\n");
- }
- if(brackit){
- sb.append(")");
- }
- stack.get(ctx.parent).add(sb.toString());
- }
- if(ctx.parent == null){
- builder.append(sb.toString());
- }
+ ArrayList<String> ruleStack = stack.remove(ctx);
+ StringBuilder sb = new StringBuilder();
+ boolean brackit = ruleStack.size() > 1;
+ if (brackit) {
+ sb.append("(");
+ }
+ sb.append(ruleStack.get(0));
+ for (int i = 1; i < ruleStack.size(); i++) {
+ sb.append(" ");
+ sb.append(ruleStack.get(i));
+ }
+ if (brackit) {
+ sb.append(")");
+ }
+ if (sb.length() < 80) {
+ stack.get(ctx.parent).add(sb.toString());
+ } else {
+ // Current line is too long, regenerate it using 1 line per item.
+ sb.setLength(0);
+ if (brackit) {
+ sb.append("(");
+ }
+ if (!ruleStack.isEmpty()) {
+ sb.append(ruleStack.remove(0)).append("\r\n");
+ }
+ while (!ruleStack.isEmpty()) {
+ sb.append(indent(ruleStack.remove(0))).append("\r\n");
+ }
+ if (brackit) {
+ sb.append(")");
+ }
+ stack.get(ctx.parent).add(sb.toString());
+ }
+ if (ctx.parent == null) {
+ builder.append(sb.toString());
+ }
}
-
- static String indent(String input){
- return " " + input.replaceAll("\r\n(.)","\r\n $1");
+
+ static String indent(String input) {
+ return " " + input.replaceAll("\r\n(.)", "\r\n $1");
}
@Override
public String toString() {
return builder.toString();
}
-
-
+
+
}
diff --git a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
index 8de9f362b7..5a03b91959 100644
--- a/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
+++ b/asdc-controller/src/test/java/org/onap/so/asdc/utils/TreeUtils.java
@@ -21,7 +21,6 @@
package org.onap.so.asdc.utils;
import java.util.Arrays;
-
import org.antlr.v4.runtime.Parser;
import org.antlr.v4.runtime.tree.ParseTree;
import org.antlr.v4.runtime.tree.ParseTreeWalker;
@@ -29,19 +28,20 @@ import org.antlr.v4.runtime.tree.ParseTreeWalker;
public class TreeUtils {
- /**
- * Print the tree, splitting at appropriate points, instead of rendering a single long line.
- * @param parseTree
- * @param parser
- * @return
- */
- public static String printTree(final ParseTree parseTree, final Parser parser){
- final TreePrinterListener listener = new TreePrinterListener(Arrays.asList(parser.getRuleNames()));
+ /**
+ * Print the tree, splitting at appropriate points, instead of rendering a single long line.
+ *
+ * @param parseTree
+ * @param parser
+ * @return
+ */
+ public static String printTree(final ParseTree parseTree, final Parser parser) {
+ final TreePrinterListener listener = new TreePrinterListener(Arrays.asList(parser.getRuleNames()));
ParseTreeWalker.DEFAULT.walk(listener, parseTree);
return listener.toString();
- }
-
- public static String normalizeWhiteSpace(String input){
- return input.replaceAll("\\s+", " ").replaceAll("([^\\w])\\s+", "$1");
+ }
+
+ public static String normalizeWhiteSpace(String input) {
+ return input.replaceAll("\\s+", " ").replaceAll("([^\\w])\\s+", "$1");
}
}