diff options
author | ChrisC <cc697w@intl.att.com> | 2017-01-31 11:40:03 +0100 |
---|---|---|
committer | ChrisC <cc697w@intl.att.com> | 2017-01-31 12:59:33 +0100 |
commit | 025301d08b061482c1f046d562bf017c8cbcfe8d (patch) | |
tree | 68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /asdc-controller | |
parent | 2754ad52f833278a5c925bd788a16d1dce16a598 (diff) |
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d
Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'asdc-controller')
78 files changed, 12647 insertions, 0 deletions
diff --git a/asdc-controller/README b/asdc-controller/README new file mode 100644 index 0000000000..cc342884c8 --- /dev/null +++ b/asdc-controller/README @@ -0,0 +1 @@ +This package contains the Catalog Database hibernate configuration and supporting classes.
diff --git a/asdc-controller/WebContent/WEB-INF/ejb-jar.xml b/asdc-controller/WebContent/WEB-INF/ejb-jar.xml new file mode 100644 index 0000000000..c103a40921 --- /dev/null +++ b/asdc-controller/WebContent/WEB-INF/ejb-jar.xml @@ -0,0 +1,4 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ejb-jar version="3.1" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"> + <display-name>ASDCController</display-name> + </ejb-jar>
\ No newline at end of file diff --git a/asdc-controller/WebContent/WEB-INF/jboss-deployment-structure.xml b/asdc-controller/WebContent/WEB-INF/jboss-deployment-structure.xml new file mode 100644 index 0000000000..9a24bfc509 --- /dev/null +++ b/asdc-controller/WebContent/WEB-INF/jboss-deployment-structure.xml @@ -0,0 +1,17 @@ +<jboss-deployment-structure> + <deployment> + <!-- Exclusions allow you to prevent the server from automatically adding some dependencies --> + <exclusions> + <module name="org.apache.log4j" /> + <module name="org.slf4j" /> + <module name="org.slf4j.impl" /> + </exclusions> + <dependencies> + <module name="org.jboss.jandex" slot="main" /> + <module name="org.javassist" slot="main" /> + <module name="org.antlr" slot="main" /> + <module name="org.dom4j" slot="main" /> + </dependencies> + </deployment> +</jboss-deployment-structure> + diff --git a/asdc-controller/WebContent/WEB-INF/jboss-web.xml b/asdc-controller/WebContent/WEB-INF/jboss-web.xml new file mode 100644 index 0000000000..2a1f26f2c4 --- /dev/null +++ b/asdc-controller/WebContent/WEB-INF/jboss-web.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?>
+
+<jboss-web>
+ <context-root>asdc</context-root>
+ <security-domain>other</security-domain>
+</jboss-web>
\ No newline at end of file diff --git a/asdc-controller/WebContent/WEB-INF/web.xml b/asdc-controller/WebContent/WEB-INF/web.xml new file mode 100644 index 0000000000..a8ccd17fec --- /dev/null +++ b/asdc-controller/WebContent/WEB-INF/web.xml @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
+ <display-name>ASDC Controller</display-name>
+
+
+ <!-- enable the Asynchronous Job Service -->
+ <context-param>
+ <param-name>resteasy.async.job.service.enabled</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>resteasy.jndi.resources</param-name>
+ <param-value>java:module/MsoPropertiesFactory</param-value>
+ </context-param>
+
+ <!-- The next context parameters are all optional.
+ Their default values are shown as example param-values -->
+
+ <!-- How many jobs results can be held in memory at once? -->
+ <context-param>
+ <param-name>resteasy.async.job.service.max.job.results</param-name>
+ <param-value>100</param-value>
+ </context-param>
+
+ <!-- Maximum wait time on a job when a client is querying for it -->
+ <context-param>
+ <param-name>resteasy.async.job.service.max.wait</param-name>
+ <param-value>300000</param-value>
+ </context-param>
+
+ <!-- Thread pool size of background threads that run the job -->
+ <context-param>
+ <param-name>resteasy.async.job.service.thread.pool.size</param-name>
+ <param-value>100</param-value>
+ </context-param>
+
+ <!-- Set the base path for the Job uris -->
+ <context-param>
+ <param-name>resteasy.async.job.service.base.path</param-name>
+ <param-value>/asynch/jobs</param-value>
+ </context-param>
+ <context-param>
+ <param-name>resteasy.scan</param-name>
+ <param-value>true</param-value>
+ </context-param>
+
+ <!--
+ <context-param>
+ <param-name>resteasy.servlet.mapping.prefix</param-name>
+ <param-value>/v1</param-value>
+ </context-param>
+ -->
+ <context-param>
+ <param-name>log.configuration</param-name>
+ <param-value>logback.asdc.xml</param-value>
+ </context-param>
+
+ <context-param>
+ <param-name>mso.configuration</param-name>
+ <param-value>MSO_PROP_ASDC=mso.asdc.json,MSO_PROP_TOPOLOGY=topology.properties</param-value>
+
+ </context-param>
+
+ <context-param>
+ <param-name>resteasy.resources</param-name>
+ <param-value>org.openecomp.mso.logger.MsoLoggingServlet,org.openecomp.mso.asdc.healthcheck.HealthCheckHandler</param-value>
+ </context-param>
+
+ <listener>
+ <listener-class>
+ org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap
+ </listener-class>
+ </listener>
+ <servlet>
+ <servlet-name>asdccontroller-servlet</servlet-name>
+ <servlet-class>
+ org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher
+ </servlet-class>
+ </servlet>
+ <servlet-mapping>
+ <servlet-name>asdccontroller-servlet</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+
+ <filter>
+ <filter-name>LogFilter</filter-name>
+ <filter-class>org.openecomp.mso.logger.LogFilter</filter-class>
+ </filter>
+ <filter-mapping>
+ <filter-name>LogFilter</filter-name>
+ <url-pattern>/*</url-pattern>
+ </filter-mapping>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>SiteStatus</web-resource-name>
+ <description>SiteStatus APIs</description>
+ <url-pattern>/setStatus/*</url-pattern>
+ <http-method>POST</http-method>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>SiteControl-Client</role-name>
+ </auth-constraint>
+ </security-constraint>
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>ApplicationRealm</realm-name>
+ </login-config>
+ <security-role>
+ <role-name>SiteControl-Client</role-name>
+ </security-role>
+</web-app>
\ No newline at end of file diff --git a/asdc-controller/notif.txt b/asdc-controller/notif.txt new file mode 100644 index 0000000000..3472d9a2c2 --- /dev/null +++ b/asdc-controller/notif.txt @@ -0,0 +1,140 @@ +{ + "distributionID" : "5v1234d8-5b6d-42c4-7t54-47v95n58qb7", + “distributionVersion” : “1607”, + "serviceName" : "Nimbus", + “serviceInvariantUUID” : “c66232fe-d7b0-40f0-8e5e-9128e694c28b”, + “serviceVersion” : “2.0”, + "serviceUUID" : "4e0697d8-5b6d-42c4-8c74-46c33d46624c", + "serviceDescription" : "Nimbus service description", + "serviceArtifacts":[ + { + "artifactName" : "vnf_catalog.xml", + "artifactType" : "VNF_CATALOG", + "artifactUUID" :"4e1444d8-5b6d-42c4-8c74-46c55d43425b", + "artifactVersion" : "1" , + "artifactURL" : "/asdc/v1/catalog/services/Nimbus/2.0/artifacts/vnf_catalog.xml" , + "artifactDescription" : "VNF Catalog Artifact" , + "artifactChecksum" : "14e389rnbvq6tf==" + } + ], + "resources":[ + { + "resourceInstanceName" : "PCRF1", + "resourceName" : "PCRF", + "resourceInvariantUUID" : "ff420d27-4585-445a-8a86-a6f64333b337", + "resourceVersion": "1.0", + "resourceUUID" : "4e5555d8-5b6d-42c4-8c74-46c33d8904f", + "resourceType" : "VF", + "artifacts" : [ + { + "artifactName" : "license.xml", + "artifactType" : "VF_LICENSE", + "artifactUUID" :"4e1111d8-5b6d-42c4-8c74-46c12d43424c", + "artifactVersion" : "1" , + "artifactURL" : "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/ PCRF1/artifacts/license.xml" , + "artifactDescription" : "VF License Model Artifact" , + "artifactChecksum" : "14e389rnbvq8vq==" + } + ], + "vfModules": [ + { + "vfModuleModelName": "PCRF-module-0", + "vfModuleModelInvariantUUID" : "7ebcc262-2d4a-4131-bfed-32cb92d251ce", + "vfModuleModelVersion": "1", + "vfModuleModelUUID": "9g6666d8-5b6d-42c4-8c74-46c33d8904f", + "vfModuleModelDescription": "PCRF VF Module", + "isBase": TRUE, + "artifacts": [ + { + "artifactName": "pcrf-base-module.yaml", + "artifactLabel": "PCRF::base::module-0", + "artifactType": "HEAT", + "artifactUUID": "d1dc0ac0-0b07-11e6-b512-3e1d05defe78", + "artifactVersion": "1", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/artifacts/pcrf-base-module.yaml", + "artifactDescription": "PCRF VF Module HEAT base template artifact", + "artifactTimeout": 60, + "artifactChecksum": "dy6389rnbvq8vq==" + }, + { + "artifactName": "pcrf-nested.yaml", + "artifactLabel": "PCRF::nested-1", + "artifactType": "HEAT_NESTED", + "artifactUUID": "4e1111d8-5b6d-42c4-8c74-46c12d43424c", + "artifactVersion": "2", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/artifacts/pcrf-nested.yaml", + "artifactDescription": "PCRF VF Module HEAT nested template artifact", + "artifactChecksum": "76hd389rnbvq8vq==" + }, + { + "artifactName": "pcrf-base-module.env", + "artifactLabel": "PCRF::base::module-0-env", + "artifactType": "HEAT_ENV", + "artifactUUID": "2636916f-aa37-4c79-b3ea-0e68d6e139e6", + "artifactVersion": "3", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/pcrf-base-module.env", + "artifactDescription": "PCRF VF Module HEAT environment artifact", + "generatedFromUUID" : “d1dc0ac0-0b07-11e6-b512-3e1d05defe78”, + "artifactChecksum": "3d6555rnbvq3tq==" + }, + { + "artifactName": "pcrf-getfile.sh", + "artifactLabel": "PCRF::getfile-1", + "artifactType": "HEAT_ARTIFACT", + "artifactUUID": "c1492a80-0b07-11e6-b512-3e1d05defe78", + "artifactVersion": "3", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/artifacts/pcrf-getfile.sh", + "artifactDescription": "HEAT getfile artifact", + "artifactChecksum": "fds3555rnbvq3tq==" + }, + ] + }, + { + "vfModuleModelName": "PCRF-module-0-vol", + "vfModuleModelInvariantUUID" : "7ebcc262-2d4a-4131-cfed-32cb92d25222", + "vfModuleModelVersion": "1", + "vfModuleModelUUID": "9g6446d8-5b6d-42c4-8c74-46c33d89f50", + "vfModuleModelDescription": "PCRF volume VF Module", + "artifacts": [ + { + "artifactName": "pcrf-ppd-pcm-module-volume.yaml", + "artifactLabel": "PCRF::PPD_PCM::module-0-vol", + "artifactType": "HEAT_VOL", + "artifactUUID": "48a0b856-22b9-4362-875c-3c960ee2a336", + "artifactVersion": "1", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/artifacts/pcrf-ppd-pcm-module-volume.yaml", + "artifactDescription": "VF Module HEAT Volume base template artifact", + "artifactTimeout": 60, + "artifactChecksum": "zsc389rnbvq8vq==" + }, + { + "artifactName": "pcrf-ppd-pcm-module-volume.env", + "artifactLabel": "PCRF::PPD_PCM::module-0-vol-env", + "artifactType": "HEAT_VOL_ENV", + "artifactUUID": "3d6eea53-58f1-4434-aabe-1c92cbaa6936", + "artifactVersion": "1", + "artifactURL": "/asdc/v1/catalog/services/Nimbus/2.0/resourceInstances/PCRF1/artifacts/pcrf-ppd-pcm-module-volume.env", + "artifactDescription": "VF Module HEAT Volume env artifact", + "generatedFromUUID": "48a0b856-22b9-4362-875c-3c960ee2a336", + "artifactChecksum": "g8m389rnbvq8vq==" + } + ] + }, + ] + }, + { + "resourceInstanceName" : "aaa_2", + "resourceName" : "aaa", + "resourceInvariantUUID" : "ff420d27-5555-335a-8a77-a6f64999b337", + "resourceVersion": "1.0", + "resourceUUID" : "4e5555d8-5b6d-42c4-8c74-46c33d8904f", + "resourceType" : "VF", + "artifacts": [ + ... + ], + "vfModules": [ + ... + ] + } + ] +} diff --git a/asdc-controller/pom.xml b/asdc-controller/pom.xml new file mode 100644 index 0000000000..61bb3eaf46 --- /dev/null +++ b/asdc-controller/pom.xml @@ -0,0 +1,111 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.openecomp</groupId> + <artifactId>mso</artifactId> + <version>0.0.4-SNAPSHOT</version> + </parent> + + <groupId>org.openecomp.mso</groupId> + <artifactId>asdc-controller</artifactId> + <name>asdc-controller</name> + <description>ASDC CLient and Controller</description> + <packaging>war</packaging> + + <build> + <finalName>${project.artifactId}-${project.version}</finalName> + <plugins> + <plugin> + <artifactId>maven-war-plugin</artifactId> + <version>2.3</version> + <configuration> + <warSourceDirectory>WebContent</warSourceDirectory> + <failOnMissingWebXml>false</failOnMissingWebXml> + <attachClasses>true</attachClasses> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-all</artifactId> + <version>1.10.19</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>mso-catalog-db</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.jboss.spec.javax.ejb</groupId> + <artifactId>jboss-ejb-api_3.2_spec</artifactId> + <version>1.0.0.Final</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.jboss.ejb3</groupId> + <artifactId>jboss-ejb3-ext-api</artifactId> + <version>2.2.0.Final</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <version>3.1.0</version> + <scope>test</scope> + </dependency> + + <dependency> + <groupId>org.openecomp.sdc</groupId> + <artifactId>sdc-distribution-client</artifactId> + <version>1.1.2</version> + <exclusions> + <exclusion> <!-- declare the exclusion here --> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </exclusion> + </exclusions> + </dependency> + + <dependency> + <groupId>org.apache.httpcomponents</groupId> + <artifactId>httpmime</artifactId> + <version>4.5</version> + </dependency> + + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>common</artifactId> + <version>${project.version}</version> + </dependency> + + <dependency> + <groupId>org.yaml</groupId> + <artifactId>snakeyaml</artifactId> + <version>1.15</version> + </dependency> + + <dependency> + <groupId>javax</groupId> + <artifactId>javaee-web-api</artifactId> + <version>6.0</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.openecomp.mso</groupId> + <artifactId>status-control</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>commons-io</groupId> + <artifactId>commons-io</artifactId> + </dependency> + </dependencies> + +</project> diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/ASDCControllerSingleton.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/ASDCControllerSingleton.java new file mode 100644 index 0000000000..d8ac7d6491 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/ASDCControllerSingleton.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc; + + +import javax.annotation.PreDestroy; +import javax.ejb.ConcurrencyManagement; +import javax.ejb.ConcurrencyManagementType; +import javax.ejb.Lock; +import javax.ejb.LockType; +import javax.ejb.Schedule; +import javax.ejb.Singleton; +import javax.ejb.Startup; + +import org.openecomp.mso.asdc.client.ASDCGlobalController; +import org.openecomp.mso.logger.MsoLogger; + +@Singleton(name = "ASDCController") +@Lock(LockType.READ) +@Startup +@ConcurrencyManagement(ConcurrencyManagementType.CONTAINER) +public class ASDCControllerSingleton { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + private static boolean working = false; + + private ASDCGlobalController globalController = new ASDCGlobalController (); + + /** + * Main Constructor of the ASDC Singleton + */ + public ASDCControllerSingleton () { + } + + @Schedule(second ="30", minute = "*", hour = "*", persistent = false) + public void periodicControllerTask () { + if (isWorking ()) { + LOGGER.debug ("Another thread is already trying to init ASDC, cancel this periodic call"); + return; + } + try { + setWorking (true); + + globalController.updateControllersConfigIfNeeded(); + globalController.checkInStoppedState(); + + } finally { + setWorking (false); + } + } + + @PreDestroy + private void terminate () { + globalController.closeASDC (); + } + + private static synchronized boolean isWorking () { + return ASDCControllerSingleton.working; + } + + private static synchronized void setWorking (boolean working) { + ASDCControllerSingleton.working = working; + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java new file mode 100644 index 0000000000..1d87ccbe21 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCConfiguration.java @@ -0,0 +1,418 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client; + + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Properties; + +import org.codehaus.jackson.JsonNode; + +import org.openecomp.sdc.api.consumer.IConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +public class ASDCConfiguration implements IConfiguration { + + private MsoPropertiesFactory msoPropertiesFactory; + + // SHell command to obtain the same encryption, 128 bits key, key must be HEX + // echo -n "This is a test string" | openssl aes-128-ecb -e -K 546573746F736973546573746F736973 -nosalt | xxd + + private String configKey; + + private MsoJsonProperties msoProperties; + + private String asdcControllerName; + + public static final String MSO_PROP_ASDC = "MSO_PROP_ASDC"; + public static final String PARAMETER_PATTERN = "asdc-connections"; + + public static final String CONSUMER_GROUP_ATTRIBUTE_NAME = "consumerGroup"; + public static final String CONSUMER_ID_ATTRIBUTE_NAME = "consumerId"; + public static final String ENVIRONMENT_NAME_ATTRIBUTE_NAME = "environmentName"; + public static final String PASSWORD_ATTRIBUTE_NAME = "password"; + public static final String POLLING_INTERVAL_ATTRIBUTE_NAME = "pollingInterval"; + public static final String RELEVANT_ARTIFACT_TYPES_ATTRIBUTE_NAME = "relevantArtifactTypes"; + public static final String USER_ATTRIBUTE_NAME = "user"; + public static final String ASDC_ADDRESS_ATTRIBUTE_NAME = "asdcAddress"; + public static final String POLLING_TIMEOUT_ATTRIBUTE_NAME = "pollingTimeout"; + public static final String ACTIVATE_SERVER_TLS_AUTH = "activateServerTLSAuth"; + 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 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, + VF_MODULES_METADATA}; + + public static final List<String> SUPPORTED_ARTIFACT_TYPES_LIST = Collections.unmodifiableList(Arrays.asList(SUPPORTED_ARTIFACT_TYPES)); + + /** + * Default constructor, the mso.properties is searched in the classpath (for testing) + * Or in /etc/ecomp/mso/config/mso.properties + * + * @param controllerName The controllerName of the config JSON tree + * @throws ASDCParametersException in case of issues with the parameters + * @throws IOException If the key file has not been loaded properly + */ + public ASDCConfiguration (String controllerName) throws ASDCParametersException, IOException { + + Properties keyProp = new Properties (); + this.asdcControllerName = controllerName; + + keyProp.load (Thread.currentThread ().getContextClassLoader ().getResourceAsStream ("config-key.properties")); + configKey = (String) keyProp.get ("asdc.config.key"); + + // This structure contains static values initialized by servlet initializer + this.msoPropertiesFactory = new MsoPropertiesFactory (); + + refreshASDCConfig (); + + } + + public String getAsdcControllerName () { + return asdcControllerName; + } + + private JsonNode getASDCControllerConfigJsonNode () { + if (this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { + return this.msoProperties.getJsonRootNode ().get (PARAMETER_PATTERN).get (this.asdcControllerName); + } else { + return null; + } + + } + + /** + * This method reload the config if needed. + * + * @return true if config has been reloaded, false otherwise + * @throws ASDCParametersException In case the parameters validation fails + * @throws MsoPropertiesException + */ + public boolean refreshASDCConfig () throws ASDCParametersException { + + try { + if (msoPropertiesFactory.propertiesHaveChanged (MSO_PROP_ASDC, msoProperties)) { + msoProperties = msoPropertiesFactory.getMsoJsonProperties (MSO_PROP_ASDC); + + this.testAllParameters (); + return true; + } else { + return false; + } + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("mso.asdc.json not initialized properly, ASDC config cannot be reloaded", + e); + } + } + + /** + * This method is useful to check whether a mso properties config has been changed. + * + * @return true is a new config is availabe, false otherwise + * @throws ASDCParametersException + * @throws MsoPropertiesException + */ + public boolean hasASDCConfigChanged () throws ASDCParametersException { + try { + return msoPropertiesFactory.propertiesHaveChanged (MSO_PROP_ASDC, msoProperties); + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("mso.asdc.json not initialized properly, ASDC config cannot be read", e); + } + } + + @Override + public String getConsumerGroup () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (CONSUMER_GROUP_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (CONSUMER_GROUP_ATTRIBUTE_NAME).asText (); + + if ("NULL".equals (config) || config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getConsumerID () { + + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (CONSUMER_ID_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (CONSUMER_ID_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getEnvironmentName () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (ENVIRONMENT_NAME_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (ENVIRONMENT_NAME_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getPassword () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (PASSWORD_ATTRIBUTE_NAME) != null) { + String config = this.msoProperties.getEncryptedProperty (masterConfigNode.get (PASSWORD_ATTRIBUTE_NAME), + null, + this.configKey); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public int getPollingInterval () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (POLLING_INTERVAL_ATTRIBUTE_NAME) != null) { + return masterConfigNode.get (POLLING_INTERVAL_ATTRIBUTE_NAME).asInt (); + } else { + return 0; + } + } + + @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); + } + + @Override + public String getUser () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (USER_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (USER_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getAsdcAddress () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (ASDC_ADDRESS_ATTRIBUTE_NAME) != null) { + String config = masterConfigNode.get (ASDC_ADDRESS_ATTRIBUTE_NAME).asText (); + + if (config.isEmpty ()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public int getPollingTimeout () { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode (); + if (masterConfigNode != null && masterConfigNode.get (POLLING_TIMEOUT_ATTRIBUTE_NAME) != null) { + return masterConfigNode.get (POLLING_TIMEOUT_ATTRIBUTE_NAME).asInt (); + } else { + return 0; + } + } + + @Override + public boolean activateServerTLSAuth() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(ACTIVATE_SERVER_TLS_AUTH) != null) { + return masterConfigNode.get(ACTIVATE_SERVER_TLS_AUTH).asBoolean(false); + } else { + return false; + } + } + + @Override + public String getKeyStorePassword() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(KEY_STORE_PASSWORD) != null) { + String config = this.msoProperties.getEncryptedProperty(masterConfigNode.get(KEY_STORE_PASSWORD), null, + this.configKey); + + if (config.isEmpty()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + @Override + public String getKeyStorePath() { + JsonNode masterConfigNode = getASDCControllerConfigJsonNode(); + if (masterConfigNode != null && masterConfigNode.get(KEY_STORE_PATH) != null) { + String config = masterConfigNode.get(KEY_STORE_PATH).asText(); + + if (config.isEmpty()) { + return null; + } else { + return config; + } + } else { + return null; + } + } + + public void testAllParameters () throws ASDCParametersException { + + // Special case for this attribute that can be null from getConsumerGroup + if (this.getConsumerGroup () == null + && (getASDCControllerConfigJsonNode () == null + || !"NULL".equals (getASDCControllerConfigJsonNode ().get (CONSUMER_GROUP_ATTRIBUTE_NAME).asText ()))) { + throw new ASDCParametersException (CONSUMER_GROUP_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getConsumerID () == null || this.getConsumerID ().isEmpty ()) { + throw new ASDCParametersException (CONSUMER_ID_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getEnvironmentName () == null || this.getEnvironmentName ().isEmpty ()) { + throw new ASDCParametersException (ENVIRONMENT_NAME_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getAsdcAddress () == null || this.getAsdcAddress ().isEmpty ()) { + throw new ASDCParametersException (ASDC_ADDRESS_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPassword () == null || this.getPassword ().isEmpty ()) { + throw new ASDCParametersException (PASSWORD_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPollingInterval () == 0) { + throw new ASDCParametersException (POLLING_INTERVAL_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getPollingTimeout () == 0) { + throw new ASDCParametersException (POLLING_TIMEOUT_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getRelevantArtifactTypes () == null || this.getRelevantArtifactTypes ().isEmpty ()) { + throw new ASDCParametersException (RELEVANT_ARTIFACT_TYPES_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + + if (this.getUser () == null || this.getUser ().isEmpty ()) { + throw new ASDCParametersException (USER_ATTRIBUTE_NAME + + " parameter cannot be found in config mso.properties"); + } + } + + /** + * This method triggers the MsoPropertiesFactory to get the ASDC config from the cache and extracts all controllers + * defined. + * + * @return A list of controller Names defined in the cache config + * @throws ASDCParametersException In cas of issues with the cache + */ + public static List <String> getAllDefinedControllers () throws ASDCParametersException { + + MsoJsonProperties msoProp; + try { + List <String> result = new ArrayList <String> (); + msoProp = new MsoPropertiesFactory ().getMsoJsonProperties (MSO_PROP_ASDC); + + if (msoProp.getJsonRootNode ().get (PARAMETER_PATTERN) != null) { + Iterator <Entry <String, JsonNode>> it = msoProp.getJsonRootNode () + .get (PARAMETER_PATTERN) + .getFields (); + + Entry <String, JsonNode> entry; + while (it.hasNext ()) { + entry = it.next (); + result.add (entry.getKey ()); + + } + } + return result; + } catch (MsoPropertiesException e) { + throw new ASDCParametersException ("Unable to get the JSON Properties in cache:" + MSO_PROP_ASDC, e); + } + + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java new file mode 100644 index 0000000000..b553100816 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCController.java @@ -0,0 +1,570 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client; + + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.DistributionClientFactory; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.sdc.utils.DistributionStatusEnum; +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.IVfResourceInstaller; +import org.openecomp.mso.asdc.installer.VfResourceStructure; +import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller; +import org.openecomp.mso.asdc.util.ASDCNotificationLogging; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoAlarmLogger; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.utils.UUIDChecker; + +public class ASDCController { + + protected static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + + protected static MsoAlarmLogger alarmLogger = new MsoAlarmLogger (); + + protected boolean isAsdcClientAutoManaged = false; + + protected String controllerName; + + /** + * Inner class for Notification callback + * + * + */ + private final class ASDCNotificationCallBack implements INotificationCallback { + + private ASDCController asdcController; + + ASDCNotificationCallBack (ASDCController controller) { + asdcController = controller; + } + + /** + * This method can be called multiple times at the same moment. + * The controller must be thread safe ! + */ + @Override + public void activateCallback (INotificationData iNotif) { + long startTime = System.currentTimeMillis (); + UUIDChecker.generateUUID (LOGGER); + MsoLogger.setServiceName ("NotificationHandler"); + MsoLogger.setLogContext (iNotif.getDistributionID (), iNotif.getServiceUUID ()); + String event = "Receive a callback notification in ASDC, nb of resources: " + iNotif.getResources ().size (); + LOGGER.debug(event); + asdcController.treatNotification (iNotif); + LOGGER.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Completed the treatment of the notification"); + } + } + + // ***** Controller STATUS code + + protected int nbOfNotificationsOngoing = 0; + + public int getNbOfNotificationsOngoing () { + return nbOfNotificationsOngoing; + } + + private ASDCControllerStatus controllerStatus = ASDCControllerStatus.STOPPED; + + protected synchronized final void changeControllerStatus (ASDCControllerStatus newControllerStatus) { + switch (newControllerStatus) { + + case BUSY: + ++this.nbOfNotificationsOngoing; + this.controllerStatus = newControllerStatus; + break; + + case IDLE: + if (this.nbOfNotificationsOngoing > 1) { + --this.nbOfNotificationsOngoing; + } else { + this.nbOfNotificationsOngoing = 0; + this.controllerStatus = newControllerStatus; + } + + break; + default: + this.controllerStatus = newControllerStatus; + break; + + } + } + + public synchronized final ASDCControllerStatus getControllerStatus () { + return this.controllerStatus; + } + + // ***** END of Controller STATUS code + + protected ASDCConfiguration asdcConfig; + private IDistributionClient distributionClient; + private IVfResourceInstaller resourceInstaller; + + public ASDCController (String controllerConfigName) { + isAsdcClientAutoManaged = true; + this.controllerName = controllerConfigName; + this.resourceInstaller = new VfResourceInstaller(); + } + + public ASDCController (String controllerConfigName, IDistributionClient asdcClient, IVfResourceInstaller resourceinstaller) { + + distributionClient = asdcClient; + this.resourceInstaller = resourceinstaller; + this.controllerName = controllerConfigName; + } + + public ASDCController (String controllerConfigName,IDistributionClient asdcClient) { + distributionClient = asdcClient; + this.controllerName = controllerConfigName; + this.resourceInstaller = new VfResourceInstaller(); + } + + /** + * This method refresh the ASDC Controller config and restart the client. + * + * @return true if config has been reloaded, false otherwise + * @throws ASDCControllerException If case of issue with the init or close called during the config reload + * @throws ASDCParametersException If there is an issue with the parameters + * @throws IOException In case of the key file could not be loaded properly + */ + public boolean updateConfigIfNeeded () throws ASDCParametersException, ASDCControllerException, IOException { + LOGGER.debug ("Checking whether ASDC config must be reloaded"); + + try { + if (this.asdcConfig != null && this.asdcConfig.hasASDCConfigChanged ()) { + LOGGER.debug ("ASDC Config must be reloaded"); + this.closeASDC (); + this.asdcConfig.refreshASDCConfig (); + this.initASDC (); + return true; + } else { + LOGGER.debug ("ASDC Config must NOT be reloaded"); + return false; + } + } catch (ASDCParametersException ep) { + // Try to close it at least to make it consistent with the file specified + // We cannot let it run with a different config file, even if it's bad. + // This call could potentially throw a ASDCController exception if the controller is currently BUSY. + this.closeASDC (); + + throw ep; + } + } + + /** + * 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 + * @throws ASDCParametersException If there is an issue with the parameters provided + * @throws IOException In case of issues when trying to load the key file + */ + public void initASDC () throws ASDCControllerException, ASDCParametersException, IOException { + String event = "Initialize the ASDC Controller"; + MsoLogger.setServiceName ("InitASDC"); + LOGGER.debug (event); + if (this.getControllerStatus () != ASDCControllerStatus.STOPPED) { + String endEvent = "The controller is already initialized, call the closeASDC method first"; + throw new ASDCControllerException (endEvent); + } + + if (asdcConfig == null) { + asdcConfig = new ASDCConfiguration (this.controllerName); + + } + // attempt to refresh during init as MsoProperties is may be pointing to an old file + // Be careful this is static in MsoProperties + asdcConfig.refreshASDCConfig (); + + if (this.distributionClient == null) { + distributionClient = DistributionClientFactory.createDistributionClient (); + } + long initStartTime = System.currentTimeMillis (); + IDistributionClientResult result = this.distributionClient.init (asdcConfig, + new ASDCNotificationCallBack (this)); + if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + String endEvent = "ASDC distribution client init failed with reason:" + + result.getDistributionMessageResult (); + LOGGER.recordMetricEvent (initStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, "Initialization of the ASDC Controller failed with reason:" + result.getDistributionMessageResult (), "ASDC", "init", null); + LOGGER.debug (endEvent); + asdcConfig = null; + + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + throw new ASDCControllerException ("Initialization of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult ()); + } + LOGGER.recordMetricEvent (initStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully initialize ASDC Controller", "ASDC", "init", null); + + long clientstartStartTime = System.currentTimeMillis (); + result = this.distributionClient.start (); + if (!result.getDistributionActionResult ().equals (DistributionActionResultEnum.SUCCESS)) { + String endEvent = "ASDC distribution client start failed with reason:" + + result.getDistributionMessageResult (); + LOGGER.recordMetricEvent (clientstartStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.UnknownError, endEvent, "ASDC", "start", null); + LOGGER.debug (endEvent); + asdcConfig = null; + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + throw new ASDCControllerException ("Startup of the ASDC Controller failed with reason: " + + result.getDistributionMessageResult ()); + } + LOGGER.recordMetricEvent (clientstartStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully start ASDC distribution client", "ASDC", "start", null); + + + this.changeControllerStatus (ASDCControllerStatus.IDLE); + LOGGER.info (MessageEnum.ASDC_INIT_ASDC_CLIENT_SUC, "ASDC", "changeControllerStatus"); + } + + /** + * 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. + */ + public void closeASDC () throws ASDCControllerException { + + MsoLogger.setServiceName ("CloseController"); + if (this.getControllerStatus () == ASDCControllerStatus.BUSY) { + throw new ASDCControllerException ("Cannot close the ASDC controller as it's currently in BUSY state"); + } + if (this.distributionClient != null) { + this.distributionClient.stop (); + // If auto managed we can set it to Null, ASDCController controls it. + // In the other case the client of this class has specified it, so we can't reset it + if (isAsdcClientAutoManaged) { + // Next init will initialize it with a new ASDC Client + this.distributionClient = null; + } + + } + this.changeControllerStatus (ASDCControllerStatus.STOPPED); + } + + private boolean checkResourceAlreadyDeployed (VfResourceStructure vfResource) throws ArtifactInstallerException { + + if (this.resourceInstaller.isResourceAlreadyDeployed (vfResource)) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_ALREADY_EXIST, + vfResource.getResourceInstance().getResourceInstanceName(), + vfResource.getResourceInstance().getResourceUUID(), + vfResource.getResourceInstance().getResourceName(), "", ""); + + this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DOWNLOADED,null); + this.sendDeployNotificationsForResource(vfResource,DistributionStatusEnum.ALREADY_DEPLOYED,null); + + return true; + } else { + return false; + } + + } + + private final static String UUID_PARAM = "(UUID:"; + + private IDistributionClientDownloadResult downloadTheArtifact (IArtifactInfo artifact, + String distributionId) throws ASDCDownloadException { + + LOGGER.debug ("Trying to download the artifact : " + artifact.getArtifactURL () + + UUID_PARAM + + artifact.getArtifactUUID () + + ")"); + IDistributionClientDownloadResult downloadResult; + + + try { + downloadResult = distributionClient.download (artifact); + if (null == downloadResult) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_NULL, artifact.getArtifactUUID (), "", ""); + return downloadResult; + } + } 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 ()); + + throw new ASDCDownloadException ("Exception caught when downloading the artifact", e); + } + + if (DistributionActionResultEnum.SUCCESS.equals(downloadResult.getDistributionActionResult ())) { + + LOGGER.info (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_SUC, + artifact.getArtifactURL (), + artifact.getArtifactUUID (), + String.valueOf (downloadResult.getArtifactPayload ().length), "", ""); + + } else { + + LOGGER.error (MessageEnum.ASDC_ARTIFACT_DOWNLOAD_FAIL, + artifact.getArtifactName (), + artifact.getArtifactURL (), + artifact.getArtifactUUID (), + downloadResult.getDistributionMessageResult (), "", "", MsoLogger.ErrorCode.DataError, "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 ()); + + } + + this.sendASDCNotification (NotificationType.DOWNLOAD, + artifact.getArtifactURL (), + asdcConfig.getConsumerID (), + distributionId, + DistributionStatusEnum.DOWNLOAD_OK, + null, + System.currentTimeMillis ()); + return downloadResult; + + } + + + private void sendDeployNotificationsForResource(VfResourceStructure vfResourceStructure,DistributionStatusEnum distribStatus, String errorReason) { + + for (IArtifactInfo artifactInfo : vfResourceStructure.getResourceInstance().getArtifacts()) { + + if (DistributionStatusEnum.DEPLOY_OK.equals(distribStatus) + // This could be NULL if the artifact is a VF module artifact, this won't be present in the MAP + && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()) != null + && vfResourceStructure.getArtifactsMapByUUID().get(artifactInfo.getArtifactUUID()).getDeployedInDb() == 0) { + this.sendASDCNotification (NotificationType.DEPLOY, + artifactInfo.getArtifactURL (), + asdcConfig.getConsumerID (), + vfResourceStructure.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 (), + vfResourceStructure.getNotification().getDistributionID(), + distribStatus, + errorReason, + System.currentTimeMillis ()); + } + } + } + + private void deployResourceStructure (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException { + + LOGGER.info (MessageEnum.ASDC_START_DEPLOY_ARTIFACT, vfResourceStructure.getResourceInstance().getResourceInstanceName(), vfResourceStructure.getResourceInstance().getResourceUUID(), "ASDC", "deployResourceStructure"); + try { + vfResourceStructure.createVfModuleStructures(); + resourceInstaller.installTheResource (vfResourceStructure); + + } catch (ArtifactInstallerException e) { + + sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_ERROR,e.getMessage()); + throw e; + } + + if (vfResourceStructure.isDeployedSuccessfully()) { + LOGGER.info (MessageEnum.ASDC_ARTIFACT_DEPLOY_SUC, + vfResourceStructure.getResourceInstance().getResourceName(), + vfResourceStructure.getResourceInstance().getResourceUUID(), + String.valueOf (vfResourceStructure.getVfModuleStructure().size()), "ASDC", "deployResourceStructure"); + sendDeployNotificationsForResource(vfResourceStructure,DistributionStatusEnum.DEPLOY_OK ,null); + } + + } + + private enum NotificationType { + DOWNLOAD, DEPLOY + } + + private 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, notificationType.name (), status.name (), artifactURL, "ASDC", "sendASDCNotification"); + LOGGER.debug (event); + + long subStarttime = System.currentTimeMillis (); + String action = ""; + try { + IDistributionStatusMessage message = new DistributionStatusMessage (artifactURL, + consumerID, + distributionID, + status, + timestamp); + + switch (notificationType) { + case DOWNLOAD: + if (errorReason != null) { + this.distributionClient.sendDownloadStatus (message, errorReason); + } else { + this.distributionClient.sendDownloadStatus (message); + } + action = "sendDownloadStatus"; + break; + case DEPLOY: + if (errorReason != null) { + this.distributionClient.sendDeploymentStatus (message, errorReason); + } else { + this.distributionClient.sendDeploymentStatus (message); + } + action = "sendDeploymentdStatus"; + break; + default: + break; + } + } catch (RuntimeException e) { + // TODO: May be a list containing the unsent notification should be + // kept + LOGGER.warn (MessageEnum.ASDC_SEND_NOTIF_ASDC_EXEC, "ASDC", "sendASDCNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException - sendASDCNotification", e); + } + LOGGER.recordMetricEvent (subStarttime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully sent notification to ASDC", "ASDC", action, null); + } + + public void treatNotification (INotificationData iNotif) { + + int noOfArtifacts = 0; + for (IResourceInstance resource : iNotif.getResources ()) { + noOfArtifacts += resource.getArtifacts ().size (); + } + LOGGER.info (MessageEnum.ASDC_RECEIVE_CALLBACK_NOTIF, + String.valueOf (noOfArtifacts), + iNotif.getServiceUUID (), "ASDC", "treatNotification"); + + try { + LOGGER.debug(ASDCNotificationLogging.dumpASDCNotification(iNotif)); + LOGGER.info(MessageEnum.ASDC_RECEIVE_SERVICE_NOTIF, iNotif.getServiceUUID(), "ASDC", "treatNotification"); + this.changeControllerStatus(ASDCControllerStatus.BUSY); + // Process only the Resource artifacts in MSO + for (IResourceInstance resource : iNotif.getResources()) { + + // We process only VNF resource on MSO Side + if ("VF".equals(resource.getResourceType())) { + this.processResourceNotification(iNotif,resource); + } + } + + + + } catch (RuntimeException e) { + LOGGER.error (MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Unexpected exception caught during the notification processing", "ASDC", "treatNotification", MsoLogger.ErrorCode.SchemaError, "RuntimeException in treatNotification", + e); + } finally { + this.changeControllerStatus (ASDCControllerStatus.IDLE); + } + } + + + private void processResourceNotification (INotificationData iNotif,IResourceInstance resource) { + // For each artifact, create a structure describing the VFModule in a ordered flat level + VfResourceStructure vfResourceStructure = new VfResourceStructure(iNotif,resource); + try { + + if (!this.checkResourceAlreadyDeployed(vfResourceStructure)) { + for (IArtifactInfo artifact : resource.getArtifacts()) { + + IDistributionClientDownloadResult resultArtifact = this.downloadTheArtifact(artifact, + iNotif.getDistributionID()); + + if (resultArtifact != null) { + if (ASDCConfiguration.VF_MODULES_METADATA.equals(artifact.getArtifactType())) { + LOGGER.debug("VF_MODULE_ARTIFACT: "+new String(resultArtifact.getArtifactPayload(),"UTF-8")); + LOGGER.debug(ASDCNotificationLogging.dumpVfModuleMetaDataList(distributionClient.decodeVfModuleArtifact(resultArtifact.getArtifactPayload()))); + } + vfResourceStructure.addArtifactToStructure(distributionClient,artifact, resultArtifact); + + } + + } + + this.deployResourceStructure(vfResourceStructure); + + } + } catch (ArtifactInstallerException | ASDCDownloadException | UnsupportedEncodingException e) { + LOGGER.error(MessageEnum.ASDC_GENERAL_EXCEPTION_ARG, + "Exception caught during Installation of artifact", "ASDC", "processResourceNotification", MsoLogger.ErrorCode.BusinessProcesssError, "Exception in processResourceNotification", e); + } + } + + private static final String UNKNOWN="Unknown"; + + /** + * @return the address of the ASDC we are connected to. + */ + public String getAddress () { + if (asdcConfig != null) { + return asdcConfig.getAsdcAddress (); + } + return UNKNOWN; + } + + /** + * @return the environment name of the ASDC we are connected to. + */ + public String getEnvironment () { + if (asdcConfig != null) { + return asdcConfig.getEnvironmentName (); + } + return UNKNOWN; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java new file mode 100644 index 0000000000..53de5fc5ab --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCControllerStatus.java @@ -0,0 +1,27 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client; + + + +public enum ASDCControllerStatus { + STOPPED, IDLE, BUSY +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java new file mode 100644 index 0000000000..4e10953efb --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/ASDCGlobalController.java @@ -0,0 +1,217 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client; + + + +import java.io.IOException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + + +public class ASDCGlobalController { + + private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.ASDC); + private Map <String,ASDCController> controllers = new HashMap <String,ASDCController> (); + + private MsoJsonProperties msoProp= null; + + private void loadControllers () throws ASDCParametersException { + + List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); + + StringBuffer controllerListLog = new StringBuffer("List of controllers loaded:"); + for (String controllerName : controllerNames) { + controllers.put(controllerName, new ASDCController(controllerName)); + controllerListLog.append(controllerName); + controllerListLog.append(";"); + } + LOGGER.debug(controllerListLog.toString()); + } + + private boolean sameControllersDefined() throws ASDCParametersException { + List<String> controllerNames = ASDCConfiguration.getAllDefinedControllers(); + if (controllerNames.size() == controllers.size()) { + boolean areIdentical = true; + + for (String name:controllerNames) { + if (!controllers.containsKey(name)) { + areIdentical = false; + break; + } + } + return areIdentical; + + } else { + return false; + } + } + + /** + * Check that controllers list needs to be updated or not. + * @param return true if the list has been updated + */ + private boolean updateControllersListIfNeeded () { + boolean updateNeeded=false; + try { + + MsoPropertiesFactory msoPropFactory = new MsoPropertiesFactory(); + MsoJsonProperties newMsoProp; + + newMsoProp = msoPropFactory.getMsoJsonProperties(ASDCConfiguration.MSO_PROP_ASDC); + + if (msoPropFactory.propertiesHaveChanged(ASDCConfiguration.MSO_PROP_ASDC, msoProp) && !sameControllersDefined()) { + updateNeeded = true; + LOGGER.debug("List of ASDC controllers has been changed, trying to kill them"); + this.closeASDC(); + + // Wait that all controllers are down before restarting, next pass will kill them all + if (this.controllers.size() == 0) { + msoProp = newMsoProp; + this.loadControllers(); + } + } + + } catch (ASDCParametersException e) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + "All ASDC Hosts", + "All ASDC Envs", "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in updateControllersListIfNeeded", + e); + } catch (MsoPropertiesException e) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + "All ASDC Hosts", + "All ASDC Envs", "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "MsoPropertiesException in updateControllersListIfNeeded", + e); + } + return updateNeeded; + + + } + + /** + * Checks for each controller if it is STOPPED and restart if it is the case. + */ + public void checkInStoppedState () { + + for (ASDCController controller : controllers.values()) { + if (ASDCControllerStatus.STOPPED.equals (controller.getControllerStatus ())) { + + // Try to restart just in case of issues + try { + controller.initASDC (); + } catch (ASDCControllerException ec) { + LOGGER.warn (MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in checkInStoppedState", + ec); + } catch (ASDCParametersException ep) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in checkInStoppedState", + ep); + } catch (RuntimeException | IOException e) { + LOGGER.error (MessageEnum.ASDC_SINGLETON_CHECKT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in checkInStoppedState", + e); + } + } + } + } + + public void closeASDC () { + List<String> controllerToRemove = new LinkedList<String>(); + + for (ASDCController controller : controllers.values()) { + try { + controller.closeASDC (); + controllerToRemove.add(controller.controllerName); + + } catch (RuntimeException e) { + LOGGER.warn (MessageEnum.ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + "RuntimeException", + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in closeASDC", + e); + } catch (ASDCControllerException e) { + LOGGER.warn (MessageEnum.ASDC_SHUTDOWN_ASDC_CLIENT_EXC, + "ASDCControllerException", + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in closeASDC", + e); + } + } + + // Now remove the ones properly closed + for (String toRemove:controllerToRemove) { + controllers.remove(toRemove); + } + + } + + /** + * Check whether the config has been changed + */ + public boolean updateControllersConfigIfNeeded () { + boolean listUpdated=updateControllersListIfNeeded(); + if (!listUpdated) { + + for (ASDCController controller : controllers.values()) { + try { + controller.updateConfigIfNeeded (); + } catch (ASDCControllerException ec) { + LOGGER.warn (MessageEnum.ASDC_INIT_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCControllerException in updateControllersConfigIfNeeded", + ec); + } catch (ASDCParametersException ep) { + LOGGER.warn (MessageEnum.ASDC_LOAD_ASDC_CLIENT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "ASDCParametersException in updateControllersConfigIfNeeded", + ep); + } catch (RuntimeException | IOException e) { + LOGGER.error (MessageEnum.ASDC_SINGLETON_CHECKT_EXC, + controller.getAddress (), + controller.getEnvironment (), "ASDC", "closeASDC", MsoLogger.ErrorCode.BusinessProcesssError, "RuntimeException in updateControllersConfigIfNeeded", + e); + } + } + } + return listUpdated; + } + + public Map<String, ASDCController> getControllers() { + return controllers; + } + + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java new file mode 100644 index 0000000000..dddcaff243 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/DistributionStatusMessage.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client; + + +import org.openecomp.sdc.api.consumer.IDistributionStatusMessage; +import org.openecomp.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; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java new file mode 100644 index 0000000000..72c5a5a4fb --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.exceptions; + + +/** + * Exception of the ASDC controller. + */ +public class ASDCControllerException extends Exception { + + /** + * serialization id. + */ + 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); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCControllerException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java new file mode 100644 index 0000000000..59d32236ed --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.exceptions; + + +/** + * Exception during download from ASDC. + */ +public class ASDCDownloadException extends Exception { + + /** + * serialization id. + */ + 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); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCDownloadException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java new file mode 100644 index 0000000000..fdedd40c04 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.exceptions; + + +/** + * Exception of the ASDC controller. + */ +public class ASDCParametersException extends Exception { + + /** + * serialization id. + */ + 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); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ASDCParametersException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java new file mode 100644 index 0000000000..af698ad809 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerException.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.exceptions; + + +/** + * Exception during artifact installation. + */ +public class ArtifactInstallerException extends Exception { + + /** + * serialization id. + */ + 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); + + } + + /** + * @param message The message to dump + * @param cause The Throwable cause object + */ + public ArtifactInstallerException (final String message, final Throwable cause) { + super (message, cause); + + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java new file mode 100644 index 0000000000..f0b6ec4853 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/healthcheck/HealthCheckHandler.java @@ -0,0 +1,97 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.healthcheck; + + +import org.openecomp.mso.MsoStatusUtil; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; +import org.openecomp.mso.properties.MsoJsonProperties; +import org.openecomp.mso.properties.MsoPropertiesFactory; +import org.openecomp.mso.HealthCheckUtils; +import org.openecomp.mso.utils.UUIDChecker; +import org.apache.http.HttpStatus; + +import javax.ws.rs.GET; +import javax.ws.rs.HEAD; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.QueryParam; +import javax.ws.rs.core.Response; + + +@Path("/") + public class HealthCheckHandler { + + private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC); + private static final String MSO_PROP_ASDC = "MSO_PROP_ASDC"; + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + private static final String SUC_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>"; + private static final String NOT_FOUND = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Application Not Ready</title></head><body>Application Not Ready. Properties file missing or invalid or database Connection failed</body></html>"; + + private static final Response OK_RESPONSE = Response.status (HttpStatus.SC_OK).entity (SUC_HTML).build (); + private static final Response NOK_RESPONSE = Response.status (HttpStatus.SC_SERVICE_UNAVAILABLE).entity (NOT_FOUND).build (); + + @HEAD + @GET + @Path("/healthcheck") + @Produces("text/html") + public Response healthcheck (@QueryParam("requestId") String requestId) { + long startTime = System.currentTimeMillis (); + MsoLogger.setServiceName ("Healthcheck"); + UUIDChecker.verifyOldUUID(requestId, msoLogger); + HealthCheckUtils healthCheck = new HealthCheckUtils (); + if (!healthCheck.siteStatusCheck(msoLogger, startTime)) { + return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE; + } + + MsoJsonProperties props = loadMsoProperties (); + if (props == null) { + msoLogger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.ServiceNotAvailable, "Application Not Ready"); + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + + if (!healthCheck.catalogDBCheck (msoLogger, startTime)) { + return HealthCheckUtils.NOT_STARTED_RESPONSE; + } + msoLogger.debug("healthcheck - Successful"); + return HealthCheckUtils.HEALTH_CHECK_RESPONSE; + } + + private MsoJsonProperties loadMsoProperties () { + MsoJsonProperties msoProperties; + try { + msoProperties = msoPropertiesFactory.getMsoJsonProperties(MSO_PROP_ASDC); + } catch (Exception e) { + msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND, MSO_PROP_ASDC, "", "", MsoLogger.ErrorCode.DataError, "Exception - getMsoJsonProperties", e); + return null; + } + + if (msoProperties !=null && msoProperties.getJsonRootNode().getElements().hasNext()) { + return msoProperties; + } else { + msoLogger.error (MessageEnum.ASDC_PROPERTIES_NOT_FOUND , MSO_PROP_ASDC, "", "", MsoLogger.ErrorCode.DataError, "ASDC properties not found"); + return null; + } + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java new file mode 100644 index 0000000000..5e59be526f --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/ASDCElementInfo.java @@ -0,0 +1,212 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.mso.asdc.client.ASDCConfiguration; + +/** + * A class representing a generic element whose information can be used for example to log artifacts, resource... data. + */ +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() { + StringBuffer sb = new StringBuffer(); + 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); + IVfModuleMetadata 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/openecomp/mso/asdc/installer/BigDecimalVersion.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java new file mode 100644 index 0000000000..a0932ed3b6 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/BigDecimalVersion.java @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.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("\\."); + StringBuffer newVersion = new StringBuffer(); + 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(); + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java new file mode 100644 index 0000000000..25c3b9c6a7 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IArtifactOrchestrator.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + + + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; + +public interface IArtifactOrchestrator { + + void installTheArtifact (INotificationData iNotif, IResourceInstance resource, IArtifactInfo artifact, IDistributionClientDownloadResult downloadResult) throws ArtifactInstallerException; + + boolean isArtifactAlreadyDeployed (INotificationData iNotif,IResourceInstance resource,IArtifactInfo artifact) throws ArtifactInstallerException; + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java new file mode 100644 index 0000000000..5f0f9305eb --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/IVfResourceInstaller.java @@ -0,0 +1,32 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + + + +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; + +public interface IVfResourceInstaller { + + boolean isResourceAlreadyDeployed (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException; + + public void installTheResource (VfResourceStructure vfResourceStructure) throws ArtifactInstallerException; +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java new file mode 100644 index 0000000000..c7f19ea1bf --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleArtifact.java @@ -0,0 +1,70 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + + +import java.io.UnsupportedEncodingException; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; + +/** + * 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 Object catalogObject; + + public VfModuleArtifact(IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + artifactInfo=artifactinfo; + result = new String(clientResult.getArtifactPayload(), "UTF-8"); + + } + + public Object getCatalogObject() { + return catalogObject; + } + + public void setCatalogObject(Object catalogObject) { + this.catalogObject = catalogObject; + } + + public IArtifactInfo getArtifactInfo() { + return artifactInfo; + } + + public String getResult() { + return result; + } + + public int getDeployedInDb() { + return deployedInDb; + } + + public void incrementDeployedInDB() { + ++deployedInDb; + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java new file mode 100644 index 0000000000..239bc8ab99 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfModuleStructure.java @@ -0,0 +1,117 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.db.catalog.beans.VfModule; + +public final class VfModuleStructure { + + private final IVfModuleMetadata vfModuleMetadata; + + 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; + + public VfModuleStructure(VfResourceStructure vfParentResource,IVfModuleMetadata vfmoduleMetadata) throws ArtifactInstallerException { + + vfModuleMetadata = vfmoduleMetadata; + parentVfResource = vfParentResource; + + artifactsMap = new HashMap<String, List<VfModuleArtifact>>(); + + 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) { + + if (artifactsMap.containsKey(vfModuleArtifact.getArtifactInfo().getArtifactType())) { + artifactsMap.get(vfModuleArtifact.getArtifactInfo().getArtifactType()).add(vfModuleArtifact); + + } else { + List<VfModuleArtifact> nestedList = new LinkedList<VfModuleArtifact>(); + nestedList.add(vfModuleArtifact); + + artifactsMap.put(vfModuleArtifact.getArtifactInfo().getArtifactType(), nestedList); + } + } + + public List<VfModuleArtifact> getOrderedArtifactList() { + + List <VfModuleArtifact> artifactsList = new LinkedList <VfModuleArtifact>(); + + artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT)); + artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_ENV)); + artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); + + for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_NESTED))) { + artifactsList.add(artifact); + } + + for (VfModuleArtifact artifact:(artifactsMap.get(ASDCConfiguration.HEAT_ARTIFACT))) { + artifactsList.add(artifact); + } + + artifactsList.addAll(artifactsMap.get(ASDCConfiguration.HEAT_VOL)); + + return null; + } + + public IVfModuleMetadata getVfModuleMetadata() { + return vfModuleMetadata; + } + + public VfResourceStructure getParentVfResource() { + return parentVfResource; + } + + public Map<String, List<VfModuleArtifact>> getArtifactsMap() { + return artifactsMap; + } + + + public VfModule getCatalogVfModule() { + return catalogVfModule; + } + + public void setCatalogVfModule(VfModule catalogVfModule) { + this.catalogVfModule = catalogVfModule; + } + + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java new file mode 100644 index 0000000000..7be5e7010b --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/VfResourceStructure.java @@ -0,0 +1,165 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer; + + +import java.io.UnsupportedEncodingException; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.VnfResource; + +/** + * This structure exists to avoid having issues if the order of the vfResource/vfmodule artifact is not good (tree structure). + * + * + */ +public final class VfResourceStructure { + + private boolean isDeployedSuccessfully=false; + /** + * The Raw notification data. + */ + private final INotificationData notification; + + /** + * The resource we will try to deploy. + */ + private final IResourceInstance resourceInstance; + + /** + * The list of VfModules defined for this resource. + */ + private final List<VfModuleStructure> vfModulesStructureList; + + /** + * The list of VfModulesMetadata defined for this resource. + */ + private List<IVfModuleMetadata> vfModulesMetadataList; + + private VnfResource catalogVnfResource; + + private Service catalogService; + + /** + * The list of artifacts existing in this resource hashed by UUID. + */ + private final Map<String, VfModuleArtifact> artifactsMapByUUID; + + + public VfResourceStructure(INotificationData notificationdata, IResourceInstance resourceinstance) { + notification=notificationdata; + resourceInstance=resourceinstance; + + + vfModulesStructureList = new LinkedList<VfModuleStructure>(); + artifactsMapByUUID = new HashMap<String, VfModuleArtifact>(); + } + + public void addArtifactToStructure(IDistributionClient distributionClient,IArtifactInfo artifactinfo,IDistributionClientDownloadResult clientResult) throws UnsupportedEncodingException { + VfModuleArtifact vfModuleArtifact = new VfModuleArtifact(artifactinfo,clientResult); + + 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_ARTIFACT: + case ASDCConfiguration.HEAT_NET: + case ASDCConfiguration.OTHER: + artifactsMapByUUID.put(artifactinfo.getArtifactUUID(), vfModuleArtifact); + break; + + case ASDCConfiguration.VF_MODULES_METADATA: + vfModulesMetadataList = distributionClient.decodeVfModuleArtifact(clientResult.getArtifactPayload()); + break; + + default: + break; + + } + } + + public void createVfModuleStructures() throws ArtifactInstallerException { + + if (vfModulesMetadataList == null) { + throw new ArtifactInstallerException("VfModule Meta DATA could not be decoded properly or was not present in the notification"); + } + for (IVfModuleMetadata vfModuleMeta:vfModulesMetadataList) { + vfModulesStructureList.add(new VfModuleStructure(this,vfModuleMeta)); + } + } + + public INotificationData getNotification() { + return notification; + } + + public IResourceInstance getResourceInstance() { + return resourceInstance; + } + + public List<VfModuleStructure> getVfModuleStructure() { + return vfModulesStructureList; + } + + public boolean isDeployedSuccessfully() { + return isDeployedSuccessfully; + } + + public void setSuccessfulDeployment() { + isDeployedSuccessfully = true; + } + + public Map<String, VfModuleArtifact> getArtifactsMapByUUID() { + return artifactsMapByUUID; + } + + public List<VfModuleStructure> getVfModulesStructureList() { + return vfModulesStructureList; + } + + public VnfResource getCatalogVnfResource() { + return catalogVnfResource; + } + + public void setCatalogVnfResource(VnfResource catalogVnfResource) { + this.catalogVnfResource = catalogVnfResource; + } + + public Service getCatalogService() { + return catalogService; + } + + public void setCatalogService(Service catalogService) { + this.catalogService = catalogService; + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java new file mode 100644 index 0000000000..4cef0f1013 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/installer/heat/VfResourceInstaller.java @@ -0,0 +1,596 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.installer.heat; + + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + +import org.hibernate.exception.ConstraintViolationException; +import org.hibernate.exception.LockAcquisitionException; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.ASDCElementInfo; +import org.openecomp.mso.asdc.installer.BigDecimalVersion; +import org.openecomp.mso.asdc.installer.IVfResourceInstaller; +import org.openecomp.mso.asdc.installer.VfModuleArtifact; +import org.openecomp.mso.asdc.installer.VfModuleStructure; +import org.openecomp.mso.asdc.installer.VfResourceStructure; +import org.openecomp.mso.asdc.util.YamlEditor; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.HeatEnvironment; +import org.openecomp.mso.db.catalog.beans.HeatFiles; +import org.openecomp.mso.db.catalog.beans.HeatTemplate; +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.VfModule; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import org.openecomp.mso.logger.MessageEnum; +import org.openecomp.mso.logger.MsoLogger; + +public class VfResourceInstaller implements IVfResourceInstaller { + + private MsoLogger logger; + + public VfResourceInstaller() { + logger = MsoLogger.getMsoLogger(MsoLogger.Catalog.ASDC); + } + + @Override + public boolean isResourceAlreadyDeployed(VfResourceStructure vfResourceStructure) + throws ArtifactInstallerException { + boolean status = false; + + try (CatalogDatabase db = new CatalogDatabase()) { + + logger.info(MessageEnum.ASDC_CHECK_HEAT_TEMPLATE, "VNFResource", + VfResourceInstaller.createVNFName(vfResourceStructure), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), "", ""); + + VnfResource vnfResource = db.getVnfResource( + VfResourceInstaller.createVNFName(vfResourceStructure), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion())); + + if (vnfResource != null) { + status = true; + + } + + if (status) { + logger.info(MessageEnum.ASDC_ARTIFACT_ALREADY_DEPLOYED_DETAIL, + vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceUUID(), + vfResourceStructure.getNotification().getServiceName(), + BigDecimalVersion.castAndCheckNotificationVersionToString( + vfResourceStructure.getNotification().getServiceVersion()), + vfResourceStructure.getNotification().getServiceUUID(), + vfResourceStructure.getResourceInstance().getResourceName(), "", ""); + } else { + logger.info(MessageEnum.ASDC_ARTIFACT_NOT_DEPLOYED_DETAIL, + vfResourceStructure.getResourceInstance().getResourceInstanceName(), + vfResourceStructure.getResourceInstance().getResourceUUID(), + 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, "", "", MsoLogger.ErrorCode.SchemaError, "Exception - isResourceAlreadyDeployed"); + throw new ArtifactInstallerException("Exception caught during checking existence of the VNF Resource.", e); + } + } + + @Override + public void installTheResource(VfResourceStructure vfResourceStructure) throws ArtifactInstallerException { + + // 1. Add the DB object list (Hashed) to be created from the HashMap + // UUID + // The DB objects will be stored in each VfModuleArtifact objects + // Those objects could be reused by different VfModule + + for (VfModuleArtifact vfModuleArtifact : vfResourceStructure.getArtifactsMapByUUID().values()) { + + switch (vfModuleArtifact.getArtifactInfo().getArtifactType()) { + case ASDCConfiguration.HEAT: + case ASDCConfiguration.HEAT_VOL: + case ASDCConfiguration.HEAT_NESTED: + VfResourceInstaller.createHeatTemplateFromArtifact(vfResourceStructure, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_ENV: + VfResourceInstaller.createHeatEnvFromArtifact(vfResourceStructure, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_ARTIFACT: + VfResourceInstaller.createHeatFileFromArtifact(vfResourceStructure, vfModuleArtifact); + break; + case ASDCConfiguration.HEAT_NET: + case ASDCConfiguration.OTHER: + logger.warn(MessageEnum.ASDC_ARTIFACT_TYPE_NOT_SUPPORT, vfModuleArtifact.getArtifactInfo().getArtifactType()+"(Artifact Name:"+vfModuleArtifact.getArtifactInfo().getArtifactName()+")", "", "", MsoLogger.ErrorCode.DataError, "Artifact type not supported"); + break; + default: + break; + + } + } + + // in case of deployment failure, use a string that will represent the type of artifact that failed... + List<ASDCElementInfo> artifactListForLogging = new ArrayList<>(); + + CatalogDatabase catalogDB = new CatalogDatabase(); + // 2. Create the VFModules/VNFResource objects by linking them to the + // objects created before and store them in Resource/module structure + // Opening a DB transaction, starting from here + try { + + VfResourceInstaller.createService(vfResourceStructure); + + VfResourceInstaller.createVnfResource(vfResourceStructure); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure)); + + catalogDB.saveOrUpdateVnfResource(vfResourceStructure.getCatalogVnfResource()); + catalogDB.saveService(vfResourceStructure.getCatalogService()); + + for (VfModuleStructure vfModuleStructure : vfResourceStructure.getVfModuleStructure()) { + + // Here we set the right db structure according to the Catalog + // DB + + // We expect only one MAIN HEAT per VFMODULE + // we can also obtain from it the Env ArtifactInfo, that's why + // we + // get the Main IArtifactInfo + + HeatTemplate heatMainTemplate = null; + HeatEnvironment heatEnv = null; + + HeatTemplate heatVolumeTemplate = null; + HeatEnvironment heatVolumeEnv = null; + + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT)) { + IArtifactInfo mainEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT) + .get(0).getArtifactInfo().getGeneratedArtifact(); + + // MAIN HEAT + heatMainTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT).get(0).getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo + .createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).getArtifactInfo())); + + catalogDB.saveHeatTemplate(heatMainTemplate, heatMainTemplate.getParameters()); + // Indicate we have deployed it in the DB + vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT).get(0).incrementDeployedInDB(); + + + // VOLUME HEAT + // We expect only one VOL HEAT per VFMODULE + // we can also obtain from it the Env ArtifactInfo, that's why + // we get the Volume IArtifactInfo + + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_VOL)) { + IArtifactInfo volEnvArtifactInfo = vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0) + .getArtifactInfo().getGeneratedArtifact(); + + heatVolumeTemplate = (HeatTemplate) vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_VOL).get(0).getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).getArtifactInfo())); + + catalogDB.saveHeatTemplate(heatVolumeTemplate, heatVolumeTemplate.getParameters()); + // Indicate we have deployed it in the DB + vfModuleStructure.getArtifactsMap().get(ASDCConfiguration.HEAT_VOL).get(0).incrementDeployedInDB(); + + if (volEnvArtifactInfo != null) { + heatVolumeEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() + .get(volEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(volEnvArtifactInfo)); + + catalogDB.saveHeatEnvironment(heatVolumeEnv); + // Indicate we have deployed it in the DB + vfResourceStructure.getArtifactsMapByUUID().get(volEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); + } + + } + + // NESTED HEAT + // Here we expect many HEAT_NESTED template to be there + // check first if we really have nested heat templates + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_NESTED)) { + for (VfModuleArtifact heatNestedArtifact : vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_NESTED)) { + + // Check if this nested is well referenced by the MAIN HEAT + String parentArtifactType = VfResourceInstaller.identifyParentOfNestedTemplate(vfModuleStructure,heatNestedArtifact); + HeatTemplate heatNestedTemplate = (HeatTemplate) heatNestedArtifact.getCatalogObject(); + + if (parentArtifactType != null) { + + switch (parentArtifactType) { + case ASDCConfiguration.HEAT: + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + break; + case ASDCConfiguration.HEAT_VOL: + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + catalogDB.saveNestedHeatTemplate (heatVolumeTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + break; + + default: + break; + + } + } else { // Assume it belongs to HEAT MAIN + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatNestedArtifact.getArtifactInfo())); + + catalogDB.saveNestedHeatTemplate (heatMainTemplate.getId(), heatNestedTemplate, heatNestedTemplate.getTemplateName()); + // Indicate we have deployed it in the DB + heatNestedArtifact.incrementDeployedInDB(); + } + } + } + + if (mainEnvArtifactInfo != null) { + heatEnv = (HeatEnvironment) vfResourceStructure.getArtifactsMapByUUID() + .get(mainEnvArtifactInfo.getArtifactUUID()).getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(mainEnvArtifactInfo)); + + catalogDB.saveHeatEnvironment(heatEnv); + // Indicate we have deployed it in the DB + vfResourceStructure.getArtifactsMapByUUID().get(mainEnvArtifactInfo.getArtifactUUID()).incrementDeployedInDB(); + } + + } + + + // here we expect one VFModule to be there + VfResourceInstaller.createVfModule(vfModuleStructure,heatMainTemplate, heatVolumeTemplate, heatEnv, heatVolumeEnv); + VfModule vfModule = vfModuleStructure.getCatalogVfModule(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure)); + + catalogDB.saveOrUpdateVfModule(vfModule); + + // Here we expect many HEAT_TEMPLATE files to be there + if (vfModuleStructure.getArtifactsMap().containsKey(ASDCConfiguration.HEAT_ARTIFACT)) { + for (VfModuleArtifact heatArtifact : vfModuleStructure.getArtifactsMap() + .get(ASDCConfiguration.HEAT_ARTIFACT)) { + + HeatFiles heatFile = (HeatFiles) heatArtifact.getCatalogObject(); + + // Add this one for logging + artifactListForLogging.add(ASDCElementInfo.createElementFromVfArtifactInfo(heatArtifact.getArtifactInfo())); + + + catalogDB.saveVfModuleToHeatFiles (vfModule.getId(), heatFile); + // Indicate we will deploy it in the DB + heatArtifact.incrementDeployedInDB(); + } + } + + } + + catalogDB.commit(); + vfResourceStructure.setSuccessfulDeployment(); + + } catch (Exception e) { + + 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, vfResourceStructure.getResourceInstance().getResourceName(), + vfResourceStructure.getNotification().getServiceVersion(), "", "", MsoLogger.ErrorCode.DataError, "Exception - ASCDC Artifact already deployed", e); + } else { + String endEvent = "Exception caught during installation of the VFResource. Transaction rollback."; + String elementToLog = (artifactListForLogging.size() > 0 ? artifactListForLogging.get(artifactListForLogging.size()-1).toString() : "No element listed"); + logger.error(MessageEnum.ASDC_ARTIFACT_INSTALL_EXC, elementToLog, "", "", MsoLogger.ErrorCode.DataError, "Exception caught during installation of the VFResource. Transaction rollback", e); + catalogDB.rollback(); + throw new ArtifactInstallerException( + "Exception caught during installation of the VFResource. Transaction rollback.", e); + } + + } finally { + catalogDB.close(); + // Debug log the whole collection... + logger.debug(artifactListForLogging.toString()); + } + + } + + private 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; + + } + + private static void createVnfResource(VfResourceStructure vfResourceStructure) { + VnfResource vnfResource = new VnfResource(); + + vnfResource.setAsdcUuid(vfResourceStructure.getResourceInstance().getResourceUUID()); + vnfResource.setDescription(vfResourceStructure.getNotification().getServiceDescription()); + + vnfResource.setOrchestrationMode("HEAT"); + // Set the version but Version is stored into ASDC_SERVICE_MODEL_VERSION + vnfResource.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfResourceStructure.getNotification().getServiceVersion())); + vnfResource.setVnfType(VfResourceInstaller.createVNFName(vfResourceStructure)); + vnfResource.setModelVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfResourceStructure.getResourceInstance().getResourceVersion())); + + vnfResource.setModelInvariantUuid(vfResourceStructure.getResourceInstance().getResourceInvariantUUID()); + vnfResource.setModelCustomizationName(vfResourceStructure.getResourceInstance().getResourceInstanceName()); + vnfResource.setModelName(vfResourceStructure.getResourceInstance().getResourceName()); + vnfResource.setServiceModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); + + vfResourceStructure.setCatalogVnfResource(vnfResource); + } + + private static void createVfModule(VfModuleStructure vfModuleStructure,HeatTemplate heatMain, HeatTemplate heatVolume,HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { + VfModule vfModule = new VfModule(); + vfModule.setType(createVfModuleName(vfModuleStructure)); + vfModule.setAsdcUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelUUID()); + vfModule.setDescription(vfModuleStructure.getVfModuleMetadata().getVfModuleModelDescription()); + + if (vfModuleStructure.getVfModuleMetadata().isBase()) { + vfModule.setIsBase(1); + } else { + vfModule.setIsBase(0); + } + + vfModule.setModelInvariantUuid(vfModuleStructure.getVfModuleMetadata().getVfModuleModelInvariantUUID()); + vfModule.setModelName(vfModuleStructure.getVfModuleMetadata().getVfModuleModelName()); + + vfModule.setVersion(BigDecimalVersion.castAndCheckNotificationVersionToString(vfModuleStructure.getParentVfResource().getNotification().getServiceVersion())); + vfModule.setModelVersion(BigDecimalVersion.castAndCheckNotificationVersionToString( + vfModuleStructure.getVfModuleMetadata().getVfModuleModelVersion())); + + vfModuleStructure.setCatalogVfModule(vfModule); + + VfResourceInstaller.createVfModuleLinks(vfModule, vfModuleStructure.getParentVfResource().getCatalogVnfResource(), heatMain,heatVolume, heatEnv,heatVolumeEnv); + } + + private static void createVfModuleLinks(VfModule vfModule, VnfResource vnfResource, HeatTemplate heatMain, + HeatTemplate heatVolume, HeatEnvironment heatEnv, HeatEnvironment heatVolumeEnv) { + + if (heatMain !=null) { + vfModule.setTemplateId(heatMain.getId()); + } + if (heatEnv != null) { + vfModule.setEnvironmentId(heatEnv.getId()); + } + if (heatVolume != null) { + vfModule.setVolTemplateId(heatVolume.getId()); + } + if (heatVolumeEnv != null) { + vfModule.setVolEnvironmentId(heatVolumeEnv.getId()); + } + + vfModule.setVnfResourceId(vnfResource.getId()); + + } + + private static Set<HeatTemplateParam> extractHeatTemplateParameters(String yamlFile) { + + // Scan the payload downloadResult and extract the HeatTemplate + // parameters + YamlEditor yamlEditor = new YamlEditor(yamlFile.getBytes()); + return yamlEditor.getParameterList(); + + } + + + public static 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 static 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; + } + + StringBuffer sb = new StringBuffer(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(); + } + + private static void createHeatTemplateFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + HeatTemplate heatTemplate = new HeatTemplate(); + + // TODO Set the label + heatTemplate.setAsdcLabel("label"); + // Use the ResourceName of the ASDC template because the HEAT could be + // reused + heatTemplate.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); + heatTemplate.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + + List<String> typeList = new ArrayList<String>(); + 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())); + Set<HeatTemplateParam> heatParam = VfResourceInstaller + .extractHeatTemplateParameters(vfModuleArtifact.getResult()); + heatTemplate.setParameters(heatParam); + + vfModuleArtifact.setCatalogObject(heatTemplate); + } + + private static void createHeatEnvFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + HeatEnvironment heatEnvironment = new HeatEnvironment(); + + heatEnvironment.setName(vfModuleArtifact.getArtifactInfo().getArtifactName()); + // TODO Set the label + heatEnvironment.setAsdcLabel("Label"); + + List<String> typeList = new ArrayList<String>(); + typeList.add(ASDCConfiguration.HEAT); + typeList.add(ASDCConfiguration.HEAT_VOL); + + heatEnvironment.setEnvironment(verifyTheFilePrefixInArtifacts(vfModuleArtifact.getResult(),vfResourceStructure,typeList)); + heatEnvironment.setAsdcUuid(vfModuleArtifact.getArtifactInfo().getArtifactUUID()); + heatEnvironment.setDescription(vfModuleArtifact.getArtifactInfo().getArtifactDescription()); + heatEnvironment.setVersion(BigDecimalVersion + .castAndCheckNotificationVersionToString(vfModuleArtifact.getArtifactInfo().getArtifactVersion())); + heatEnvironment.setAsdcResourceName(VfResourceInstaller.createVNFName(vfResourceStructure)); + + vfModuleArtifact.setCatalogObject(heatEnvironment); + + } + + private static void createHeatFileFromArtifact(VfResourceStructure vfResourceStructure, + VfModuleArtifact vfModuleArtifact) { + + HeatFiles heatFile = new HeatFiles(); + // TODO Set the label + heatFile.setAsdcLabel("Label"); + 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())); + + heatFile.setAsdcResourceName(vfResourceStructure.getResourceInstance().getResourceName()); + vfModuleArtifact.setCatalogObject(heatFile); + + } + + private static void createService(VfResourceStructure vfResourceStructure) { + + Service service = new Service(); + service.setDescription(vfResourceStructure.getNotification().getServiceDescription()); + service.setServiceName(vfResourceStructure.getNotification().getServiceName()); + service.setServiceNameVersionId(vfResourceStructure.getNotification().getServiceUUID()); + service.setVersion(vfResourceStructure.getNotification().getServiceVersion()); + service.setModelInvariantUUID(vfResourceStructure.getNotification().getServiceInvariantUUID()); + + vfResourceStructure.setCatalogService(service); + } + + + private static String createVNFName(VfResourceStructure vfResourceStructure) { + + return vfResourceStructure.getNotification().getServiceName() + "/" + vfResourceStructure.getResourceInstance().getResourceInstanceName(); + } + + private static String createVfModuleName(VfModuleStructure vfModuleStructure) { + + return createVNFName(vfModuleStructure.getParentVfResource())+"::"+vfModuleStructure.getVfModuleMetadata().getVfModuleModelName(); + } + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java new file mode 100644 index 0000000000..312613d1bc --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ASDCNotificationLogging.java @@ -0,0 +1,335 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.util; + + +import java.util.List; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; + +public class ASDCNotificationLogging { + + public static String dumpASDCNotification(INotificationData asdcNotification) { + + if (asdcNotification == null) { + return "NULL"; + } + StringBuffer buffer = new StringBuffer("ASDC Notification:"); + buffer.append(System.lineSeparator()); + + buffer.append("DistributionID:"); + buffer.append(testNull(asdcNotification.getDistributionID())); + buffer.append(System.lineSeparator()); + + + buffer.append("ServiceName:"); + buffer.append(testNull(asdcNotification.getServiceName())); + buffer.append(System.lineSeparator()); + + + buffer.append("ServiceVersion:"); + buffer.append(testNull(asdcNotification.getServiceVersion())); + buffer.append(System.lineSeparator()); + + + buffer.append("ServiceUUID:"); + buffer.append(testNull(asdcNotification.getServiceUUID())); + buffer.append(System.lineSeparator()); + + + buffer.append("ServiceInvariantUUID:"); + buffer.append(testNull(asdcNotification.getServiceInvariantUUID())); + buffer.append(System.lineSeparator()); + + + buffer.append("ServiceDescription:"); + buffer.append(testNull(asdcNotification.getServiceDescription())); + buffer.append(System.lineSeparator()); + + + buffer.append("Service Artifacts List:"); + buffer.append(System.lineSeparator()); + buffer.append(testNull(dumpArtifactInfoList(asdcNotification.getServiceArtifacts()))); + buffer.append(System.lineSeparator()); + + buffer.append("Resource Instances List:"); + buffer.append(System.lineSeparator()); + buffer.append(testNull(dumpASDCResourcesList(asdcNotification))); + buffer.append(System.lineSeparator()); + + + return buffer.toString(); + } + + public static String dumpVfModuleMetaDataList(List<IVfModuleMetadata> moduleMetaDataList) { + if (moduleMetaDataList == null ) { + return null; + } + + StringBuffer buffer = new StringBuffer(); + buffer.append("{"); + + for (IVfModuleMetadata 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(IVfModuleMetadata moduleMetaData) { + + if (moduleMetaData == null ) { + return "NULL"; + } + + StringBuffer buffer = new StringBuffer("VfModuleMetaData:"); + buffer.append(System.lineSeparator()); + + buffer.append("VfModuleModelName:"); + buffer.append(testNull(moduleMetaData.getVfModuleModelName())); + buffer.append(System.lineSeparator()); + + buffer.append("VfModuleModelVersion:"); + buffer.append(testNull(moduleMetaData.getVfModuleModelVersion())); + buffer.append(System.lineSeparator()); + + buffer.append("VfModuleModelUUID:"); + buffer.append(testNull(moduleMetaData.getVfModuleModelUUID())); + buffer.append(System.lineSeparator()); + + buffer.append("VfModuleModelInvariantUUID:"); + buffer.append(testNull(moduleMetaData.getVfModuleModelInvariantUUID())); + buffer.append(System.lineSeparator()); + + buffer.append("VfModuleModelDescription:"); + buffer.append(testNull(moduleMetaData.getVfModuleModelDescription())); + buffer.append(System.lineSeparator()); + + buffer.append("Artifacts UUID List:"); + + if (moduleMetaData.getArtifacts() != null) { + buffer.append("{"); + + for (String artifactUUID:moduleMetaData.getArtifacts()) { + buffer.append(System.lineSeparator()); + buffer.append(testNull(artifactUUID)); + 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()); + + buffer.append("isBase:"); + buffer.append(moduleMetaData.isBase()); + buffer.append(System.lineSeparator()); + + return buffer.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; + } + + StringBuffer buffer = new StringBuffer(); + 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; + } + + StringBuffer buffer = new StringBuffer("Resource Instance Info:"); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceInstanceName:"); + buffer.append(testNull(resourceInstance.getResourceInstanceName())); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceInvariantUUID:"); + buffer.append(testNull(resourceInstance.getResourceInvariantUUID())); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceName:"); + buffer.append(testNull(resourceInstance.getResourceName())); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceType:"); + buffer.append(testNull(resourceInstance.getResourceType())); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceUUID:"); + buffer.append(testNull(resourceInstance.getResourceUUID())); + buffer.append(System.lineSeparator()); + + buffer.append("ResourceVersion:"); + buffer.append(testNull(resourceInstance.getResourceVersion())); + buffer.append(System.lineSeparator()); + + buffer.append("Resource Artifacts List:"); + buffer.append(System.lineSeparator()); + buffer.append(testNull(dumpArtifactInfoList(resourceInstance.getArtifacts()))); + buffer.append(System.lineSeparator()); + + return buffer.toString(); + + } + + + private static String dumpArtifactInfoList(List<IArtifactInfo> artifactsList) { + + if (artifactsList == null || artifactsList.isEmpty()) { + return null; + } + + StringBuffer buffer = new StringBuffer(); + 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; + } + + StringBuffer buffer = new StringBuffer("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()); + + return buffer.toString(); + } +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java new file mode 100644 index 0000000000..b45cf06c6f --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/NotificationLogging.java @@ -0,0 +1,168 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.openecomp.mso.asdc.util; + + + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.openecomp.sdc.api.notification.INotificationData; + + +public class NotificationLogging implements InvocationHandler { + + private static Map<Object, List<Method>> objectMethodsToLog = new HashMap<>(); + + private static InvocationHandler handler = new InvocationHandler() { + @Override + public Object invoke(Object arg0, Method arg1, Object[] arg2) + throws Throwable { + 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 !!! + } + + StringBuffer buffer = new StringBuffer("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) { + buffer.append("UNREADABLE"); + } + buffer.append(System.lineSeparator()); + } + } + + return buffer.toString(); + } + + private static final 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<Method>()); + } + + 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/openecomp/mso/asdc/util/ToLog.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ToLog.java new file mode 100644 index 0000000000..524cc9704a --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/ToLog.java @@ -0,0 +1,29 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.openecomp.mso.asdc.util; + + + + +public @interface ToLog { + +} diff --git a/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java new file mode 100644 index 0000000000..773ff86444 --- /dev/null +++ b/asdc-controller/src/main/java/org/openecomp/mso/asdc/util/YamlEditor.java @@ -0,0 +1,177 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.util; + + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +import org.yaml.snakeyaml.Yaml; + +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; + +public class YamlEditor { + + private static final String REFER_PATTERN = "file:///"; + private Map <String, Object> yml; + private Yaml yaml = new Yaml (); + + public YamlEditor () { + + } + + public YamlEditor (byte[] body) { + init (body); + } + + @SuppressWarnings("unchecked") + private 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 <String> (); + + @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 (); + @SuppressWarnings("unchecked") + Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); + String type = resourceEntry.get ("type"); + + if (type.contains (REFER_PATTERN)) { + typeList.add (type); + } + it.remove (); // avoids a ConcurrentModificationException + } + return typeList; + } + + public synchronized List <String> getYamlResourceTypeList () { + List <String> typeList = new ArrayList <String> (); + + @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 (); + @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 () { + Set <HeatTemplateParam> paramSet = new HashSet <HeatTemplateParam> (); + @SuppressWarnings("unchecked") + Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); + Iterator <Entry <String, Object>> it = resourceMap.entrySet ().iterator (); + + while (it.hasNext ()) { + HeatTemplateParam param = new HeatTemplateParam (); + Map.Entry <String, Object> pair = it.next (); + @SuppressWarnings("unchecked") + Map <String, String> resourceEntry = (Map <String, String>) pair.getValue (); + + param.setParamName (pair.getKey ()); + // System.out.println(pair.getKey()+":"+type); + if (resourceEntry.containsKey("default")) { + param.setRequired (false); + } else { + param.setRequired (true); + } + // Now set the type + String value = resourceEntry.get ("type"); + param.setParamType (value); + + paramSet.add (param); + + } + return paramSet; + + } + + public synchronized void addParameterList (Set <HeatTemplateParam> heatSet) { + + @SuppressWarnings("unchecked") + Map <String, Object> resourceMap = (Map <String, Object>) yml.get ("parameters"); + if (resourceMap == null) { + resourceMap = new LinkedHashMap <String, Object> (); + this.yml.put ("parameters", resourceMap); + } + for (HeatTemplateParam heatParam : heatSet) { + Map <String, Object> paramInfo = new HashMap <String, Object> (); + paramInfo.put ("type", heatParam.getParamType ()); + + resourceMap.put (heatParam.getParamName (), paramInfo); + } + + // this.yml.put("parameters", resourceMap); + + } + + public boolean isParentTemplate (String templateBody) { + return templateBody.contains (REFER_PATTERN); + } + + 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 synchronized String encode () { + return this.yaml.dump (this.yml); + } + + /** + * This method return the YAml file as a string. + * + */ + @Override + public String toString () { + + return encode (); + } + +} diff --git a/asdc-controller/src/main/resources/config-key.properties b/asdc-controller/src/main/resources/config-key.properties new file mode 100644 index 0000000000..b6a0cde18f --- /dev/null +++ b/asdc-controller/src/main/resources/config-key.properties @@ -0,0 +1,21 @@ +### +# ============LICENSE_START======================================================= +# ECOMP MSO +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +### + +asdc.config.key=566B754875657232314F5548556D3665 diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java new file mode 100644 index 0000000000..9ca02e218a --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTest.java @@ -0,0 +1,38 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:38:29 GMT 2016 + */ + +package org.openecomp.mso.asdc; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCControllerSingletonESTest extends ASDCControllerSingletonESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); + PrivateAccess.callMethod((Class<ASDCControllerSingleton>) ASDCControllerSingleton.class, aSDCControllerSingleton0, "setWorking", (Object) true, (Class<?>) boolean.class); + aSDCControllerSingleton0.periodicControllerTask(); + } + + @Test(timeout = 4000) + public void test1() throws Throwable { + ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); + Object object0 = PrivateAccess.callMethod((Class<ASDCControllerSingleton>) ASDCControllerSingleton.class, aSDCControllerSingleton0, "terminate"); + assertNull(object0); + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + ASDCControllerSingleton aSDCControllerSingleton0 = new ASDCControllerSingleton(); + aSDCControllerSingleton0.periodicControllerTask(); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java new file mode 100644 index 0000000000..e099e9ceaf --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/ASDCControllerSingletonESTestscaffolding.java @@ -0,0 +1,120 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:38:29 GMT 2016 + */ + +package org.openecomp.mso.asdc; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCControllerSingletonESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.ASDCControllerSingleton"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCControllerSingletonESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.properties.AbstractMsoProperties", + "org.openecomp.mso.properties.MsoPropertiesParameters$MsoPropertiesType", + "org.openecomp.mso.properties.MsoPropertiesParameters", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "org.openecomp.mso.logger.MsoLogger$ErrorCode", + "com.att.eelf.configuration.EELFLogger", + "org.openecomp.mso.properties.MsoJavaProperties", + "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException", + "com.att.eelf.configuration.SLF4jWrapper", + "com.att.eelf.i18n.EELFResourceManager", + "org.openecomp.mso.properties.MsoPropertiesException", + "org.openecomp.mso.logger.MsoLogger", + "org.openecomp.mso.logger.MessageEnum", + "com.att.eelf.i18n.EELFResolvableErrorEnum", + "org.openecomp.mso.logger.MsoLogger$ResponseCode", + "org.openecomp.mso.properties.MsoJsonProperties", + "org.openecomp.mso.entity.MsoRequest", + "org.openecomp.mso.asdc.ASDCControllerSingleton", + "org.openecomp.mso.logger.MsoLogger$StatusCode", + "com.att.eelf.configuration.EELFManager", + "com.att.eelf.i18n.EELFMsgs", + "org.openecomp.mso.properties.MsoPropertiesFactory", + "org.openecomp.mso.asdc.client.ASDCGlobalController", + "com.att.eelf.configuration.EELFLogger$Level", + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCControllerSingletonESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.logger.MsoLogger$Catalog", + "org.openecomp.mso.logger.MsoLogger", + "com.att.eelf.i18n.EELFResourceManager", + "com.att.eelf.i18n.EELFMsgs", + "com.att.eelf.i18n.EELFResourceManager$RESOURCE_TYPES", + "com.att.eelf.configuration.EELFLogger$Level", + "com.att.eelf.configuration.EELFManager", + "org.openecomp.mso.logger.MessageEnum", + "org.openecomp.mso.asdc.ASDCControllerSingleton", + "org.openecomp.mso.asdc.client.ASDCGlobalController", + "org.openecomp.mso.properties.MsoPropertiesFactory", + "org.openecomp.mso.properties.MsoPropertiesParameters$MsoPropertiesType", + "org.openecomp.mso.properties.MsoPropertiesException", + "org.openecomp.mso.logger.MsoLogger$ErrorCode" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java new file mode 100644 index 0000000000..e2112cee03 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTest.java @@ -0,0 +1,134 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:39:00 GMT 2016 + */ + +package org.openecomp.mso.asdc.client; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; +import org.openecomp.sdc.utils.DistributionStatusEnum; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class DistributionStatusMessageESTest extends DistributionStatusMessageESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); + long long0 = distributionStatusMessage0.getTimestamp(); + assertEquals(1L, long0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DEPLOYED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("n*lho0\"NQ4azb%8]KN", "n*lho0\"NQ4azb%8]KN", "BMWmXl2i-B", distributionStatusEnum0, (-58L)); + long long0 = distributionStatusMessage0.getTimestamp(); + assertEquals("BMWmXl2i-B", distributionStatusMessage0.getDistributionID()); + assertEquals((-58L), long0); + assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getConsumerID()); + assertEquals("n*lho0\"NQ4azb%8]KN", distributionStatusMessage0.getArtifactURL()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); + DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); + DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L)); + String string0 = distributionStatusMessage1.getDistributionID(); + assertNotNull(string0); + assertEquals((-833L), distributionStatusMessage1.getTimestamp()); + assertEquals("", distributionStatusMessage1.getArtifactURL()); + assertEquals("*? q^M(_q^3$ZQ", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("", "", "", distributionStatusEnum0, 1L); + distributionStatusMessage0.getDistributionID(); + assertEquals(1L, distributionStatusMessage0.getTimestamp()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L); + String string0 = distributionStatusMessage0.getConsumerID(); + assertEquals("ALREADY_DEPLOYED", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); + DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); + DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage((String) null, "", "Qcuo3~gd})vsI*", distributionStatusEnum1, 0L); + String string0 = distributionStatusMessage1.getConsumerID(); + assertNotNull(string0); + assertEquals(1L, distributionStatusMessage0.getTimestamp()); + assertEquals("", string0); + assertEquals("Qcuo3~gd})vsI*", distributionStatusMessage1.getDistributionID()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage("ALREADY_DEPLOYED", "ALREADY_DEPLOYED", "ALREADY_DEPLOYED", distributionStatusEnum0, 0L); + String string0 = distributionStatusMessage0.getArtifactURL(); + assertEquals("ALREADY_DEPLOYED", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + DistributionStatusEnum distributionStatusEnum0 = DistributionStatusEnum.ALREADY_DOWNLOADED; + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, distributionStatusEnum0, 1L); + DistributionStatusEnum distributionStatusEnum1 = distributionStatusMessage0.getStatus(); + DistributionStatusMessage distributionStatusMessage1 = new DistributionStatusMessage("", (String) null, "*? q^M(_q^3$ZQ", distributionStatusEnum1, (-833L)); + String string0 = distributionStatusMessage1.getArtifactURL(); + assertEquals("", string0); + assertEquals("*? q^M(_q^3$ZQ", distributionStatusMessage1.getDistributionID()); + assertNotNull(string0); + assertEquals((-833L), distributionStatusMessage1.getTimestamp()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); + long long0 = distributionStatusMessage0.getTimestamp(); + assertEquals(0L, long0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); + String string0 = distributionStatusMessage0.getDistributionID(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); + distributionStatusMessage0.getStatus(); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); + String string0 = distributionStatusMessage0.getConsumerID(); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + DistributionStatusMessage distributionStatusMessage0 = new DistributionStatusMessage((String) null, (String) null, (String) null, (DistributionStatusEnum) null, 0L); + String string0 = distributionStatusMessage0.getArtifactURL(); + assertNull(string0); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java new file mode 100644 index 0000000000..f234ca64d5 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/DistributionStatusMessageESTestscaffolding.java @@ -0,0 +1,79 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:39:00 GMT 2016 + */ + +package org.openecomp.mso.asdc.client; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class DistributionStatusMessageESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.DistributionStatusMessage"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(DistributionStatusMessageESTestscaffolding.class.getClassLoader() , + "org.openecomp.sdc.utils.DistributionStatusEnum", + "org.openecomp.mso.asdc.client.DistributionStatusMessage", + "org.openecomp.sdc.api.consumer.IDistributionStatusMessage" + ); + } + + private static void resetClasses() { + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java new file mode 100644 index 0000000000..37af59c639 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTest.java @@ -0,0 +1,26 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:39:27 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.mock.java.lang.MockThrowable; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCControllerExceptionESTest extends ASDCControllerExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ASDCControllerException aSDCControllerException0 = new ASDCControllerException("org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"); + MockThrowable mockThrowable0 = new MockThrowable("B+;:\"w4^M(-Y:e~=", (Throwable) aSDCControllerException0); + ASDCControllerException aSDCControllerException1 = new ASDCControllerException("The list of prefixes must not be null", (Throwable) mockThrowable0); + assertFalse(aSDCControllerException1.equals((Object)aSDCControllerException0)); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java new file mode 100644 index 0000000000..d6041c2fb2 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCControllerExceptionESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:39:27 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCControllerExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCControllerExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCControllerExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ASDCControllerException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java new file mode 100644 index 0000000000..75f4b5d27c --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:38:49 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCDownloadExceptionESTest extends ASDCDownloadExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ASDCDownloadException aSDCDownloadException0 = new ASDCDownloadException(""); + ASDCDownloadException aSDCDownloadException1 = new ASDCDownloadException("", (Throwable) aSDCDownloadException0); + assertFalse(aSDCDownloadException1.equals((Object)aSDCDownloadException0)); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java new file mode 100644 index 0000000000..5db3c2098f --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCDownloadExceptionESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:38:49 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCDownloadExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCDownloadExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ASDCDownloadException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java new file mode 100644 index 0000000000..afc28346e3 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:39:10 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCParametersExceptionESTest extends ASDCParametersExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ASDCParametersException aSDCParametersException0 = new ASDCParametersException("4vI_{2b<h&iIy"); + ASDCParametersException aSDCParametersException1 = new ASDCParametersException((String) null, (Throwable) aSDCParametersException0); + assertFalse(aSDCParametersException1.equals((Object)aSDCParametersException0)); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java new file mode 100644 index 0000000000..ce3afc92cd --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ASDCParametersExceptionESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:39:10 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCParametersExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCParametersExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCParametersExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ASDCParametersException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java new file mode 100644 index 0000000000..2a1c8177de --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTest.java @@ -0,0 +1,24 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:38:39 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.junit.Test; +import static org.junit.Assert.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ArtifactInstallerExceptionESTest extends ArtifactInstallerExceptionESTestscaffolding { + + @Test(timeout = 4000) + public void test0() throws Throwable { + ArtifactInstallerException artifactInstallerException0 = new ArtifactInstallerException("kD=Ua3["); + ArtifactInstallerException artifactInstallerException1 = new ArtifactInstallerException("kD=Ua3[", (Throwable) artifactInstallerException0); + assertFalse(artifactInstallerException1.equals((Object)artifactInstallerException0)); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java new file mode 100644 index 0000000000..0bd3d65f0e --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/exceptions/ArtifactInstallerExceptionESTestscaffolding.java @@ -0,0 +1,82 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:38:39 GMT 2016 + */ + +package org.openecomp.mso.asdc.client.exceptions; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ArtifactInstallerExceptionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ArtifactInstallerExceptionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ArtifactInstallerExceptionESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java new file mode 100644 index 0000000000..168f830f83 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCConfigurationTest.java @@ -0,0 +1,356 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.tests; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.io.IOException; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + +/** + * THis class tests the ASDC Controller by using the ASDC Mock CLient + * + * + */ +public class ASDCConfigurationTest { + + public static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + public final String ASDC_PROP = ASDCConfigurationTest.class.getClassLoader().getResource("mso.json").toString().substring(5); + public final String ASDC_PROP2 = ASDCConfigurationTest.class.getClassLoader().getResource("mso2.json").toString().substring(5); + public final String ASDC_PROP3 = ASDCConfigurationTest.class.getClassLoader().getResource("mso3.json").toString().substring(5); + public final String ASDC_PROP_BAD = ASDCConfigurationTest.class.getClassLoader().getResource("mso-bad.json").toString().substring(5); + public final String ASDC_PROP_WITH_NULL = ASDCConfigurationTest.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5); + public final String ASDC_PROP_DOUBLE_CONFIG = ASDCConfigurationTest.class.getClassLoader().getResource("mso-two-configs.json").toString().substring(5); + public final String ASDC_PROP4_WITH_TLS = ASDCConfigurationTest.class.getClassLoader().getResource("mso4-with-TLS.json").toString().substring(5); + + @BeforeClass + public static final void prepareBeforeAllTests() { + msoPropertiesFactory.removeAllMsoProperties(); + } + + @Before + public final void prepareBeforeEachTest () throws MsoPropertiesException { + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + } + + @After + public final void cleanAfterEachTest () { + msoPropertiesFactory.removeAllMsoProperties(); + } + + @Test + public final void testTheInit() throws ASDCParametersException, IOException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + assertNotNull(asdcConfig.getUser()); + assertTrue("User".equals(asdcConfig.getUser())); + + assertNotNull(asdcConfig.getPassword()); + assertTrue("ThePassword".equals(asdcConfig.getPassword())); + + assertNotNull(asdcConfig.getConsumerGroup()); + assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup())); + + assertNotNull(asdcConfig.getConsumerID()); + assertTrue("consumerId".equals(asdcConfig.getConsumerID())); + + assertNotNull(asdcConfig.getEnvironmentName()); + assertTrue("environmentName".equals(asdcConfig.getEnvironmentName())); + + assertNotNull(asdcConfig.getAsdcAddress()); + assertTrue("hostname".equals(asdcConfig.getAsdcAddress())); + + assertNotNull(asdcConfig.getPollingInterval()); + assertTrue(asdcConfig.getPollingInterval() == 10); + + assertNotNull(asdcConfig.getPollingTimeout()); + assertTrue(asdcConfig.getPollingTimeout() == 30); + + assertNotNull(asdcConfig.getRelevantArtifactTypes()); + assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size()); + + assertFalse(asdcConfig.activateServerTLSAuth()); + + } + + @Test + public final void testAllParametersMethod() throws ASDCParametersException, IOException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + + // No exception should be raised + asdcConfig.testAllParameters(); + } + + @Test + public final void testTheRefreshConfigFalseCase() throws ASDCParametersException, IOException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + + // No update should be done as we use the mso.properties located in the resource folder for testing + assertFalse(asdcConfig.hasASDCConfigChanged()); + assertFalse(asdcConfig.refreshASDCConfig()); + + assertNotNull(asdcConfig.getUser()); + assertTrue("User".equals(asdcConfig.getUser())); + + assertNotNull(asdcConfig.getPassword()); + assertTrue("ThePassword".equals(asdcConfig.getPassword())); + + assertNotNull(asdcConfig.getConsumerGroup()); + assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup())); + + assertNotNull(asdcConfig.getConsumerID()); + assertTrue("consumerId".equals(asdcConfig.getConsumerID())); + + assertNotNull(asdcConfig.getEnvironmentName()); + assertTrue("environmentName".equals(asdcConfig.getEnvironmentName())); + + assertNotNull(asdcConfig.getAsdcAddress()); + assertTrue("hostname".equals(asdcConfig.getAsdcAddress())); + + assertNotNull(asdcConfig.getPollingInterval()); + assertTrue(asdcConfig.getPollingInterval() == 10); + + assertNotNull(asdcConfig.getPollingTimeout()); + assertTrue(asdcConfig.getPollingTimeout() == 30); + + assertNotNull(asdcConfig.getRelevantArtifactTypes()); + assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size()); + + msoPropertiesFactory.removeAllMsoProperties(); + + try { + asdcConfig.refreshASDCConfig(); + fail("Should have thrown an ASDCParametersException because config does not exist anymore!"); + } catch (ASDCParametersException e) { + assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded"))); + } + + try { + asdcConfig.hasASDCConfigChanged(); + fail("Should have thrown an ASDCParametersException because config does not exist anymore!"); + } catch (ASDCParametersException e) { + assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be read"))); + } + + } + + + @Test + public final void testToChangeTheFileAndRefresh () throws ASDCParametersException, IOException, MsoPropertiesException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP2); + msoPropertiesFactory.reloadMsoProperties(); + + // SHould be the same file untouched just a different file name, there should be no difference between them + // In a normal case a different Filename should force the system to reload the config but not here as we have changed the filename by reflection + assertFalse(asdcConfig.hasASDCConfigChanged()); + assertFalse(asdcConfig.refreshASDCConfig()); + + assertNotNull(asdcConfig.getUser()); + assertTrue("User".equals(asdcConfig.getUser())); + + assertNotNull(asdcConfig.getPassword()); + assertTrue("ThePassword".equals(asdcConfig.getPassword())); + + assertNotNull(asdcConfig.getConsumerGroup()); + assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup())); + + assertNotNull(asdcConfig.getConsumerID()); + assertTrue("consumerId".equals(asdcConfig.getConsumerID())); + + assertNotNull(asdcConfig.getEnvironmentName()); + assertTrue("environmentName".equals(asdcConfig.getEnvironmentName())); + + assertNotNull(asdcConfig.getAsdcAddress()); + assertTrue("hostname".equals(asdcConfig.getAsdcAddress())); + + assertNotNull(asdcConfig.getPollingInterval()); + assertTrue(asdcConfig.getPollingInterval() == 10); + + assertNotNull(asdcConfig.getPollingTimeout()); + assertTrue(asdcConfig.getPollingTimeout() == 30); + + assertNotNull(asdcConfig.getRelevantArtifactTypes()); + assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size()); + + // Set another file that has some attributes changed + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3); + msoPropertiesFactory.reloadMsoProperties(); + + // SHould be the same file untouched just a different file name, so new config + assertTrue(asdcConfig.hasASDCConfigChanged()); + assertTrue(asdcConfig.refreshASDCConfig()); + + assertNotNull(asdcConfig.getUser()); + assertTrue("User".equals(asdcConfig.getUser())); + + assertNotNull(asdcConfig.getPassword()); + assertTrue("ThePassword".equals(asdcConfig.getPassword())); + + assertNotNull(asdcConfig.getConsumerGroup()); + assertTrue("consumerGroup".equals(asdcConfig.getConsumerGroup())); + + assertNotNull(asdcConfig.getConsumerID()); + assertTrue("consumerId".equals(asdcConfig.getConsumerID())); + + assertNotNull(asdcConfig.getEnvironmentName()); + assertTrue("environmentName".equals(asdcConfig.getEnvironmentName())); + + // only this field has been changed + assertNotNull(asdcConfig.getAsdcAddress()); + assertTrue("hostname1".equals(asdcConfig.getAsdcAddress())); + + assertNotNull(asdcConfig.getPollingInterval()); + assertTrue(asdcConfig.getPollingInterval() == 10); + + assertNotNull(asdcConfig.getPollingTimeout()); + assertTrue(asdcConfig.getPollingTimeout() == 30); + + assertNotNull(asdcConfig.getRelevantArtifactTypes()); + assertTrue(asdcConfig.getRelevantArtifactTypes().size() == ASDCConfiguration.SUPPORTED_ARTIFACT_TYPES_LIST.size()); + + + // reload the good property file for other test cases + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + + } + + @Test + public final void testAllParametersCheck () throws ASDCParametersException, IOException, MsoPropertiesException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD); + msoPropertiesFactory.reloadMsoProperties(); + // SHould be a bad file, it should raise an exception + try { + asdcConfig.refreshASDCConfig(); + fail("Should have thrown an ASDCControllerException because one param is missing!"); + } catch (ASDCParametersException e) { + assertTrue(e.getMessage().contains(("consumerGroup parameter cannot be found in config mso.properties"))); + } + + + // reload the good property file for other test cases + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + + assertTrue(asdcConfig.refreshASDCConfig()); + + } + + @Test + public final void testConsumerGroupWithNULL () throws MsoPropertiesException, ASDCParametersException, IOException { + ASDCConfiguration asdcConfig = new ASDCConfiguration("asdc-controller1"); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_NULL); + msoPropertiesFactory.reloadMsoProperties(); + + asdcConfig.refreshASDCConfig(); + assertTrue(asdcConfig.getConsumerGroup()==null); + + // reload the good property file for other test cases + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + + assertTrue(asdcConfig.refreshASDCConfig()); + + + } + + @Test + public final void testGetAllDefinedControllers() throws MsoPropertiesException, ASDCParametersException, IOException { + List<String> listControllers = ASDCConfiguration.getAllDefinedControllers(); + + assertTrue(listControllers.size()==1); + assertTrue("asdc-controller1".equals(listControllers.get(0))); + + ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1"); + assertTrue(asdcConfiguration.getAsdcControllerName().equals("asdc-controller1")); + + + // Try to reload a wrong Json file + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD); + msoPropertiesFactory.reloadMsoProperties(); + + listControllers = ASDCConfiguration.getAllDefinedControllers(); + assertTrue(listControllers.size()==0); + + } + + @Test + public final void testABadInit() throws MsoPropertiesException { + msoPropertiesFactory.removeAllMsoProperties(); + + try { + ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1"); + fail("Should have thrown an ASDCParametersException because prop factory is empty!"); + } catch (ASDCParametersException e) { + assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded"))); + } catch (IOException e) { + fail("Should have thrown an ASDCParametersException, not IOException because file is corrupted!"); + } + } + + @Test + public final void testFileDoesNotExist() throws MsoPropertiesException, ASDCParametersException, IOException { + + ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1"); + + msoPropertiesFactory.removeAllMsoProperties(); + + try { + asdcConfiguration.refreshASDCConfig(); + fail("Should have thrown an ASDCParametersException because factory is empty!"); + } catch (ASDCParametersException e) { + assertTrue(e.getMessage().contains(("mso.asdc.json not initialized properly, ASDC config cannot be reloaded"))); + } + } + + @Test + public final void testWithTLS () throws ASDCParametersException, IOException, MsoPropertiesException { + ASDCConfiguration asdcConfiguration = new ASDCConfiguration("asdc-controller1"); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP4_WITH_TLS); + msoPropertiesFactory.reloadMsoProperties(); + + asdcConfiguration.refreshASDCConfig(); + + assertTrue(asdcConfiguration.activateServerTLSAuth()); + assertTrue("/test".equals(asdcConfiguration.getKeyStorePath())); + assertTrue("ThePassword".equals(asdcConfiguration.getKeyStorePassword())); + } + +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java new file mode 100644 index 0000000000..b6c5577b63 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCControllerTest.java @@ -0,0 +1,412 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.tests; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Matchers.any; +import java.io.IOException; +import java.lang.reflect.Field; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.codec.binary.Base64; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; + +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.consumer.INotificationCallback; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.impl.mock.DistributionClientStubImpl; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.ASDCController; +import org.openecomp.mso.asdc.client.ASDCControllerStatus; +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + + +/** + * THis class tests the ASDC Controller by using the ASDC Mock CLient + * + * + */ +public class ASDCControllerTest { + + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + private static String heatExample; + private static String heatExampleMD5HashBase64; + + private static INotificationData iNotif; + + private static IDistributionClientDownloadResult downloadResult; + private static IDistributionClientDownloadResult downloadCorruptedResult; + + private static IDistributionClientResult successfulClientInitResult; + private static IDistributionClientResult unsuccessfulClientInitResult; + + private static IArtifactInfo artifactInfo1; + + private static IResourceInstance resource1; + + private static VfResourceInstaller vnfInstaller; + + public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString().substring(5); + public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString().substring(5); + public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString().substring(5); + public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json").toString().substring(5); + public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5); + + @BeforeClass + public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, NoSuchAlgorithmException, ArtifactInstallerException { + + heatExample = new String(Files.readAllBytes(Paths.get(ASDCControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] md5Hash = md.digest(heatExample.getBytes()); + heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); + + iNotif= Mockito.mock(INotificationData.class); + + // Create fake ArtifactInfo + artifactInfo1 = Mockito.mock(IArtifactInfo.class); + Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(ASDCControllerTest.heatExampleMD5HashBase64); + + Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); + Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); + Mockito.when(artifactInfo1.getArtifactURL()).thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); + Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); + + // Now provision the NotificationData mock + List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>(); + listArtifact.add(artifactInfo1); + + // Create fake resource Instance + resource1 = Mockito.mock (IResourceInstance.class); + Mockito.when (resource1.getResourceType ()).thenReturn ("VF"); + Mockito.when (resource1.getResourceName ()).thenReturn ("resourceName"); + Mockito.when (resource1.getArtifacts ()).thenReturn (listArtifact); + + List<IResourceInstance> resources = new ArrayList<> (); + resources.add (resource1); + + Mockito.when(iNotif.getResources()).thenReturn(resources); + Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); + Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); + Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); + Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); + + downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); + Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); + + downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample+"badone").getBytes()); + Mockito.when(downloadCorruptedResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); + + vnfInstaller = Mockito.mock(VfResourceInstaller.class); + + // Mock now the ASDC distribution client behavior + successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(successfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.SUCCESS); + + unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.GENERAL_ERROR); + + } + + @Before + public final void initBeforeEachTest() throws MsoPropertiesException { + // load the config + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + } + + @AfterClass + public static final void kill () throws MsoPropertiesException { + + msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); + + } + + @Test + public final void testTheInitWithASDCStub() throws ASDCControllerException, ASDCParametersException, IOException { + + ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl()); + asdcController.initASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + } + + @Test + public final void testTheNotificationWithASDCStub() throws ASDCControllerException, ASDCParametersException, IOException { + + ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller); + asdcController.initASDC(); + // try to send a notif, this should fail internally, we just want to ensure that in case of crash, controller status goes to IDLE + asdcController.treatNotification(iNotif); + + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + + } + + @Test + public final void testASecondInit() throws ASDCControllerException, ASDCParametersException, IOException { + ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller); + asdcController.initASDC(); + // try to send a notif, this should fail internally, we just want to ensure that in case of crash, controller status goes to IDLE + + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + + try { + asdcController.initASDC(); + fail("ASDCControllerException should have been raised for the init"); + } catch (ASDCControllerException e) { + assertTrue("The controller is already initialized, call the closeASDC method first".equals(e.getMessage())); + } + + // No changes expected on the controller state + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + } + + @Test + public final void testInitCrashWithMockitoClient() throws ASDCParametersException, IOException { + + IDistributionClient distributionClient; + // First case for init method + distributionClient = Mockito.mock(IDistributionClient.class); + Mockito.when(distributionClient.download(artifactInfo1)).thenThrow(new RuntimeException("ASDC Client not initialized")); + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(unsuccessfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(unsuccessfulClientInitResult); + + ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller); + + // This should return an exception + try { + asdcController.initASDC(); + fail("ASDCControllerException should have been raised for the init"); + } catch (ASDCControllerException e) { + assertTrue("Initialization of the ASDC Controller failed with reason: null".equals(e.getMessage())); + } + + assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.STOPPED); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + + // Second case for start method + + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(unsuccessfulClientInitResult); + + // This should return an exception + try { + asdcController.initASDC(); + fail("ASDCControllerException should have been raised for the init"); + } catch (ASDCControllerException e) { + assertTrue("Startup of the ASDC Controller failed with reason: null".equals(e.getMessage())); + } + + assertTrue(asdcController.getControllerStatus() == ASDCControllerStatus.STOPPED); + assertTrue(asdcController.getNbOfNotificationsOngoing()== 0); + } + + @Test + public final void testTheStop() throws ASDCControllerException, ASDCParametersException, IOException { + + ASDCController asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller); + + asdcController.closeASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED); + + + asdcController = new ASDCController("asdc-controller1",new DistributionClientStubImpl(),vnfInstaller); + asdcController.initASDC(); + asdcController.closeASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED); + } + + @Test + public final void testConfigRefresh () throws ASDCParametersException, ASDCControllerException, IOException, MsoPropertiesException { + IDistributionClient distributionClient; + distributionClient = Mockito.mock(IDistributionClient.class); + Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult); + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult); + + + ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller); + + // it should not raise any exception even if controller is not yet initialized + asdcController.updateConfigIfNeeded(); + + asdcController.initASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertFalse(asdcController.updateConfigIfNeeded()); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3); + msoPropertiesFactory.reloadMsoProperties(); + // It should fail if it tries to refresh the config as the init will now fail + assertTrue(asdcController.updateConfigIfNeeded()); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + } + + @Test + public final void testConfigRefreshWhenBusy () throws IOException, MsoPropertiesException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, ASDCParametersException, ASDCControllerException { + IDistributionClient distributionClient; + distributionClient = Mockito.mock(IDistributionClient.class); + Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult); + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult); + + ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller); + + // it should not raise any exception even if controller is not yet initialized + asdcController.updateConfigIfNeeded(); + + asdcController.initASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertFalse(asdcController.updateConfigIfNeeded()); + + // Simulate a BUSY case by reflection + Field controllerStatus; + controllerStatus = ASDCController.class.getDeclaredField("controllerStatus"); + controllerStatus.setAccessible(true); + controllerStatus.set(asdcController,ASDCControllerStatus.BUSY); + + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP3); + msoPropertiesFactory.reloadMsoProperties(); + // It should fail if it tries to refresh the config as the init will now fail + try { + asdcController.updateConfigIfNeeded(); + fail ("ASDCControllerException should have been raised"); + } catch (ASDCControllerException e) { + assertTrue("Cannot close the ASDC controller as it's currently in BUSY state".equals(e.getMessage())); + } + + // Try it a second time to see if we still see the changes + try { + asdcController.updateConfigIfNeeded(); + fail ("ASDCControllerException should have been raised"); + } catch (ASDCControllerException e) { + assertTrue("Cannot close the ASDC controller as it's currently in BUSY state".equals(e.getMessage())); + } + + // Revert to Idle by reflection + controllerStatus.set(asdcController,ASDCControllerStatus.IDLE); + controllerStatus.setAccessible(false); + + // This should work now, controller should be restarted + assertTrue(asdcController.updateConfigIfNeeded()); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + } + + + @Test + public final void testBadConfigRefresh () throws ASDCParametersException, ASDCControllerException, IOException, MsoPropertiesException { + IDistributionClient distributionClient; + distributionClient = Mockito.mock(IDistributionClient.class); + Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult); + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult); + + + ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller); + + // it should not raise any exception even if controller is not yet initialized + asdcController.updateConfigIfNeeded(); + + asdcController.initASDC(); + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.IDLE); + assertFalse(asdcController.updateConfigIfNeeded()); + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_BAD); + msoPropertiesFactory.reloadMsoProperties(); + // It should fail if it tries to refresh the config as the init will now fail + try { + asdcController.updateConfigIfNeeded(); + fail ("ASDCParametersException should have been raised"); + } catch (ASDCParametersException ep) { + assertTrue("consumerGroup parameter cannot be found in config mso.properties".equals(ep.getMessage())); + } + + // This should stop the controller, as it can't work with a bad config file + assertTrue(asdcController.getControllerStatus()== ASDCControllerStatus.STOPPED); + + + msoPropertiesFactory.changeMsoPropertiesFilePath(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + msoPropertiesFactory.reloadMsoProperties(); + } + + @Test + public final void testConfigAccess () throws ASDCControllerException, ASDCParametersException, IOException { + IDistributionClient distributionClient; + distributionClient = Mockito.mock(IDistributionClient.class); + Mockito.when(distributionClient.download(artifactInfo1)).thenReturn(downloadResult); + Mockito.when(distributionClient.init(any(ASDCConfiguration.class),any(INotificationCallback.class))).thenReturn(successfulClientInitResult); + Mockito.when(distributionClient.start()).thenReturn(successfulClientInitResult); + + + ASDCController asdcController = new ASDCController("asdc-controller1",distributionClient,vnfInstaller); + + assertTrue("Unknown".equals(asdcController.getAddress())); + assertTrue("Unknown".equals(asdcController.getEnvironment())); + + asdcController.initASDC(); + + assertTrue("hostname".equals(asdcController.getAddress())); + assertTrue("environmentName".equals(asdcController.getEnvironment())); + + } + +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java new file mode 100644 index 0000000000..23b7a80dbe --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCElementInfoTest.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.openecomp.mso.asdc.client.tests; + + + +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.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.asdc.installer.ASDCElementInfo; +import org.openecomp.mso.asdc.installer.VfModuleStructure; +import org.openecomp.mso.asdc.installer.VfResourceStructure; + + +public class ASDCElementInfoTest { + + @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); + + assertEquals(elementInfoFromNullVfArtifact.toString(), ""); + assertEquals(elementInfoFromNullVfModuleStructure.toString(), ""); + assertEquals(elementInfoFromNullVfResourceStructure.toString(), ""); + + assertNotNull(elementInfoFromNullVfArtifact); + assertNotNull(elementInfoFromNullVfModuleStructure); + assertNotNull(elementInfoFromNullVfResourceStructure); + + assertNotNull(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(elementInfoFromNullVfArtifact.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType()); + assertEquals(elementInfoFromNullVfModuleStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType()); + assertEquals(elementInfoFromNullVfResourceStructure.getType(), ASDCElementInfo.EMPTY_INSTANCE.getType()); + } + + @Test + public void createASDCElementInfoFromVfResourceTest() { + + String resourceInstanceName = "Resource 1"; + + UUID generatedUUID = UUID.randomUUID(); + + 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()); + + VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance); + + ASDCElementInfo elementInfoFromVfResource = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure); + + 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(elementInfoFromVfResource.toString().contains("MyInfo1: someValue")); + elementInfoFromVfResource.addElementInfo("MyInfo1", "someValue"); + assertTrue(elementInfoFromVfResource.toString().contains("MyInfo1: someValue")); + } + + @Test + public void createASDCElementInfoFromVfModuleTest() throws ArtifactInstallerException { + + String resourceInstanceName = "Resource 1"; + + UUID generatedUUID = UUID.randomUUID(); + + 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()); + + VfResourceStructure vfResourceStructure = new VfResourceStructure(notificationData, resourceInstance); + + // Create module structure now + + String vfModuleModelName = "Module Model XYZ"; + + UUID generatedUUIDForModule = UUID.randomUUID(); + + IVfModuleMetadata moduleMetadata = Mockito.mock(IVfModuleMetadata.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); + + ASDCElementInfo elementInfoFromVfModule = ASDCElementInfo.createElementFromVfModuleStructure(vfModuleStructure); + + 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(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(); + + 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); + + 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(elementInfoFromArtifact.toString().contains("MyInfo3: someValue")); + elementInfoFromArtifact.addElementInfo("MyInfo3", "someValue"); + assertTrue(elementInfoFromArtifact.toString().contains("MyInfo3: someValue")); + } + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java new file mode 100644 index 0000000000..9ac50c4854 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/ASDCGlobalControllerTest.java @@ -0,0 +1,213 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.tests; + + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import java.io.IOException; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.codec.binary.Base64; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mockito; + +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.api.results.IDistributionClientResult; +import org.openecomp.sdc.utils.DistributionActionResultEnum; +import org.openecomp.mso.asdc.client.ASDCConfiguration; +import org.openecomp.mso.asdc.client.ASDCGlobalController; +import org.openecomp.mso.asdc.client.exceptions.ASDCControllerException; +import org.openecomp.mso.asdc.client.exceptions.ASDCParametersException; +import org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException; +import org.openecomp.mso.properties.MsoJavaProperties; +import org.openecomp.mso.properties.MsoPropertiesException; +import org.openecomp.mso.properties.MsoPropertiesFactory; + + + +/** + * THis class tests the ASDC Controller by using the ASDC Mock CLient + * + * + */ +public class ASDCGlobalControllerTest { + + private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory(); + + private static String heatExample; + private static String heatExampleMD5HashBase64; + + private static INotificationData iNotif; + + private static IDistributionClientDownloadResult downloadResult; + private static IDistributionClientDownloadResult downloadCorruptedResult; + + private static IDistributionClientResult successfulClientInitResult; + private static IDistributionClientResult unsuccessfulClientInitResult; + + private static IArtifactInfo artifactInfo1; + + private static IResourceInstance resource1; + + public static final String ASDC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.json").toString().substring(5); + public static final String ASDC_PROP2 = MsoJavaProperties.class.getClassLoader().getResource("mso2.json").toString().substring(5); + public static final String ASDC_PROP3 = MsoJavaProperties.class.getClassLoader().getResource("mso3.json").toString().substring(5); + public static final String ASDC_PROP_BAD = MsoJavaProperties.class.getClassLoader().getResource("mso-bad.json").toString().substring(5); + public static final String ASDC_PROP_WITH_NULL = MsoJavaProperties.class.getClassLoader().getResource("mso-with-NULL.json").toString().substring(5); + public static final String ASDC_PROP_WITH_DOUBLE = MsoJavaProperties.class.getClassLoader().getResource("mso-two-configs.json").toString().substring(5); + public static final String ASDC_PROP_WITH_DOUBLE2 = MsoJavaProperties.class.getClassLoader().getResource("mso-two-configs2.json").toString().substring(5); + + @BeforeClass + public static final void prepareMockNotification() throws MsoPropertiesException, IOException, URISyntaxException, NoSuchAlgorithmException, ArtifactInstallerException { + + heatExample = new String(Files.readAllBytes(Paths.get(ASDCGlobalControllerTest.class.getClassLoader().getResource("resource-examples/autoscaling.yaml").toURI()))); + MessageDigest md = MessageDigest.getInstance("MD5"); + byte[] md5Hash = md.digest(heatExample.getBytes()); + heatExampleMD5HashBase64 = Base64.encodeBase64String(md5Hash); + + iNotif= Mockito.mock(INotificationData.class); + + // Create fake ArtifactInfo + artifactInfo1 = Mockito.mock(IArtifactInfo.class); + Mockito.when(artifactInfo1.getArtifactChecksum()).thenReturn(ASDCGlobalControllerTest.heatExampleMD5HashBase64); + + Mockito.when(artifactInfo1.getArtifactName()).thenReturn("artifact1"); + Mockito.when(artifactInfo1.getArtifactType()).thenReturn(ASDCConfiguration.HEAT); + Mockito.when(artifactInfo1.getArtifactURL()).thenReturn("https://localhost:8080/v1/catalog/services/srv1/2.0/resources/aaa/1.0/artifacts/aaa.yml"); + Mockito.when(artifactInfo1.getArtifactUUID()).thenReturn("UUID1"); + Mockito.when(artifactInfo1.getArtifactDescription()).thenReturn("testos artifact1"); + + // Now provision the NotificationData mock + List<IArtifactInfo> listArtifact = new ArrayList<IArtifactInfo>(); + listArtifact.add(artifactInfo1); + + // Create fake resource Instance + resource1 = Mockito.mock (IResourceInstance.class); + Mockito.when (resource1.getResourceType ()).thenReturn ("VF"); + Mockito.when (resource1.getResourceName ()).thenReturn ("resourceName"); + Mockito.when (resource1.getArtifacts ()).thenReturn (listArtifact); + + List<IResourceInstance> resources = new ArrayList<> (); + resources.add (resource1); + + Mockito.when(iNotif.getResources()).thenReturn(resources); + Mockito.when(iNotif.getDistributionID()).thenReturn("distributionID1"); + Mockito.when(iNotif.getServiceName()).thenReturn("serviceName1"); + Mockito.when(iNotif.getServiceUUID()).thenReturn("serviceNameUUID1"); + Mockito.when(iNotif.getServiceVersion()).thenReturn("1.0"); + + downloadResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadResult.getArtifactPayload()).thenReturn(heatExample.getBytes()); + Mockito.when(downloadResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadResult.getDistributionMessageResult()).thenReturn("Success"); + + downloadCorruptedResult = Mockito.mock(IDistributionClientDownloadResult.class); + Mockito.when(downloadCorruptedResult.getArtifactPayload()).thenReturn((heatExample+"badone").getBytes()); + Mockito.when(downloadCorruptedResult.getDistributionActionResult()).thenReturn(DistributionActionResultEnum.SUCCESS); + Mockito.when(downloadCorruptedResult.getDistributionMessageResult()).thenReturn("Success"); + + + // Mock now the ASDC distribution client behavior + successfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(successfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.SUCCESS); + + unsuccessfulClientInitResult = Mockito.mock(IDistributionClientResult.class); + Mockito.when(unsuccessfulClientInitResult.getDistributionActionResult ()).thenReturn(DistributionActionResultEnum.GENERAL_ERROR); + + } + + @Before + public final void initBeforeEachTest() throws MsoPropertiesException { + // load the config + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP); + } + + @AfterClass + public static final void kill () throws MsoPropertiesException { + + msoPropertiesFactory.removeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC); + } + + @Test + public final void testUpdateControllersConfigIfNeeded() throws ASDCControllerException, ASDCParametersException, IOException, MsoPropertiesException { + + ASDCGlobalController asdcGlobalController = new ASDCGlobalController(); + assertTrue(asdcGlobalController.getControllers().size()==0); + + // first init + assertTrue(asdcGlobalController.updateControllersConfigIfNeeded()); + assertTrue(asdcGlobalController.getControllers().size()==1); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null); + + // Add a second one + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_DOUBLE); + assertTrue(asdcGlobalController.updateControllersConfigIfNeeded()); + assertTrue(asdcGlobalController.getControllers().size()==2); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller2") != null); + // Check that update does nothing + assertFalse(asdcGlobalController.updateControllersConfigIfNeeded()); + assertTrue(asdcGlobalController.getControllers().size()==2); + + // Change the second one name + msoPropertiesFactory.removeAllMsoProperties(); + msoPropertiesFactory.initializeMsoProperties(ASDCConfiguration.MSO_PROP_ASDC, ASDC_PROP_WITH_DOUBLE2); + assertTrue(asdcGlobalController.updateControllersConfigIfNeeded()); + assertTrue(asdcGlobalController.getControllers().size()==2); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller2B") != null); + + + } + + @Test + public final void testCloseASDC() { + + ASDCGlobalController asdcGlobalController = new ASDCGlobalController(); + assertTrue(asdcGlobalController.getControllers().size()==0); + + // first init + assertTrue(asdcGlobalController.updateControllersConfigIfNeeded()); + assertTrue(asdcGlobalController.getControllers().size()==1); + assertTrue(asdcGlobalController.getControllers().get("asdc-controller1") != null); + + asdcGlobalController.closeASDC(); + assertTrue(asdcGlobalController.getControllers().size()==0); + + + } + +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java new file mode 100644 index 0000000000..7decaffb2b --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/BigDecimalVersionTest.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.tests; + + +import static org.junit.Assert.assertTrue; +import java.math.BigDecimal; +import org.junit.Test; + +import org.openecomp.mso.asdc.installer.BigDecimalVersion; + + +public class BigDecimalVersionTest { + + @Test + 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"))); + + 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.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/openecomp/mso/asdc/client/tests/YamlTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java new file mode 100644 index 0000000000..bce9324de9 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/client/tests/YamlTest.java @@ -0,0 +1,165 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.mso.asdc.client.tests; + + +import static org.junit.Assert.*; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.apache.commons.io.IOUtils; +import org.junit.Test; + +import org.openecomp.mso.asdc.installer.heat.VfResourceInstaller; +import org.openecomp.mso.asdc.util.YamlEditor; +import org.openecomp.mso.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(); + + 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> (); + + HeatTemplateParam heatParam1 = new HeatTemplateParam(); + heatParam1.setId(1); + heatParam1.setParamName("testos1"); + heatParam1.setParamType("string"); + + HeatTemplateParam heatParam2 = new HeatTemplateParam(); + heatParam2.setId(2); + heatParam2.setParamName("testos2"); + heatParam2.setParamType("number"); + + newParamSet.add(heatParam1); + newParamSet.add(heatParam2); + + decoder.addParameterList(newParamSet); + + Set <HeatTemplateParam> paramSet = decoder.getParameterList(); + 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> (); + + HeatTemplateParam heatParam1 = new HeatTemplateParam(); + heatParam1.setId(1); + heatParam1.setParamName("testos1"); + heatParam1.setParamType("string"); + + HeatTemplateParam heatParam2 = new HeatTemplateParam(); + heatParam2.setId(2); + heatParam2.setParamName("testos2"); + heatParam2.setParamType("number"); + + newParamSet.add(heatParam1); + newParamSet.add(heatParam2); + + decoder.addParameterList(newParamSet); + + Set <HeatTemplateParam> paramSet = decoder.getParameterList(); + + 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 VfResourceInstallerTest() throws Exception { + + assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami toto, est dans le bois: toto ici","toto"))); + assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami file:///toto, est dans le bois: file:///toto ici","toto"))); + assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami file:///toto, est dans le bois: toto ici","toto"))); + assertTrue("mon ami toto, est dans le bois: toto ici".equals(VfResourceInstaller.verifyTheFilePrefixInString("mon ami toto, est dans le bois: file:///toto ici","toto"))); + + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTest.java new file mode 100644 index 0000000000..8dd5afe7e0 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTest.java @@ -0,0 +1,139 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:35:55 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.util.List; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCElementInfoESTest extends ASDCElementInfoESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iResourceInstance0).getResourceInstanceName(); + doReturn((String) null).when(iResourceInstance0).getResourceInvariantUUID(); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure0); + String string0 = aSDCElementInfo0.getType(); + assertEquals("VNF_RESOURCE", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfModuleStructure((VfModuleStructure) null); + Map<String, String> map0 = aSDCElementInfo0.getElementInfoMap(); + assertTrue(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + Map<String, String> map0 = ASDCElementInfo.EMPTY_INSTANCE.getElementInfoMap(); + assertTrue(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.EMPTY_INSTANCE; + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iArtifactInfo0).getArtifactName(); + doReturn((String) null).when(iArtifactInfo0).getArtifactType(); + doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); + ASDCElementInfo aSDCElementInfo1 = ASDCElementInfo.createElementFromVfArtifactInfo(iArtifactInfo0); + aSDCElementInfo0.toString(); + PrivateAccess.setVariable((Class<ASDCElementInfo>) ASDCElementInfo.class, aSDCElementInfo1, "elementInfoMap", (Object) null); + aSDCElementInfo0.toString(); + // Undeclared exception! + try { + aSDCElementInfo1.toString(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.ASDCElementInfo", e); + } + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.EMPTY_INSTANCE; + aSDCElementInfo0.addElementInfo("V$", (String) null); + assertEquals("", aSDCElementInfo0.getType()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfModuleStructure((VfModuleStructure) null); + String string0 = aSDCElementInfo0.EMPTY_INSTANCE.getType(); + assertEquals("", string0); + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, (IResourceInstance) null); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List) null).when(iVfModuleMetadata0).getArtifacts(); + VfModuleStructure vfModuleStructure0 = null; + try { + vfModuleStructure0 = new VfModuleStructure(vfResourceStructure0, iVfModuleMetadata0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn(" Name").when(iResourceInstance0).getResourceInstanceName(); + doReturn(" Name").when(iResourceInstance0).getResourceInvariantUUID(); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfResourceStructure(vfResourceStructure0); + String string0 = aSDCElementInfo0.toString(); + assertEquals("Resource Instance Invariant UUID: Name, Resource Instance Name: Name", string0); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfArtifactInfo((IArtifactInfo) null); + aSDCElementInfo0.addElementInfo((String) null, ""); + assertEquals("", aSDCElementInfo0.getType()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iArtifactInfo0).getArtifactName(); + doReturn((String) null).when(iArtifactInfo0).getArtifactType(); + doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); + ASDCElementInfo aSDCElementInfo0 = ASDCElementInfo.createElementFromVfArtifactInfo(iArtifactInfo0); + String string0 = aSDCElementInfo0.getType(); + assertNull(string0); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTestscaffolding.java new file mode 100644 index 0000000000..075970b066 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/ASDCElementInfoESTestscaffolding.java @@ -0,0 +1,100 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:35:55 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCElementInfoESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.ASDCElementInfo"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCElementInfoESTestscaffolding.class.getClassLoader() , + "org.openecomp.sdc.api.IDistributionClient", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.openecomp.mso.asdc.installer.VfResourceStructure", + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException", + "org.openecomp.mso.db.catalog.beans.VnfResource", + "org.openecomp.sdc.api.notification.IVfModuleMetadata", + "org.openecomp.mso.db.catalog.beans.VfModule", + "org.openecomp.sdc.api.results.IDistributionClientResult", + "org.openecomp.sdc.api.notification.IArtifactInfo", + "org.openecomp.mso.db.catalog.beans.Service", + "org.openecomp.mso.asdc.installer.VfModuleStructure", + "org.openecomp.sdc.api.notification.INotificationData", + "org.openecomp.mso.asdc.installer.VfModuleArtifact", + "org.openecomp.sdc.api.notification.IResourceInstance", + "org.openecomp.mso.asdc.installer.ASDCElementInfo", + "org.openecomp.sdc.api.results.IDistributionClientDownloadResult", + "org.openecomp.mso.asdc.installer.ASDCElementInfo$ASDCElementTypeEnum" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(ASDCElementInfoESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.installer.ASDCElementInfo$ASDCElementTypeEnum", + "org.openecomp.mso.asdc.installer.ASDCElementInfo", + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java new file mode 100644 index 0000000000..4675f05477 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTest.java @@ -0,0 +1,138 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:37:47 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.math.BigDecimal; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.junit.runner.RunWith; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class BigDecimalVersionESTest extends BigDecimalVersionESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + String string0 = BigDecimalVersion.castAndCheckNotificationVersionToString("9"); + assertEquals("9", string0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("0"); + assertEquals(0, bigDecimal0.shortValue()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("9"); + assertEquals(9, bigDecimal0.byteValue()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + BigDecimal bigDecimal0 = BigDecimalVersion.castAndCheckNotificationVersion("-1"); + assertEquals(-1, bigDecimal0.byteValue()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersionToString("fgt+&6@pL9`5EE}.!.,"); + fail("Expecting exception: NumberFormatException"); + + } catch(NumberFormatException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.math.BigDecimal", e); + } + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersionToString((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersion((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersion("."); + fail("Expecting exception: ArrayIndexOutOfBoundsException"); + + } catch(ArrayIndexOutOfBoundsException e) { + // + // 0 + // + verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersion("Mf**K`5E.~Fu.,q"); + fail("Expecting exception: NumberFormatException"); + + } catch(NumberFormatException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.math.BigDecimal", e); + } + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + BigDecimalVersion bigDecimalVersion0 = new BigDecimalVersion(); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + // Undeclared exception! + try { + BigDecimalVersion.castAndCheckNotificationVersionToString("."); + fail("Expecting exception: ArrayIndexOutOfBoundsException"); + + } catch(ArrayIndexOutOfBoundsException e) { + // + // 0 + // + verifyException("org.openecomp.mso.asdc.installer.BigDecimalVersion", e); + } + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java new file mode 100644 index 0000000000..c04ada8396 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/BigDecimalVersionESTestscaffolding.java @@ -0,0 +1,77 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:37:47 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class BigDecimalVersionESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.BigDecimalVersion"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(BigDecimalVersionESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.installer.BigDecimalVersion" + ); + } + + private static void resetClasses() { + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java new file mode 100644 index 0000000000..c9b29ae57f --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTest.java @@ -0,0 +1,154 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:20:32 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.results.IDistributionClientDownloadResult; +import org.openecomp.sdc.impl.DistributionClientDownloadResultImpl; +import org.openecomp.sdc.utils.DistributionActionResultEnum; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfModuleArtifactESTest extends VfModuleArtifactESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.CONF_MISSING_ARTIFACT_TYPES; + byte[] byteArray0 = new byte[1]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "7pKd8", "7pKd8", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + PrivateAccess.setVariable((Class<VfModuleArtifact>) VfModuleArtifact.class, vfModuleArtifact0, "result", (Object) null); + vfModuleArtifact0.getResult(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; + byte[] byteArray0 = new byte[0]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o<Q", "o<Q", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.getResult(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; + byte[] byteArray0 = new byte[0]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o<Q", "o<Q", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.incrementDeployedInDB(); + int int0 = vfModuleArtifact0.getDeployedInDb(); + assertEquals(1, int0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.CONF_MISSING_ASDC_FQDN; + byte[] byteArray0 = new byte[2]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "qZr'D", "qZr'D", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + PrivateAccess.setVariable((Class<VfModuleArtifact>) VfModuleArtifact.class, vfModuleArtifact0, "deployedInDb", (Object) (-40)); + int int0 = vfModuleArtifact0.getDeployedInDb(); + assertEquals((-40), int0); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; + byte[] byteArray0 = new byte[0]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o<Q", "o<Q", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.setCatalogObject(byteArray0); + vfModuleArtifact0.getCatalogObject(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("o<Q").when(iArtifactInfo0).toString(); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; + byte[] byteArray0 = new byte[0]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o<Q", "o<Q", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.getArtifactInfo(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + VfModuleArtifact vfModuleArtifact0 = null; + try { + vfModuleArtifact0 = new VfModuleArtifact((IArtifactInfo) null, (IDistributionClientDownloadResult) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleArtifact", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_ALREADY_INITIALIZED; + byte[] byteArray0 = new byte[0]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "o<Q", "o<Q", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.getCatalogObject(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.CONF_MISSING_ARTIFACT_TYPES; + byte[] byteArray0 = new byte[1]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "7pKd8", "7pKd8", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.getResult(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.CONF_MISSING_ASDC_FQDN; + byte[] byteArray0 = new byte[2]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "qZr'D", "qZr'D", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact(iArtifactInfo0, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + int int0 = vfModuleArtifact0.getDeployedInDb(); + assertEquals(0, int0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.DISTRIBUTION_CLIENT_IS_TERMINATED; + byte[] byteArray0 = new byte[5]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "", "", byteArray0); + VfModuleArtifact vfModuleArtifact0 = new VfModuleArtifact((IArtifactInfo) null, (IDistributionClientDownloadResult) distributionClientDownloadResultImpl0); + vfModuleArtifact0.getArtifactInfo(); + assertEquals(0, vfModuleArtifact0.getDeployedInDb()); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTestscaffolding.java new file mode 100644 index 0000000000..75c5f1588f --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleArtifactESTestscaffolding.java @@ -0,0 +1,83 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:20:32 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfModuleArtifactESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.VfModuleArtifact"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleArtifactESTestscaffolding.class.getClassLoader() , + "org.openecomp.mso.asdc.installer.VfModuleArtifact", + "org.openecomp.sdc.utils.DistributionActionResultEnum", + "org.openecomp.sdc.impl.DistributionClientResultImpl", + "org.openecomp.sdc.impl.DistributionClientDownloadResultImpl", + "org.openecomp.sdc.api.results.IDistributionClientResult", + "org.openecomp.sdc.api.results.IDistributionClientDownloadResult", + "org.openecomp.sdc.api.notification.IArtifactInfo" + ); + } + + private static void resetClasses() { + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java new file mode 100644 index 0000000000..f3c20c5eb7 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTest.java @@ -0,0 +1,108 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:37:00 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; + +import java.util.LinkedList; +import java.util.List; + +import static org.evosuite.runtime.EvoAssertions.verifyException; +import static org.evosuite.shaded.org.mockito.Mockito.doReturn; +import static org.evosuite.shaded.org.mockito.Mockito.mock; +import static org.junit.Assert.fail; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfModuleStructureESTest extends VfModuleStructureESTestscaffolding { + + @Test(timeout = 4000) + public void test1() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List) null).when(iVfModuleMetadata0).getArtifacts(); + VfModuleStructure vfModuleStructure0 = null; + try { + vfModuleStructure0 = new VfModuleStructure(vfResourceStructure0, iVfModuleMetadata0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); + } + } + + @Test(timeout = 4000) + public void test2() throws Throwable { + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List) null).when(iVfModuleMetadata0).getArtifacts(); + VfModuleStructure vfModuleStructure0 = null; + try { + vfModuleStructure0 = new VfModuleStructure((VfResourceStructure) null, iVfModuleMetadata0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); + } + } + + @Test(timeout = 4000) + public void test3() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + LinkedList<String> linkedList0 = new LinkedList<String>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList0).when(iVfModuleMetadata0).getArtifacts(); + linkedList0.add(""); + VfModuleStructure vfModuleStructure0 = null; + try { + vfModuleStructure0 = new VfModuleStructure(vfResourceStructure0, iVfModuleMetadata0); + fail("Expecting exception: Exception"); + + } catch(Exception e) { + // + // Artifact (UUID:) referenced in the VFModule UUID list has not been downloaded, cancelling the Resource deployment + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); + } + } + + @Test(timeout = 4000) + public void test4() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.setSuccessfulDeployment(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List) null).when(iVfModuleMetadata0).getArtifacts(); + vfResourceStructure0.setSuccessfulDeployment(); + VfModuleStructure vfModuleStructure0 = null; + try { + vfModuleStructure0 = new VfModuleStructure(vfResourceStructure0, iVfModuleMetadata0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfModuleStructure", e); + } + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java new file mode 100644 index 0000000000..f6aa2ab5f2 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfModuleStructureESTestscaffolding.java @@ -0,0 +1,96 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:37:00 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfModuleStructureESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.VfModuleStructure"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfModuleStructureESTestscaffolding.class.getClassLoader() , + "org.openecomp.sdc.api.IDistributionClient", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.openecomp.mso.asdc.installer.VfResourceStructure", + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException", + "org.openecomp.mso.db.catalog.beans.VnfResource", + "org.openecomp.sdc.api.notification.IVfModuleMetadata", + "org.openecomp.mso.db.catalog.beans.VfModule", + "org.openecomp.sdc.api.results.IDistributionClientResult", + "org.openecomp.sdc.api.notification.IArtifactInfo", + "org.openecomp.mso.db.catalog.beans.Service", + "org.openecomp.mso.asdc.installer.VfModuleStructure", + "org.openecomp.sdc.api.notification.INotificationData", + "org.openecomp.mso.asdc.installer.VfModuleArtifact", + "org.openecomp.sdc.api.notification.IResourceInstance", + "org.openecomp.sdc.api.results.IDistributionClientDownloadResult" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VfModuleStructureESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTest.java new file mode 100644 index 0000000000..4a27df3a48 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTest.java @@ -0,0 +1,400 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:29:36 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.db.catalog.beans.Service; +import org.openecomp.mso.db.catalog.beans.VnfResource; +import java.time.chrono.ChronoLocalDate; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.evosuite.runtime.mock.java.time.chrono.MockHijrahDate; +import org.junit.runner.RunWith; +import org.openecomp.sdc.api.IDistributionClient; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.impl.DistributionClientDownloadResultImpl; +import org.openecomp.sdc.impl.mock.DistributionClientDownloadResultStubImpl; +import org.openecomp.sdc.impl.mock.DistributionClientStubImpl; +import org.openecomp.sdc.utils.DistributionActionResultEnum; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class VfResourceStructureESTest extends VfResourceStructureESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesStructureList", (Object) null); + vfResourceStructure0.getVfModuleStructure(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + LinkedList<Object> linkedList0 = new LinkedList<Object>(); + linkedList0.add((Object) vfResourceStructure0); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesStructureList", (Object) linkedList0); + vfResourceStructure0.getVfModuleStructure(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + VfResourceStructure vfResourceStructure0 = new VfResourceStructure((INotificationData) null, (IResourceInstance) null); + vfResourceStructure0.getResourceInstance(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("").when(iNotificationData0).toString(); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getNotification(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + Service service0 = new Service(); + service0.setId(6); + vfResourceStructure0.setCatalogService(service0); + vfResourceStructure0.getCatalogService(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + Iterator<ChronoLocalDate> iterator0 = (Iterator<ChronoLocalDate>) mock(Iterator.class, new ViolatedAssumptionAnswer()); + List<ChronoLocalDate> list0 = (List<ChronoLocalDate>) mock(List.class, new ViolatedAssumptionAnswer()); + doReturn((Iterator) null).when(list0).iterator(); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesMetadataList", (Object) list0); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "isDeployedSuccessfully", (Object) true); + List<MockHijrahDate> list1 = (List<MockHijrahDate>) mock(List.class, new ViolatedAssumptionAnswer()); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "isDeployedSuccessfully", (Object) true); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesStructureList", (Object) list1); + // Undeclared exception! + try { + vfResourceStructure0.createVfModuleStructures(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.installer.VfResourceStructure", e); + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + Iterator<ChronoLocalDate> iterator0 = (Iterator<ChronoLocalDate>) mock(Iterator.class, new ViolatedAssumptionAnswer()); + doReturn(false).when(iterator0).hasNext(); + List<ChronoLocalDate> list0 = (List<ChronoLocalDate>) mock(List.class, new ViolatedAssumptionAnswer()); + doReturn(iterator0).when(list0).iterator(); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesMetadataList", (Object) list0); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "isDeployedSuccessfully", (Object) true); + List<MockHijrahDate> list1 = (List<MockHijrahDate>) mock(List.class, new ViolatedAssumptionAnswer()); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "isDeployedSuccessfully", (Object) true); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesStructureList", (Object) list1); + vfResourceStructure0.createVfModuleStructures(); + IDistributionClient iDistributionClient0 = mock(IDistributionClient.class, new ViolatedAssumptionAnswer()); + IArtifactInfo iArtifactInfo0 = null; + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.ARTIFACT_NOT_FOUND; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, ""); + List<Object> list2 = (List<Object>) mock(List.class, new ViolatedAssumptionAnswer()); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesMetadataList", (Object) list2); + // Undeclared exception! + try { + vfResourceStructure0.addArtifactToStructure(iDistributionClient0, (IArtifactInfo) null, distributionClientDownloadResultImpl0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + ChronoLocalDate chronoLocalDate0 = mock(ChronoLocalDate.class, new ViolatedAssumptionAnswer()); + Iterator<ChronoLocalDate> iterator0 = (Iterator<ChronoLocalDate>) mock(Iterator.class, new ViolatedAssumptionAnswer()); + doReturn(true).when(iterator0).hasNext(); + doReturn(chronoLocalDate0).when(iterator0).next(); + List<ChronoLocalDate> list0 = (List<ChronoLocalDate>) mock(List.class, new ViolatedAssumptionAnswer()); + doReturn(iterator0).when(list0).iterator(); + PrivateAccess.setVariable((Class<VfResourceStructure>) VfResourceStructure.class, vfResourceStructure0, "vfModulesMetadataList", (Object) list0); + // Undeclared exception! + try { + vfResourceStructure0.createVfModuleStructures(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // $java.time.chrono.ChronoLocalDate$$EnhancerByMockitoWithCGLIB$$27d47344 cannot be cast to org.openecomp.sdc.api.notification.IVfModuleMetadata + // + verifyException("org.openecomp.mso.asdc.installer.VfResourceStructure", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + try { + vfResourceStructure0.createVfModuleStructures(); + fail("Expecting exception: Exception"); + + } catch(Exception e) { + // + // VfModule Meta DATA could not be decoded properly or was not present in the notification + // + verifyException("org.openecomp.mso.asdc.installer.VfResourceStructure", e); + } + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("%[76").when(iArtifactInfo0).getArtifactType(); + DistributionClientDownloadResultStubImpl distributionClientDownloadResultStubImpl0 = (DistributionClientDownloadResultStubImpl)distributionClientStubImpl0.download(iArtifactInfo0); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo0, distributionClientDownloadResultStubImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("HEAT_ARTIFACT").when(iArtifactInfo0).getArtifactType(); + doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); + DistributionClientDownloadResultStubImpl distributionClientDownloadResultStubImpl0 = (DistributionClientDownloadResultStubImpl)distributionClientStubImpl0.download(iArtifactInfo0); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo0, distributionClientDownloadResultStubImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionClientDownloadResultStubImpl distributionClientDownloadResultStubImpl0 = (DistributionClientDownloadResultStubImpl)distributionClientStubImpl0.download(iArtifactInfo0); + IArtifactInfo iArtifactInfo1 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("HEAT").when(iArtifactInfo1).getArtifactType(); + doReturn("%[76").when(iArtifactInfo1).getArtifactUUID(); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo1, distributionClientDownloadResultStubImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + DistributionClientDownloadResultStubImpl distributionClientDownloadResultStubImpl0 = (DistributionClientDownloadResultStubImpl)distributionClientStubImpl0.download(iArtifactInfo0); + IArtifactInfo iArtifactInfo1 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("HEAT_NET").when(iArtifactInfo1).getArtifactType(); + doReturn("HEAT_ENV").when(iArtifactInfo1).getArtifactUUID(); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo1, distributionClientDownloadResultStubImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure((INotificationData) null, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("HEAT_ENV").when(iArtifactInfo0).getArtifactType(); + doReturn("*Z\"P4rvOA+mW").when(iArtifactInfo0).getArtifactUUID(); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.UEB_KEYS_CREATION_FAILED; + byte[] byteArray0 = new byte[6]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "]=)|;N.$hV]d^", "s:h+", byteArray0); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo0, distributionClientDownloadResultImpl0); + Map<String, VfModuleArtifact> map0 = vfResourceStructure0.getArtifactsMapByUUID(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + assertFalse(map0.isEmpty()); + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("VF_MODULES_METADATA").when(iArtifactInfo0).getArtifactType(); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.BAD_REQUEST; + byte[] byteArray0 = new byte[2]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "<B['", "<B['", byteArray0); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo0, distributionClientDownloadResultImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + DistributionClientStubImpl distributionClientStubImpl0 = new DistributionClientStubImpl(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("HEAT_NESTED").when(iArtifactInfo0).getArtifactType(); + doReturn("HEAT_NESTED").when(iArtifactInfo0).getArtifactUUID(); + DistributionActionResultEnum distributionActionResultEnum0 = DistributionActionResultEnum.BAD_REQUEST; + byte[] byteArray0 = new byte[2]; + DistributionClientDownloadResultImpl distributionClientDownloadResultImpl0 = new DistributionClientDownloadResultImpl(distributionActionResultEnum0, "<B['", "<B['", byteArray0); + vfResourceStructure0.addArtifactToStructure(distributionClientStubImpl0, iArtifactInfo0, distributionClientDownloadResultImpl0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getCatalogService(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getVfModulesStructureList(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getArtifactsMapByUUID(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + + vfResourceStructure0.setSuccessfulDeployment(); + boolean boolean0 = vfResourceStructure0.isDeployedSuccessfully(); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getCatalogVnfResource(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getVfModuleStructure(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + boolean boolean0 = vfResourceStructure0.isDeployedSuccessfully(); + assertFalse(boolean0); + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure((INotificationData) null, iResourceInstance0); + vfResourceStructure0.getNotification(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test24() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + VnfResource vnfResource0 = new VnfResource(); + vfResourceStructure0.setCatalogVnfResource(vnfResource0); + vfResourceStructure0.getCatalogVnfResource(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test25() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + Service service0 = new Service(); + vfResourceStructure0.setCatalogService(service0); + vfResourceStructure0.getCatalogService(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } + + @Test(timeout = 4000) + public void test26() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iResourceInstance0).toString(); + VfResourceStructure vfResourceStructure0 = new VfResourceStructure(iNotificationData0, iResourceInstance0); + vfResourceStructure0.getResourceInstance(); + assertFalse(vfResourceStructure0.isDeployedSuccessfully()); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTestscaffolding.java new file mode 100644 index 0000000000..f78949eecc --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/installer/VfResourceStructureESTestscaffolding.java @@ -0,0 +1,105 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:29:36 GMT 2016 + */ + +package org.openecomp.mso.asdc.installer; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class VfResourceStructureESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.installer.VfResourceStructure"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(VfResourceStructureESTestscaffolding.class.getClassLoader() , + "org.openecomp.sdc.api.IDistributionClient", + "org.openecomp.mso.db.catalog.beans.ServiceRecipe", + "org.openecomp.mso.db.catalog.utils.MavenLikeVersioning", + "org.openecomp.mso.asdc.installer.VfResourceStructure", + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException", + "org.openecomp.mso.db.catalog.beans.VnfResource", + "org.openecomp.sdc.utils.DistributionActionResultEnum", + "org.openecomp.sdc.impl.DistributionClientResultImpl", + "org.openecomp.sdc.impl.mock.DistributionClientStubImpl", + "org.openecomp.sdc.impl.DistributionClientDownloadResultImpl", + "org.openecomp.sdc.api.consumer.IConfiguration", + "org.openecomp.sdc.api.notification.IVfModuleMetadata", + "org.openecomp.sdc.api.results.IDistributionClientResult", + "org.openecomp.mso.db.catalog.beans.Service", + "org.openecomp.sdc.api.notification.IArtifactInfo", + "org.openecomp.sdc.impl.mock.DistributionClientDownloadResultStubImpl", + "org.openecomp.sdc.api.consumer.INotificationCallback", + "org.openecomp.mso.asdc.installer.VfModuleStructure", + "org.openecomp.sdc.api.notification.INotificationData", + "org.openecomp.mso.asdc.installer.VfModuleArtifact", + "org.openecomp.sdc.api.notification.IResourceInstance", + "org.openecomp.sdc.impl.mock.DistributionClientResultStubImpl", + "org.openecomp.sdc.api.results.IDistributionClientDownloadResult", + "org.openecomp.sdc.api.consumer.IDistributionStatusMessage" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(VfResourceStructureESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.openecomp.mso.asdc.client.exceptions.ArtifactInstallerException" + ); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java new file mode 100644 index 0000000000..77c70e015e --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTest.java @@ -0,0 +1,746 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:31:27 GMT 2016 + */ + +package org.openecomp.mso.asdc.util; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import java.util.Collection; +import java.util.Comparator; +import java.util.ConcurrentModificationException; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.function.Predicate; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.openecomp.sdc.api.notification.IArtifactInfo; +import org.openecomp.sdc.api.notification.INotificationData; +import org.openecomp.sdc.api.notification.IResourceInstance; +import org.openecomp.sdc.api.notification.IVfModuleMetadata; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class ASDCNotificationLoggingESTest extends ASDCNotificationLoggingESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + LinkedList<IResourceInstance> linkedList0 = new LinkedList<IResourceInstance>(); + LinkedList<IArtifactInfo> linkedList1 = new LinkedList<IArtifactInfo>(); + Integer integer0 = new Integer(2147483645); + Integer integer1 = new Integer(2147483645); + Integer integer2 = new Integer(2147483645); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iArtifactInfo0).getArtifactChecksum(); + doReturn((String) null).when(iArtifactInfo0).getArtifactDescription(); + doReturn((String) null).when(iArtifactInfo0).getArtifactName(); + doReturn((Integer) null).when(iArtifactInfo0).getArtifactTimeout(); + doReturn((String) null).when(iArtifactInfo0).getArtifactType(); + doReturn((String) null).when(iArtifactInfo0).getArtifactURL(); + doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); + doReturn((String) null).when(iArtifactInfo0).getArtifactVersion(); + doReturn((IArtifactInfo) null).when(iArtifactInfo0).getGeneratedArtifact(); + doReturn((List) null).when(iArtifactInfo0).getRelatedArtifacts(); + IArtifactInfo iArtifactInfo1 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("Resource Instance Info:").when(iArtifactInfo1).getArtifactChecksum(); + doReturn("~1xF'ZQr|qhuc{").when(iArtifactInfo1).getArtifactDescription(); + doReturn("").when(iArtifactInfo1).getArtifactName(); + doReturn(integer1).when(iArtifactInfo1).getArtifactTimeout(); + doReturn("7<\"g").when(iArtifactInfo1).getArtifactType(); + doReturn("").when(iArtifactInfo1).getArtifactURL(); + doReturn("").when(iArtifactInfo1).getArtifactUUID(); + doReturn("7<\"g").when(iArtifactInfo1).getArtifactVersion(); + doReturn(iArtifactInfo0).when(iArtifactInfo1).getGeneratedArtifact(); + doReturn(linkedList1, linkedList1).when(iArtifactInfo1).getRelatedArtifacts(); + LinkedList<IArtifactInfo> linkedList2 = new LinkedList<IArtifactInfo>(); + Integer integer3 = new Integer(1); + LinkedList<IArtifactInfo> linkedList3 = new LinkedList<IArtifactInfo>(); + IArtifactInfo iArtifactInfo2 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn("-X^ og(1=?-*/%4", "%jgpj", (String) null).when(iArtifactInfo2).getArtifactChecksum(); + doReturn("7<\"g", "", (String) null).when(iArtifactInfo2).getArtifactDescription(); + doReturn("7 'W{]65Y%Vh_ynFOr", "]+O?<_o+Mx?P@|^<:|/", (String) null).when(iArtifactInfo2).getArtifactName(); + doReturn(integer0, integer3, (Integer) null).when(iArtifactInfo2).getArtifactTimeout(); + doReturn("]+O?<_o+Mx?P@|^<:|/", "", (String) null).when(iArtifactInfo2).getArtifactType(); + doReturn("i]\r7Wr. <gStwjW", "Ns3ZUZX(", (String) null).when(iArtifactInfo2).getArtifactURL(); + doReturn("7 'W{]65Y%Vh_ynFOr", "7<\"g", (String) null).when(iArtifactInfo2).getArtifactUUID(); + doReturn("7 'W{]65Y%Vh_ynFOr", "YuS7'", (String) null).when(iArtifactInfo2).getArtifactVersion(); + doReturn(iArtifactInfo1, (IArtifactInfo) null, (IArtifactInfo) null).when(iArtifactInfo2).getGeneratedArtifact(); + doReturn(linkedList2, linkedList2, linkedList3, linkedList3, (List) null).when(iArtifactInfo2).getRelatedArtifacts(); + linkedList1.add(iArtifactInfo2); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("~1xF'ZQr|qhuc{").when(iNotificationData0).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); + doReturn(linkedList1).when(iNotificationData0).getServiceArtifacts(); + doReturn("").when(iNotificationData0).getServiceDescription(); + doReturn("").when(iNotificationData0).getServiceInvariantUUID(); + doReturn("").when(iNotificationData0).getServiceName(); + doReturn("").when(iNotificationData0).getServiceUUID(); + doReturn("TvEm!").when(iNotificationData0).getServiceVersion(); + String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData1).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData1).getResources(); + doReturn(linkedList1).when(iNotificationData1).getServiceArtifacts(); + doReturn("").when(iNotificationData1).getServiceDescription(); + doReturn("Tz)|, ,").when(iNotificationData1).getServiceInvariantUUID(); + doReturn("").when(iNotificationData1).getServiceName(); + doReturn("").when(iNotificationData1).getServiceUUID(); + doReturn("Tz)|, ,").when(iNotificationData1).getServiceVersion(); + String string1 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + assertFalse(string1.equals((Object)string0)); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.add(iVfModuleMetadata0); + LinkedList<Object> linkedList1 = new LinkedList<Object>(); + Object object0 = new Object(); + linkedList1.push(object0); + linkedList0.spliterator(); + linkedList0.removeAll(linkedList1); + linkedList0.clear(); + LinkedList<String> linkedList2 = new LinkedList<String>(); + IVfModuleMetadata iVfModuleMetadata1 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List<String>) null, (List<String>) null, linkedList2, (List<String>) null).when(iVfModuleMetadata1).getArtifacts(); + doReturn("e.tf%6&", "e.tf%6&", "").when(iVfModuleMetadata1).getVfModuleModelDescription(); + doReturn("", "", "").when(iVfModuleMetadata1).getVfModuleModelInvariantUUID(); + doReturn("", "", "e.tf%6&").when(iVfModuleMetadata1).getVfModuleModelName(); + doReturn("VfModuleMetaData:", "e.tf%6&", "BaseArtifactInfoImpl [artifactName=").when(iVfModuleMetadata1).getVfModuleModelUUID(); + doReturn("e.tf%6&", "e.tf%6&", "e.tf%6&").when(iVfModuleMetadata1).getVfModuleModelVersion(); + doReturn(false, false).when(iVfModuleMetadata1).isBase(); + linkedList0.add(iVfModuleMetadata1); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + // Undeclared exception! + try { + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.ASDCNotificationLogging", e); + } + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging1 = new ASDCNotificationLogging(); + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List<String>) null, (List<String>) null).when(iVfModuleMetadata0).getArtifacts(); + doReturn("TTq", (String) null).when(iVfModuleMetadata0).getVfModuleModelDescription(); + doReturn("", (String) null).when(iVfModuleMetadata0).getVfModuleModelInvariantUUID(); + doReturn("w1e~\"rjNBjuq*0HB!3&", (String) null).when(iVfModuleMetadata0).getVfModuleModelName(); + doReturn("+l", (String) null).when(iVfModuleMetadata0).getVfModuleModelUUID(); + doReturn("]", (String) null).when(iVfModuleMetadata0).getVfModuleModelVersion(); + doReturn(true, false).when(iVfModuleMetadata0).isBase(); + linkedList0.add(iVfModuleMetadata0); + IVfModuleMetadata iVfModuleMetadata1 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.removeFirstOccurrence(aSDCNotificationLogging1); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + assertEquals("{\nVfModuleMetaData:\nVfModuleModelName:NULL\nVfModuleModelVersion:NULL\nVfModuleModelUUID:NULL\nVfModuleModelInvariantUUID:NULL\nVfModuleModelDescription:NULL\nArtifacts UUID List:NULL\nisBase:false\n\n\n}\n", string0); + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + List<IResourceInstance> list0 = (List<IResourceInstance>) mock(List.class, new ViolatedAssumptionAnswer()); + List<IArtifactInfo> list1 = (List<IArtifactInfo>) mock(List.class, new ViolatedAssumptionAnswer()); + doReturn(false).when(list1).isEmpty(); + doReturn((Iterator) null).when(list1).iterator(); + doReturn(0).when(list1).size(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn(list1).when(iNotificationData0).getServiceArtifacts(); + doReturn("9").when(iNotificationData0).getServiceDescription(); + doReturn("9").when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn("Type not recognized").when(iNotificationData0).getServiceUUID(); + doReturn("").when(iNotificationData0).getServiceVersion(); + // Undeclared exception! + try { + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.ASDCNotificationLogging", e); + } + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + LinkedList<IResourceInstance> linkedList0 = new LinkedList<IResourceInstance>(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("(ICU8j3G)Z4Z[GAE").when(iNotificationData0).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); + doReturn((List<IArtifactInfo>) null).when(iNotificationData0).getServiceArtifacts(); + doReturn(")&42fB6dZT&HRAb1a").when(iNotificationData0).getServiceDescription(); + doReturn("(ICU8j3G)Z4Z[GAE").when(iNotificationData0).getServiceInvariantUUID(); + doReturn(")&42fB6dZT&HRAb1a").when(iNotificationData0).getServiceName(); + doReturn(")&42fB6dZT&HRAb1a").when(iNotificationData0).getServiceUUID(); + doReturn("cHH N9Ha9YUPSpX00i").when(iNotificationData0).getServiceVersion(); + String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + assertEquals("ASDC Notification:\nDistributionID:(ICU8j3G)Z4Z[GAE\nServiceName:)&42fB6dZT&HRAb1a\nServiceVersion:cHH N9Ha9YUPSpX00i\nServiceUUID:)&42fB6dZT&HRAb1a\nServiceInvariantUUID:(ICU8j3G)Z4Z[GAE\nServiceDescription:)&42fB6dZT&HRAb1a\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n", string0); + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + assertEquals(0, linkedList0.size()); + + LinkedList<String> linkedList1 = new LinkedList<String>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList1, linkedList1).when(iVfModuleMetadata0).getArtifacts(); + doReturn(", artifactTimeout=").when(iVfModuleMetadata0).getVfModuleModelDescription(); + doReturn(", artifactChecksum=").when(iVfModuleMetadata0).getVfModuleModelInvariantUUID(); + doReturn(", artifactTimeout=").when(iVfModuleMetadata0).getVfModuleModelName(); + doReturn(", artifactTimeout=").when(iVfModuleMetadata0).getVfModuleModelUUID(); + doReturn(", artifactTimeout=").when(iVfModuleMetadata0).getVfModuleModelVersion(); + doReturn(false).when(iVfModuleMetadata0).isBase(); + IVfModuleMetadata iVfModuleMetadata1 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.add(iVfModuleMetadata1); + linkedList1.push("dzjz-zmMzFE"); + linkedList0.listIterator(); + linkedList0.toArray(); + linkedList0.add(iVfModuleMetadata0); + linkedList0.pollFirst(); + String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + assertEquals("{\nVfModuleMetaData:\nVfModuleModelName:, artifactTimeout=\nVfModuleModelVersion:, artifactTimeout=\nVfModuleModelUUID:, artifactTimeout=\nVfModuleModelInvariantUUID:, artifactChecksum=\nVfModuleModelDescription:, artifactTimeout=\nArtifacts UUID List:{\ndzjz-zmMzFE\n\n}\n\nisBase:false\n\n\n}\n", string0); + + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + LinkedList<IResourceInstance> linkedList2 = new LinkedList<IResourceInstance>(); + LinkedList<IResourceInstance> linkedList3 = new LinkedList<IResourceInstance>((Collection<? extends IResourceInstance>) linkedList2); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn((List) null).when(iNotificationData0).getResources(); + doReturn((List) null).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn((String) null).when(iNotificationData0).getServiceUUID(); + doReturn((String) null).when(iNotificationData0).getServiceVersion(); + String string1 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + assertEquals("ASDC Notification:\nDistributionID:NULL\nServiceName:NULL\nServiceVersion:NULL\nServiceUUID:NULL\nServiceInvariantUUID:NULL\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n", string1); + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn((List) null).when(iNotificationData0).getResources(); + doReturn((List) null).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn((String) null).when(iNotificationData0).getServiceUUID(); + doReturn((String) null).when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + List<IVfModuleMetadata> list0 = linkedList0.subList(0, 0); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + linkedList0.removeAll(list0); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + Comparator<Object> comparator0 = (Comparator<Object>) mock(Comparator.class, new ViolatedAssumptionAnswer()); + linkedList0.sort(comparator0); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.offerLast(iVfModuleMetadata0); + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData1).getDistributionID(); + doReturn((List) null).when(iNotificationData1).getResources(); + doReturn((List) null).when(iNotificationData1).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData1).getServiceDescription(); + doReturn((String) null).when(iNotificationData1).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData1).getServiceName(); + doReturn((String) null).when(iNotificationData1).getServiceUUID(); + doReturn((String) null).when(iNotificationData1).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + // Undeclared exception! + try { + ASDCNotificationLogging.dumpVfModuleMetaDataList(list0); + fail("Expecting exception: ConcurrentModificationException"); + + } catch(ConcurrentModificationException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.util.SubList", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging1 = new ASDCNotificationLogging(); + LinkedList<IResourceInstance> linkedList0 = new LinkedList<IResourceInstance>(); + LinkedList<IArtifactInfo> linkedList1 = new LinkedList<IArtifactInfo>(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("ResourceInstanceName:").when(iNotificationData0).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); + doReturn(linkedList1).when(iNotificationData0).getServiceArtifacts(); + doReturn("ResourceInstanceName:").when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn("ResourceInstanceName:").when(iNotificationData0).getServiceName(); + doReturn("pr26M0Ud8~n6#j/;g").when(iNotificationData0).getServiceUUID(); + doReturn((String) null).when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + ASDCNotificationLogging aSDCNotificationLogging2 = new ASDCNotificationLogging(); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("ResourceInstanceName:").when(iNotificationData1).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData1).getResources(); + doReturn(linkedList1).when(iNotificationData1).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData1).getServiceDescription(); + doReturn("").when(iNotificationData1).getServiceInvariantUUID(); + doReturn("pr26M0Ud8~n6#j/;g").when(iNotificationData1).getServiceName(); + doReturn("").when(iNotificationData1).getServiceUUID(); + doReturn("Resource Artifacts List:").when(iNotificationData1).getServiceVersion(); + String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + assertEquals("ASDC Notification:\nDistributionID:ResourceInstanceName:\nServiceName:pr26M0Ud8~n6#j/;g\nServiceVersion:Resource Artifacts List:\nServiceUUID:\nServiceInvariantUUID:\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n", string0); + + ASDCNotificationLogging aSDCNotificationLogging3 = new ASDCNotificationLogging(); + LinkedList<IVfModuleMetadata> linkedList2 = new LinkedList<IVfModuleMetadata>(); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList2); + LinkedList<IResourceInstance> linkedList3 = new LinkedList<IResourceInstance>(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactChecksum(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactDescription(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactName(); + doReturn((Integer) null, (Integer) null, (Integer) null).when(iArtifactInfo0).getArtifactTimeout(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactType(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactURL(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactUUID(); + doReturn((String) null, (String) null, (String) null).when(iArtifactInfo0).getArtifactVersion(); + doReturn((IArtifactInfo) null, (IArtifactInfo) null, (IArtifactInfo) null).when(iArtifactInfo0).getGeneratedArtifact(); + doReturn((List) null, (List) null, (List) null).when(iArtifactInfo0).getRelatedArtifacts(); + linkedList1.add(iArtifactInfo0); + INotificationData iNotificationData2 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("tlh7ku").when(iNotificationData2).getDistributionID(); + doReturn(linkedList3, linkedList0).when(iNotificationData2).getResources(); + doReturn(linkedList1).when(iNotificationData2).getServiceArtifacts(); + doReturn("").when(iNotificationData2).getServiceDescription(); + doReturn("").when(iNotificationData2).getServiceInvariantUUID(); + doReturn("tlh7ku").when(iNotificationData2).getServiceName(); + doReturn("_B4BTx//Er%IWM}et0").when(iNotificationData2).getServiceUUID(); + doReturn("").when(iNotificationData2).getServiceVersion(); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList1).when(iResourceInstance0).getArtifacts(); + doReturn("").when(iResourceInstance0).getResourceInstanceName(); + doReturn("Resource Artifacts List:").when(iResourceInstance0).getResourceInvariantUUID(); + doReturn("Hq^8Xl<>T").when(iResourceInstance0).getResourceName(); + doReturn((String) null).when(iResourceInstance0).getResourceType(); + doReturn("ASDC Notification:\nDistributionID:ResourceInstanceName:\nServiceName:ResourceInstanceName:\nServiceVersion:NULL\nServiceUUID:pr26M0Ud8~n6#j/;g\nServiceInvariantUUID:NULL\nServiceDescription:ResourceInstanceName:\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n").when(iResourceInstance0).getResourceUUID(); + doReturn("zIQ?4(U$K ").when(iResourceInstance0).getResourceVersion(); + linkedList0.add(iResourceInstance0); + IResourceInstance iResourceInstance1 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList1).when(iResourceInstance1).getArtifacts(); + doReturn("ASDC Notification:\nDistributionID:ResourceInstanceName:\nServiceName:pr26M0Ud8~n6#j/;g\nServiceVersion:Resource Artifacts List:\nServiceUUID:\nServiceInvariantUUID:\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n").when(iResourceInstance1).getResourceInstanceName(); + doReturn("5yNU;|<:T-ixwLB").when(iResourceInstance1).getResourceInvariantUUID(); + doReturn("").when(iResourceInstance1).getResourceName(); + doReturn("xguM[yK-\"").when(iResourceInstance1).getResourceType(); + doReturn("").when(iResourceInstance1).getResourceUUID(); + doReturn("ASDC Notification:\nDistributionID:ResourceInstanceName:\nServiceName:pr26M0Ud8~n6#j/;g\nServiceVersion:Resource Artifacts List:\nServiceUUID:\nServiceInvariantUUID:\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n").when(iResourceInstance1).getResourceVersion(); + linkedList1.removeFirstOccurrence((Object) null); + linkedList0.add(iResourceInstance1); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData2); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + String string1 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList2); + assertEquals("\n}\n", string1); + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn((List) null).when(iNotificationData0).getResources(); + doReturn((List) null).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn((String) null).when(iNotificationData0).getServiceUUID(); + doReturn((String) null).when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData1).getDistributionID(); + doReturn((List) null).when(iNotificationData1).getResources(); + doReturn((List) null).when(iNotificationData1).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData1).getServiceDescription(); + doReturn((String) null).when(iNotificationData1).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData1).getServiceName(); + doReturn((String) null).when(iNotificationData1).getServiceUUID(); + doReturn((String) null).when(iNotificationData1).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + INotificationData iNotificationData2 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData2).getDistributionID(); + doReturn((List) null).when(iNotificationData2).getResources(); + doReturn((List) null).when(iNotificationData2).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData2).getServiceDescription(); + doReturn((String) null).when(iNotificationData2).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData2).getServiceName(); + doReturn((String) null).when(iNotificationData2).getServiceUUID(); + doReturn((String) null).when(iNotificationData2).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData2); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData3 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData3).getDistributionID(); + doReturn((List) null).when(iNotificationData3).getResources(); + doReturn((List) null).when(iNotificationData3).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData3).getServiceDescription(); + doReturn((String) null).when(iNotificationData3).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData3).getServiceName(); + doReturn((String) null).when(iNotificationData3).getServiceUUID(); + doReturn((String) null).when(iNotificationData3).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData3); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData4 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData4).getDistributionID(); + doReturn((List) null).when(iNotificationData4).getResources(); + doReturn((List) null).when(iNotificationData4).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData4).getServiceDescription(); + doReturn((String) null).when(iNotificationData4).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData4).getServiceName(); + doReturn((String) null).when(iNotificationData4).getServiceUUID(); + doReturn((String) null).when(iNotificationData4).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData4); + INotificationData iNotificationData5 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData5).getDistributionID(); + doReturn((List) null).when(iNotificationData5).getResources(); + doReturn((List) null).when(iNotificationData5).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData5).getServiceDescription(); + doReturn((String) null).when(iNotificationData5).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData5).getServiceName(); + doReturn((String) null).when(iNotificationData5).getServiceUUID(); + doReturn((String) null).when(iNotificationData5).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData5); + INotificationData iNotificationData6 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData6).getDistributionID(); + doReturn((List) null).when(iNotificationData6).getResources(); + doReturn((List) null).when(iNotificationData6).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData6).getServiceDescription(); + doReturn((String) null).when(iNotificationData6).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData6).getServiceName(); + doReturn((String) null).when(iNotificationData6).getServiceUUID(); + doReturn((String) null).when(iNotificationData6).getServiceVersion(); + String string0 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData6); + assertEquals("ASDC Notification:\nDistributionID:NULL\nServiceName:NULL\nServiceVersion:NULL\nServiceUUID:NULL\nServiceInvariantUUID:NULL\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n", string0); + + ASDCNotificationLogging.dumpASDCNotification((INotificationData) null); + String string1 = ASDCNotificationLogging.dumpASDCNotification((INotificationData) null); + assertEquals("NULL", string1); + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + LinkedList<IArtifactInfo> linkedList0 = new LinkedList<IArtifactInfo>(); + IArtifactInfo iArtifactInfo0 = mock(IArtifactInfo.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iArtifactInfo0).getArtifactChecksum(); + doReturn((String) null).when(iArtifactInfo0).getArtifactDescription(); + doReturn((String) null).when(iArtifactInfo0).getArtifactName(); + doReturn((Integer) null).when(iArtifactInfo0).getArtifactTimeout(); + doReturn((String) null).when(iArtifactInfo0).getArtifactType(); + doReturn((String) null).when(iArtifactInfo0).getArtifactURL(); + doReturn((String) null).when(iArtifactInfo0).getArtifactUUID(); + doReturn((String) null).when(iArtifactInfo0).getArtifactVersion(); + doReturn((IArtifactInfo) null).when(iArtifactInfo0).getGeneratedArtifact(); + doReturn((List) null).when(iArtifactInfo0).getRelatedArtifacts(); + linkedList0.add(iArtifactInfo0); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn((List<IResourceInstance>) null).when(iNotificationData0).getResources(); + doReturn(linkedList0).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn((String) null).when(iNotificationData0).getServiceUUID(); + doReturn("(").when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + assertNull(string0); + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + LinkedList<IVfModuleMetadata> linkedList1 = new LinkedList<IVfModuleMetadata>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList1.add(iVfModuleMetadata0); + LinkedList<String> linkedList2 = new LinkedList<String>(); + LinkedList<String> linkedList3 = new LinkedList<String>(); + linkedList1.removeFirst(); + linkedList0.addAll((Collection<? extends IVfModuleMetadata>) linkedList1); + LinkedList<String> linkedList4 = new LinkedList<String>(); + LinkedList<String> linkedList5 = new LinkedList<String>(); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + LinkedList<IResourceInstance> linkedList6 = new LinkedList<IResourceInstance>(); + LinkedList<IArtifactInfo> linkedList7 = new LinkedList<IArtifactInfo>(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("]=ztki(=]").when(iNotificationData0).getDistributionID(); + doReturn(linkedList6, linkedList6).when(iNotificationData0).getResources(); + doReturn(linkedList7).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn("").when(iNotificationData0).getServiceInvariantUUID(); + doReturn("").when(iNotificationData0).getServiceName(); + doReturn("VG).").when(iNotificationData0).getServiceUUID(); + doReturn("").when(iNotificationData0).getServiceVersion(); + linkedList0.spliterator(); + linkedList0.containsAll(linkedList1); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + LinkedList<IResourceInstance> linkedList8 = new LinkedList<IResourceInstance>(); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("C'K").when(iNotificationData1).getDistributionID(); + doReturn(linkedList6, linkedList8).when(iNotificationData1).getResources(); + doReturn(linkedList7).when(iNotificationData1).getServiceArtifacts(); + doReturn("NotificationDataImpl [distributionID=").when(iNotificationData1).getServiceDescription(); + doReturn((String) null).when(iNotificationData1).getServiceInvariantUUID(); + doReturn("B.").when(iNotificationData1).getServiceName(); + doReturn("").when(iNotificationData1).getServiceUUID(); + doReturn("").when(iNotificationData1).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.add(iVfModuleMetadata0); + linkedList0.add((IVfModuleMetadata) null); + LinkedList<String> linkedList1 = new LinkedList<String>(); + IVfModuleMetadata iVfModuleMetadata1 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList1, linkedList1, linkedList1, linkedList1).when(iVfModuleMetadata1).getArtifacts(); + doReturn("8u1XbrrMy{J2", "").when(iVfModuleMetadata1).getVfModuleModelDescription(); + doReturn("YR/UZ7qrmvO", "8u1XbrrMy{J2").when(iVfModuleMetadata1).getVfModuleModelInvariantUUID(); + doReturn("8u1XbrrMy{J2", ".l=(8f`8f}.9>yn").when(iVfModuleMetadata1).getVfModuleModelName(); + doReturn("", "YR/UZ7qrmvO").when(iVfModuleMetadata1).getVfModuleModelUUID(); + doReturn("[66/OPYLD.B%", ".l=(8f`8f}.9>yn").when(iVfModuleMetadata1).getVfModuleModelVersion(); + doReturn(false, true).when(iVfModuleMetadata1).isBase(); + LinkedList<IVfModuleMetadata> linkedList2 = new LinkedList<IVfModuleMetadata>(); + linkedList2.add((IVfModuleMetadata) null); + linkedList2.offer((IVfModuleMetadata) null); + Predicate<IVfModuleMetadata> predicate0 = (Predicate<IVfModuleMetadata>) mock(Predicate.class, new ViolatedAssumptionAnswer()); + doReturn(true, false).when(predicate0).test(any()); + linkedList2.removeIf(predicate0); + linkedList0.retainAll(linkedList2); + LinkedList<String> linkedList3 = new LinkedList<String>(); + IVfModuleMetadata iVfModuleMetadata2 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn(linkedList3, linkedList3, linkedList3, linkedList1).when(iVfModuleMetadata2).getArtifacts(); + doReturn("YR/UZ7qrmvO", "8u1XbrrMy{J2").when(iVfModuleMetadata2).getVfModuleModelDescription(); + doReturn("", "8u1XbrrMy{J2").when(iVfModuleMetadata2).getVfModuleModelInvariantUUID(); + doReturn("[66/OPYLD.B%", "").when(iVfModuleMetadata2).getVfModuleModelName(); + doReturn("", "[66/OPYLD.B%").when(iVfModuleMetadata2).getVfModuleModelUUID(); + doReturn((String) null, "").when(iVfModuleMetadata2).getVfModuleModelVersion(); + doReturn(true, false).when(iVfModuleMetadata2).isBase(); + linkedList0.add(iVfModuleMetadata2); + linkedList0.push(iVfModuleMetadata1); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging1 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging2 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging3 = new ASDCNotificationLogging(); + String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + assertEquals("{\nVfModuleMetaData:\nVfModuleModelName:.l=(8f`8f}.9>yn\nVfModuleModelVersion:.l=(8f`8f}.9>yn\nVfModuleModelUUID:YR/UZ7qrmvO\nVfModuleModelInvariantUUID:8u1XbrrMy{J2\nVfModuleModelDescription:\nArtifacts UUID List:\n}\n\nisBase:true\n\n,\nNULL\n,\nVfModuleMetaData:\nVfModuleModelName:\nVfModuleModelVersion:\nVfModuleModelUUID:[66/OPYLD.B%\nVfModuleModelInvariantUUID:8u1XbrrMy{J2\nVfModuleModelDescription:8u1XbrrMy{J2\nArtifacts UUID List:\n}\n\nisBase:false\n\n\n}\n", string0); + + LinkedList<IResourceInstance> linkedList4 = new LinkedList<IResourceInstance>(); + LinkedList<IResourceInstance> linkedList5 = new LinkedList<IResourceInstance>((Collection<? extends IResourceInstance>) linkedList4); + LinkedList<IArtifactInfo> linkedList6 = new LinkedList<IArtifactInfo>(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("95y$c-.BW5V()41WR").when(iNotificationData0).getDistributionID(); + doReturn(linkedList5, linkedList4).when(iNotificationData0).getResources(); + doReturn(linkedList6).when(iNotificationData0).getServiceArtifacts(); + doReturn(", artifactTimeout=").when(iNotificationData0).getServiceDescription(); + doReturn("[66/OPYLD.B%").when(iNotificationData0).getServiceInvariantUUID(); + doReturn("[66/OPYLD.B%").when(iNotificationData0).getServiceName(); + doReturn(", artifactChecksum=").when(iNotificationData0).getServiceUUID(); + doReturn("W1vX^KnIx[x").when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + ASDCNotificationLogging aSDCNotificationLogging4 = new ASDCNotificationLogging(); + ASDCNotificationLogging aSDCNotificationLogging5 = new ASDCNotificationLogging(); + LinkedList<IResourceInstance> linkedList7 = new LinkedList<IResourceInstance>(); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("").when(iNotificationData1).getDistributionID(); + doReturn(linkedList4, linkedList7).when(iNotificationData1).getResources(); + doReturn(linkedList6).when(iNotificationData1).getServiceArtifacts(); + doReturn("3l\"ZrTP`IQ-4x]").when(iNotificationData1).getServiceDescription(); + doReturn("").when(iNotificationData1).getServiceInvariantUUID(); + doReturn("").when(iNotificationData1).getServiceName(); + doReturn("").when(iNotificationData1).getServiceUUID(); + doReturn("").when(iNotificationData1).getServiceVersion(); + String string1 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + assertEquals("ASDC Notification:\nDistributionID:\nServiceName:\nServiceVersion:\nServiceUUID:\nServiceInvariantUUID:\nServiceDescription:3l\"ZrTP`IQ-4x]\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n", string1); + } + + @Test(timeout = 4000) + public void test12() throws Throwable { + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData0).getDistributionID(); + doReturn((List) null).when(iNotificationData0).getResources(); + doReturn((List) null).when(iNotificationData0).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn((String) null).when(iNotificationData0).getServiceUUID(); + doReturn((String) null).when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + INotificationData iNotificationData1 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData1).getDistributionID(); + doReturn((List) null).when(iNotificationData1).getResources(); + doReturn((List) null).when(iNotificationData1).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData1).getServiceDescription(); + doReturn((String) null).when(iNotificationData1).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData1).getServiceName(); + doReturn((String) null).when(iNotificationData1).getServiceUUID(); + doReturn((String) null).when(iNotificationData1).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData1); + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + INotificationData iNotificationData2 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData2).getDistributionID(); + doReturn((List) null).when(iNotificationData2).getResources(); + doReturn((List) null).when(iNotificationData2).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData2).getServiceDescription(); + doReturn((String) null).when(iNotificationData2).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData2).getServiceName(); + doReturn((String) null).when(iNotificationData2).getServiceUUID(); + doReturn((String) null).when(iNotificationData2).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData2); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging aSDCNotificationLogging1 = new ASDCNotificationLogging(); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData3 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData3).getDistributionID(); + doReturn((List) null).when(iNotificationData3).getResources(); + doReturn((List) null).when(iNotificationData3).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData3).getServiceDescription(); + doReturn((String) null).when(iNotificationData3).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData3).getServiceName(); + doReturn((String) null).when(iNotificationData3).getServiceUUID(); + doReturn((String) null).when(iNotificationData3).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData3); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + ASDCNotificationLogging aSDCNotificationLogging2 = new ASDCNotificationLogging(); + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + doReturn((List) null, (List) null, (List) null).when(iVfModuleMetadata0).getArtifacts(); + doReturn((String) null, (String) null, (String) null).when(iVfModuleMetadata0).getVfModuleModelDescription(); + doReturn((String) null, (String) null, (String) null).when(iVfModuleMetadata0).getVfModuleModelInvariantUUID(); + doReturn((String) null, (String) null, (String) null).when(iVfModuleMetadata0).getVfModuleModelName(); + doReturn((String) null, (String) null, (String) null).when(iVfModuleMetadata0).getVfModuleModelUUID(); + doReturn((String) null, (String) null, (String) null).when(iVfModuleMetadata0).getVfModuleModelVersion(); + doReturn(false, false, false).when(iVfModuleMetadata0).isBase(); + linkedList0.add(iVfModuleMetadata0); + linkedList0.removeLastOccurrence("ASDC Notification:\nDistributionID:NULL\nServiceName:NULL\nServiceVersion:NULL\nServiceUUID:NULL\nServiceInvariantUUID:NULL\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\n\n}\n\n"); + linkedList0.remove((Object) null); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging aSDCNotificationLogging3 = new ASDCNotificationLogging(); + String string0 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + String string1 = ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + assertEquals("{\nVfModuleMetaData:\nVfModuleModelName:NULL\nVfModuleModelVersion:NULL\nVfModuleModelUUID:NULL\nVfModuleModelInvariantUUID:NULL\nVfModuleModelDescription:NULL\nArtifacts UUID List:NULL\nisBase:false\n\n\n}\n", string1); + assertTrue(string1.equals((Object)string0)); + + ASDCNotificationLogging aSDCNotificationLogging4 = new ASDCNotificationLogging(); + ASDCNotificationLogging.dumpVfModuleMetaDataList((List<IVfModuleMetadata>) null); + INotificationData iNotificationData4 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn((String) null).when(iNotificationData4).getDistributionID(); + doReturn((List) null).when(iNotificationData4).getResources(); + doReturn((List) null).when(iNotificationData4).getServiceArtifacts(); + doReturn((String) null).when(iNotificationData4).getServiceDescription(); + doReturn((String) null).when(iNotificationData4).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData4).getServiceName(); + doReturn((String) null).when(iNotificationData4).getServiceUUID(); + doReturn((String) null).when(iNotificationData4).getServiceVersion(); + String string2 = ASDCNotificationLogging.dumpASDCNotification(iNotificationData4); + assertEquals("ASDC Notification:\nDistributionID:NULL\nServiceName:NULL\nServiceVersion:NULL\nServiceUUID:NULL\nServiceInvariantUUID:NULL\nServiceDescription:NULL\nService Artifacts List:\nNULL\nResource Instances List:\nNULL\n", string2); + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + ASDCNotificationLogging aSDCNotificationLogging0 = new ASDCNotificationLogging(); + LinkedList<IResourceInstance> linkedList0 = new LinkedList<IResourceInstance>(); + IResourceInstance iResourceInstance0 = mock(IResourceInstance.class, new ViolatedAssumptionAnswer()); + doReturn((List) null).when(iResourceInstance0).getArtifacts(); + doReturn((String) null).when(iResourceInstance0).getResourceInstanceName(); + doReturn((String) null).when(iResourceInstance0).getResourceInvariantUUID(); + doReturn((String) null).when(iResourceInstance0).getResourceName(); + doReturn((String) null).when(iResourceInstance0).getResourceType(); + doReturn((String) null).when(iResourceInstance0).getResourceUUID(); + doReturn((String) null).when(iResourceInstance0).getResourceVersion(); + linkedList0.add(iResourceInstance0); + LinkedList<IArtifactInfo> linkedList1 = new LinkedList<IArtifactInfo>(); + INotificationData iNotificationData0 = mock(INotificationData.class, new ViolatedAssumptionAnswer()); + doReturn("(n,0").when(iNotificationData0).getDistributionID(); + doReturn(linkedList0, linkedList0).when(iNotificationData0).getResources(); + doReturn(linkedList1).when(iNotificationData0).getServiceArtifacts(); + doReturn("(n,0").when(iNotificationData0).getServiceDescription(); + doReturn((String) null).when(iNotificationData0).getServiceInvariantUUID(); + doReturn((String) null).when(iNotificationData0).getServiceName(); + doReturn("").when(iNotificationData0).getServiceUUID(); + doReturn("t1N;ZSJsATt:&Ug").when(iNotificationData0).getServiceVersion(); + ASDCNotificationLogging.dumpASDCNotification(iNotificationData0); + LinkedList<IVfModuleMetadata> linkedList2 = new LinkedList<IVfModuleMetadata>(); + linkedList2.clear(); + // Undeclared exception! + try { + linkedList2.remove(); + fail("Expecting exception: NoSuchElementException"); + + } catch(NoSuchElementException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("java.util.LinkedList", e); + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + LinkedList<IVfModuleMetadata> linkedList0 = new LinkedList<IVfModuleMetadata>(); + ASDCNotificationLogging.dumpVfModuleMetaDataList(linkedList0); + IVfModuleMetadata iVfModuleMetadata0 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.add(iVfModuleMetadata0); + linkedList0.remove((Object) "\n}\n"); + IVfModuleMetadata iVfModuleMetadata1 = mock(IVfModuleMetadata.class, new ViolatedAssumptionAnswer()); + linkedList0.offerLast(iVfModuleMetadata1); + // Undeclared exception! + try { + linkedList0.subList((-1), (-1)); + fail("Expecting exception: IndexOutOfBoundsException"); + + } catch(IndexOutOfBoundsException e) { + // + // fromIndex = -1 + // + verifyException("java.util.SubList", e); + } + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java new file mode 100644 index 0000000000..1344bbe45d --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/ASDCNotificationLoggingESTestscaffolding.java @@ -0,0 +1,81 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:31:27 GMT 2016 + */ + +package org.openecomp.mso.asdc.util; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class ASDCNotificationLoggingESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.util.ASDCNotificationLogging"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(ASDCNotificationLoggingESTestscaffolding.class.getClassLoader() , + "org.openecomp.sdc.api.notification.INotificationData", + "org.openecomp.sdc.api.notification.IResourceInstance", + "org.openecomp.sdc.api.notification.IVfModuleMetadata", + "org.openecomp.mso.asdc.util.ASDCNotificationLogging", + "org.openecomp.sdc.api.notification.IArtifactInfo" + ); + } + + private static void resetClasses() { + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java new file mode 100644 index 0000000000..c050a9cc20 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTest.java @@ -0,0 +1,420 @@ +/* + * This file was automatically generated by EvoSuite + * Fri Nov 25 13:17:51 GMT 2016 + */ + +package org.openecomp.mso.asdc.util; + +import org.junit.Test; +import static org.junit.Assert.*; +import static org.evosuite.shaded.org.mockito.Mockito.*; +import static org.evosuite.runtime.MockitoExtension.*; +import static org.evosuite.runtime.EvoAssertions.*; + +import org.openecomp.mso.db.catalog.beans.HeatTemplateParam; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.evosuite.runtime.EvoRunner; +import org.evosuite.runtime.EvoRunnerParameters; +import org.evosuite.runtime.PrivateAccess; +import org.evosuite.runtime.ViolatedAssumptionAnswer; +import org.junit.runner.RunWith; +import org.yaml.snakeyaml.Yaml; + +@RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) +public class YamlEditorESTest extends YamlEditorESTestscaffolding { + + @Test(timeout = 4000) + public void test00() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + boolean boolean0 = yamlEditor0.isParentTemplate("file:///"); + assertTrue(boolean0); + } + + @Test(timeout = 4000) + public void test01() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<String, Object> hashMap0 = new HashMap<String, Object>(); + Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); + doReturn((String) null, (String) null).when(yaml0).dump(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); + yamlEditor0.encode((Map<String, Object>) hashMap0); + Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn((Object) null).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + yamlEditor0.toString(); + // Undeclared exception! + try { + yamlEditor0.getYamlResourceTypeList(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test02() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<Object, String> hashMap0 = new HashMap<Object, String>(); + Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); + Object object0 = new Object(); + Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(hashMap0, object0).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + yamlEditor0.getParameterList(); + // Undeclared exception! + try { + yamlEditor0.getYamlResourceTypeList(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // java.lang.Object cannot be cast to java.util.Map + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test03() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + // Undeclared exception! + try { + yamlEditor0.getYamlNestedFileResourceTypeList(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test04() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<Object, String> hashMap0 = new HashMap<Object, String>(); + Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0); + Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(hashMap0, (Object) null).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + yamlEditor0.getYamlNestedFileResourceTypeList(); + // Undeclared exception! + try { + yamlEditor0.getParameterList(); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test05() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<String, Object> hashMap0 = new HashMap<String, Object>(); + Set<Map.Entry<String, Object>> set0 = (Set<Map.Entry<String, Object>>)hashMap0.entrySet(); + hashMap0.put("null\n", set0); + // Undeclared exception! + try { + yamlEditor0.encode((Map<String, Object>) hashMap0); + fail("Expecting exception: StackOverflowError"); + + } catch(StackOverflowError e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test06() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + Set<Map.Entry<String, Object>> set0 = (Set<Map.Entry<String, Object>>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn((Iterator) null).when(set0).iterator(); + Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(set0).when(map0).entrySet(); + doReturn(2655).when(map0).size(); + // Undeclared exception! + try { + yamlEditor0.encode(map0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.yaml.snakeyaml.representer.BaseRepresenter", e); + } + } + + @Test(timeout = 4000) + public void test07() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn((-300)).when(map0).size(); + // Undeclared exception! + try { + yamlEditor0.encode(map0); + fail("Expecting exception: IllegalArgumentException"); + + } catch(IllegalArgumentException e) { + // + // Illegal Capacity: -300 + // + verifyException("java.util.ArrayList", e); + } + } + + @Test(timeout = 4000) + public void test08() throws Throwable { + byte[] byteArray0 = new byte[0]; + YamlEditor yamlEditor0 = new YamlEditor(byteArray0); + Map<HeatTemplateParam, String> map0 = (Map<HeatTemplateParam, String>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn("").when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + // Undeclared exception! + try { + yamlEditor0.addParameterList(linkedHashSet0); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // java.lang.String cannot be cast to java.util.Map + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test09() throws Throwable { + byte[] byteArray0 = new byte[1]; + YamlEditor yamlEditor0 = null; + try { + yamlEditor0 = new YamlEditor(byteArray0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // special characters are not allowed + // + verifyException("org.yaml.snakeyaml.reader.StreamReader", e); + } + } + + @Test(timeout = 4000) + public void test10() throws Throwable { + byte[] byteArray0 = new byte[1]; + byteArray0[0] = (byte)37; + YamlEditor yamlEditor0 = null; + try { + yamlEditor0 = new YamlEditor(byteArray0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // while scanning a directive + // in 'reader', line 1, column 1: + // % + // ^ + // expected alphabetic or numeric character, but found \u0000(0) + // in 'reader', line 1, column 2: + // % + // ^ + // + verifyException("org.yaml.snakeyaml.scanner.ScannerImpl", e); + } + } + + @Test(timeout = 4000) + public void test11() throws Throwable { + byte[] byteArray0 = new byte[2]; + byteArray0[1] = (byte) (-80); + YamlEditor yamlEditor0 = null; + try { + yamlEditor0 = new YamlEditor(byteArray0); + fail("Expecting exception: RuntimeException"); + + } catch(RuntimeException e) { + // + // java.nio.charset.MalformedInputException: Input length = 1 + // + verifyException("org.yaml.snakeyaml.reader.StreamReader", e); + } + } + + @Test(timeout = 4000) + public void test13() throws Throwable { + byte[] byteArray0 = new byte[1]; + byteArray0[0] = (byte)110; + YamlEditor yamlEditor0 = null; + try { + yamlEditor0 = new YamlEditor(byteArray0); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // java.lang.String cannot be cast to java.util.Map + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test14() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + String string0 = yamlEditor0.encode(); + assertEquals("null\n", string0); + } + + @Test(timeout = 4000) + public void test15() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<Object, String> hashMap0 = new HashMap<Object, String>(); + Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(hashMap0).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + Set<HeatTemplateParam> set0 = (Set<HeatTemplateParam>) mock(Set.class, new ViolatedAssumptionAnswer()); + doReturn((Iterator) null).when(set0).iterator(); + // Undeclared exception! + try { + yamlEditor0.addParameterList(set0); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test16() throws Throwable { + byte[] byteArray0 = new byte[0]; + YamlEditor yamlEditor0 = new YamlEditor(byteArray0); + HashMap<HeatTemplateParam, String> hashMap0 = new HashMap<HeatTemplateParam, String>(); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) hashMap0); + LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>(); + HeatTemplateParam heatTemplateParam0 = mock(HeatTemplateParam.class, new ViolatedAssumptionAnswer()); + doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamName(); + doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamType(); + linkedHashSet0.add(heatTemplateParam0); + yamlEditor0.addParameterList(linkedHashSet0); + Set<HeatTemplateParam> set0 = yamlEditor0.getParameterList(); + assertFalse(set0.isEmpty()); + } + + @Test(timeout = 4000) + public void test17() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<Object, String> hashMap0 = new HashMap<Object, String>(); + Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(hashMap0).when(map0).get(any()); + hashMap0.put(yamlEditor0, "V28"); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + // Undeclared exception! + try { + yamlEditor0.getParameterList(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // java.lang.String cannot be cast to java.util.Map + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test18() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<Object, String> hashMap0 = new HashMap<Object, String>(); + Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(hashMap0).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + List<String> list0 = yamlEditor0.getYamlResourceTypeList(); + assertEquals(0, list0.size()); + } + + @Test(timeout = 4000) + public void test19() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + // Undeclared exception! + try { + yamlEditor0.isParentTemplate((String) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test20() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + yamlEditor0.verifyTemplate(); + yamlEditor0.isParentTemplate("\""); + Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer()); + doReturn(yamlEditor0).when(map0).get(any()); + PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0); + // Undeclared exception! + try { + yamlEditor0.getYamlNestedFileResourceTypeList(); + fail("Expecting exception: ClassCastException"); + + } catch(ClassCastException e) { + // + // org.openecomp.mso.asdc.util.YamlEditor cannot be cast to java.util.Map + // + verifyException("org.openecomp.mso.asdc.util.YamlEditor", e); + } + } + + @Test(timeout = 4000) + public void test21() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + HashMap<String, Object> hashMap0 = new HashMap<String, Object>(); + String string0 = yamlEditor0.encode((Map<String, Object>) hashMap0); + assertEquals("{}\n", string0); + } + + @Test(timeout = 4000) + public void test22() throws Throwable { + YamlEditor yamlEditor0 = null; + try { + yamlEditor0 = new YamlEditor((byte[]) null); + fail("Expecting exception: NullPointerException"); + + } catch(NullPointerException e) { + // + // no message in exception (getMessage() returned null) + // + } + } + + @Test(timeout = 4000) + public void test23() throws Throwable { + YamlEditor yamlEditor0 = new YamlEditor(); + String string0 = yamlEditor0.toString(); + assertEquals("null\n", string0); + } +} diff --git a/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java new file mode 100644 index 0000000000..dca8696ef2 --- /dev/null +++ b/asdc-controller/src/test/java/org/openecomp/mso/asdc/util/YamlEditorESTestscaffolding.java @@ -0,0 +1,255 @@ +/** + * Scaffolding file used to store all the setups needed to run + * tests automatically generated by EvoSuite + * Fri Nov 25 13:17:51 GMT 2016 + */ + +package org.openecomp.mso.asdc.util; + +import org.evosuite.runtime.annotation.EvoSuiteClassExclude; +import org.junit.BeforeClass; +import org.junit.Before; +import org.junit.After; +import org.junit.AfterClass; +import org.evosuite.runtime.sandbox.Sandbox; + +@EvoSuiteClassExclude +public class YamlEditorESTestscaffolding { + + @org.junit.Rule + public org.evosuite.runtime.vnet.NonFunctionalRequirementRule nfr = new org.evosuite.runtime.vnet.NonFunctionalRequirementRule(); + + private static final java.util.Properties defaultProperties = (java.util.Properties) java.lang.System.getProperties().clone(); + + private org.evosuite.runtime.thread.ThreadStopper threadStopper = new org.evosuite.runtime.thread.ThreadStopper (org.evosuite.runtime.thread.KillSwitchHandler.getInstance(), 3000); + + @BeforeClass + public static void initEvoSuiteFramework() { + org.evosuite.runtime.RuntimeSettings.className = "org.openecomp.mso.asdc.util.YamlEditor"; + org.evosuite.runtime.GuiSupport.initialize(); + org.evosuite.runtime.RuntimeSettings.maxNumberOfThreads = 100; + org.evosuite.runtime.RuntimeSettings.maxNumberOfIterationsPerLoop = 10000; + org.evosuite.runtime.RuntimeSettings.mockSystemIn = true; + org.evosuite.runtime.RuntimeSettings.sandboxMode = org.evosuite.runtime.sandbox.Sandbox.SandboxMode.RECOMMENDED; + org.evosuite.runtime.sandbox.Sandbox.initializeSecurityManagerForSUT(); + org.evosuite.runtime.classhandling.JDKClassResetter.init(); + initializeClasses(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + } + + @AfterClass + public static void clearEvoSuiteFramework(){ + Sandbox.resetDefaultSecurityManager(); + java.lang.System.setProperties((java.util.Properties) defaultProperties.clone()); + } + + @Before + public void initTestCase(){ + threadStopper.storeCurrentThreads(); + threadStopper.startRecordingTime(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().initHandler(); + org.evosuite.runtime.sandbox.Sandbox.goingToExecuteSUTCode(); + + org.evosuite.runtime.GuiSupport.setHeadless(); + org.evosuite.runtime.Runtime.getInstance().resetRuntime(); + org.evosuite.runtime.agent.InstrumentingAgent.activate(); + } + + @After + public void doneWithTestCase(){ + threadStopper.killAndJoinClientThreads(); + org.evosuite.runtime.jvm.ShutdownHookHandler.getInstance().safeExecuteAddedHooks(); + org.evosuite.runtime.classhandling.JDKClassResetter.reset(); + resetClasses(); + org.evosuite.runtime.sandbox.Sandbox.doneWithExecutingSUTCode(); + org.evosuite.runtime.agent.InstrumentingAgent.deactivate(); + org.evosuite.runtime.GuiSupport.restoreHeadlessMode(); + } + + private static void initializeClasses() { + org.evosuite.runtime.classhandling.ClassStateSupport.initializeClasses(YamlEditorESTestscaffolding.class.getClassLoader() , + "org.yaml.snakeyaml.parser.ParserImpl", + "org.yaml.snakeyaml.nodes.SequenceNode", + "org.yaml.snakeyaml.composer.ComposerException", + "org.yaml.snakeyaml.introspector.BeanAccess", + "org.yaml.snakeyaml.representer.Representer$RepresentJavaBean", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentNumber", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentBoolean", + "org.yaml.snakeyaml.scanner.ScannerImpl$Chomping", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlPairs", + "org.yaml.snakeyaml.emitter.Emitter$ExpectNothing", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentList", + "org.yaml.snakeyaml.events.Event", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlInt", + "org.yaml.snakeyaml.nodes.Node", + "org.yaml.snakeyaml.introspector.MissingProperty", + "org.yaml.snakeyaml.emitter.Emitable", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlTimestamp", + "org.yaml.snakeyaml.constructor.Constructor$ConstructYamlObject", + "org.yaml.snakeyaml.composer.Composer", + "org.yaml.snakeyaml.tokens.FlowMappingStartToken", + "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentStart", + "org.yaml.snakeyaml.constructor.SafeConstructor", + "org.yaml.snakeyaml.nodes.NodeId", + "org.yaml.snakeyaml.events.SequenceEndEvent", + "org.yaml.snakeyaml.events.MappingStartEvent", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentArray", + "org.yaml.snakeyaml.parser.Parser", + "org.yaml.snakeyaml.tokens.AnchorToken", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentDate", + "org.yaml.snakeyaml.parser.Production", + "org.yaml.snakeyaml.introspector.Property", + "org.yaml.snakeyaml.tokens.StreamStartToken", + "org.yaml.snakeyaml.DumperOptions$Version", + "org.yaml.snakeyaml.constructor.ConstructorException", + "org.yaml.snakeyaml.emitter.EmitterException", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlBool", + "org.yaml.snakeyaml.error.MarkedYAMLException", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlFloat", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentNull", + "org.yaml.snakeyaml.events.DocumentEndEvent", + "org.yaml.snakeyaml.error.Mark", + "org.yaml.snakeyaml.emitter.Emitter$ExpectFirstFlowMappingKey", + "org.yaml.snakeyaml.tokens.DocumentEndToken", + "org.yaml.snakeyaml.introspector.PropertyUtils", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.Escaper", + "org.yaml.snakeyaml.events.StreamStartEvent", + "org.yaml.snakeyaml.error.YAMLException", + "org.yaml.snakeyaml.scanner.ScannerImpl", + "org.yaml.snakeyaml.reader.UnicodeReader", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlOmap", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentMap", + "org.yaml.snakeyaml.parser.ParserImpl$ParseBlockNode", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper", + "org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentStart", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlNull", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlStr", + "org.yaml.snakeyaml.events.CollectionEndEvent", + "org.yaml.snakeyaml.DumperOptions", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentSet", + "org.yaml.snakeyaml.resolver.Resolver", + "org.yaml.snakeyaml.tokens.Token", + "org.yaml.snakeyaml.events.SequenceStartEvent", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlMap", + "org.yaml.snakeyaml.constructor.Constructor$ConstructMapping", + "org.yaml.snakeyaml.serializer.Serializer$1", + "org.yaml.snakeyaml.constructor.Constructor", + "org.yaml.snakeyaml.scanner.ScannerException", + "org.yaml.snakeyaml.tokens.ScalarToken", + "org.yaml.snakeyaml.resolver.ResolverTuple", + "org.yaml.snakeyaml.constructor.AbstractConstruct", + "org.yaml.snakeyaml.tokens.TagToken", + "org.yaml.snakeyaml.nodes.CollectionNode", + "org.yaml.snakeyaml.nodes.ScalarNode", + "org.yaml.snakeyaml.TypeDescription", + "org.yaml.snakeyaml.events.AliasEvent", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSet", + "org.yaml.snakeyaml.constructor.Constructor$ConstructSequence", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlSeq", + "org.yaml.snakeyaml.reader.ReaderException", + "org.yaml.snakeyaml.tokens.DocumentStartToken", + "org.yaml.snakeyaml.util.UriEncoder", + "org.yaml.snakeyaml.serializer.SerializerException", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper$2", + "org.yaml.snakeyaml.events.MappingEndEvent", + "org.yaml.snakeyaml.parser.VersionTagsTuple", + "org.yaml.snakeyaml.DumperOptions$FlowStyle", + "org.yaml.snakeyaml.events.DocumentStartEvent", + "org.yaml.snakeyaml.tokens.FlowMappingEndToken", + "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentRoot", + "org.yaml.snakeyaml.representer.BaseRepresenter", + "org.yaml.snakeyaml.nodes.AnchorNode", + "org.yaml.snakeyaml.tokens.FlowSequenceStartToken", + "org.yaml.snakeyaml.tokens.FlowSequenceEndToken", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructYamlBinary", + "org.openecomp.mso.asdc.util.YamlEditor", + "org.yaml.snakeyaml.emitter.EmitterState", + "org.yaml.snakeyaml.events.Event$ID", + "org.yaml.snakeyaml.parser.ParserImpl$ParseImplicitDocumentStart", + "org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder", + "org.yaml.snakeyaml.DumperOptions$LineBreak", + "org.yaml.snakeyaml.constructor.Construct", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentEnum", + "org.yaml.snakeyaml.introspector.PropertyUtils$1", + "org.yaml.snakeyaml.serializer.Serializer", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentPrimitiveArray", + "org.yaml.snakeyaml.scanner.Constant", + "org.yaml.snakeyaml.representer.SafeRepresenter", + "org.openecomp.mso.db.catalog.beans.HeatTemplateParam", + "org.yaml.snakeyaml.parser.ParserException", + "org.yaml.snakeyaml.tokens.AliasToken", + "org.yaml.snakeyaml.emitter.ScalarAnalysis", + "org.yaml.snakeyaml.constructor.SafeConstructor$ConstructUndefined", + "org.yaml.snakeyaml.events.CollectionStartEvent", + "org.yaml.snakeyaml.parser.ParserImpl$ParseStreamStart", + "org.yaml.snakeyaml.DumperOptions$ScalarStyle", + "org.yaml.snakeyaml.tokens.StreamEndToken", + "org.yaml.snakeyaml.constructor.BaseConstructor", + "org.yaml.snakeyaml.representer.BaseRepresenter$1", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentByteArray", + "org.yaml.snakeyaml.nodes.MappingNode", + "org.yaml.snakeyaml.Yaml", + "org.yaml.snakeyaml.constructor.Constructor$ConstructScalar", + "org.yaml.snakeyaml.scanner.SimpleKey", + "org.yaml.snakeyaml.resolver.Resolver$1", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentIterator", + "org.yaml.snakeyaml.emitter.Emitter$ExpectStreamStart", + "org.yaml.snakeyaml.tokens.DirectiveToken", + "org.yaml.snakeyaml.representer.Represent", + "org.yaml.snakeyaml.events.StreamEndEvent", + "org.yaml.snakeyaml.tokens.Token$ID", + "org.yaml.snakeyaml.parser.ParserImpl$ParseDocumentEnd", + "org.yaml.snakeyaml.nodes.Tag", + "org.yaml.snakeyaml.util.ArrayStack", + "org.yaml.snakeyaml.representer.SafeRepresenter$RepresentString", + "org.yaml.snakeyaml.events.ImplicitTuple", + "org.yaml.snakeyaml.scanner.Scanner", + "org.yaml.snakeyaml.emitter.Emitter$ExpectFirstDocumentStart", + "org.yaml.snakeyaml.events.NodeEvent", + "org.yaml.snakeyaml.emitter.Emitter", + "org.yaml.snakeyaml.reader.StreamReader", + "org.yaml.snakeyaml.representer.Representer", + "org.yaml.snakeyaml.emitter.Emitter$ExpectDocumentEnd", + "org.yaml.snakeyaml.events.ScalarEvent" + ); + } + + private static void resetClasses() { + org.evosuite.runtime.classhandling.ClassResetter.getInstance().setClassLoader(YamlEditorESTestscaffolding.class.getClassLoader()); + + org.evosuite.runtime.classhandling.ClassStateSupport.resetClasses( + "org.yaml.snakeyaml.constructor.SafeConstructor", + "org.yaml.snakeyaml.nodes.NodeId", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.UnicodeEscaper", + "org.yaml.snakeyaml.external.com.google.gdata.util.common.base.PercentEscaper", + "org.yaml.snakeyaml.util.UriEncoder", + "org.yaml.snakeyaml.nodes.Tag", + "org.yaml.snakeyaml.representer.SafeRepresenter", + "org.yaml.snakeyaml.DumperOptions$FlowStyle", + "org.yaml.snakeyaml.representer.BaseRepresenter$1", + "org.yaml.snakeyaml.DumperOptions$ScalarStyle", + "org.yaml.snakeyaml.DumperOptions$LineBreak", + "org.yaml.snakeyaml.resolver.Resolver", + "org.yaml.snakeyaml.introspector.BeanAccess", + "org.yaml.snakeyaml.reader.StreamReader", + "org.yaml.snakeyaml.reader.UnicodeReader", + "org.yaml.snakeyaml.error.YAMLException", + "org.yaml.snakeyaml.reader.ReaderException", + "org.yaml.snakeyaml.emitter.Emitter", + "org.yaml.snakeyaml.serializer.Serializer$1", + "org.yaml.snakeyaml.resolver.Resolver$1", + "org.yaml.snakeyaml.scanner.Constant", + "org.yaml.snakeyaml.introspector.PropertyUtils$1", + "org.yaml.snakeyaml.parser.ParserImpl", + "org.yaml.snakeyaml.scanner.ScannerImpl", + "org.yaml.snakeyaml.events.Event$ID", + "org.yaml.snakeyaml.tokens.Token$ID", + "org.yaml.snakeyaml.error.MarkedYAMLException", + "org.yaml.snakeyaml.scanner.ScannerException", + "org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder", + "org.yaml.snakeyaml.parser.ParserException", + "org.openecomp.mso.asdc.util.YamlEditor" + ); + } +} diff --git a/asdc-controller/src/test/resources/logback-test.xml b/asdc-controller/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..a23395fe1b --- /dev/null +++ b/asdc-controller/src/test/resources/logback-test.xml @@ -0,0 +1,47 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + --> + +<configuration > + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> diff --git a/asdc-controller/src/test/resources/mso-bad.json b/asdc-controller/src/test/resources/mso-bad.json new file mode 100644 index 0000000000..be372fcb62 --- /dev/null +++ b/asdc-controller/src/test/resources/mso-bad.json @@ -0,0 +1,15 @@ +{ + "asdc-connections":{, + "asdc-controller1":{ + "user": "testuser", + "consumerGroup": "consumerGroup", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname1", + + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso-two-configs.json b/asdc-controller/src/test/resources/mso-two-configs.json new file mode 100644 index 0000000000..20c5f31e58 --- /dev/null +++ b/asdc-controller/src/test/resources/mso-two-configs.json @@ -0,0 +1,26 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User1", + "consumerGroup": "consumerGroup1", + "consumerId": "consumerId1", + "environmentName": "environmentName1", + "asdcAddress": "hostname1", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + }, + "asdc-controller2":{ + "user": "User2", + "consumerGroup": "consumerGroup2", + "consumerId": "consumerId2", + "environmentName": "environmentName2", + "asdcAddress": "hostname2", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso-two-configs2.json b/asdc-controller/src/test/resources/mso-two-configs2.json new file mode 100644 index 0000000000..29db2ee864 --- /dev/null +++ b/asdc-controller/src/test/resources/mso-two-configs2.json @@ -0,0 +1,26 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User1", + "consumerGroup": "consumerGroup1", + "consumerId": "consumerId1", + "environmentName": "environmentName1", + "asdcAddress": "hostname1", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + }, + "asdc-controller2B":{ + "user": "User2", + "consumerGroup": "consumerGroup2", + "consumerId": "consumerId2", + "environmentName": "environmentName2", + "asdcAddress": "hostname2", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso-with-NULL.json b/asdc-controller/src/test/resources/mso-with-NULL.json new file mode 100644 index 0000000000..b7ef75b759 --- /dev/null +++ b/asdc-controller/src/test/resources/mso-with-NULL.json @@ -0,0 +1,15 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User", + "consumerGroup": "NULL", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso.json b/asdc-controller/src/test/resources/mso.json new file mode 100644 index 0000000000..d74ee07c6d --- /dev/null +++ b/asdc-controller/src/test/resources/mso.json @@ -0,0 +1,15 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User", + "consumerGroup": "consumerGroup", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso2.json b/asdc-controller/src/test/resources/mso2.json new file mode 100644 index 0000000000..2d31fc420a --- /dev/null +++ b/asdc-controller/src/test/resources/mso2.json @@ -0,0 +1,15 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User", + "consumerGroup": "consumerGroup", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso3.json b/asdc-controller/src/test/resources/mso3.json new file mode 100644 index 0000000000..ac84dcf96c --- /dev/null +++ b/asdc-controller/src/test/resources/mso3.json @@ -0,0 +1,15 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User", + "consumerGroup": "consumerGroup", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname1", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30 + + } + } +} diff --git a/asdc-controller/src/test/resources/mso4-with-TLS.json b/asdc-controller/src/test/resources/mso4-with-TLS.json new file mode 100644 index 0000000000..8e7c506f2d --- /dev/null +++ b/asdc-controller/src/test/resources/mso4-with-TLS.json @@ -0,0 +1,17 @@ +{ + "asdc-connections":{ + "asdc-controller1":{ + "user": "User", + "consumerGroup": "consumerGroup", + "consumerId": "consumerId", + "environmentName": "environmentName", + "asdcAddress": "hostname", + "password": "1c551b8b5ab91fcd5a0907b11c304199", + "pollingInterval":10, + "pollingTimeout":30, + "activateServerTLSAuth": true, + "keyStorePassword":"1c551b8b5ab91fcd5a0907b11c304199", + "keyStorePath": "/test" + } + } +} diff --git a/asdc-controller/src/test/resources/resource-examples/autoscaling.yaml b/asdc-controller/src/test/resources/resource-examples/autoscaling.yaml new file mode 100644 index 0000000000..88eabb736e --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/autoscaling.yaml @@ -0,0 +1,216 @@ +heat_template_version: 2013-05-23 +description: AutoScaling Wordpress +parameters: + image: + type: string + description: Image used for servers + key: + type: string + description: SSH key to connect to the servers + flavor: + type: string + description: flavor used by the web servers + database_flavor: + type: string + description: flavor used by the db server + network: + type: string + description: Network used by the server + subnet_id: + type: string + description: subnet on which the load balancer will be located + database_name: + type: string + description: Name of the wordpress DB + default: wordpress + database_user: + type: string + description: Name of the wordpress user + default: wordpress + external_network_id: + type: string + description: UUID of a Neutron external network +resources: + database_password: + type: OS::Heat::RandomString + database_root_password: + type: OS::Heat::RandomString + db: + type: OS::Nova::Server + properties: + flavor: {get_param: database_flavor} + image: {get_param: image} + key_name: {get_param: key} + networks: [{network: {get_param: network} }] + user_data_format: RAW + user_data: + str_replace: + template: | + #!/bin/bash -v + yum -y install mariadb mariadb-server + systemctl enable mariadb.service + systemctl start mariadb.service + mysqladmin -u root password $db_rootpassword + cat << EOF | mysql -u root --password=$db_rootpassword + CREATE DATABASE $db_name; + GRANT ALL PRIVILEGES ON $db_name.* TO "$db_user"@"%" + IDENTIFIED BY "$db_password"; + FLUSH PRIVILEGES; + EXIT + EOF + params: + $db_rootpassword: {get_attr: [database_root_password, value]} + $db_name: {get_param: database_name} + $db_user: {get_param: database_user} + $db_password: {get_attr: [database_password, value]} + asg: + type: OS::Heat::AutoScalingGroup + properties: + min_size: 1 + max_size: 3 + resource: + type: lb_server.yaml + properties: + flavor: {get_param: flavor} + image: {get_param: image} + key_name: {get_param: key} + network: {get_param: network} + pool_id: {get_resource: pool} + metadata: {"metering.stack": {get_param: "OS::stack_id"}} + user_data: + str_replace: + template: | + #!/bin/bash -v + yum -y install httpd wordpress + systemctl enable httpd.service + systemctl start httpd.service + setsebool -P httpd_can_network_connect_db=1 + + sed -i "/Deny from All/d" /etc/httpd/conf.d/wordpress.conf + sed -i "s/Require local/Require all granted/" /etc/httpd/conf.d/wordpress.conf + sed -i s/database_name_here/$db_name/ /etc/wordpress/wp-config.php + sed -i s/username_here/$db_user/ /etc/wordpress/wp-config.php + sed -i s/password_here/$db_password/ /etc/wordpress/wp-config.php + sed -i s/localhost/$db_host/ /etc/wordpress/wp-config.php + + systemctl restart httpd.service + params: + $db_name: {get_param: database_name} + $db_user: {get_param: database_user} + $db_password: {get_attr: [database_password, value]} + $db_host: {get_attr: [db, first_address]} + web_server_scaleup_policy: + type: OS::Heat::ScalingPolicy + properties: + adjustment_type: change_in_capacity + auto_scaling_group_id: {get_resource: asg} + cooldown: 60 + scaling_adjustment: 1 + web_server_scaledown_policy: + type: OS::Heat::ScalingPolicy + properties: + adjustment_type: change_in_capacity + auto_scaling_group_id: {get_resource: asg} + cooldown: 60 + scaling_adjustment: -1 + cpu_alarm_high: + type: OS::Ceilometer::Alarm + properties: + description: Scale-up if the average CPU > 50% for 1 minute + meter_name: cpu_util + statistic: avg + period: 60 + evaluation_periods: 1 + threshold: 50 + alarm_actions: + - {get_attr: [web_server_scaleup_policy, alarm_url]} + matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}} + comparison_operator: gt + cpu_alarm_low: + type: OS::Ceilometer::Alarm + properties: + description: Scale-down if the average CPU < 15% for 10 minutes + meter_name: cpu_util + statistic: avg + period: 600 + evaluation_periods: 1 + threshold: 15 + alarm_actions: + - {get_attr: [web_server_scaledown_policy, alarm_url]} + matching_metadata: {'metadata.user_metadata.stack': {get_param: "OS::stack_id"}} + comparison_operator: lt + monitor: + type: OS::Neutron::HealthMonitor + properties: + type: TCP + delay: 5 + max_retries: 5 + timeout: 5 + pool: + type: OS::Neutron::Pool + properties: + protocol: HTTP + monitors: [{get_resource: monitor}] + subnet_id: {get_param: subnet_id} + lb_method: ROUND_ROBIN + vip: + protocol_port: 80 + lb: + type: OS::Neutron::LoadBalancer + properties: + protocol_port: 80 + pool_id: {get_resource: pool} + + # assign a floating ip address to the load balancer + # pool. + lb_floating: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: external_network_id} + port_id: {get_attr: [pool, vip, port_id]} + + outputs: + scale_up_url: + description: > + This URL is the webhook to scale up the autoscaling group. You + can invoke the scale-up operation by doing an HTTP POST to this + URL; no body nor extra headers are needed. + value: {get_attr: [web_server_scaleup_policy, alarm_url]} + scale_dn_url: + description: > + This URL is the webhook to scale down the autoscaling group. + You can invoke the scale-down operation by doing an HTTP POST to + this URL; no body nor extra headers are needed. + value: {get_attr: [web_server_scaledown_policy, alarm_url]} + pool_ip_address: + value: {get_attr: [pool, vip, address]} + description: The IP address of the load balancing pool + website_url: + value: + str_replace: + template: http://host/wordpress/ + params: + host: { get_attr: [lb_floating, floating_ip_address] } + description: > + This URL is the "external" URL that can be used to access the + Wordpress site. + ceilometer_query: + value: + str_replace: + template: > + ceilometer statistics -m cpu_util + -q metadata.user_metadata.stack=stackval -p 600 -a avg + params: + stackval: { get_param: "OS::stack_id" } + description: > + This is a Ceilometer query for statistics on the cpu_util meter + Samples about OS::Nova::Server instances in this stack. The -q + parameter selects Samples according to the subject's metadata. + When a VM's metadata includes an item of the form metering.X=Y, + the corresponding Ceilometer resource has a metadata item of the + form user_metadata.X=Y and samples about resources so tagged can + be queried with a Ceilometer query term of the form + metadata.user_metadata.X=Y. In this case the nested stacks give + their VMs metadata that is passed as a nested stack parameter, + and this stack passes a metadata of the form metering.stack=Y, + where Y is this stack's ID. diff --git a/asdc-controller/src/test/resources/resource-examples/mixed.yaml b/asdc-controller/src/test/resources/resource-examples/mixed.yaml new file mode 100644 index 0000000000..9dc4a4208f --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/mixed.yaml @@ -0,0 +1,1523 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template that creates internal networks, load balancers and servers for vMMSC. + +parameters: + oam_net_name: + type: string + description: UID of OAM network + oam_network_netmask: + type: string + label: oam network netmask + description: oam network gateway + oam_network_gateway: + type: string + label: oam network gateway + description: oam network gateway + oam_network_route_1: + type: string + label: oam network route 1 + description: oam network route 1 + oam_network_route_2: + type: string + label: oam network route 2 + description: oam network route 2 + external_dns: + type: string + label: dns server + description: dns server for MMSC + external_ntp: + type: string + label: ntp server + description: ntp server for MMSC + lb1_oam_net_ip: + type: string + label: management network ip for mmsc + description: the ip of the management network for mmsc + lb2_oam_net_ip: + type: string + label: management network ip for mmsc + description: the ip of the management network for mmsc + dmz_protected_net: + type: string + description: UID of dmz_protected network + dmz_protected_net_local_ip1: + type: string + label: mmsc dmz protected network local ip1 + description: the local ip1 of the mmsc dmz protected network + dmz_protected_net_local_ip2: + type: string + label: mmsc dmz protected network local ip2 + description: the local ip2 of the mmsc dmz protected network + dmz_protected_net_floating_ip: + type: string + label: mmsc dmz protected floating ip + description: mmsc dmz direct floating ip + cor_direct_net: + type: string + label: cor direct net UID + description: cor direct net + cor_direct_net_local_ip1: + type: string + label: mmsc cor direct network local ip1 + description: the local ip1 of the mmsc cor direct network + cor_direct_net_local_ip2: + type: string + label: mmsc cor direct network local ip2 + description: the local ip2 of the mmsc cor direct network + cor_direct_net_floating_ip: + type: string + label: mmsc cor direct floating ip + description: mmsc cor direct floating ip + mms_traffic_net_name: + type: string + description: Name of MMS traffic network + mms_traffic_net_cidr: + type: string + description: MMS traffic network address (CIDR notation) + mms_traffic_netmask: + type: string + description: MMS traffic network subnet mask + mms_traffic_net_gateway: + type: string + description: MMS traffic network gateway address + mms_traffic_start: + type: string + label: mmsc traffic start IP + description: mmsc traffic start IP + mms_traffic_end: + type: string + label: mmsc traffic end IP + description: mmsc traffic end IP + mms_traffic_net_cidr: + type: string + label: mmsc traffic cidr + description: mmsc traffic cidr + mms_traffic_net_local_ip1: + type: string + label: mmsc traffic network local ip1 + description: the local ip1 of the mmsc traffic network + mms_traffic_net_local_ip2: + type: string + label: mmsc traffic network local ip2 + description: the local ip2 of the mmsc traffic network + mms_traffic_net_floating_ip: + type: string + label: mmsc traffic floating ip + description: mmsc traffic floating ip + nems_internal_name: + type: string + label: nems internal network name + description: nems internal network name + nems_internal_start: + type: string + label: nems internal start + description: nems internal start + nems_internal_end: + type: string + label: nems internal end + description: nems internal end + nems_internal_cidr: + type: string + label: nems ineternal cidr + description: nems internal cidr + nems_internal_netmask: + type: string + description: NEMS internal network subnet mask + nems_internal_gateway: + type: string + label: nems internal gw + description: nems internal gw + nems_traffic_name: + type: string + label: nems traffic name + description: nems traffic name + nems_traffic_start: + type: string + label: nems traffic start + description: nems traffic start + nems_traffic_end: + type: string + label: nems traffic end + description: nems traffic end + nems_traffic_cidr: + type: string + label: nems traffic cidr + description: nems traffic cidr + nems_traffic_netmask: + type: string + description: NEMS traffic network subnet mask + nems_traffic_gateway: + type: string + description: NEMS traffic network gateway + nems_traffic_net_local_ip1: + type: string + label: nems traffic network local ip1 + description: the local ip1 of the nems traffic network + nems_traffic_net_local_ip2: + type: string + label: nems traffic network local ip2 + description: the local ip2 of the nems traffic network + nems_traffic_net_floating_ip: + type: string + label: nems traffic floating ip + description: nems traffic floating ip + nems_user_web_name: + type: string + label: nems user web name + description: nems user web name + nems_user_web_start: + type: string + label: nems user web start + description: nems user web end + nems_user_web_end: + type: string + label: nems user web end + description: nems user web end + nems_user_web_cidr: + type: string + label: nems user web cidr + description: nems user web cidr + nems_user_web_netmask: + type: string + description: NEMS user web network subnet mask + nems_user_web_gateway: + type: string + description: NEMS user web network gateway + nems_user_web_net_local_ip1: + type: string + label: nems user web network local ip1 + description: the local ip1 of the nems user web network + nems_user_web_net_local_ip2: + type: string + label: nems user web network local ip2 + description: the local ip2 of the nems user web network + nems_user_web_net_floating_ip: + type: string + label: nems user web floating ip + description: nems user web floating ip + nems_imap_name: + type: string + label: nems imap name + description: nems imap name + nems_imap_netmask: + type: string + label: nems imap subnet mask + description: nems imap subnet mask + nems_imap_start: + type: string + label: nems imap start + description: nems imap start + nems_imap_end: + type: string + label: nems imap end + description: nems imap end + nems_imap_cidr: + type: string + label: nems imap cidr + description: nems imap cidr + nems_imap_gateway: + type: string + label: nems imap gateway + description: nems imap gateway + eca_traffic_name: + type: string + label: eca traffic name + description: eca traffic name + eca_traffic_start: + type: string + label: eca traffic start + description: eca traffic start + eca_traffic_end: + type: string + label: eca traffic end + description: eca traffic end + eca_traffic_cidr: + type: string + label: eca traffic cidr + description: eca traffic cidr + eca_traffic_netmask: + type: string + description: ECA traffic network subnet mask + eca_traffic_net_local_ip1: + type: string + label: eca traffic network local ip1 + description: the local ip1 of the eca traffic network + eca_traffic_net_local_ip2: + type: string + label: eca traffic network local ip2 + description: the local ip2 of the eca traffic network + eca_traffic_net_floating_ip: + type: string + label: eca traffic floating ip + description: eca traffic floating ip + eca_mgmt_name: + type: string + label: eca management name + description: eca management name + eca_mgmt_start: + type: string + label: eca management start + description: eca management start + eca_mgmt_end: + type: string + label: eca management end + description: eca management end + eca_mgmt_cidr: + type: string + label: eca management cidr + description: eca management cidr + eca_mgmt_netmask: + type: string + description: ECA mgmt network subnet mask + ha_net_name: + type: string + label: ha_failover network name + description: ha_failover network name + ha_net_start: + type: string + label: ha net start + description: ha net start + ha_net_end: + type: string + label: ha net end + description: ha net end + ha_net_cidr: + type: string + label: ha net cidr + description: ha net cidr + ha_net_local_ip1: + type: string + label: ha net network local ip1 + description: the local ip1 of the ha network + ha_net_local_ip2: + type: string + label: ha net network local ip2 + description: the local ip2 of the ha network + lb1_name: + type: string + label: MMSC load balancer instance name + description: MMSC load balancer instance name + lb_image_name: + type: string + label: MMSC load balancer image name + description: MMSC load balancer image name + lb_flavor_name: + type: string + label: Load balancer flavor name + description: the flavor name of MMSC load balancer instance + lb1_name: + type: string + label: MMSC load balancer1 instance name + description: MMSC load balancer1 instance name + lb2_name: + type: string + label: MMSC load balancer2 instance name + description: MMSC load balancer2 instance name + availabilityzone_name: + type: string + label: MMSC availabilityzone name + description: MMSC availabilityzone name + security_group_name: + type: string + label: MMSC security group name + description: MMSC security group name + mmsc_image: + type: string + description: Image for MMSC server + mmsc_flavor: + type: string + description: Flavor for MMSC server +# mmsc_cinder_volume_size: +# type: number +# label: MMSC Cinder volume size +# description: the size of the MMSC Cinder volume + nems_fe_image: + type: string + description: Image for NEMS FE server + nems_fe_flavor: + type: string + description: Flavor for NEMS FE server + nems_be_image: + type: string + description: Image for NEMS BE server + nems_be_flavor: + type: string + description: Flavor for NEMS BE server + eca_trx_image: + type: string + description: Image for ECA TRX server + eca_trx_flavor: + type: string + description: Flavor for ECA TRX server + eca_oam_image: + type: string + description: Image for ECA OAM server + eca_oam_flavor: + type: string + description: Flavor for ECA OAM server + mmsc1_name: + type: string + description: MMSC1 server name + mmsc1_oam_net_ip: + type: string + description: OAM_net IP for MMSC1 + mmsc1_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC1 + mmsc2_name: + type: string + description: MMSC2 server name + mmsc2_oam_net_ip: + type: string + description: OAM_net IP for MMSC2 + mmsc2_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC2 + mmsc3_name: + type: string + description: MMSC3 server name + mmsc3_oam_net_ip: + type: string + description: OAM_net IP for MMSC3 + mmsc3_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC3 + mmsc4_name: + type: string + description: MMSC4 server name + mmsc4_oam_net_ip: + type: string + description: OAM_net IP for MMSC4 + mmsc4_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC4 + mmsc5_name: + type: string + description: MMSC5 server name + mmsc5_oam_net_ip: + type: string + description: OAM_net IP for MMSC5 + mmsc5_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC5 + nems_fe1_name: + type: string + description: NEMS_FE1 server name + nems_fe1_node_role: + type: string + label: nems node role + description: nems node role + nems_fe1_oam_net_ip: + type: string + description: OAM_net IP for NEMS_FE1 + nems_fe1_nems_traffic_net_ip: + type: string + description: nems_traffic_net IP for NEMS_FE1 + nems_fe1_nems_user_web_net_ip: + type: string + description: nems_web_user_net IP for NEMS_FE1 + nems_fe1_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE1 + nems_fe1_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_FE1 + nems_fe2_name: + type: string + description: NEMS_FE2 server name + nems_fe2_node_role: + type: string + label: nems node role + description: nems node role + nems_fe2_oam_net_ip: + type: string + description: OAM_net IP for NEMS_FE2 + nems_fe2_nems_traffic_net_ip: + type: string + description: nems_traffic_net IP for NEMS_FE2 + nems_fe2_nems_user_web_net_ip: + type: string + description: nems_web_user_net IP for NEMS_FE2 + nems_fe2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE2 + nems_fe2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE2 + nems_fe2_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_FE2 + nems_be1_name: + type: string + description: NEMS_BE2 server name + nems_be1_node_role: + type: string + label: nems node role + description: nems node role + nems_be1_oam_net_ip: + type: string + description: OAM_net IP for NEMS_BE1 + nems_be1_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_BE1 + nems_be1_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_BE1 + nems_be2_name: + type: string + description: NEMS_BE2 server name + nems_be2_node_role: + type: string + label: nems node role + description: nems node role + nems_be2_oam_net_ip: + type: string + description: OAM_net IP for NEMS_BE2 + nems_be2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_BE2 + nems_be2_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_BE2 + eca_oam1_name: + type: string + description: ECA_OAM1 server name + eca_oam1_oam_net_ip: + type: string + description: OAM_net IP for ECA_OAM1 + eca_oam1_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_OAM1 + eca_oam2_name: + type: string + description: ECA_OAM2 server name + eca_oam2_oam_net_ip: + type: string + description: OAM_net IP for ECA_OAM2 + eca_oam2_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_OAM2 + eca_trx1_name: + type: string + description: ECA_TRX1 server name + eca_trx1_oam_net_ip: + type: string + description: OAM_net IP for ECA_TRX1 + eca_trx1_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_TRX1 + eca_trx1_eca_traffic_net_ip: + type: string + description: eca_traffic_net IP for ECA_TRX1 + +resources: + mms_security_group: + type: OS::Neutron::SecurityGroup + properties: + description: mmsc security group + name: {get_param: security_group_name} + rules: [{"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": egress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0} + ] + + mms_traffic_net: + type: OS::Contrail::VirtualNetwork + properties: + name: { get_param: mms_traffic_net_name } + + mms_traffic_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: mms_traffic_net_name} + network_id: { get_resource: mms_traffic_net } + cidr: { get_param: mms_traffic_net_cidr } + allocation_pools: [{"start": {get_param: mms_traffic_start}, "end": {get_param: mms_traffic_end}}] + gateway_ip: { get_param: mms_traffic_net_gateway } + enable_dhcp: false + + nems_internal_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: nems_internal_name} + + nems_internal_network_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: nems_internal_name} + allocation_pools: [{"start": {get_param: nems_internal_start}, "end": {get_param: nems_internal_end}}] + cidr: {get_param: nems_internal_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: nems_internal_net} + + nems_traffic_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: nems_traffic_name} + + nems_traffic_network_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: nems_traffic_name} + allocation_pools: [{"start": {get_param: nems_traffic_start}, "end": {get_param: nems_traffic_end}}] + cidr: {get_param: nems_traffic_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: nems_traffic_net} + + nems_user_web_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: nems_user_web_name} + + nems_user_web_network_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: nems_user_web_name} + allocation_pools: [{"start": {get_param: nems_user_web_start}, "end": {get_param: nems_user_web_end}}] + cidr: {get_param: nems_user_web_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: nems_user_web_net} + + nems_imap_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: nems_imap_name} + + nems_imap_network_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: nems_imap_name} + allocation_pools: [{"start": {get_param: nems_imap_start}, "end": {get_param: nems_imap_end}}] + cidr: {get_param: nems_imap_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: nems_imap_net} + + eca_traffic_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: eca_traffic_name} + + eca_traffic_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: eca_traffic_name} + allocation_pools: [{"start": {get_param: eca_traffic_start}, "end": {get_param: eca_traffic_end}}] + cidr: {get_param: eca_traffic_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: eca_traffic_net} + + ha_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: ha_net_name} + + ha_net_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: ha_net_name} + allocation_pools: [{"start": {get_param: ha_net_start}, "end": {get_param: ha_net_end}}] + cidr: {get_param: ha_net_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: ha_net} + + eca_mgmt_net: + type: OS::Contrail::VirtualNetwork + properties: + name: {get_param: eca_mgmt_name} + + eca_mgmt_network_ip_subnet: + type: OS::Neutron::Subnet + properties: + name: {get_param: eca_mgmt_name} + allocation_pools: [{"start": {get_param: eca_mgmt_start}, "end": {get_param: eca_mgmt_end}}] + cidr: {get_param: eca_mgmt_cidr} + enable_dhcp: false + gateway_ip: null + network_id: {get_resource: eca_mgmt_net} + + lb1_instance: + type: OS::Nova::Server + properties: + name: {get_param: lb1_name} + image: {get_param: lb_image_name} + flavor: {get_param: lb_flavor_name} + availability_zone: {get_param: availabilityzone_name} + networks: + - port: {get_resource: lb1_mgmt_port} + - port: {get_resource: lb1_dmz_protected_port} + - port: {get_resource: lb1_cor_direct_port} + - port: {get_resource: lb1_mms_traffic_port} + - port: {get_resource: lb1_nems_traffic_port} + - port: {get_resource: lb1_nems_user_web_port} + - port: {get_resource: lb1_eca_traffic_port} + - port: {get_resource: lb1_ha_net_port} + + lb1_mgmt_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: oam_net_name} + fixed_ips: [{"ip_address": {get_param: lb1_oam_net_ip}}] + security_groups: [{get_resource: mms_security_group}] + + lb1_mms_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: mms_traffic_net} + fixed_ips: [{"ip_address": {get_param: mms_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: mms_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_dmz_protected_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: dmz_protected_net} + fixed_ips: [{"ip_address": {get_param: dmz_protected_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: dmz_protected_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_cor_direct_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: cor_direct_net} + fixed_ips: [{"ip_address": {get_param: cor_direct_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: cor_direct_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_nems_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_traffic_net} + fixed_ips: [{"ip_address": {get_param: nems_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_nems_user_web_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_user_web_net} + fixed_ips: [{"ip_address": {get_param: nems_user_web_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_user_web_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_ha_net_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: ha_net} + fixed_ips: [{"ip_address": {get_param: ha_net_local_ip1}}] + + lb1_eca_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: eca_traffic_net} + fixed_ips: [{"ip_address": {get_param: eca_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: eca_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_instance: + type: OS::Nova::Server + properties: + name: {get_param: lb2_name} + image: {get_param: lb_image_name} + flavor: {get_param: lb_flavor_name} + availability_zone: {get_param: availabilityzone_name} + networks: + - port: {get_resource: lb2_mgmt_port} + - port: {get_resource: lb2_dmz_protected_port} + - port: {get_resource: lb2_cor_direct_port} + - port: {get_resource: lb2_mms_traffic_port} + - port: {get_resource: lb2_nems_traffic_port} + - port: {get_resource: lb2_nems_user_web_port} + - port: {get_resource: lb2_eca_traffic_port} + - port: {get_resource: lb2_ha_net_port} + + lb2_mgmt_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: oam_net_name} + fixed_ips: [{"ip_address": {get_param: lb2_oam_net_ip}}] + security_groups: [{get_resource: mms_security_group}] + + lb2_mms_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: mms_traffic_net} + fixed_ips: [{"ip_address": {get_param: mms_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: mms_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_dmz_protected_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: dmz_protected_net} + fixed_ips: [{"ip_address": {get_param: dmz_protected_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: dmz_protected_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_cor_direct_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: cor_direct_net} + fixed_ips: [{"ip_address": {get_param: cor_direct_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: cor_direct_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_nems_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_traffic_net} + fixed_ips: [{"ip_address": {get_param: nems_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_nems_user_web_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_user_web_net} + fixed_ips: [{"ip_address": {get_param: nems_user_web_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_user_web_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_ha_net_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: ha_net} + fixed_ips: [{"ip_address": {get_param: ha_net_local_ip2}}] + + lb2_eca_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: eca_traffic_net} + fixed_ips: [{"ip_address": {get_param: eca_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: eca_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + server_mmsc1: + type: OS::Nova::Server + properties: + name: { get_param: mmsc1_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc1_port_0 } + - port: { get_resource: mmsc1_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc1_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc1_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW +# mmsc1_volume: +# type: OS::Cinder::Volume +# properties: +# size: {get_param: mmsc_cinder_volume_size} + +# mmsc1_volume_attachment: +# type: OS::Cinder::VolumeAttachment +# properties: +# volume_id: {get_resource: mmsc1_volume} +# instance_uuid: {get_resource: server_mmsc1} + + mmsc1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc1_oam_net_ip } + ] + + mmsc1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc1_mms_traffic_net_ip } + ] + + server_mmsc2: + type: OS::Nova::Server + properties: + name: { get_param: mmsc2_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc2_port_0 } + - port: { get_resource: mmsc2_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc2_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc2_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW +# mmsc2_volume: +# type: OS::Cinder::Volume +# properties: +# size: {get_param: mmsc_cinder_volume_size} + +# mmsc2_volume_attachment: +# type: OS::Cinder::VolumeAttachment +# properties: +# volume_id: {get_resource: mmsc2_volume} +# instance_uuid: {get_resource: server_mmsc2} + + mmsc2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc2_oam_net_ip } + ] + + mmsc2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc2_mms_traffic_net_ip } + ] + + server_mmsc3: + type: OS::Nova::Server + properties: + name: { get_param: mmsc3_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc3_port_0 } + - port: { get_resource: mmsc3_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc3_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc3_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW + + mmsc3_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc3_oam_net_ip } + ] + + mmsc3_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc3_mms_traffic_net_ip } + ] + + server_mmsc4: + type: OS::Nova::Server + properties: + name: { get_param: mmsc4_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc4_port_0 } + - port: { get_resource: mmsc4_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc4_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc4_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW + + mmsc4_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc4_oam_net_ip } + ] + + mmsc4_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc4_mms_traffic_net_ip } + ] + + server_mmsc5: + type: OS::Nova::Server + properties: + name: { get_param: mmsc5_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc5_port_0 } + - port: { get_resource: mmsc5_port_1 } + + mmsc5_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc5_oam_net_ip } + ] + + mmsc5_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc5_mms_traffic_net_ip } + ] + + server_nems_fe1: + type: OS::Nova::Server + properties: + name: { get_param: nems_fe1_name } + image: { get_param: nems_fe_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_fe_flavor } + networks: + - port: { get_resource: nems_fe1_port_0 } + - port: { get_resource: nems_fe1_port_1 } + - port: { get_resource: nems_fe1_port_2 } + - port: { get_resource: nems_fe1_port_3 } + - port: { get_resource: nems_fe1_port_4 } + user_data: + str_replace: + template: | + nems.mgmt.ip=${nems.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.traffic.ip=${nems.traffic.ip} + nems.traffic.netmask=${nems.traffic.netmask} + nems.traffic.gateway=${nems.traffic.gateway} + nems.fe0.internal.ip=${nems.fe0.internal.ip} + nems.fe1.internal.ip=${nems.fe1.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.userweb.ip=${nems.userweb.ip} + nems.userweb.netmask=${nems.userweb.netmask} + nems.userweb.gateway=${nems.userweb.gateway} + nems.imap.ip=${nems.imap.ip} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.mgmt.ip}: {get_param: nems_fe1_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.traffic.ip}: {get_param: nems_fe1_nems_traffic_net_ip} + ${nems.traffic.netmask}: {get_param: nems_traffic_netmask} + ${nems.traffic.gateway}: {get_param: nems_traffic_gateway} + ${nems.fe0.internal.ip}: {get_param: nems_fe1_nems_internal_net_ip} + ${nems.fe1.internal.ip}: {get_param: nems_fe2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.userweb.ip}: {get_param: nems_fe1_nems_user_web_net_ip} + ${nems.userweb.netmask}: {get_param: nems_user_web_netmask} + ${nems.userweb.gateway}: {get_param: nems_user_web_gateway} + ${nems.imap.ip}: {get_param: nems_fe1_nems_imap_net_ip} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.internal.ip}: {get_param: nems_be1_nems_internal_net_ip} + ${nems.be.imap.ip}: {get_param: nems_be1_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_fe1_node_role} + user_data_format: RAW + + nems_fe1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_oam_net_ip } + ] + + nems_fe_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_fe1_port_0} + + nems_fe1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_traffic_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_traffic_net_ip } + ] + + nems_fe1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_user_web_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_user_web_net_ip } + ] + + nems_fe1_port_3: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_internal_net_ip } + ] + + nems_fe1_port_4: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_imap_net_ip } + ] + + server_nems_fe2: + type: OS::Nova::Server + properties: + name: { get_param: nems_fe2_name } + image: { get_param: nems_fe_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_fe_flavor } + networks: + - port: { get_resource: nems_fe2_port_0 } + - port: { get_resource: nems_fe2_port_1 } + - port: { get_resource: nems_fe2_port_2 } + - port: { get_resource: nems_fe2_port_3 } + - port: { get_resource: nems_fe2_port_4 } + user_data: + str_replace: + template: | + nems.mgmt.ip=${nems.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.traffic.ip=${nems.traffic.ip} + nems.traffic.netmask=${nems.traffic.netmask} + nems.traffic.gateway=${nems.traffic.gateway} + nems.fe0.internal.ip=${nems.fe0.internal.ip} + nems.fe1.internal.ip=${nems.fe1.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.userweb.ip=${nems.userweb.ip} + nems.userweb.netmask=${nems.userweb.netmask} + nems.userweb.gateway=${nems.userweb.gateway} + nems.imap.ip=${nems.imap.ip} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.mgmt.ip}: {get_param: nems_fe2_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.traffic.ip}: {get_param: nems_fe2_nems_traffic_net_ip} + ${nems.traffic.netmask}: {get_param: nems_traffic_netmask} + ${nems.traffic.gateway}: {get_param: nems_traffic_gateway} + ${nems.fe0.internal.ip}: {get_param: nems_fe1_nems_internal_net_ip} + ${nems.fe1.internal.ip}: {get_param: nems_fe2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.userweb.ip}: {get_param: nems_fe2_nems_user_web_net_ip} + ${nems.userweb.netmask}: {get_param: nems_user_web_netmask} + ${nems.userweb.gateway}: {get_param: nems_user_web_gateway} + ${nems.imap.ip}: {get_param: nems_fe2_nems_imap_net_ip} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.internal.ip}: {get_param: nems_be2_nems_internal_net_ip} + ${nems.be.imap.ip}: {get_param: nems_be2_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_fe2_node_role} + user_data_format: RAW + + nems_fe2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_oam_net_ip } + ] + + nems_fe_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_fe2_port_0} + + nems_fe2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_traffic_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_traffic_net_ip } + ] + + nems_fe2_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_user_web_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_user_web_net_ip } + ] + + nems_fe2_port_3: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_internal_net_ip } + ] + + nems_fe2_port_4: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_imap_net_ip } + ] + + server_nems_be1: + type: OS::Nova::Server + properties: + name: { get_param: nems_be1_name } + image: { get_param: nems_be_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_be_flavor } + networks: + - port: { get_resource: nems_be1_port_0 } + - port: { get_resource: nems_be1_port_1 } + - port: { get_resource: nems_be1_port_2 } + user_data: + str_replace: + template: | + nems.be.mgmt.ip=${nems.be.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.be.mgmt.ip}: {get_param: nems_be1_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.be.internal.ip}: {get_param: nems_be1_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.imap.ip}: {get_param: nems_be1_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_be1_node_role} + user_data_format: RAW + + nems_be1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_be1_oam_net_ip } + ] + + nems_be_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_be1_port_0} + + nems_be1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_be1_nems_internal_net_ip } + ] + + nems_be1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_be1_nems_imap_net_ip } + ] + + server_nems_be2: + type: OS::Nova::Server + properties: + name: { get_param: nems_be2_name } + image: { get_param: nems_be_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_be_flavor } + networks: + - port: { get_resource: nems_be2_port_0 } + - port: { get_resource: nems_be2_port_1 } + - port: { get_resource: nems_be2_port_2 } + user_data: + str_replace: + template: | + nems.be.mgmt.ip=${nems.be.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.be.mgmt.ip}: {get_param: nems_be2_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.be.internal.ip}: {get_param: nems_be2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.imap.ip}: {get_param: nems_be2_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_be1_node_role} + user_data_format: RAW + + nems_be2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_be2_oam_net_ip } + ] + + nems_be_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_be2_port_0} + + nems_be2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_be2_nems_internal_net_ip } + ] + + nems_be2_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_be2_nems_imap_net_ip } + ] + + server_eca_oam1: + type: OS::Nova::Server + properties: + name: { get_param: eca_oam1_name } + image: { get_param: eca_oam_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_oam_flavor } + networks: + - port: { get_resource: eca_oam1_port_0 } + - port: { get_resource: eca_oam1_port_1 } + + eca_oam1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_oam1_oam_net_ip } + ] + + eca_oam1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_oam1_eca_mgmt_net_ip } + ] + + server_eca_oam2: + type: OS::Nova::Server + properties: + name: { get_param: eca_oam2_name } + image: { get_param: eca_oam_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_oam_flavor } + networks: + - port: { get_resource: eca_oam2_port_0 } + - port: { get_resource: eca_oam2_port_1 } + + eca_oam2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_oam2_oam_net_ip } + ] + + eca_oam2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_oam2_eca_mgmt_net_ip } + ] + + server_eca_trx1: + type: OS::Nova::Server + properties: + name: { get_param: eca_trx1_name } + image: { get_param: eca_trx_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_trx_flavor } + networks: + - port: { get_resource: eca_trx1_port_0 } + - port: { get_resource: eca_trx1_port_1 } + - port: { get_resource: eca_trx1_port_2 } + + + eca_trx1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_oam_net_ip } + ] + + eca_trx1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_eca_mgmt_net_ip } + ] + + eca_trx1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_traffic_net } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_eca_traffic_net_ip } + ] diff --git a/asdc-controller/src/test/resources/resource-examples/network.yaml b/asdc-controller/src/test/resources/resource-examples/network.yaml new file mode 100644 index 0000000000..ae10346cbc --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/network.yaml @@ -0,0 +1,32 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template that creates one COR network (direct). + +parameters: + cor_direct_net_name: + type: string + description: Name of COR direct network + cor_direct_net_cidr: + type: string + description: Direct network address (CIDR notation) + cor_direct_net_gateway: + type: string + description: Direct network gateway address + cor_direct_net_RT: + type: string + description: Direct network route-target (RT) + +resources: + cor_direct_net: + type: OS::Contrail::VirtualNetwork + properties: + name: { get_param: cor_direct_net_name } + route_targets: [ get_param: cor_direct_net_RT ] + + cor_direct_ip_subnet: + type: OS::Neutron::Subnet + properties: + network_id: { get_resource: cor_direct_net } + cidr: {get_param: cor_direct_net_cidr} + gateway_ip: { get_param: cor_direct_net_gateway } diff --git a/asdc-controller/src/test/resources/resource-examples/simpleTest.yaml b/asdc-controller/src/test/resources/resource-examples/simpleTest.yaml new file mode 100644 index 0000000000..8bfda2b056 --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/simpleTest.yaml @@ -0,0 +1,39 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template that creates one COR network (direct). + +parameters: + cor_direct_net_name: + type: string + description: Name of COR direct network + default: testCorDirectNet + cor_direct_net_cidr: + type: string + description: Direct network address (CIDR notation) + cor_direct_net_gateway: + type: string + description: Direct network gateway address + cor_direct_net_RT: + type: string + description: Direct network route-target (RT) + default: testCorDirectNet + ip_port_snmp_manager: + type: string + default: 162 + description: SNMP manager IP port + + +resources: + cor_direct_net: + type: file:///my_test.yaml + properties: + name: { get_param: cor_direct_net_name } + route_targets: [ get_param: cor_direct_net_RT ] + + cor_direct_ip_subnet: + type: OS::Neutron::Subnet + properties: + network_id: { get_resource: cor_direct_net } + cidr: {get_param: cor_direct_net_cidr} + gateway_ip: { get_param: cor_direct_net_gateway } diff --git a/asdc-controller/src/test/resources/resource-examples/simpleTestWithoutParam.yaml b/asdc-controller/src/test/resources/resource-examples/simpleTestWithoutParam.yaml new file mode 100644 index 0000000000..0a2db2b2bd --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/simpleTestWithoutParam.yaml @@ -0,0 +1,18 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template that creates one COR network (direct). + +resources: + cor_direct_net: + type: file:///my_test.yaml + properties: + name: { get_param: cor_direct_net_name } + route_targets: [ get_param: cor_direct_net_RT ] + + cor_direct_ip_subnet: + type: OS::Neutron::Subnet + properties: + network_id: { get_resource: cor_direct_net } + cidr: {get_param: cor_direct_net_cidr} + gateway_ip: { get_param: cor_direct_net_gateway } diff --git a/asdc-controller/src/test/resources/resource-examples/vnf.yaml b/asdc-controller/src/test/resources/resource-examples/vnf.yaml new file mode 100644 index 0000000000..d4420de14c --- /dev/null +++ b/asdc-controller/src/test/resources/resource-examples/vnf.yaml @@ -0,0 +1,1449 @@ +heat_template_version: 2013-05-23 + +description: > + HOT template that creates internal networks, load balancers and servers for vMMSC. + +parameters: + oam_net_name: + type: string + description: UID of OAM network + oam_network_netmask: + type: string + label: oam network netmask + description: oam network gateway + oam_network_gateway: + type: string + label: oam network gateway + description: oam network gateway + oam_network_route_1: + type: string + label: oam network route 1 + description: oam network route 1 + oam_network_route_2: + type: string + label: oam network route 2 + description: oam network route 2 + external_dns: + type: string + label: dns server + description: dns server for MMSC + external_ntp: + type: string + label: ntp server + description: ntp server for MMSC + lb1_oam_net_ip: + type: string + label: management network ip for mmsc + description: the ip of the management network for mmsc + lb2_oam_net_ip: + type: string + label: management network ip for mmsc + description: the ip of the management network for mmsc + dmz_protected_net: + type: string + description: UID of dmz_protected network + dmz_protected_net_local_ip1: + type: string + label: mmsc dmz protected network local ip1 + description: the local ip1 of the mmsc dmz protected network + dmz_protected_net_local_ip2: + type: string + label: mmsc dmz protected network local ip2 + description: the local ip2 of the mmsc dmz protected network + dmz_protected_net_floating_ip: + type: string + label: mmsc dmz protected floating ip + description: mmsc dmz direct floating ip + cor_direct_net: + type: string + label: cor direct net UID + description: cor direct net + cor_direct_net_local_ip1: + type: string + label: mmsc cor direct network local ip1 + description: the local ip1 of the mmsc cor direct network + cor_direct_net_local_ip2: + type: string + label: mmsc cor direct network local ip2 + description: the local ip2 of the mmsc cor direct network + cor_direct_net_floating_ip: + type: string + label: mmsc cor direct floating ip + description: mmsc cor direct floating ip + mms_traffic_net_name: + type: string + description: Name of MMS traffic network + mms_traffic_net_cidr: + type: string + description: MMS traffic network address (CIDR notation) + mms_traffic_netmask: + type: string + description: MMS traffic network subnet mask + mms_traffic_net_gateway: + type: string + description: MMS traffic network gateway address + mms_traffic_start: + type: string + label: mmsc traffic start IP + description: mmsc traffic start IP + mms_traffic_end: + type: string + label: mmsc traffic end IP + description: mmsc traffic end IP + mms_traffic_net_cidr: + type: string + label: mmsc traffic cidr + description: mmsc traffic cidr + mms_traffic_net_local_ip1: + type: string + label: mmsc traffic network local ip1 + description: the local ip1 of the mmsc traffic network + mms_traffic_net_local_ip2: + type: string + label: mmsc traffic network local ip2 + description: the local ip2 of the mmsc traffic network + mms_traffic_net_floating_ip: + type: string + label: mmsc traffic floating ip + description: mmsc traffic floating ip + nems_internal_name: + type: string + label: nems internal network name + description: nems internal network name + nems_internal_start: + type: string + label: nems internal start + description: nems internal start + nems_internal_end: + type: string + label: nems internal end + description: nems internal end + nems_internal_cidr: + type: string + label: nems ineternal cidr + description: nems internal cidr + nems_internal_netmask: + type: string + description: NEMS internal network subnet mask + nems_internal_gateway: + type: string + label: nems internal gw + description: nems internal gw + nems_traffic_name: + type: string + label: nems traffic name + description: nems traffic name + nems_traffic_start: + type: string + label: nems traffic start + description: nems traffic start + nems_traffic_end: + type: string + label: nems traffic end + description: nems traffic end + nems_traffic_cidr: + type: string + label: nems traffic cidr + description: nems traffic cidr + nems_traffic_netmask: + type: string + description: NEMS traffic network subnet mask + nems_traffic_gateway: + type: string + description: NEMS traffic network gateway + nems_traffic_net_local_ip1: + type: string + label: nems traffic network local ip1 + description: the local ip1 of the nems traffic network + nems_traffic_net_local_ip2: + type: string + label: nems traffic network local ip2 + description: the local ip2 of the nems traffic network + nems_traffic_net_floating_ip: + type: string + label: nems traffic floating ip + description: nems traffic floating ip + nems_user_web_name: + type: string + label: nems user web name + description: nems user web name + nems_user_web_start: + type: string + label: nems user web start + description: nems user web end + nems_user_web_end: + type: string + label: nems user web end + description: nems user web end + nems_user_web_cidr: + type: string + label: nems user web cidr + description: nems user web cidr + nems_user_web_netmask: + type: string + description: NEMS user web network subnet mask + nems_user_web_gateway: + type: string + description: NEMS user web network gateway + nems_user_web_net_local_ip1: + type: string + label: nems user web network local ip1 + description: the local ip1 of the nems user web network + nems_user_web_net_local_ip2: + type: string + label: nems user web network local ip2 + description: the local ip2 of the nems user web network + nems_user_web_net_floating_ip: + type: string + label: nems user web floating ip + description: nems user web floating ip + nems_imap_name: + type: string + label: nems imap name + description: nems imap name + nems_imap_netmask: + type: string + label: nems imap subnet mask + description: nems imap subnet mask + nems_imap_start: + type: string + label: nems imap start + description: nems imap start + nems_imap_end: + type: string + label: nems imap end + description: nems imap end + nems_imap_cidr: + type: string + label: nems imap cidr + description: nems imap cidr + nems_imap_gateway: + type: string + label: nems imap gateway + description: nems imap gateway + eca_traffic_name: + type: string + label: eca traffic name + description: eca traffic name + eca_traffic_start: + type: string + label: eca traffic start + description: eca traffic start + eca_traffic_end: + type: string + label: eca traffic end + description: eca traffic end + eca_traffic_cidr: + type: string + label: eca traffic cidr + description: eca traffic cidr + eca_traffic_netmask: + type: string + description: ECA traffic network subnet mask + eca_traffic_net_local_ip1: + type: string + label: eca traffic network local ip1 + description: the local ip1 of the eca traffic network + eca_traffic_net_local_ip2: + type: string + label: eca traffic network local ip2 + description: the local ip2 of the eca traffic network + eca_traffic_net_floating_ip: + type: string + label: eca traffic floating ip + description: eca traffic floating ip + eca_mgmt_name: + type: string + label: eca management name + description: eca management name + eca_mgmt_start: + type: string + label: eca management start + description: eca management start + eca_mgmt_end: + type: string + label: eca management end + description: eca management end + eca_mgmt_cidr: + type: string + label: eca management cidr + description: eca management cidr + eca_mgmt_netmask: + type: string + description: ECA mgmt network subnet mask + ha_net_name: + type: string + label: ha_failover network name + description: ha_failover network name + ha_net_start: + type: string + label: ha net start + description: ha net start + ha_net_end: + type: string + label: ha net end + description: ha net end + ha_net_cidr: + type: string + label: ha net cidr + description: ha net cidr + ha_net_local_ip1: + type: string + label: ha net network local ip1 + description: the local ip1 of the ha network + ha_net_local_ip2: + type: string + label: ha net network local ip2 + description: the local ip2 of the ha network + lb1_name: + type: string + label: MMSC load balancer instance name + description: MMSC load balancer instance name + lb_image_name: + type: string + label: MMSC load balancer image name + description: MMSC load balancer image name + lb_flavor_name: + type: string + label: Load balancer flavor name + description: the flavor name of MMSC load balancer instance + lb1_name: + type: string + label: MMSC load balancer1 instance name + description: MMSC load balancer1 instance name + lb2_name: + type: string + label: MMSC load balancer2 instance name + description: MMSC load balancer2 instance name + availabilityzone_name: + type: string + label: MMSC availabilityzone name + description: MMSC availabilityzone name + security_group_name: + type: string + label: MMSC security group name + description: MMSC security group name + mmsc_image: + type: string + description: Image for MMSC server + mmsc_flavor: + type: string + description: Flavor for MMSC server +# mmsc_cinder_volume_size: +# type: number +# label: MMSC Cinder volume size +# description: the size of the MMSC Cinder volume + nems_fe_image: + type: string + description: Image for NEMS FE server + nems_fe_flavor: + type: string + description: Flavor for NEMS FE server + nems_be_image: + type: string + description: Image for NEMS BE server + nems_be_flavor: + type: string + description: Flavor for NEMS BE server + eca_trx_image: + type: string + description: Image for ECA TRX server + eca_trx_flavor: + type: string + description: Flavor for ECA TRX server + eca_oam_image: + type: string + description: Image for ECA OAM server + eca_oam_flavor: + type: string + description: Flavor for ECA OAM server + cmaui_name: + type: string + description: CMAUI server name + cmaui_image: + type: string + description: Image for CMAUI server + cmaui_flavor: + type: string + description: Flavor for CMAUI server +# cmaui_cinder_volume_size: +# type: number +# label: CMAUI Cinder volume size +# description: the size of the CMAUI Cinder volume + mmsc1_name: + type: string + description: MMSC1 server name + mmsc1_oam_net_ip: + type: string + description: OAM_net IP for MMSC1 + mmsc1_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC1 + mmsc2_name: + type: string + description: MMSC2 server name + mmsc2_oam_net_ip: + type: string + description: OAM_net IP for MMSC2 + mmsc2_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC2 + mmsc3_name: + type: string + description: MMSC3 server name + mmsc3_oam_net_ip: + type: string + description: OAM_net IP for MMSC3 + mmsc3_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC3 + mmsc4_name: + type: string + description: MMSC4 server name + mmsc4_oam_net_ip: + type: string + description: OAM_net IP for MMSC4 + mmsc4_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC4 + mmsc5_name: + type: string + description: MMSC5 server name + mmsc5_oam_net_ip: + type: string + description: OAM_net IP for MMSC5 + mmsc5_mms_traffic_net_ip: + type: string + description: mms_traffic_net IP for MMSC5 + nems_fe1_name: + type: string + description: NEMS_FE1 server name + nems_fe1_node_role: + type: string + label: nems node role + description: nems node role + nems_fe1_oam_net_ip: + type: string + description: OAM_net IP for NEMS_FE1 + nems_fe1_nems_traffic_net_ip: + type: string + description: nems_traffic_net IP for NEMS_FE1 + nems_fe1_nems_user_web_net_ip: + type: string + description: nems_web_user_net IP for NEMS_FE1 + nems_fe1_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE1 + nems_fe1_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_FE1 + nems_fe2_name: + type: string + description: NEMS_FE2 server name + nems_fe2_node_role: + type: string + label: nems node role + description: nems node role + nems_fe2_oam_net_ip: + type: string + description: OAM_net IP for NEMS_FE2 + nems_fe2_nems_traffic_net_ip: + type: string + description: nems_traffic_net IP for NEMS_FE2 + nems_fe2_nems_user_web_net_ip: + type: string + description: nems_web_user_net IP for NEMS_FE2 + nems_fe2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE2 + nems_fe2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_FE2 + nems_fe2_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_FE2 + nems_be1_name: + type: string + description: NEMS_BE2 server name + nems_be1_node_role: + type: string + label: nems node role + description: nems node role + nems_be1_oam_net_ip: + type: string + description: OAM_net IP for NEMS_BE1 + nems_be1_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_BE1 + nems_be1_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_BE1 + nems_be2_name: + type: string + description: NEMS_BE2 server name + nems_be2_node_role: + type: string + label: nems node role + description: nems node role + nems_be2_oam_net_ip: + type: string + description: OAM_net IP for NEMS_BE2 + nems_be2_nems_internal_net_ip: + type: string + description: nems_internal_net IP for NEMS_BE2 + nems_be2_nems_imap_net_ip: + type: string + description: nems_imap_net IP for NEMS_BE2 + eca_oam1_name: + type: string + description: ECA_OAM1 server name + eca_oam1_oam_net_ip: + type: string + description: OAM_net IP for ECA_OAM1 + eca_oam1_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_OAM1 + eca_oam2_name: + type: string + description: ECA_OAM2 server name + eca_oam2_oam_net_ip: + type: string + description: OAM_net IP for ECA_OAM2 + eca_oam2_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_OAM2 + eca_trx1_name: + type: string + description: ECA_TRX1 server name + eca_trx1_oam_net_ip: + type: string + description: OAM_net IP for ECA_TRX1 + eca_trx1_eca_mgmt_net_ip: + type: string + description: eca_mgmt_net IP for ECA_TRX1 + eca_trx1_eca_traffic_net_ip: + type: string + description: eca_traffic_net IP for ECA_TRX1 + cmaui_oam_net_ip: + type: string + description: eca_mgmt_net IP for CMAUI + +resources: + mms_security_group: + type: OS::Neutron::SecurityGroup + properties: + description: mmsc security group + name: {get_param: security_group_name} + rules: [{"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": egress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": egress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": tcp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "port_range_min": 1, "port_range_max": 65535, "protocol": udp, "remote_ip_prefix": 0.0.0.0/0}, + {"direction": ingress, "ethertype": IPv4, "protocol": icmp, "remote_ip_prefix": 0.0.0.0/0} + ] + + lb1_instance: + type: OS::Nova::Server + properties: + name: {get_param: lb1_name} + image: {get_param: lb_image_name} + flavor: {get_param: lb_flavor_name} + availability_zone: {get_param: availabilityzone_name} + networks: + - port: {get_resource: lb1_mgmt_port} + - port: {get_resource: lb1_dmz_protected_port} + - port: {get_resource: lb1_cor_direct_port} + - port: {get_resource: lb1_mms_traffic_port} + - port: {get_resource: lb1_nems_traffic_port} + - port: {get_resource: lb1_nems_user_web_port} + - port: {get_resource: lb1_eca_traffic_port} + - port: {get_resource: lb1_ha_net_port} + + lb1_mgmt_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: oam_net_name} + fixed_ips: [{"ip_address": {get_param: lb1_oam_net_ip}}] + security_groups: [{get_resource: mms_security_group}] + + lb1_mms_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: mms_traffic_net} + fixed_ips: [{"ip_address": {get_param: mms_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: mms_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_dmz_protected_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: dmz_protected_net} + fixed_ips: [{"ip_address": {get_param: dmz_protected_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: dmz_protected_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_cor_direct_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: cor_direct_net} + fixed_ips: [{"ip_address": {get_param: cor_direct_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: cor_direct_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_nems_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_traffic_net} + fixed_ips: [{"ip_address": {get_param: nems_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_nems_user_web_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_user_web_net} + fixed_ips: [{"ip_address": {get_param: nems_user_web_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_user_web_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb1_ha_net_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: ha_net} + fixed_ips: [{"ip_address": {get_param: ha_net_local_ip1}}] + + lb1_eca_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: eca_traffic_net} + fixed_ips: [{"ip_address": {get_param: eca_traffic_net_local_ip1}}] + allowed_address_pairs: [{"ip_address": {get_param: eca_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_instance: + type: OS::Nova::Server + properties: + name: {get_param: lb2_name} + image: {get_param: lb_image_name} + flavor: {get_param: lb_flavor_name} + availability_zone: {get_param: availabilityzone_name} + networks: + - port: {get_resource: lb2_mgmt_port} + - port: {get_resource: lb2_dmz_protected_port} + - port: {get_resource: lb2_cor_direct_port} + - port: {get_resource: lb2_mms_traffic_port} + - port: {get_resource: lb2_nems_traffic_port} + - port: {get_resource: lb2_nems_user_web_port} + - port: {get_resource: lb2_eca_traffic_port} + - port: {get_resource: lb2_ha_net_port} + + lb2_mgmt_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: oam_net_name} + fixed_ips: [{"ip_address": {get_param: lb2_oam_net_ip}}] + security_groups: [{get_resource: mms_security_group}] + + lb2_mms_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: mms_traffic_net} + fixed_ips: [{"ip_address": {get_param: mms_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: mms_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_dmz_protected_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: dmz_protected_net} + fixed_ips: [{"ip_address": {get_param: dmz_protected_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: dmz_protected_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_cor_direct_port: + type: OS::Neutron::Port + properties: + network_id: {get_param: cor_direct_net} + fixed_ips: [{"ip_address": {get_param: cor_direct_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: cor_direct_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_nems_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_traffic_net} + fixed_ips: [{"ip_address": {get_param: nems_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_nems_user_web_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: nems_user_web_net} + fixed_ips: [{"ip_address": {get_param: nems_user_web_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: nems_user_web_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + lb2_ha_net_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: ha_net} + fixed_ips: [{"ip_address": {get_param: ha_net_local_ip2}}] + + lb2_eca_traffic_port: + type: OS::Neutron::Port + properties: + network_id: {get_resource: eca_traffic_net} + fixed_ips: [{"ip_address": {get_param: eca_traffic_net_local_ip2}}] + allowed_address_pairs: [{"ip_address": {get_param: eca_traffic_net_floating_ip} }] + security_groups: [{get_resource: mms_security_group}] + + server_mmsc1: + type: OS::Nova::Server + properties: + name: { get_param: mmsc1_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc1_port_0 } + - port: { get_resource: mmsc1_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc1_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc1_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW +# mmsc1_volume: +# type: OS::Cinder::Volume +# properties: +# size: {get_param: mmsc_cinder_volume_size} + +# mmsc1_volume_attachment: +# type: OS::Cinder::VolumeAttachment +# properties: +# volume_id: {get_resource: mmsc1_volume} +# instance_uuid: {get_resource: server_mmsc1} + + mmsc1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc1_oam_net_ip } + ] + + mmsc1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc1_mms_traffic_net_ip } + ] + + server_mmsc2: + type: OS::Nova::Server + properties: + name: { get_param: mmsc2_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc2_port_0 } + - port: { get_resource: mmsc2_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc2_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc2_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW +# mmsc2_volume: +# type: OS::Cinder::Volume +# properties: +# size: {get_param: mmsc_cinder_volume_size} + +# mmsc2_volume_attachment: +# type: OS::Cinder::VolumeAttachment +# properties: +# volume_id: {get_resource: mmsc2_volume} +# instance_uuid: {get_resource: server_mmsc2} + + mmsc2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc2_oam_net_ip } + ] + + mmsc2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc2_mms_traffic_net_ip } + ] + + server_mmsc3: + type: OS::Nova::Server + properties: + name: { get_param: mmsc3_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc3_port_0 } + - port: { get_resource: mmsc3_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc3_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc3_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW + + mmsc3_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc3_oam_net_ip } + ] + + mmsc3_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc3_mms_traffic_net_ip } + ] + + server_mmsc4: + type: OS::Nova::Server + properties: + name: { get_param: mmsc4_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc4_port_0 } + - port: { get_resource: mmsc4_port_1 } + user_data: + str_replace: + template: | + mmsc.mgmt.ip=${mmsc.mgmt.ip} + mmsc.mgmt.netmask=${mmsc.mgmt.netmask} + mmsc.mgmt.gateway=${mmsc.mgmt.gateway} + mmsc.traffic.ip=${mmsc.traffic.ip} + mmsc.traffic.netmask=${mmsc.traffic.netmask} + mmsc.traffic.gateway=${mmsc.traffic.gateway} + mmsc.mgmt.route.1=${mmsc.mgmt.route.1} + mmsc.mgmt.route.2=${mmsc.mgmt.route.2} + mmsc.external.dns=${mmsc.external.dns} + mmsc.external.ntp=${mmsc.external.ntp} + params: + ${mmsc.mgmt.ip}: {get_param: mmsc4_oam_net_ip} + ${mmsc.mgmt.netmask}: {get_param: oam_network_netmask} + ${mmsc.mgmt.gateway}: {get_param: oam_network_gateway} + ${mmsc.traffic.ip}: {get_param: mmsc4_mms_traffic_net_ip} + ${mmsc.traffic.netmask}: {get_param: mms_traffic_netmask} + ${mmsc.traffic.gateway}: {get_param: mms_traffic_net_gateway} + ${mmsc.mgmt.route.1}: {get_param: oam_network_route_1} + ${mmsc.mgmt.route.2}: {get_param: oam_network_route_2} + ${mmsc.external.dns}: {get_param: external_dns} + ${mmsc.external.ntp}: {get_param: external_ntp} + user_data_format: RAW + + mmsc4_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc4_oam_net_ip } + ] + + mmsc4_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc4_mms_traffic_net_ip } + ] + + server_mmsc5: + type: OS::Nova::Server + properties: + name: { get_param: mmsc5_name } + image: { get_param: mmsc_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: mmsc_flavor } + networks: + - port: { get_resource: mmsc5_port_0 } + - port: { get_resource: mmsc5_port_1 } + + mmsc5_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: mmsc5_oam_net_ip } + ] + + mmsc5_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: mms_traffic_net } + fixed_ips: [ + "ip_address": { get_param: mmsc5_mms_traffic_net_ip } + ] + + server_nems_fe1: + type: OS::Nova::Server + properties: + name: { get_param: nems_fe1_name } + image: { get_param: nems_fe_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_fe_flavor } + networks: + - port: { get_resource: nems_fe1_port_0 } + - port: { get_resource: nems_fe1_port_1 } + - port: { get_resource: nems_fe1_port_2 } + - port: { get_resource: nems_fe1_port_3 } + - port: { get_resource: nems_fe1_port_4 } + user_data: + str_replace: + template: | + nems.mgmt.ip=${nems.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.traffic.ip=${nems.traffic.ip} + nems.traffic.netmask=${nems.traffic.netmask} + nems.traffic.gateway=${nems.traffic.gateway} + nems.fe0.internal.ip=${nems.fe0.internal.ip} + nems.fe1.internal.ip=${nems.fe1.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.userweb.ip=${nems.userweb.ip} + nems.userweb.netmask=${nems.userweb.netmask} + nems.userweb.gateway=${nems.userweb.gateway} + nems.imap.ip=${nems.imap.ip} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.mgmt.ip}: {get_param: nems_fe1_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.traffic.ip}: {get_param: nems_fe1_nems_traffic_net_ip} + ${nems.traffic.netmask}: {get_param: nems_traffic_netmask} + ${nems.traffic.gateway}: {get_param: nems_traffic_gateway} + ${nems.fe0.internal.ip}: {get_param: nems_fe1_nems_internal_net_ip} + ${nems.fe1.internal.ip}: {get_param: nems_fe2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.userweb.ip}: {get_param: nems_fe1_nems_user_web_net_ip} + ${nems.userweb.netmask}: {get_param: nems_user_web_netmask} + ${nems.userweb.gateway}: {get_param: nems_user_web_gateway} + ${nems.imap.ip}: {get_param: nems_fe1_nems_imap_net_ip} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.internal.ip}: {get_param: nems_be1_nems_internal_net_ip} + ${nems.be.imap.ip}: {get_param: nems_be1_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_fe1_node_role} + user_data_format: RAW + + nems_fe1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_oam_net_ip } + ] + + nems_fe_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_fe1_port_0} + + nems_fe1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_traffic_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_traffic_net_ip } + ] + + nems_fe1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_user_web_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_user_web_net_ip } + ] + + nems_fe1_port_3: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_internal_net_ip } + ] + + nems_fe1_port_4: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe1_nems_imap_net_ip } + ] + + server_nems_fe2: + type: OS::Nova::Server + properties: + name: { get_param: nems_fe2_name } + image: { get_param: nems_fe_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_fe_flavor } + networks: + - port: { get_resource: nems_fe2_port_0 } + - port: { get_resource: nems_fe2_port_1 } + - port: { get_resource: nems_fe2_port_2 } + - port: { get_resource: nems_fe2_port_3 } + - port: { get_resource: nems_fe2_port_4 } + user_data: + str_replace: + template: | + nems.mgmt.ip=${nems.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.traffic.ip=${nems.traffic.ip} + nems.traffic.netmask=${nems.traffic.netmask} + nems.traffic.gateway=${nems.traffic.gateway} + nems.fe0.internal.ip=${nems.fe0.internal.ip} + nems.fe1.internal.ip=${nems.fe1.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.userweb.ip=${nems.userweb.ip} + nems.userweb.netmask=${nems.userweb.netmask} + nems.userweb.gateway=${nems.userweb.gateway} + nems.imap.ip=${nems.imap.ip} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.mgmt.ip}: {get_param: nems_fe2_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.traffic.ip}: {get_param: nems_fe2_nems_traffic_net_ip} + ${nems.traffic.netmask}: {get_param: nems_traffic_netmask} + ${nems.traffic.gateway}: {get_param: nems_traffic_gateway} + ${nems.fe0.internal.ip}: {get_param: nems_fe1_nems_internal_net_ip} + ${nems.fe1.internal.ip}: {get_param: nems_fe2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.userweb.ip}: {get_param: nems_fe2_nems_user_web_net_ip} + ${nems.userweb.netmask}: {get_param: nems_user_web_netmask} + ${nems.userweb.gateway}: {get_param: nems_user_web_gateway} + ${nems.imap.ip}: {get_param: nems_fe2_nems_imap_net_ip} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.internal.ip}: {get_param: nems_be2_nems_internal_net_ip} + ${nems.be.imap.ip}: {get_param: nems_be2_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_fe2_node_role} + user_data_format: RAW + + nems_fe2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_oam_net_ip } + ] + + nems_fe_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_fe2_port_0} + + nems_fe2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_traffic_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_traffic_net_ip } + ] + + nems_fe2_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_user_web_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_user_web_net_ip } + ] + + nems_fe2_port_3: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_internal_net_ip } + ] + + nems_fe2_port_4: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_fe2_nems_imap_net_ip } + ] + + server_nems_be1: + type: OS::Nova::Server + properties: + name: { get_param: nems_be1_name } + image: { get_param: nems_be_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_be_flavor } + networks: + - port: { get_resource: nems_be1_port_0 } + - port: { get_resource: nems_be1_port_1 } + - port: { get_resource: nems_be1_port_2 } + user_data: + str_replace: + template: | + nems.be.mgmt.ip=${nems.be.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.be.mgmt.ip}: {get_param: nems_be1_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.be.internal.ip}: {get_param: nems_be1_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.imap.ip}: {get_param: nems_be1_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_be1_node_role} + user_data_format: RAW + + nems_be1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_be1_oam_net_ip } + ] + + nems_be_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_be1_port_0} + + nems_be1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_be1_nems_internal_net_ip } + ] + + nems_be1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_be1_nems_imap_net_ip } + ] + + server_nems_be2: + type: OS::Nova::Server + properties: + name: { get_param: nems_be2_name } + image: { get_param: nems_be_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: nems_be_flavor } + networks: + - port: { get_resource: nems_be2_port_0 } + - port: { get_resource: nems_be2_port_1 } + - port: { get_resource: nems_be2_port_2 } + user_data: + str_replace: + template: | + nems.be.mgmt.ip=${nems.be.mgmt.ip} + nems.mgmt.netmask=${nems.mgmt.netmask} + nems.mgmt.gateway=${nems.mgmt.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.internal.netmask=${nems.internal.netmask} + nems.internal.gateway=${nems.internal.gateway} + nems.imap.netmask=${nems.imap.netmask} + nems.imap.gateway=${nems.imap.gateway} + nems.be.internal.ip=${nems.be.internal.ip} + nems.be.imap.ip=${nems.be.imap.ip} + nems.mgmt.route.1=${nems.mgmt.route.1} + nems.mgmt.route.2=${nems.mgmt.route.2} + nems.external.dns=${nems.external.dns} + nems.external.ntp=${nems.external.ntp} + nems.node=${nems.node} + params: + ${nems.be.mgmt.ip}: {get_param: nems_be2_oam_net_ip} + ${nems.mgmt.netmask}: {get_param: oam_network_netmask} + ${nems.mgmt.gateway}: {get_param: oam_network_gateway} + ${nems.be.internal.ip}: {get_param: nems_be2_nems_internal_net_ip} + ${nems.internal.netmask}: {get_param: nems_internal_netmask} + ${nems.internal.gateway}: {get_param: nems_internal_gateway} + ${nems.imap.netmask}: {get_param: nems_imap_netmask} + ${nems.imap.gateway}: {get_param: nems_imap_gateway} + ${nems.be.imap.ip}: {get_param: nems_be2_nems_imap_net_ip} + ${nems.mgmt.route.1}: {get_param: oam_network_route_1} + ${nems.mgmt.route.2}: {get_param: oam_network_route_2} + ${nems.external.dns}: {get_param: external_dns} + ${nems.external.ntp}: {get_param: external_ntp} + ${nems.node}: {get_param: nems_be1_node_role} + user_data_format: RAW + + nems_be2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: nems_be2_oam_net_ip } + ] + + nems_be_floating_ip: + type: OS::Neutron::FloatingIP + properties: + floating_network_id: {get_param: oam_net_name} + port_id: {get_resource: nems_be2_port_0} + + nems_be2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_internal_net } + fixed_ips: [ + "ip_address": { get_param: nems_be2_nems_internal_net_ip } + ] + + nems_be2_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: nems_imap_net } + fixed_ips: [ + "ip_address": { get_param: nems_be2_nems_imap_net_ip } + ] + + server_eca_oam1: + type: OS::Nova::Server + properties: + name: { get_param: eca_oam1_name } + image: { get_param: eca_oam_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_oam_flavor } + networks: + - port: { get_resource: eca_oam1_port_0 } + - port: { get_resource: eca_oam1_port_1 } + + eca_oam1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_oam1_oam_net_ip } + ] + + eca_oam1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_oam1_eca_mgmt_net_ip } + ] + + server_eca_oam2: + type: OS::Nova::Server + properties: + name: { get_param: eca_oam2_name } + image: { get_param: eca_oam_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_oam_flavor } + networks: + - port: { get_resource: eca_oam2_port_0 } + - port: { get_resource: eca_oam2_port_1 } + + eca_oam2_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_oam2_oam_net_ip } + ] + + eca_oam2_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_oam2_eca_mgmt_net_ip } + ] + + server_eca_trx1: + type: OS::Nova::Server + properties: + name: { get_param: eca_trx1_name } + image: { get_param: eca_trx_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: eca_trx_flavor } + networks: + - port: { get_resource: eca_trx1_port_0 } + - port: { get_resource: eca_trx1_port_1 } + - port: { get_resource: eca_trx1_port_2 } + + + eca_trx1_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_oam_net_ip } + ] + + eca_trx1_port_1: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_mgmt_net } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_eca_mgmt_net_ip } + ] + + eca_trx1_port_2: + type: OS::Neutron::Port + properties: + network_id: { get_resource: eca_traffic_net } + fixed_ips: [ + "ip_address": { get_param: eca_trx1_eca_traffic_net_ip } + ] + + server_cmaui: + type: OS::Nova::Server + properties: + name: { get_param: cmaui_name } + image: { get_param: cmaui_image } + availability_zone: { get_param: availabilityzone_name } + flavor: { get_param: cmaui_flavor } + networks: + - port: { get_resource: cmaui_port_0 } + +# cmaui_volume: +# type: OS::Cinder::Volume +# properties: +# size: {get_param: cmaui_cinder_volume_size} + +# cmaui_volume_attachment: +# type: OS::Cinder::VolumeAttachment +# properties: +# volume_id: {get_resource: cmaui_volume} +# instance_uuid: {get_resource: server_cmaui} + + cmaui_port_0: + type: OS::Neutron::Port + properties: + network_id: { get_param: oam_net_name } + fixed_ips: [ + "ip_address": { get_param: cmaui_oam_net_ip } + ] + |