diff options
Diffstat (limited to 'ms')
73 files changed, 1588 insertions, 803 deletions
diff --git a/ms/blueprintsprocessor/.gitignore b/ms/blueprintsprocessor/.gitignore deleted file mode 100644 index 04f991d12..000000000 --- a/ms/blueprintsprocessor/.gitignore +++ /dev/null @@ -1,32 +0,0 @@ -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -.classpath -.settings/ - -# Target dirs in all projects -**/target-ide/* -**/target/* -**/logs/* -**/tokens/* -**/lib/cachedir/** - -# Added for Intellij IDEA IDE -**/debug-logs/* -**/.idea/* -**/*.iml -**/*.project -**/.springBeans -**/.directory - -**/transaction.log -**/*versionsBackup -**/blackDuckHub* -**/*.jsonld -/target-ide/ diff --git a/ms/blueprintsprocessor/application/pom.xml b/ms/blueprintsprocessor/application/pom.xml index 64452a061..a67b10d4a 100755 --- a/ms/blueprintsprocessor/application/pom.xml +++ b/ms/blueprintsprocessor/application/pom.xml @@ -70,6 +70,11 @@ <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>configs-api</artifactId> </dependency> + <dependency> + <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> + <artifactId>health-api</artifactId> + </dependency> + <!-- Functions --> <dependency> diff --git a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.java b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.java index 82693c4fd..ce802b7b5 100644 --- a/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.java +++ b/ms/blueprintsprocessor/application/src/main/java/org/onap/ccsdk/cds/blueprintsprocessor/SwaggerConfig.java @@ -28,7 +28,6 @@ import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import java.util.Collections; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux; /** * SwaggerConfig @@ -36,7 +35,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebFlux; * @author Brinda Santh 8/13/2018 */ @Configuration -@EnableSwagger2WebFlux +//@EnableSwagger2WebFlux public class SwaggerConfig { @Bean diff --git a/ms/blueprintsprocessor/application/src/main/resources/logback.xml b/ms/blueprintsprocessor/application/src/main/resources/logback.xml index 1c3c7dc4b..872ee4f15 100644 --- a/ms/blueprintsprocessor/application/src/main/resources/logback.xml +++ b/ms/blueprintsprocessor/application/src/main/resources/logback.xml @@ -1,36 +1,36 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="info"/>
- <logger name="org.springframework.web" level="info"/>
- <logger name="org.hibernate" level="error"/>
- <logger name="org.onap.ccsdk.cds" level="info"/>
-
- <root level="info">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="info"/> + <logger name="org.springframework.web" level="info"/> + <logger name="org.hibernate" level="error"/> + <logger name="org.onap.ccsdk.cds" level="info"/> + + <root level="info"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/application/src/main/resources/sql/schema-local.sql b/ms/blueprintsprocessor/application/src/main/resources/sql/schema-local.sql index ad048b017..05df4200a 100644 --- a/ms/blueprintsprocessor/application/src/main/resources/sql/schema-local.sql +++ b/ms/blueprintsprocessor/application/src/main/resources/sql/schema-local.sql @@ -6,8 +6,8 @@ -- ----------------------------------------------------- -- table CONFIG_MODEL -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL ( - config_model_id INT(11) NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS sdnctl.BLUEPRINT_MODEL ( + blueprint_model_id VARCHAR(50) NOT NULL, service_uuid VARCHAR(50) NULL DEFAULT NULL, distribution_id VARCHAR(50) NULL DEFAULT NULL, service_name VARCHAR(255) NULL DEFAULT NULL, @@ -27,25 +27,25 @@ CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL ( published varchar(1) not null, updated_by varchar(100) not null, tags longtext null default null, - primary key PK_CONFIG_MODEL (config_model_id), - UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version) + primary key PK_BLUEPRINT_MODEL (blueprint_model_id), + UNIQUE KEY UK_BLUEPRINT_MODEL (artifact_name , artifact_version) ) ENGINE=InnoDB; -- ----------------------------------------------------- -- table CONFIG_MODEL_CONTENT -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS sdnctl.CONFIG_MODEL_CONTENT ( - config_model_content_id INT(11) NOT NULL AUTO_INCREMENT, - config_model_id INT NOT NULL, +CREATE TABLE IF NOT EXISTS sdnctl.BLUEPRINT_MODEL_CONTENT ( + blueprint_model_content_id VARCHAR(50) NOT NULL, + blueprint_model_id VARCHAR(50) NOT NULL, name VARCHAR(100) NOT NULL, content_type VARCHAR(50) NOT NULL, description LONGTEXT NULL DEFAULT NULL, updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - content LONGTEXT NULL DEFAULT NULL, - PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id), - UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type), - FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES sdnctl.CONFIG_MODEL(config_model_id) ON DELETE CASCADE + content LONGBLOB NULL DEFAULT NULL, + PRIMARY KEY PK_BLUEPRINT_MODEL_CONTENT (blueprint_model_content_id), + UNIQUE KEY UK_BLUEPRINT_MODEL_CONTENT (blueprint_model_id, name, content_type), + FOREIGN KEY FK_BLUEPRINT_MODEL_CONTENT (blueprint_model_id) REFERENCES sdnctl.BLUEPRINT_MODEL(blueprint_model_id) ON DELETE CASCADE ) ENGINE=InnoDB; -- ----------------------------------------------------- diff --git a/ms/blueprintsprocessor/application/src/main/resources/sql/schema.sql b/ms/blueprintsprocessor/application/src/main/resources/sql/schema.sql index 58564dce5..8bf39eed2 100644 --- a/ms/blueprintsprocessor/application/src/main/resources/sql/schema.sql +++ b/ms/blueprintsprocessor/application/src/main/resources/sql/schema.sql @@ -1,8 +1,8 @@ -- ----------------------------------------------------- -- table CONFIG_MODEL -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL ( - config_model_id INT(11) NOT NULL AUTO_INCREMENT, +CREATE TABLE IF NOT EXISTS configurator.BLUEPRINT_MODEL ( + blueprint_model_id VARCHAR(50) NOT NULL, service_uuid VARCHAR(50) NULL DEFAULT NULL, distribution_id VARCHAR(50) NULL DEFAULT NULL, service_name VARCHAR(255) NULL DEFAULT NULL, @@ -22,25 +22,25 @@ CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL ( published varchar(1) not null, updated_by varchar(100) not null, tags longtext null default null, - primary key PK_CONFIG_MODEL (config_model_id), - UNIQUE KEY UK_CONFIG_MODEL (artifact_name , artifact_version) + primary key PK_BLUEPRINT_MODEL (blueprint_model_id), + UNIQUE KEY UK_BLUEPRINT_MODEL (artifact_name , artifact_version) ) ENGINE=InnoDB; -- ----------------------------------------------------- -- table CONFIG_MODEL_CONTENT -- ----------------------------------------------------- -CREATE TABLE IF NOT EXISTS configurator.CONFIG_MODEL_CONTENT ( - config_model_content_id INT(11) NOT NULL AUTO_INCREMENT, - config_model_id INT NOT NULL, +CREATE TABLE IF NOT EXISTS configurator.BLUEPRINT_MODEL_CONTENT ( + blueprint_model_content_id VARCHAR(50) NOT NULL, + blueprint_model_id VARCHAR(50) NOT NULL, name VARCHAR(100) NOT NULL, content_type VARCHAR(50) NOT NULL, description LONGTEXT NULL DEFAULT NULL, updated_date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - content LONGTEXT NULL DEFAULT NULL, - PRIMARY KEY PK_CONFIG_MODEL_CONTENT (config_model_content_id), - UNIQUE KEY UK_CONFIG_MODEL_CONTENT (config_model_id, name, content_type), - FOREIGN KEY FK_CONFIG_MODEL_CONTENT (config_model_id) REFERENCES configurator.CONFIG_MODEL(config_model_id) ON DELETE CASCADE + content LONGBLOB NULL DEFAULT NULL, + PRIMARY KEY PK_BLUEPRINT_MODEL_CONTENT (blueprint_model_content_id), + UNIQUE KEY UK_BLUEPRINT_MODEL_CONTENT (blueprint_model_id, name, content_type), + FOREIGN KEY FK_BLUEPRINT_MODEL_CONTENT (blueprint_model_id) REFERENCES configurator.BLUEPRINT_MODEL(blueprint_model_id) ON delete CASCADE ) ENGINE=InnoDB; -- ----------------------------------------------------- diff --git a/ms/blueprintsprocessor/application/src/test/resources/application.properties b/ms/blueprintsprocessor/application/src/test/resources/application.properties index 766498fdc..d56e9582c 100644 --- a/ms/blueprintsprocessor/application/src/test/resources/application.properties +++ b/ms/blueprintsprocessor/application/src/test/resources/application.properties @@ -77,3 +77,7 @@ blueprintsprocessor.messageclient.self-service-api.consumerTopic=receiver.t blueprintsprocessor.messageclient.self-service-api.groupId=receiver-id blueprintsprocessor.messageclient.self-service-api.clientId=default-client-id blueprintsprocessor.messageclient.self-service-api.kafkaEnable=false + + +endpoints.user.name=ccsdkapps +endpoints.user.password=ccsdkapps diff --git a/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml index eaa51c0a3..70d94f5a7 100644 --- a/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/application/src/test/resources/logback-test.xml @@ -1,41 +1,41 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~ Modifications Copyright (C) 2019 Nordix Foundation.
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %-40.40logger{39} : %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.web.HttpLogging" level="trace"/>
- <logger name="org.springframework.web.reactive.function.client.ExchangeFunctions" level="trace"/>
-
- <!-- Helpful to optimize Spring Context caching to speed-up tests
- and prevent resorting to @DirtiesContext as much as possible -->
- <logger name="org.springframework.test.context.cache" level="debug"/>
-
- <!-- Please refer to https://thoughts-on-java.org/hibernate-logging-guide/
- for a lengthy discussion on good Hibernate logging practices -->
- <logger name="org.hibernate.SQL" level="debug"/>
- <logger name="org.hibernate.type.descriptor.sql" level="trace"/>
-
- <root level="info">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ Modifications Copyright (C) 2019 Nordix Foundation. + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %-40.40logger{39} : %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.springframework.web.HttpLogging" level="trace"/> + <logger name="org.springframework.web.reactive.function.client.ExchangeFunctions" level="trace"/> + + <!-- Helpful to optimize Spring Context caching to speed-up tests + and prevent resorting to @DirtiesContext as much as possible --> + <logger name="org.springframework.test.context.cache" level="debug"/> + + <!-- Please refer to https://thoughts-on-java.org/hibernate-logging-guide/ + for a lengthy discussion on good Hibernate logging practices --> + <logger name="org.hibernate.SQL" level="debug"/> + <logger name="org.hibernate.type.descriptor.sql" level="trace"/> + + <root level="info"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml b/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml index 848083e63..2d1f1ae80 100755 --- a/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml +++ b/ms/blueprintsprocessor/distribution/src/main/dc/docker-compose.yaml @@ -1,16 +1,16 @@ -version: '3.3'
-
-services:
- db:
- image: mariadb:latest
- container_name: ccsdk-mariadb
- ports:
- - "3306:3306"
- volumes:
- - ~/vm_mysql:/var/lib/mysql
- restart: always
- environment:
- MYSQL_ROOT_PASSWORD: sdnctl
- MYSQL_DATABASE: sdnctl
- MYSQL_USER: sdnctl
- MYSQL_PASSWORD: sdnctl
+version: '3.3' + +services: + db: + image: mariadb:latest + container_name: ccsdk-mariadb + ports: + - "3306:3306" + volumes: + - ~/vm_mysql:/var/lib/mysql + restart: always + environment: + MYSQL_ROOT_PASSWORD: sdnctl + MYSQL_DATABASE: sdnctl + MYSQL_USER: sdnctl + MYSQL_PASSWORD: sdnctl diff --git a/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh index d1e09ddc3..14d772e41 100644 --- a/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh +++ b/ms/blueprintsprocessor/distribution/src/main/docker/startService.sh @@ -5,6 +5,6 @@ nodeName=BlueprintsProcessor_1.0.0_$(cat /proc/self/cgroup | grep docker | sed s echo "APP Config HOME : ${APP_CONFIG_HOME}" export APP_HOME=/opt/app/onap -keytool -import -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias ONAP -import -file $APP_CONFIG_HOME/ONAP_RootCA.cer +keytool -import -noprompt -trustcacerts -keystore $JAVA_HOME/jre/lib/security/cacerts -storepass changeit -alias ONAP -import -file $APP_CONFIG_HOME/ONAP_RootCA.cer source /etc/run.source diff --git a/ms/blueprintsprocessor/functions/ansible-awx-executor/pom.xml b/ms/blueprintsprocessor/functions/ansible-awx-executor/pom.xml index 8b59b17f7..9613030cd 100644 --- a/ms/blueprintsprocessor/functions/ansible-awx-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/ansible-awx-executor/pom.xml @@ -24,6 +24,7 @@ <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>ansible-awx-executor</artifactId> + <version>0.7.0-SNAPSHOT</version> <name>Blueprints Processor Function - Ansible AWX Executor</name> <description>Blueprints Processor Function - Ansible Executor</description> diff --git a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/resources/logback-test.xml index 5b36ac046..4313fa509 100644 --- a/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/functions/ansible-awx-executor/src/test/resources/logback-test.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{55} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{55} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/functions/cli-executor/pom.xml b/ms/blueprintsprocessor/functions/cli-executor/pom.xml index 89f409a70..b45fdb3f8 100644 --- a/ms/blueprintsprocessor/functions/cli-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/cli-executor/pom.xml @@ -23,6 +23,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>cli-executor</artifactId> + <version>0.7.0-SNAPSHOT</version> <name>Blueprints Processor Function - CLI Executor</name> <description>Blueprints Processor Function - CLI Executor</description> diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt index cf27cc2de..15365e176 100644 --- a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt +++ b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/internal/scripts/InternalSimpleCli.kt @@ -19,11 +19,12 @@ package internal.scripts import org.onap.ccsdk.cds.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.cliDeviceInfo +import org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor.getSshClientService import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractScriptComponentFunction import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.ComponentScriptExecutor -import org.onap.ccsdk.cds.blueprintsprocessor.ssh.sshClientService import org.onap.ccsdk.cds.controllerblueprints.core.asJsonPrimitive -import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService + import org.slf4j.LoggerFactory open class TestCliScriptFunction : AbstractScriptComponentFunction() { @@ -54,10 +55,10 @@ open class Check : AbstractScriptComponentFunction() { override suspend fun processNB(executionRequest: ExecutionServiceInput) { // Get the Device Information from the DSL Model - val deviceInformation = bluePrintRuntimeService.resolveDSLExpression("device-properties") + val deviceInformation = cliDeviceInfo("device-properties") // Get the Client Service - val sshClientService = BluePrintDependencyService.sshClientService(deviceInformation) + val sshClientService = getSshClientService(deviceInformation) sshClientService.startSessionNB() diff --git a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt index bc9b7103c..ad95759a9 100644 --- a/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt +++ b/ms/blueprintsprocessor/functions/cli-executor/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/cli/executor/CliExecutorExtensions.kt @@ -17,7 +17,20 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.cli.executor +import com.fasterxml.jackson.databind.JsonNode +import org.onap.ccsdk.cds.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.onap.ccsdk.cds.blueprintsprocessor.ssh.service.BlueprintSshClientService +import org.onap.ccsdk.cds.blueprintsprocessor.ssh.sshClientService +import org.onap.ccsdk.cds.controllerblueprints.core.service.BluePrintDependencyService + /** * Register the CLI module exposed dependency */ +fun AbstractComponentFunction.cliDeviceInfo(requirementName: String): JsonNode { + return bluePrintRuntimeService.resolveDSLExpression(requirementName) +} + +fun AbstractComponentFunction.getSshClientService(cliDeviceInfo: JsonNode): BlueprintSshClientService { + return BluePrintDependencyService.sshClientService(cliDeviceInfo) +} diff --git a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml index f163c0e1a..a10dfba38 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/netconf-executor/pom.xml @@ -23,6 +23,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>netconf-executor</artifactId> + <version>0.7.0-SNAPSHOT</version> <name>Blueprints Processor Function - Netconf Executor</name> <description>Blueprints Processor Function - Netconf Executor</description> diff --git a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml index cc7ac83ad..da4cf9a1b 100644 --- a/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/functions/netconf-executor/src/test/resources/logback-test.xml @@ -1,37 +1,37 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.test" level="warn"/>
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.apache.sshd" level="warn"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core" level="warn"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.springframework.test" level="warn"/> + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.apache.sshd" level="warn"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor.functions.netconf.executor.core" level="warn"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml index 0c8d93bf0..e04e741c9 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/logback-test.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json index 7142f0457..694589de1 100644 --- a/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json +++ b/ms/blueprintsprocessor/functions/python-executor/src/test/resources/payload/requests/sample-activate-request.json @@ -1,31 +1,31 @@ -{
- "actionIdentifiers": {
- "actionName": "activate",
- "blueprintName": "baseconfiguration",
- "blueprintVersion": "1.0.0",
- "mode": "sync"
- },
- "commonHeader": {
- "flags": {
- "force": true,
- "ttl": 3600
- },
- "originatorId": "sdnc",
- "requestId": "123456-1000",
- "subRequestId": "sub-123456-1000",
- "timestamp": "2012-04-23T18:25:43.511Z"
- },
- "payload": {
- "resource-assignment-request": {
- "resource-assignment-properties": {
- "request-id": "1234",
- "service-instance-id": "siid_1234",
- "vnf-id": "vnf_1234",
- "action-name": "assign-activate",
- "scope-type": "vnf-type",
- "hostname": "localhost",
- "vnf_name": "temp_vnf"
- }
- }
- }
-}
+{ + "actionIdentifiers": { + "actionName": "activate", + "blueprintName": "baseconfiguration", + "blueprintVersion": "1.0.0", + "mode": "sync" + }, + "commonHeader": { + "flags": { + "force": true, + "ttl": 3600 + }, + "originatorId": "sdnc", + "requestId": "123456-1000", + "subRequestId": "sub-123456-1000", + "timestamp": "2012-04-23T18:25:43.511Z" + }, + "payload": { + "resource-assignment-request": { + "resource-assignment-properties": { + "request-id": "1234", + "service-instance-id": "siid_1234", + "vnf-id": "vnf_1234", + "action-name": "assign-activate", + "scope-type": "vnf-type", + "hostname": "localhost", + "vnf_name": "temp_vnf" + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml index be524fe22..66210f258 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/pom.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/pom.xml @@ -23,6 +23,7 @@ </parent> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>resource-resolution</artifactId> + <version>0.7.0-SNAPSHOT</version> <packaging>jar</packaging> <name>Blueprints Processor Function - Resource Resolution</name> <description>Blueprints Processor Function - Resource Resolution</description> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml index 305c59f62..f379f37ed 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/logback-test.xml @@ -1,37 +1,37 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.mockserver.mock" level="warn"/>
- <logger name="org.onap.ccsdk.cds.controllerblueprints" level="warn"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level [%thread] %logger{50} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.mockserver.mock" level="warn"/> + <logger name="org.onap.ccsdk.cds.controllerblueprints" level="warn"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json index cd6fac128..52a8a4f84 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/inputs/input.json @@ -1,18 +1,18 @@ -{
- "api-ver": "2.00",
- "originator-id": "MSO",
- "request-id": "123456",
- "service-instance-id": "ibcx0001vm001",
- "service-type": "AVPN",
- "vnf-type": "vUSP - vDBE-IPX HUB",
- "vnf-id": 123456,
- "service-template-name": "VRR-baseconfiguration",
- "service-template-version": "1.0.0",
- "action-name": "resource-assignment-action",
- "group-name": "sample group name",
- "bundle-id": "sample bundle id",
- "bundle-mac": [
- "Sample bundle mac",
- "Sample bundle mac"
- ]
-}
+{ + "api-ver": "2.00", + "originator-id": "MSO", + "request-id": "123456", + "service-instance-id": "ibcx0001vm001", + "service-type": "AVPN", + "vnf-type": "vUSP - vDBE-IPX HUB", + "vnf-id": 123456, + "service-template-name": "VRR-baseconfiguration", + "service-template-version": "1.0.0", + "action-name": "resource-assignment-action", + "group-name": "sample group name", + "bundle-id": "sample bundle id", + "bundle-mac": [ + "Sample bundle mac", + "Sample bundle mac" + ] +} diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json index 6a7b4c2a2..cc653ccd6 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/payload/requests/sample-resourceresolution-request.json @@ -1,32 +1,32 @@ -{
- "actionIdentifiers": {
- "actionName": "sample-action",
- "blueprintName": "sample-blurprint",
- "blueprintVersion": "1.0.0",
- "mode": "sync"
- },
- "commonHeader": {
- "flags": {
- "force": true,
- "ttl": 3600
- },
- "originatorId": "sdnc",
- "requestId": "123456-1000",
- "subRequestId": "sub-123456-1000",
- "timestamp": "2012-04-23T18:25:43.511Z"
- },
- "payload": {
- "resource-assignment-request": {
- "resource-assignment-properties": {
- "request-id": "1234",
- "profile_name": "1.0.0",
- "service-instance-id": "siid_1234",
- "vnf-id": "vnf_1234",
- "action-name": "assign-activate",
- "scope-type": "vnf-type",
- "hostname": "localhost",
- "vnf_name": "temp_vnf"
- }
- }
- }
-}
+{ + "actionIdentifiers": { + "actionName": "sample-action", + "blueprintName": "sample-blurprint", + "blueprintVersion": "1.0.0", + "mode": "sync" + }, + "commonHeader": { + "flags": { + "force": true, + "ttl": 3600 + }, + "originatorId": "sdnc", + "requestId": "123456-1000", + "subRequestId": "sub-123456-1000", + "timestamp": "2012-04-23T18:25:43.511Z" + }, + "payload": { + "resource-assignment-request": { + "resource-assignment-properties": { + "request-id": "1234", + "profile_name": "1.0.0", + "service-instance-id": "siid_1234", + "vnf-id": "vnf_1234", + "action-name": "assign-activate", + "scope-type": "vnf-type", + "hostname": "localhost", + "vnf_name": "temp_vnf" + } + } + } +} diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml index c1dd50126..2872a5a8f 100644 --- a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml +++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml @@ -23,6 +23,7 @@ <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds.blueprintsprocessor.functions</groupId> <artifactId>restconf-executor</artifactId> + <version>0.7.0-SNAPSHOT</version> <name>Blueprints Processor Function - Restconf Executor</name> <description>Blueprints Processor Function - Restconf Executor</description> diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt index 17ffd5bac..74a611fbb 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModel.kt @@ -34,11 +34,11 @@ import javax.persistence.* @EntityListeners(AuditingEntityListener::class) @Entity -@Table(name = "CONFIG_MODEL", uniqueConstraints = [UniqueConstraint(columnNames = ["artifact_name", "artifact_version"])]) +@Table(name = "BLUEPRINT_MODEL", uniqueConstraints = [UniqueConstraint(columnNames = ["artifact_name", "artifact_version"])]) @Proxy(lazy = false) class BlueprintModel : Serializable { @Id - @Column(name = "config_model_id") + @Column(name = "blueprint_model_id") var id: String? = null @Column(name = "service_uuid") diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt index e0d26a7ae..bed6e4e38 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelContent.kt @@ -32,11 +32,11 @@ import javax.persistence.* */ @EntityListeners(AuditingEntityListener::class) @Entity -@Table(name = "CONFIG_MODEL_CONTENT") +@Table(name = "BLUEPRINT_MODEL_CONTENT") class BlueprintModelContent : Serializable { @Id - @Column(name = "config_model_content_id") + @Column(name = "blueprint_model_content_id") var id: String? = null @Column(name = "name", nullable = false) @@ -48,7 +48,7 @@ class BlueprintModelContent : Serializable { lateinit var contentType: String @OneToOne - @JoinColumn(name = "config_model_id") + @JoinColumn(name = "blueprint_model_id") var blueprintModel: BlueprintModel? = null @Lob diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt index f00d5cadf..f47124dd0 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/primary/domain/BlueprintModelSearch.kt @@ -32,13 +32,13 @@ import javax.persistence.* */ @Entity -@Table(name = "CONFIG_MODEL") +@Table(name = "BLUEPRINT_MODEL") @JsonTypeName("blueprintModel") @JsonTypeInfo(include = JsonTypeInfo.As.WRAPPER_OBJECT, use = JsonTypeInfo.Id.NAME) class BlueprintModelSearch : Serializable { @Id - @Column(name = "config_model_id") + @Column(name = "blueprint_model_id") var id: String? = null @Column(name = "artifact_uuid") diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt index 9ce45d11e..3e0f3516f 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/BlueprintProcessorCatalogServiceImpl.kt @@ -117,6 +117,10 @@ class BlueprintProcessorCatalogServiceImpl(bluePrintRuntimeValidatorService: Blu blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion) val deployFile = normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, artifactName, artifactVersion) + + val cacheKey = BluePrintFileUtils.compileCacheKey(deployFile) + BluePrintCompileCache.cleanClassLoader(cacheKey) + deleteNBDir(deployFile).let { if (it) log.info("Deleted deployed blueprint model :$artifactName::$artifactVersion") else log.info("Fail to delete deployed blueprint model :$artifactName::$artifactVersion") diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt index 66b5d00c4..4c02fda12 100755 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/db/service/ControllerBlueprintCatalogServiceImpl.kt @@ -21,14 +21,13 @@ package org.onap.ccsdk.cds.blueprintsprocessor.db.service import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModel import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.domain.BlueprintModelContent import org.onap.ccsdk.cds.blueprintsprocessor.db.primary.repository.BlueprintModelRepository -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants -import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintException +import org.onap.ccsdk.cds.controllerblueprints.core.* import org.onap.ccsdk.cds.controllerblueprints.core.common.ApplicationConstants import org.onap.ccsdk.cds.controllerblueprints.core.config.BluePrintLoadConfiguration import org.onap.ccsdk.cds.controllerblueprints.core.data.ErrorCode -import org.onap.ccsdk.cds.controllerblueprints.core.deleteDir import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintValidatorService -import org.onap.ccsdk.cds.controllerblueprints.core.normalizedPath +import org.onap.ccsdk.cds.controllerblueprints.core.scripts.BluePrintCompileCache +import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintFileUtils import org.slf4j.LoggerFactory import org.springframework.dao.DataIntegrityViolationException import org.springframework.stereotype.Service @@ -85,6 +84,12 @@ class ControllerBlueprintCatalogServiceImpl(bluePrintDesignTimeValidatorService: throw BluePrintException("Not a valid Archive file(${archiveFile.absolutePath})") } + // cleanup up deploy folder for the Blueprint + val blueprintDeploy = normalizedPathName(bluePrintLoadConfiguration.blueprintDeployPath, + artifactName, artifactVersion) + val cacheKey = BluePrintFileUtils.compileCacheKey(blueprintDeploy) + BluePrintCompileCache.cleanClassLoader(cacheKey) + blueprintModelRepository.findByArtifactNameAndArtifactVersion(artifactName!!, artifactVersion!!)?.let { log.info("Overwriting blueprint model :$artifactName::$artifactVersion") blueprintModelRepository.deleteByArtifactNameAndArtifactVersion(artifactName, artifactVersion) diff --git a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml index 355cd3ace..365c41c9e 100644 --- a/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/modules/commons/db-lib/src/test/resources/logback-test.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.test" level="warn"/>
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.springframework.test" level="warn"/> + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml index ebb41b854..cff57423d 100644 --- a/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/modules/commons/dmaap-lib/src/test/resources/logback-test.xml @@ -1,40 +1,40 @@ -<!--
- ~ ============LICENSE_START=======================================================
- ~ ONAP - CDS
- ~ ================================================================================
- ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. 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">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.test" level="warn"/>
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ ============LICENSE_START======================================================= + ~ ONAP - CDS + ~ ================================================================================ + ~ Copyright (C) 2019 Huawei Technologies Co., Ltd. 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"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.springframework.test" level="warn"/> + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml index e5214e139..5cc29a65e 100644 --- a/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml +++ b/ms/blueprintsprocessor/modules/commons/grpc-lib/pom.xml @@ -30,16 +30,16 @@ <dependencies> <dependency> <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>blueprint-proto</artifactId> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>blueprint-core</artifactId> </dependency> <dependency> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>processor-core</artifactId> </dependency> - <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> - </dependency> </dependencies> </project> diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties index 2ce871476..c10e96ee2 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/main/resources/application.properties @@ -1,16 +1,16 @@ -#
-# Copyright © 2017-2018 AT&T Intellectual Property.
-#
-# 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.
-#
-
+# +# Copyright © 2017-2018 AT&T Intellectual Property. +# +# 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. +# + diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml index 355cd3ace..365c41c9e 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/resources/logback-test.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
- <logger name="org.springframework.test" level="warn"/>
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + <logger name="org.springframework.test" level="warn"/> + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml index b09a8ac41..d4d030772 100644 --- a/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/configs-api/pom.xml @@ -21,8 +21,6 @@ <artifactId>inbounds</artifactId> <version>0.7.0-SNAPSHOT</version> </parent> - - <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> <artifactId>configs-api</artifactId> <version>0.7.0-SNAPSHOT</version> <packaging>jar</packaging> diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt index c48f1dd98..a3bf3709d 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandler.kt @@ -19,7 +19,7 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import com.google.protobuf.ByteString -import io.grpc.StatusException +import com.google.protobuf.util.JsonFormat import io.grpc.stub.StreamObserver import kotlinx.coroutines.runBlocking import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.handler.BluePrintModelHandler @@ -27,6 +27,7 @@ import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.common.api.Status import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintProcessorException +import org.onap.ccsdk.cds.controllerblueprints.core.asJsonString import org.onap.ccsdk.cds.controllerblueprints.core.emptyTONull import org.onap.ccsdk.cds.controllerblueprints.core.utils.currentTimestamp import org.onap.ccsdk.cds.controllerblueprints.management.api.* @@ -34,6 +35,7 @@ import org.slf4j.LoggerFactory import org.springframework.security.access.prepost.PreAuthorize import org.springframework.stereotype.Service +//TODO("Convert to coroutines handler") @Service open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: BluePrintModelHandler) : BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase() { @@ -45,6 +47,7 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu StreamObserver<BluePrintManagementOutput>) { runBlocking { + //TODO("catch if request id is missing") log.info("request(${request.commonHeader.requestId})") try { /** Get the file byte array */ @@ -56,29 +59,67 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu when (uploadAction) { UploadAction.DRAFT.toString() -> { val blueprintModel = bluePrintModelHandler.upload(byteArray, false) - responseObserver.onNext(successStatus(request.commonHeader)) + responseObserver.onNext(successStatus(request.commonHeader, blueprintModel.asJsonString())) } UploadAction.PUBLISH.toString() -> { val blueprintModel = bluePrintModelHandler.upload(byteArray, true) - responseObserver.onNext(successStatus(request.commonHeader)) + responseObserver.onNext(successStatus(request.commonHeader, blueprintModel.asJsonString())) } UploadAction.VALIDATE.toString() -> { //TODO("Not Implemented") - responseObserver.onError(failStatus("Not Implemented", + responseObserver.onNext(failStatus(request.commonHeader, + "Upload action($uploadAction) not implemented", BluePrintProcessorException("Not Implemented"))) } UploadAction.ENRICH.toString() -> { val enrichedByteArray = bluePrintModelHandler.enrichBlueprintFileSource(byteArray) - responseObserver.onNext(enrichmentStatus(request.commonHeader, enrichedByteArray)) + responseObserver.onNext(outputWithFileBytes(request.commonHeader, enrichedByteArray)) } else -> { - responseObserver.onError(failStatus("Upload action($uploadAction) not implemented", - BluePrintProcessorException("Upload action($uploadAction) not implemented"))) + responseObserver.onNext(failStatus(request.commonHeader, + "Upload action($uploadAction) not implemented", + BluePrintProcessorException("Not implemented"))) } } + } catch (e: Exception) { + responseObserver.onNext(failStatus(request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to upload CBA", e)) + } finally { responseObserver.onCompleted() + } + } + } + + @PreAuthorize("hasRole('USER')") + override fun downloadBlueprint(request: BluePrintDownloadInput, + responseObserver: StreamObserver<BluePrintManagementOutput>) { + runBlocking { + val blueprintName = request.actionIdentifiers.blueprintName + val blueprintVersion = request.actionIdentifiers.blueprintVersion + val blueprint = "blueprint $blueprintName:$blueprintVersion" + + /** Get the Search Action */ + val searchAction = request.actionIdentifiers?.actionName.emptyTONull() + ?: DownloadAction.SEARCH.toString() + + log.info("request(${request.commonHeader.requestId}): Received download $blueprint") + try { + when (searchAction) { + DownloadAction.SEARCH.toString() -> { + val downloadByteArray = bluePrintModelHandler.download(blueprintName, blueprintVersion) + responseObserver.onNext(outputWithFileBytes(request.commonHeader, downloadByteArray)) + } + else -> { + responseObserver.onNext(failStatus(request.commonHeader, + "Search action($searchAction) not implemented", + BluePrintProcessorException("Not implemented"))) + } + } } catch (e: Exception) { - responseObserver.onError(failStatus("request(${request.commonHeader.requestId}): Failed to upload CBA", e)) + responseObserver.onNext(failStatus(request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) + } finally { + responseObserver.onCompleted() } } } @@ -96,14 +137,16 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu try { bluePrintModelHandler.deleteBlueprintModel(blueprintName, blueprintVersion) responseObserver.onNext(successStatus(request.commonHeader)) - responseObserver.onCompleted() } catch (e: Exception) { - responseObserver.onError(failStatus("request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) + responseObserver.onNext(failStatus(request.commonHeader, + "request(${request.commonHeader.requestId}): Failed to delete $blueprint", e)) + } finally { + responseObserver.onCompleted() } } } - private fun enrichmentStatus(header: CommonHeader, byteArray: ByteArray): BluePrintManagementOutput = + private fun outputWithFileBytes(header: CommonHeader, byteArray: ByteArray): BluePrintManagementOutput = BluePrintManagementOutput.newBuilder() .setCommonHeader(header) .setFileChunk(FileChunk.newBuilder().setChunk(ByteString.copyFrom(byteArray))) @@ -114,21 +157,37 @@ open class BluePrintManagementGRPCHandler(private val bluePrintModelHandler: Blu .build()) .build() - private fun successStatus(header: CommonHeader): BluePrintManagementOutput = - BluePrintManagementOutput.newBuilder() - .setCommonHeader(header) - .setStatus(Status.newBuilder() - .setTimestamp(currentTimestamp()) - .setMessage(BluePrintConstants.STATUS_SUCCESS) - .setCode(200) - .build()) - .build() + private fun successStatus(header: CommonHeader, propertyContent: String? = null): BluePrintManagementOutput { + // Populate Response Payload + val propertiesBuilder = BluePrintManagementOutput.newBuilder().propertiesBuilder + propertyContent?.let { + JsonFormat.parser().merge(propertyContent, propertiesBuilder) + } + return BluePrintManagementOutput.newBuilder() + .setCommonHeader(header) + .setProperties(propertiesBuilder.build()) + .setStatus(Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_SUCCESS) + .setCode(200) + .build()) + .build() + } - private fun failStatus(message: String, e: Exception): StatusException { + private fun failStatus(header: CommonHeader, message: String, e: Exception): BluePrintManagementOutput { log.error(message, e) - return io.grpc.Status.INTERNAL - .withDescription(message) - .withCause(e) - .asException() + return BluePrintManagementOutput.newBuilder() + .setCommonHeader(header) + .setStatus(Status.newBuilder() + .setTimestamp(currentTimestamp()) + .setMessage(BluePrintConstants.STATUS_FAILURE) + .setErrorMessage(message) + .setCode(500) + .build()) + .build() +// return io.grpc.Status.INTERNAL +// .withDescription(message) +// .withCause(e) +// .asException() } } diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt index 212ffd907..526e92cea 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/handler/BluePrintModelHandler.kt @@ -123,19 +123,14 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService: @Throws(BluePrintException::class) open fun downloadBlueprintModelFileByNameAndVersion(name: String, version: String): ResponseEntity<Resource> { - val blueprintModel: BlueprintModel try { - blueprintModel = getBlueprintModelByNameAndVersion(name, version) + val archiveByteArray = download(name, version) + val fileName = "${name}_$version.zip" + return prepareResourceEntity(fileName, archiveByteArray) } catch (e: BluePrintException) { throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, String.format("Error while " + "downloading the CBA file: %s", e.message), e) } - - val fileName = blueprintModel.id + ".zip" - val file = blueprintModel.blueprintModelContent?.content - ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, - String.format("Error while downloading the CBA file: couldn't get model content")) - return prepareResourceEntity(fileName, file) } /** @@ -153,7 +148,7 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, String.format("Error while " + "downloading the CBA file: %s", e.message), e) } - val fileName = blueprintModel.id + ".zip" + val fileName = "${blueprintModel.artifactName}_${blueprintModel.artifactVersion}.zip" val file = blueprintModel.blueprintModelContent?.content ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, String.format("Error while downloading the CBA file: couldn't get model content")) @@ -319,6 +314,20 @@ open class BluePrintModelHandler(private val blueprintsProcessorCatalogService: } } + /** Common CBA download function for RestController and GRPC Handler, the [fileSource] may be + * byteArray or File Part type.*/ + open fun download(name: String, version: String): ByteArray { + try { + val blueprintModel = getBlueprintModelByNameAndVersion(name, version) + return blueprintModel.blueprintModelContent?.content + ?: throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while downloading the CBA file: couldn't get model content")) + } catch (e: BluePrintException) { + throw BluePrintException(ErrorCode.RESOURCE_NOT_FOUND.value, + String.format("Error while " + "downloading the CBA file: %s", e.message), e) + } + } + /** Common CBA Enrich function for RestController and GRPC Handler, the [fileSource] may be * byteArray or File Part type.*/ open suspend fun enrichBlueprintFileSource(fileSource: Any): ByteArray { diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt index 6e4e91abe..691cfd760 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/BluePrintManagementGRPCHandlerTest.kt @@ -20,9 +20,13 @@ package org.onap.ccsdk.cds.blueprintsprocessor.designer.api import com.google.protobuf.ByteString import io.grpc.testing.GrpcServerRule +import kotlinx.coroutines.runBlocking import org.junit.Rule import org.junit.Test import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.GRPCLibConstants +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.TokenAuthGrpcClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.grpc.service.TokenAuthGrpcClientService import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader import org.onap.ccsdk.cds.controllerblueprints.core.BluePrintConstants @@ -35,10 +39,7 @@ import org.springframework.context.annotation.ComponentScan import org.springframework.test.annotation.DirtiesContext import org.springframework.test.context.TestPropertySource import org.springframework.test.context.junit4.SpringRunner -import kotlin.test.AfterTest -import kotlin.test.BeforeTest -import kotlin.test.assertEquals -import kotlin.test.assertTrue +import kotlin.test.* @RunWith(SpringRunner::class) @EnableAutoConfiguration @@ -67,7 +68,7 @@ class BluePrintManagementGRPCHandlerTest { } @Test - fun `test upload blueprint`() { + fun `test upload and download blueprint`() { val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(grpcServerRule.channel) val id = "123_upload" val req = createUploadInputRequest(id, UploadAction.PUBLISH.toString()) @@ -77,6 +78,16 @@ class BluePrintManagementGRPCHandlerTest { assertTrue(output.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), "failed to get success status") assertEquals(id, output.commonHeader.requestId) + + val downloadId = "123_download" + val downloadReq = createDownloadInputRequest(downloadId, DownloadAction.SEARCH.toString()) + + val downloadOutput = blockingStub.downloadBlueprint(downloadReq) + assertEquals(200, downloadOutput.status.code) + assertTrue(downloadOutput.status.message.contentEquals(BluePrintConstants.STATUS_SUCCESS), + "failed to get success status") + assertNotNull(downloadOutput.fileChunk?.chunk, "failed to get cba file chunks") + assertEquals(downloadId, downloadOutput.commonHeader.requestId) } @Test @@ -96,6 +107,28 @@ class BluePrintManagementGRPCHandlerTest { assertEquals(200, output.status.code) } + /** This is Integration test sample, Do not enable this test case in server build, this is for local desktop testing*/ + private fun integrationTestGrpcManagement() { + runBlocking { + val tokenAuthGrpcClientProperties = TokenAuthGrpcClientProperties().apply { + host = "127.0.0.1" + port = 9111 + type = GRPCLibConstants.TYPE_TOKEN_AUTH + token = "Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==" + } + val basicAuthGrpcClientService = TokenAuthGrpcClientService(tokenAuthGrpcClientProperties) + val channel = basicAuthGrpcClientService.channel() + + val blockingStub = BluePrintManagementServiceGrpc.newBlockingStub(channel) + + val bluePrintUploadInput = createUploadInputRequest("12345", UploadAction.DRAFT.toString()) + + val bluePrintManagementOutput = blockingStub.uploadBlueprint(bluePrintUploadInput) + assertNotNull(bluePrintManagementOutput, "failed to get response") + } + } + + private fun createUploadInputRequest(id: String, action: String): BluePrintUploadInput { val file = normalizedFile("./src/test/resources/test-cba.zip") assertTrue(file.exists(), "couldnt get file ${file.absolutePath}") @@ -123,6 +156,23 @@ class BluePrintManagementGRPCHandlerTest { .build() } + private fun createDownloadInputRequest(id: String, action: String): BluePrintDownloadInput { + val commonHeader = CommonHeader + .newBuilder() + .setTimestamp("2012-04-23T18:25:43.511Z") + .setOriginatorId("System") + .setRequestId(id) + .setSubRequestId("1234-56").build() + + return BluePrintDownloadInput.newBuilder() + .setCommonHeader(commonHeader) + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setBlueprintName("baseconfiguration") + .setBlueprintVersion("1.0.0") + .setActionName(action).build()) + .build() + } + private fun createRemoveInputRequest(id: String): BluePrintRemoveInput { val commonHeader = CommonHeader .newBuilder() diff --git a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt index 599987361..10bf887f6 100644 --- a/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt +++ b/ms/blueprintsprocessor/modules/inbounds/designer-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/designer/api/utils/BluePrintEnhancerUtilsTest.kt @@ -22,13 +22,12 @@ import org.junit.Before import org.junit.Test import org.onap.ccsdk.cds.blueprintsprocessor.designer.api.mock.MockFilePart import org.onap.ccsdk.cds.controllerblueprints.core.* -import java.nio.file.Paths import java.util.* import kotlin.test.assertTrue class BluePrintEnhancerUtilsTest { - private val blueprintDir = "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" + private val blueprintDir = "./../../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration" private val blueprintArchivePath: String = "./target/blueprints/archive" private val blueprintEnrichmentPath: String = "./target/blueprints/enrichment" private var zipBlueprintFileName = normalizedPathName(blueprintArchivePath, "test.zip") @@ -39,7 +38,7 @@ class BluePrintEnhancerUtilsTest { assertTrue(archiveDir.exists(), "failed to create archiveDir(${archiveDir.absolutePath}") val enhancerDir = normalizedFile(blueprintEnrichmentPath).reCreateDirs() assertTrue(enhancerDir.exists(), "failed to create enhancerDir(${enhancerDir.absolutePath}") - val blueprintFile = Paths.get(blueprintDir).toFile().normalize() + val blueprintFile = normalizedFile(blueprintDir) val testZipFile = blueprintFile.compress(zipBlueprintFileName) assertTrue(testZipFile.exists(), "Failed to create blueprint test zip(${testZipFile.absolutePath}") } diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml new file mode 100644 index 000000000..6037804af --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/pom.xml @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2019-2020 Orange. + + ~ + ~ 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. + --> +<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <artifactId>inbounds</artifactId> + <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> + <version>0.7.0-SNAPSHOT</version> + </parent> + <artifactId>health-api</artifactId> + + <packaging>jar</packaging> + <name>Blueprints Processor Health API</name> + <description>checking system check health endpoints</description> + + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> + <artifactId>rest-lib</artifactId> + </dependency> + </dependencies> +</project> diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt new file mode 100644 index 000000000..0a97d37c5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/configuration/BasicAuthRestClientServiceConfiguration.kt @@ -0,0 +1,50 @@ +/* + * Copyright © 2019-2020 Orange. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.configuration + +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.springframework.beans.factory.annotation.Value +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration +import org.springframework.context.annotation.PropertySource + +@Configuration +@PropertySource("classpath:application.properties") +open class BasicAuthRestClientServiceConfiguration { + + @Value("\${endpoints.user.name}") + private val username: String? = null + + @Value("\${endpoints.user.password}") + private val password: String? = null + + @Bean + open fun getBasicAuthRestClientProperties(): BasicAuthRestClientProperties { + val basicAuthRestClientProperties = BasicAuthRestClientProperties() + basicAuthRestClientProperties.username = username.toString() + basicAuthRestClientProperties.password = password.toString() + return basicAuthRestClientProperties + } + + @Bean + open fun getBasicAuthRestClientService(): BasicAuthRestClientService { + return BasicAuthRestClientService(getBasicAuthRestClientProperties()) + } + + +} diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt new file mode 100644 index 000000000..1283ac5ac --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/controller/HealthCheckController.kt @@ -0,0 +1,48 @@ +/* + * Copyright © 2019-2020 Orange. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.controller + +import io.swagger.annotations.Api +import io.swagger.annotations.ApiOperation +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.HealthCheckService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.MediaType +import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestMethod +import org.springframework.web.bind.annotation.ResponseBody +import org.springframework.web.bind.annotation.RestController + +@RestController +@RequestMapping("/api/v1/health") +@Api(value = "/api/v1/health", + description = "gather all HealthCheckResponses for HealthChecks known to the runtime") +open class HealthCheckController { + + @Autowired + lateinit var healthApiService: HealthCheckService + + @RequestMapping(path = [""], + method = [RequestMethod.GET], + produces = [MediaType.APPLICATION_JSON_VALUE]) + @ResponseBody + @ApiOperation(value = "Health Check", hidden = true) + fun getSystemHealthCheckResponse(): ResponseEntity<HealthApiResponse> { + return ResponseEntity.ok().body(healthApiService.retrieveSystemStatus()) + } +} diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt new file mode 100644 index 000000000..4dac178e5 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthApiResponse.kt @@ -0,0 +1,6 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain + + +data class HealthApiResponse(val status: HealthCheckStatus, val checks:List<HealthCheckResponse>) + + diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt new file mode 100644 index 000000000..acac867cb --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckResponse.kt @@ -0,0 +1,6 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain + + +data class HealthCheckResponse(val name: String, val status: HealthCheckStatus) + + diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt new file mode 100644 index 000000000..a891a40d3 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/HealthCheckStatus.kt @@ -0,0 +1,6 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain + +enum class HealthCheckStatus { + UP, + DOWN +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt new file mode 100644 index 000000000..8fbc33b47 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/domain/ServiceEndpoint.kt @@ -0,0 +1,5 @@ +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain + + + +data class ServiceEndpoint(val serviceName: String, val serviceLink: String) diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt new file mode 100644 index 000000000..09fdb67f2 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/service/HealthCheckService.kt @@ -0,0 +1,91 @@ +/* + * Copyright © 2019-2020 Orange. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service + +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckResponse +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.ServiceEndpoint +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.http.HttpMethod +import org.springframework.stereotype.Service + + +@Service +class HealthCheckService { + + private var logger = LoggerFactory.getLogger(HealthCheckService::class.java) + + @Autowired + lateinit var basicAuthRestClientService: BasicAuthRestClientService + + @Autowired + lateinit var restClientProperties: BasicAuthRestClientProperties + + + open fun setupServiceEndpoint(): List<ServiceEndpoint> { + return listOf(ServiceEndpoint("Execution service", "http://cds-blueprints-processor-http:8080/api/v1/execution-service/health-check"), + ServiceEndpoint("Template service", "http://cds-blueprints-processor-http:8080/api/v1/template/health-check"), + ServiceEndpoint("Resources service", "http://cds-blueprints-processor-http:8080/api/v1/resources/health-check"), + ServiceEndpoint("SDC Listener service", "http://cds-sdc-listener:8080/api/v1/sdclistener/health-check") + ) + } + + fun retrieveSystemStatus(): HealthApiResponse { + logger.info("Retrieve System Status") + var healthApiResponse: HealthApiResponse + val listOfResponse = mutableListOf<HealthCheckResponse>() + var systemStatus: HealthCheckStatus = HealthCheckStatus.UP + + for (serviceEndpoint in setupServiceEndpoint().parallelStream()) { + var serviceStatus: HealthCheckStatus = retrieveServiceStatus(serviceEndpoint) + if (serviceStatus.equals(HealthCheckStatus.DOWN)) + systemStatus = HealthCheckStatus.DOWN + + listOfResponse.add(HealthCheckResponse(serviceEndpoint.serviceName, serviceStatus)) + } + healthApiResponse = HealthApiResponse(systemStatus, listOfResponse) + return healthApiResponse + } + + private fun retrieveServiceStatus(serviceEndpoint: ServiceEndpoint): HealthCheckStatus { + var serviceStatus: HealthCheckStatus = HealthCheckStatus.UP + try { + addClientPropertiesConfiguration(serviceEndpoint) + val result: BlueprintWebClientService.WebClientResponse<String> = basicAuthRestClientService.exchangeResource(HttpMethod.GET.name, "", "") + if (result == null || result.status != 200) { + serviceStatus = HealthCheckStatus.DOWN + + } + } catch (e: Exception) { + logger.error("service is down" + e) + serviceStatus = HealthCheckStatus.DOWN + + } + return serviceStatus + } + + private fun addClientPropertiesConfiguration(serviceEndpoint: ServiceEndpoint) { + restClientProperties.url = serviceEndpoint.serviceLink + } + + +} diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties new file mode 100644 index 000000000..aca95b481 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/main/resources/application.properties @@ -0,0 +1,18 @@ +# +# Copyright � 2019-2020 Orange. +# +# 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. +# + +endpoints.user.name=ccsdkapps +endpoints.user.password=ccsdkapps diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt new file mode 100644 index 000000000..cd02b65dc --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckApplicationTests.kt @@ -0,0 +1,55 @@ +/* + * Copyright © 2019-2020 Orange. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi + + +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintCoreConfiguration +import org.onap.ccsdk.cds.controllerblueprints.core.interfaces.BluePrintCatalogService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.boot.autoconfigure.security.SecurityProperties +import org.springframework.boot.test.autoconfigure.web.reactive.WebFluxTest +import org.springframework.context.annotation.ComponentScan +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import org.springframework.test.web.reactive.server.WebTestClient + + +@RunWith(SpringRunner::class) +@WebFluxTest +@ContextConfiguration(classes = [BluePrintCoreConfiguration::class, + BluePrintCatalogService::class, SecurityProperties::class]) +@ComponentScan(basePackages = ["org.onap.ccsdk.cds.blueprintsprocessor", "org.onap.ccsdk.cds.controllerblueprints"]) +@TestPropertySource(locations = ["classpath:application-test.properties"]) +class HealthCheckApplicationTests { + + + @Autowired + lateinit var webTestClient: WebTestClient + + @Test + fun testHealthApiUp() { + val result = webTestClient.get().uri("/api/v1/health") + .exchange() + .expectStatus().is2xxSuccessful + println(result) + } + + +} diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java new file mode 100644 index 000000000..8fb5e58fc --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/healthapi/HealthCheckServiceTest.java @@ -0,0 +1,137 @@ +/* + * Copyright © 2019-2020 Orange. + * + * 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. + */ + +package org.onap.ccsdk.cds.blueprintsprocessor.healthapi; + + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.anyString; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthApiResponse; +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.domain.HealthCheckStatus; +import org.onap.ccsdk.cds.blueprintsprocessor.healthapi.service.HealthCheckService; +import org.onap.ccsdk.cds.blueprintsprocessor.rest.BasicAuthRestClientProperties; +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BasicAuthRestClientService; +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService.WebClientResponse; +import org.springframework.http.HttpMethod; + +@RunWith(MockitoJUnitRunner.class) +public class HealthCheckServiceTest { + + @Mock + private BasicAuthRestClientService basicAuthRestClientService; + + @Mock + private BasicAuthRestClientProperties restClientProperties; + + @InjectMocks + private HealthCheckService healthCheckService = new HealthCheckService(); + + @Before + public void setup() { + } + + @Test + public void testSystemIsCompletelyDown() { + + Mockito.when(basicAuthRestClientService.exchangeResource(anyString(), anyString(), anyString())). + thenThrow(new RuntimeException()); + HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus(); + assertNotNull(healthApiResponse); + Assert.assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN); + healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> { + assertNotNull(serviceEndpoint); + assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN); + + }); + + } + + + @Test + public void testSystemIsUPAndRunning() { + + Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), anyString(), anyString())). + thenReturn(new WebClientResponse<>(200, "Success")); + HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus(); + assertNotNull(healthApiResponse); + assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.UP); + healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> { + assertNotNull(serviceEndpoint); + assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.UP); + + }); + + } + + @Test + public void testServiceIsNotFound() { + Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString())). + thenReturn(new WebClientResponse<>(404, "failure")); + HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus(); + assertNotNull(healthApiResponse); + assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN); + healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> { + assertNotNull(serviceEndpoint); + assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN); + + }); + + } + + + @Test + public void testServiceInternalServerError() { + Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString())) + .thenReturn(new WebClientResponse<>(500, "failure")); + HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus(); + assertNotNull(healthApiResponse); + assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN); + healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> { + assertNotNull(serviceEndpoint); + assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN); + + }); + + } + + @Test + public void testServiceIsRedirected() { + Mockito.when(basicAuthRestClientService.exchangeResource(eq(HttpMethod.GET.name()), any(), anyString())) + .thenReturn(new WebClientResponse<>(300, "failure")); + HealthApiResponse healthApiResponse = healthCheckService.retrieveSystemStatus(); + assertNotNull(healthApiResponse); + assertEquals(healthApiResponse.getStatus(), HealthCheckStatus.DOWN); + healthApiResponse.getChecks().stream().forEach(serviceEndpoint -> { + assertNotNull(serviceEndpoint); + assertEquals(serviceEndpoint.getStatus(), HealthCheckStatus.DOWN); + + }); + + } + +} diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties new file mode 100644 index 000000000..c9a5700c1 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/application-test.properties @@ -0,0 +1,31 @@ +# Copyright © 2019 Bell Canada. +# +# 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. + +blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 +blueprintsprocessor.db.username=sa +blueprintsprocessor.db.password= +blueprintsprocessor.db.driverClassName=org.h2.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect +# Controller Blueprints Core Configuration +blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy +blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work +blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive + +# Python executor +blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints +blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints +server.socket=localhost:8080 diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml new file mode 100644 index 000000000..ed92b8963 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/logback.xml @@ -0,0 +1,35 @@ +<!-- + ~ Copyright © 2019 Bell Canada + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="info"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker new file mode 100644 index 000000000..1f0955d45 --- /dev/null +++ b/ms/blueprintsprocessor/modules/inbounds/health-api/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker @@ -0,0 +1 @@ +mock-maker-inline diff --git a/ms/blueprintsprocessor/modules/inbounds/pom.xml b/ms/blueprintsprocessor/modules/inbounds/pom.xml index 0542fe380..a1d716110 100644 --- a/ms/blueprintsprocessor/modules/inbounds/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/pom.xml @@ -33,6 +33,7 @@ <module>designer-api</module> <module>resource-api</module> <module>selfservice-api</module> + <module>health-api</module> </modules> <dependencies> <dependency> diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/application-test.properties b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/application-test.properties index 7d74687ab..cb7837ba4 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/application-test.properties +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/application-test.properties @@ -1,33 +1,33 @@ -#
-# Copyright � 2017-2018 AT&T Intellectual Property.
-#
-# Modifications Copyright � 2019 IBM, Bell Canada.
-#
-# 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.
-#
-blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1
-blueprintsprocessor.db.username=sa
-blueprintsprocessor.db.password=
-blueprintsprocessor.db.driverClassName=org.h2.Driver
-blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop
-blueprintsprocessor.db.hibernateDDLAuto=update
-blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy
-blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect
-# Controller Blueprints Core Configuration
-blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy
-blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work
-blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive
-
-# Python executor
-blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints
-blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
+# +# Copyright � 2017-2018 AT&T Intellectual Property. +# +# Modifications Copyright � 2019 IBM, Bell Canada. +# +# 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. +# +blueprintsprocessor.db.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1 +blueprintsprocessor.db.username=sa +blueprintsprocessor.db.password= +blueprintsprocessor.db.driverClassName=org.h2.Driver +blueprintsprocessor.db.hibernateHbm2ddlAuto=create-drop +blueprintsprocessor.db.hibernateDDLAuto=update +blueprintsprocessor.db.hibernateNamingStrategy=org.hibernate.cfg.ImprovedNamingStrategy +blueprintsprocessor.db.hibernateDialect=org.hibernate.dialect.H2Dialect +# Controller Blueprints Core Configuration +blueprintsprocessor.blueprintDeployPath=./target/blueprints/deploy +blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work +blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive + +# Python executor +blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints +blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints diff --git a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/logback.xml index 56b077424..c546502cf 100644 --- a/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/logback.xml +++ b/ms/blueprintsprocessor/modules/inbounds/resource-api/src/test/resources/logback.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="info">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} %-5level %logger{100} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="info"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml index 7c53e1c04..b5cac581a 100755 --- a/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml +++ b/ms/blueprintsprocessor/modules/inbounds/selfservice-api/pom.xml @@ -33,10 +33,9 @@ <dependencies> <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>blueprint-proto</artifactId> </dependency> - <dependency> <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>blueprint-core</artifactId> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml index 4acc22433..784906b4e 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/pom.xml +++ b/ms/blueprintsprocessor/modules/services/execution-service/pom.xml @@ -57,10 +57,6 @@ <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>resource-dict</artifactId> </dependency> - <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> - </dependency> <dependency> <groupId>org.onap.ccsdk.sli.core</groupId> diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json index cd6fac128..52a8a4f84 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/inputs/input.json @@ -1,18 +1,18 @@ -{
- "api-ver": "2.00",
- "originator-id": "MSO",
- "request-id": "123456",
- "service-instance-id": "ibcx0001vm001",
- "service-type": "AVPN",
- "vnf-type": "vUSP - vDBE-IPX HUB",
- "vnf-id": 123456,
- "service-template-name": "VRR-baseconfiguration",
- "service-template-version": "1.0.0",
- "action-name": "resource-assignment-action",
- "group-name": "sample group name",
- "bundle-id": "sample bundle id",
- "bundle-mac": [
- "Sample bundle mac",
- "Sample bundle mac"
- ]
-}
+{ + "api-ver": "2.00", + "originator-id": "MSO", + "request-id": "123456", + "service-instance-id": "ibcx0001vm001", + "service-type": "AVPN", + "vnf-type": "vUSP - vDBE-IPX HUB", + "vnf-id": 123456, + "service-template-name": "VRR-baseconfiguration", + "service-template-version": "1.0.0", + "action-name": "resource-assignment-action", + "group-name": "sample group name", + "bundle-id": "sample bundle id", + "bundle-mac": [ + "Sample bundle mac", + "Sample bundle mac" + ] +} diff --git a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json index b28ac5a29..27eec8275 100644 --- a/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json +++ b/ms/blueprintsprocessor/modules/services/execution-service/src/test/resources/payload/requests/sample-execution-request.json @@ -1,20 +1,20 @@ -{
- "actionIdentifiers": {
- "actionName": "sample-action",
- "blueprintName": "sample-blurprint",
- "blueprintVersion": "1.0.0",
- "mode": "sync"
- },
- "commonHeader": {
- "flags": {
- "force": true,
- "ttl": 3600
- },
- "originatorId": "sdnc",
- "requestId": "123456-1000",
- "subRequestId": "sub-123456-1000",
- "timestamp": "2012-04-23T18:25:43.511Z"
- },
- "payload": {
- }
-}
+{ + "actionIdentifiers": { + "actionName": "sample-action", + "blueprintName": "sample-blurprint", + "blueprintVersion": "1.0.0", + "mode": "sync" + }, + "commonHeader": { + "flags": { + "force": true, + "ttl": 3600 + }, + "originatorId": "sdnc", + "requestId": "123456-1000", + "subRequestId": "sub-123456-1000", + "timestamp": "2012-04-23T18:25:43.511Z" + }, + "payload": { + } +} diff --git a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml index 56e662286..32459375e 100644 --- a/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml +++ b/ms/blueprintsprocessor/modules/services/workflow-service/src/test/resources/logback.xml @@ -1,35 +1,35 @@ -<!--
- ~ Copyright © 2017-2018 AT&T Intellectual Property.
- ~
- ~ 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.
- -->
-
-<configuration>
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <!-- encoders are assigned the type
- ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
- <encoder>
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="org.springframework" level="warn"/>
- <logger name="org.hibernate" level="info"/>
- <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/>
-
- <root level="warn">
- <appender-ref ref="STDOUT"/>
- </root>
-
-</configuration>
+<!-- + ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ + ~ 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. + --> + +<configuration> + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <!-- encoders are assigned the type + ch.qos.logback.classic.encoder.PatternLayoutEncoder by default --> + <encoder> + <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern> + </encoder> + </appender> + + + <logger name="org.springframework" level="warn"/> + <logger name="org.hibernate" level="info"/> + <logger name="org.onap.ccsdk.cds.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 5a54a7717..cd4056485 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -37,7 +37,7 @@ <jython.version>2.7.1</jython.version> <!-- Should be using released artifact as soon as available:--> <!-- https://github.com/springfox/springfox/milestone/44--> - <springfox.swagger2.version>3.0.0-SNAPSHOT</springfox.swagger2.version> + <springfox.swagger2.version>2.9.2</springfox.swagger2.version> <h2database.version>1.4.197</h2database.version> <onap.logger.slf4j>1.2.2</onap.logger.slf4j> <powermock.version>1.7.4</powermock.version> @@ -96,17 +96,17 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>io.springfox</groupId> - <artifactId>springfox-spring-webflux</artifactId> - <version>${springfox.swagger2.version}</version> - <exclusions> - <exclusion> - <groupId>org.slf4j</groupId> - <artifactId>slf4j-api</artifactId> - </exclusion> - </exclusions> - </dependency> +<!-- <dependency>--> +<!-- <groupId>io.springfox</groupId>--> +<!-- <artifactId>springfox-spring-webflux</artifactId>--> +<!-- <version>${springfox.swagger2.version}</version>--> +<!-- <exclusions>--> +<!-- <exclusion>--> +<!-- <groupId>org.slf4j</groupId>--> +<!-- <artifactId>slf4j-api</artifactId>--> +<!-- </exclusion>--> +<!-- </exclusions>--> +<!-- </dependency>--> <!-- Common Utils Dependencies --> <dependency> @@ -248,11 +248,7 @@ <artifactId>protobuf-java-util</artifactId> <version>${protobuff.java.utils.version}</version> </dependency> - <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> - <version>${project.version}</version> - </dependency> + <!-- Adaptors --> <dependency> @@ -371,6 +367,12 @@ <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> + <artifactId>health-api</artifactId> + <version>${project.version}</version> + </dependency> + <!-- North Bound --> <dependency> <groupId>org.onap.ccsdk.cds.blueprintsprocessor</groupId> @@ -460,6 +462,11 @@ </dependency> <dependency> <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>blueprint-proto</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> <artifactId>blueprint-validation</artifactId> <version>${project.version}</version> </dependency> @@ -569,10 +576,10 @@ </exclusion> </exclusions> </dependency> - <dependency> - <groupId>io.springfox</groupId> - <artifactId>springfox-spring-webflux</artifactId> - </dependency> +<!-- <dependency>--> +<!-- <groupId>io.springfox</groupId>--> +<!-- <artifactId>springfox-spring-webflux</artifactId>--> +<!-- </dependency>--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> diff --git a/ms/controllerblueprints/.gitignore b/ms/controllerblueprints/.gitignore deleted file mode 100644 index 4b5c1c0a4..000000000 --- a/ms/controllerblueprints/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -/target/
-/logs/
-.classpath
-.settings/
-
-# Target dirs in all projects
-**/target-ide/*
-**/target/*
-**/logs/*
-**/debug-logs/*
-**/tokens/*
-
-# Added for Intellij IDEA IDE
-**/debug-logs/*
-**/.idea/*
-**/*.iml
-**/*.project
-**/.springBeans
-**/.directory
-
-
-**/*versionsBackup
-**/blackDuckHub*
-**/*.jsonld
-/target-ide/
diff --git a/ms/controllerblueprints/README.md b/ms/controllerblueprints/README.md index b96dbf71a..0cb7a131b 100755 --- a/ms/controllerblueprints/README.md +++ b/ms/controllerblueprints/README.md @@ -1,13 +1,13 @@ -Application VM Arguments :
-
--DappName=ControllerBluePrints
--Dms_name=org.onap.ccsdk.cds.controllerblueprints
--DappVersion=1.0.0
--Dlogging.config=etc/logback.xml
--Dspring.config.location=opt/app/onap/config/
--Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl
--Dspring.datasource.username=sdnctl
--Dspring.datasource.password=sdnctl
--Dcontrollerblueprints.loadInitialData=true
--Dspring.profiles.active=dev
-
+Application VM Arguments : + +-DappName=ControllerBluePrints +-Dms_name=org.onap.ccsdk.cds.controllerblueprints +-DappVersion=1.0.0 +-Dlogging.config=etc/logback.xml +-Dspring.config.location=opt/app/onap/config/ +-Dspring.datasource.url=jdbc:mysql://127.0.0.1:3306/sdnctl +-Dspring.datasource.username=sdnctl +-Dspring.datasource.password=sdnctl +-Dcontrollerblueprints.loadInitialData=true +-Dspring.profiles.active=dev + diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt index fa6b0ab97..f90e27f4d 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/cds/controllerblueprints/core/scripts/BluePrintCompilerCache.kt @@ -39,6 +39,10 @@ object BluePrintCompileCache { fun cleanClassLoader(key: String) { if(hasClassLoader(key)){ + // Make sure to close all classloader loaded resources before we let go of it. + // This fixes a Delete failure message on filesystem that keeps locks on opened jars; + // like Windows and NFS. + classLoaderCache.get(key).close() classLoaderCache.invalidate(key) log.info("Cleaned compiled cache($key)") }else{ diff --git a/ms/controllerblueprints/modules/blueprint-proto/krotoPlusConfig.asciipb b/ms/controllerblueprints/modules/blueprint-proto/krotoPlusConfig.asciipb new file mode 100644 index 000000000..30255b96d --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-proto/krotoPlusConfig.asciipb @@ -0,0 +1,6 @@ +grpc_coroutines { + filter { exclude_path: "google/*" } +} +grpc_stub_exts { + support_coroutines: true +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-proto/pom.xml b/ms/controllerblueprints/modules/blueprint-proto/pom.xml new file mode 100644 index 000000000..7d4d60028 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-proto/pom.xml @@ -0,0 +1,113 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2019 IBM. + ~ + ~ 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. + --> + +<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"> + <parent> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>modules</artifactId> + <version>0.7.0-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>blueprint-proto</artifactId> + <name>Controller Blueprints Proto</name> + <description>Controller Blueprints Proto</description> + + <dependencies> + <dependency> + <groupId>com.github.marcoferrer.krotoplus</groupId> + <artifactId>kroto-plus-coroutines</artifactId> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>kr.motd.maven</groupId> + <artifactId>os-maven-plugin</artifactId> + <version>1.6.2</version> + </extension> + </extensions> + <plugins> + <plugin> + <groupId>org.xolstice.maven.plugins</groupId> + <artifactId>protobuf-maven-plugin</artifactId> + <version>0.6.1</version> + <configuration> + <protocArtifact> + com.google.protobuf:protoc:3.6.1:exe:${os.detected.classifier} + </protocArtifact> + <protoSourceRoot>${project.basedir}/../../../../components/model-catalog/proto-definition/proto + </protoSourceRoot> + </configuration> + <executions> + <execution> + <goals> + <goal>compile</goal> + </goals> + </execution> + <execution> + <id>grpc-java</id> + <goals> + <goal>compile-custom</goal> + </goals> + <configuration> + <pluginId>grpc-java</pluginId> + <pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier} + </pluginArtifact> + </configuration> + </execution> +<!-- <execution>--> +<!-- <id>grpc-coroutines</id>--> +<!-- <goals>--> +<!-- <goal>compile-custom</goal>--> +<!-- </goals>--> +<!-- <configuration>--> +<!-- <pluginId>kroto-plus</pluginId>--> +<!-- <pluginArtifact>--> +<!-- com.github.marcoferrer.krotoplus:protoc-gen-kroto-plus:${kroto-plus.version}:jar:jvm8--> +<!-- </pluginArtifact>--> +<!-- <pluginParameter>ConfigPath=${project.basedir}/krotoPlusConfig.asciipb</pluginParameter>--> +<!-- </configuration>--> +<!-- </execution>--> + </executions> + </plugin> + <plugin> + <artifactId>kotlin-maven-plugin</artifactId> + <groupId>org.jetbrains.kotlin</groupId> + <version>${kotlin.maven.version}</version> + <executions> + <execution> + <id>compile</id> + <goals> + <goal>compile</goal> + </goals> + <configuration> + <sourceDirs> + <sourceDir>${project.basedir}/target/generated-sources/protobuf/java</sourceDir> + <sourceDir>${project.basedir}/target/generated-sources/protobuf/grpc-java</sourceDir> +<!-- <sourceDir>${project.basedir}/target/generated-sources/protobuf/kroto-plus</sourceDir>--> + </sourceDirs> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/ms/controllerblueprints/modules/pom.xml b/ms/controllerblueprints/modules/pom.xml index 73b231316..6cb4ea80a 100644 --- a/ms/controllerblueprints/modules/pom.xml +++ b/ms/controllerblueprints/modules/pom.xml @@ -31,6 +31,7 @@ <module>blueprint-core</module> <module>resource-dict</module> <module>blueprint-validation</module> + <module>blueprint-proto</module> </modules> <dependencies> diff --git a/ms/controllerblueprints/parent/pom.xml b/ms/controllerblueprints/parent/pom.xml index 925b1678a..86a721149 100644 --- a/ms/controllerblueprints/parent/pom.xml +++ b/ms/controllerblueprints/parent/pom.xml @@ -30,6 +30,7 @@ <properties> <eelf.version>1.0.0</eelf.version> <guava.version>27.0.1-jre</guava.version> + <kroto-plus.version>0.5.0</kroto-plus.version> <springfox.swagger2.version>2.9.2</springfox.swagger2.version> <h2database.version>1.4.197</h2database.version> <onap.logger.slf4j>1.2.2</onap.logger.slf4j> @@ -200,6 +201,11 @@ <artifactId>protobuf-java-util</artifactId> <version>${protobuff.java.utils.version}</version> </dependency> + <dependency> + <groupId>com.github.marcoferrer.krotoplus</groupId> + <artifactId>kroto-plus-coroutines</artifactId> + <version>${kroto-plus.version}</version> + </dependency> <!-- Database --> <dependency> diff --git a/ms/sdclistener/application/pom.xml b/ms/sdclistener/application/pom.xml index da24e97bc..7b12e14ea 100644 --- a/ms/sdclistener/application/pom.xml +++ b/ms/sdclistener/application/pom.xml @@ -90,8 +90,8 @@ <scope>test</scope> </dependency> <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>blueprint-proto</artifactId> </dependency> <dependency> diff --git a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java index 77f3ea536..1937af75c 100644 --- a/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java +++ b/ms/sdclistener/application/src/main/java/org/onap/ccsdk/cds/sdclistener/service/ListenerServiceImpl.java @@ -15,30 +15,16 @@ */ package org.onap.ccsdk.cds.sdclistener.service; -import static java.lang.String.format; -import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT; -import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR; -import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Enumeration; -import java.util.List; -import java.util.regex.Pattern; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; import org.apache.commons.io.FileUtils; import org.apache.tomcat.util.http.fileupload.IOUtils; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput; import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk; +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction; import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; import org.onap.ccsdk.cds.sdclistener.dto.SdcListenerDto; import org.onap.ccsdk.cds.sdclistener.handler.BluePrintProcesssorHandler; @@ -52,6 +38,22 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Enumeration; +import java.util.List; +import java.util.UUID; +import java.util.regex.Pattern; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +import static java.lang.String.format; +import static org.onap.ccsdk.cds.sdclistener.status.SdcListenerStatus.NotificationType.SDC_LISTENER_COMPONENT; +import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_ERROR; +import static org.onap.sdc.utils.DistributionStatusEnum.COMPONENT_DONE_OK; + @Component @ConfigurationProperties("listenerservice") public class ListenerServiceImpl implements ListenerService { @@ -216,6 +218,13 @@ public class ListenerServiceImpl implements ListenerService { FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build(); FileUtil.deleteFile(file, path); return BluePrintUploadInput.newBuilder() + .setCommonHeader(CommonHeader.newBuilder() + .setRequestId(UUID.randomUUID().toString()) + .setSubRequestId(UUID.randomUUID().toString()) + .setOriginatorId("SDC-LISTENER") + .build()) + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setActionName(UploadAction.PUBLISH.toString()).build()) .setFileChunk(fileChunk) .build(); } diff --git a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java index ee20f8771..7a92c0040 100644 --- a/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java +++ b/ms/sdclistener/application/src/test/java/org/onap/ccsdk/cds/sdclistener/handler/BluePrintProcessorHandlerTest.java @@ -15,33 +15,39 @@ */ package org.onap.ccsdk.cds.sdclistener.handler; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; import com.google.protobuf.ByteString; import io.grpc.ManagedChannel; import io.grpc.inprocess.InProcessChannelBuilder; import io.grpc.inprocess.InProcessServerBuilder; import io.grpc.stub.StreamObserver; import io.grpc.testing.GrpcCleanupRule; -import java.io.File; -import java.io.IOException; -import java.nio.file.Paths; import org.apache.commons.io.FileUtils; import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; -import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; +import org.onap.ccsdk.cds.controllerblueprints.common.api.ActionIdentifiers; +import org.onap.ccsdk.cds.controllerblueprints.common.api.CommonHeader; import org.onap.ccsdk.cds.controllerblueprints.common.api.Status; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementOutput; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintManagementServiceGrpc.BluePrintManagementServiceImplBase; import org.onap.ccsdk.cds.controllerblueprints.management.api.BluePrintUploadInput; import org.onap.ccsdk.cds.controllerblueprints.management.api.FileChunk; +import org.onap.ccsdk.cds.controllerblueprints.management.api.UploadAction; +import org.onap.ccsdk.cds.sdclistener.client.SdcListenerAuthClientInterceptor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import java.io.File; +import java.io.IOException; +import java.nio.file.Paths; +import java.util.UUID; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + @RunWith(SpringRunner.class) @EnableConfigurationProperties({BluePrintProcesssorHandler.class, SdcListenerAuthClientInterceptor.class}) @SpringBootTest(classes = {BluePrintProcessorHandlerTest.class}) @@ -66,7 +72,7 @@ public class BluePrintProcessorHandlerTest { final BluePrintManagementServiceImplBase serviceImplBase = new BluePrintManagementServiceImplBase() { @Override public void uploadBlueprint(BluePrintUploadInput request, - StreamObserver<BluePrintManagementOutput> responseObserver) { + StreamObserver<BluePrintManagementOutput> responseObserver) { responseObserver.onNext(getBluePrintManagementOutput()); responseObserver.onCompleted(); } @@ -77,7 +83,7 @@ public class BluePrintProcessorHandlerTest { // Create a server, add service, start, and register. grpcCleanup.register( - InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor().build().start()); + InProcessServerBuilder.forName(serverName).addService(serviceImplBase).directExecutor().build().start()); // Create a client channel. channel = grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build()); @@ -101,7 +107,16 @@ public class BluePrintProcessorHandlerTest { byte[] bytes = FileUtils.readFileToByteArray(file); FileChunk fileChunk = FileChunk.newBuilder().setChunk(ByteString.copyFrom(bytes)).build(); - return BluePrintUploadInput.newBuilder().setFileChunk(fileChunk).build(); + + return BluePrintUploadInput.newBuilder() + .setCommonHeader(CommonHeader.newBuilder() + .setRequestId(UUID.randomUUID().toString()) + .setSubRequestId(UUID.randomUUID().toString()) + .setOriginatorId("SDC-LISTENER") + .build()) + .setActionIdentifiers(ActionIdentifiers.newBuilder() + .setActionName(UploadAction.PUBLISH.toString()).build()) + .setFileChunk(fileChunk).build(); } private BluePrintManagementOutput getBluePrintManagementOutput() { diff --git a/ms/sdclistener/parent/pom.xml b/ms/sdclistener/parent/pom.xml index cfdfc9b24..05bfdeff4 100755 --- a/ms/sdclistener/parent/pom.xml +++ b/ms/sdclistener/parent/pom.xml @@ -16,7 +16,8 @@ ~ See the License for the specific language governing permissions and ~ limitations under the License. --> -<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"> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.cds</groupId> @@ -110,9 +111,15 @@ <version>${protobuff.java.utils.version}</version> </dependency> <dependency> - <groupId>org.onap.ccsdk.cds.components</groupId> - <artifactId>proto-definition</artifactId> - <version>${project.version}</version> + <groupId>org.onap.ccsdk.cds.controllerblueprints</groupId> + <artifactId>blueprint-proto</artifactId> + <version>${project.version}</version> + <exclusions> + <exclusion> + <groupId>*</groupId> + <artifactId>*</artifactId> + </exclusion> + </exclusions> </dependency> <dependency> <groupId>io.projectreactor</groupId> |