diff options
Diffstat (limited to 'ms')
22 files changed, 449 insertions, 129 deletions
diff --git a/ms/blueprintsprocessor/distribution/pom.xml b/ms/blueprintsprocessor/distribution/pom.xml index fb5e3c12..b3eabc10 100755 --- a/ms/blueprintsprocessor/distribution/pom.xml +++ b/ms/blueprintsprocessor/distribution/pom.xml @@ -14,7 +14,9 @@ ~ 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.apps.blueprintsprocessor</groupId> @@ -33,6 +35,8 @@ <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> <docker.push.phase>deploy</docker.push.phase> <docker.verbose>true</docker.verbose> + <ccsdk.project.version>${project.version}</ccsdk.project.version> + <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> </properties> <dependencies> @@ -77,7 +81,8 @@ <phase>package</phase> <configuration> <tasks> - <fixcrlf srcdir="${basedir}" eol="unix" includes="**/*.sh, **/*.source"/> + <fixcrlf srcdir="${basedir}" eol="unix" + includes="**/*.sh, **/*.source" /> </tasks> </configuration> <goals> @@ -91,7 +96,7 @@ <artifactId>maven-assembly-plugin</artifactId> <version>3.1.0</version> <configuration> - <!-- <skipAssembly>${skip.assembly}</skipAssembly>--> + <!-- <skipAssembly>${skip.assembly}</skipAssembly> --> <outputDirectory>${basedir}/target/docker-stage</outputDirectory> <descriptors> <descriptor>src/main/docker/distribution.xml</descriptor> @@ -119,22 +124,7 @@ <goal>execute</goal> </goals> <configuration> - <source> - println project.properties['ccsdk.project.version'] - def versionArray - if (project.properties['ccsdk.project.version'] != null ) { - versionArray = project.properties['ccsdk.project.version'].split('\\.') - } - - if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) - { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest" - } else { - project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest" - } - - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'] - </source> + <source>${basedir}/../../../TagVersion.groovy</source> </configuration> </execution> </executions> @@ -147,30 +137,30 @@ <profile> <id>docker</id> <build> - <plugins> - <plugin> - <groupId>io.fabric8</groupId> - <artifactId>docker-maven-plugin</artifactId> - <version>0.26.1</version> - <inherited>false</inherited> - <configuration> - <images> - <image> - <name>${image.name}</name> - <build> - <cleanup>try</cleanup> - <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir> - <tags> - <tag>${project.version}</tag> - <tag>${project.version}-STAGING-${maven.build.timestamp}</tag> - <tag>${project.docker.latesttag.version}</tag> - </tags> - </build> - </image> - </images> - <verbose>true</verbose> - </configuration> - <executions> + <plugins> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>0.26.1</version> + <inherited>false</inherited> + <configuration> + <images> + <image> + <name>${image.name}</name> + <build> + <cleanup>try</cleanup> + <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir> + <tags> + <tag>${project.docker.latestminortag.version}</tag> + <tag>${project.docker.latestfulltag.version}</tag> + <tag>${project.docker.latesttagtimestamp.version}</tag> + </tags> + </build> + </image> + </images> + <verbose>true</verbose> + </configuration> + <executions> <execution> <id>generate-images</id> <phase>package</phase> @@ -193,4 +183,4 @@ </profile> </profiles> -</project>
\ No newline at end of file +</project> diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index 2a952f88..503e5f0b 100755 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -1,6 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- ~ Copyright © 2017-2018 AT&T Intellectual Property. + ~ Modifications Copyright © 2018 IBM. ~ ~ Licensed under the Apache License, Version 2.0 (the "License"); ~ you may not use this file except in compliance with the License. @@ -30,6 +31,7 @@ <module>resource-resolution</module> <module>python-executor</module> <module>netconf-executor</module> + <module>restconf-executor</module> </modules> <dependencies> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt index 5552e75e..876c75fa 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/resource/resolution/processor/PrimaryDataResourceAssignmentProcessor.kt @@ -18,6 +18,7 @@ package org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.processor import com.fasterxml.jackson.databind.node.JsonNodeFactory +import com.fasterxml.jackson.databind.node.MissingNode import com.fasterxml.jackson.databind.node.NullNode import org.onap.ccsdk.apps.blueprintsprocessor.db.primary.PrimaryDBLibGenericService import org.onap.ccsdk.apps.blueprintsprocessor.functions.resource.resolution.DatabaseResourceSource @@ -51,7 +52,7 @@ open class PrimaryDataResourceAssignmentProcessor(private val primaryDBLibGeneri // Check if It has Input val value = raRuntimeService.getInputValue(resourceAssignment.name) - if (value != null && value !is NullNode) { + if (value !is NullNode && value !is MissingNode) { logger.info("primary-db source template key (${resourceAssignment.name}) found from input and value is ($value)") ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, value) } else { diff --git a/ms/blueprintsprocessor/functions/restconf-executor/pom.xml b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml new file mode 100644 index 00000000..5fdae5e6 --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/pom.xml @@ -0,0 +1,40 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Copyright © 2018 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> + <artifactId>functions</artifactId> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor</groupId> + <version>0.4.1-SNAPSHOT</version> + </parent> + <modelVersion>4.0.0</modelVersion> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>restconf-executor</artifactId> + <name>Blueprints Processor Function - Restconf Executor</name> + <description>Blueprints Processor Function - Restconf Executor</description> + + <dependencies> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>python-executor</artifactId> + </dependency> + </dependencies> + + +</project>
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt new file mode 100644 index 00000000..67202df4 --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutor.kt @@ -0,0 +1,62 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor + +import org.onap.ccsdk.apps.blueprintsprocessor.core.api.data.ExecutionServiceInput +import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService +import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction +import org.slf4j.LoggerFactory +import org.springframework.beans.factory.config.ConfigurableBeanFactory +import org.springframework.context.ApplicationContext +import org.springframework.context.annotation.Scope +import org.springframework.stereotype.Component + +@Component("component-restconf-executor") +@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE) +open class ComponentRestconfExecutor(private var applicationContext: ApplicationContext, + private val blueprintJythonService: BlueprintJythonService, + var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService) : + AbstractComponentFunction() { + + private val log = LoggerFactory.getLogger(ComponentRestconfExecutor::class.java) + + lateinit var scriptComponent: RestconfComponentFunction + + override fun process(executionRequest: ExecutionServiceInput) { + scriptComponent = blueprintJythonService.jythonComponentInstance(this) as RestconfComponentFunction + checkNotNull(scriptComponent) { "failed to get netconf script component" } + + scriptComponent.bluePrintRuntimeService = bluePrintRuntimeService + scriptComponent.processId = processId + scriptComponent.workflowName = workflowName + scriptComponent.stepName = stepName + scriptComponent.interfaceName = interfaceName + scriptComponent.operationName = operationName + scriptComponent.nodeTemplateName = nodeTemplateName + scriptComponent.operationInputs = operationInputs + + // Set the Rest Lib Property Service + scriptComponent.bluePrintRestLibPropertyService = bluePrintRestLibPropertyService + + scriptComponent.process(executionServiceInput) + } + + override fun recover(runtimeException: RuntimeException, executionRequest: ExecutionServiceInput) { + scriptComponent.recover(runtimeException, executionRequest) + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt new file mode 100644 index 00000000..7b3615fe --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfComponentFunction.kt @@ -0,0 +1,33 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor + +import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService +import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.onap.ccsdk.apps.blueprintsprocessor.services.execution.AbstractComponentFunction + + +abstract class RestconfComponentFunction : AbstractComponentFunction() { + + lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService + + fun restClientService(selector: String): BlueprintWebClientService { + return bluePrintRestLibPropertyService.blueprintWebClientService(selector) + } + + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt new file mode 100644 index 00000000..300f5be1 --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/main/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/RestconfExecutorConfiguration.kt @@ -0,0 +1,29 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor + +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty +import org.springframework.boot.context.properties.EnableConfigurationProperties +import org.springframework.context.annotation.ComponentScan +import org.springframework.context.annotation.Configuration + + +@Configuration +@ComponentScan +@EnableConfigurationProperties +@ConditionalOnProperty(name = ["blueprintsprocessor.restconfEnabled"], havingValue = "true") +open class RestconfExecutorConfiguration
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt new file mode 100644 index 00000000..b195fe0f --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/functions/restconf/executor/ComponentRestconfExecutorTest.kt @@ -0,0 +1,56 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.blueprintsprocessor.functions.restconf.executor + +import org.junit.Test +import org.junit.runner.RunWith +import org.onap.ccsdk.apps.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.apps.blueprintsprocessor.core.BlueprintPropertyConfiguration +import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.BlueprintJythonService +import org.onap.ccsdk.apps.blueprintsprocessor.functions.python.executor.PythonExecutorProperty +import org.onap.ccsdk.apps.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.test.context.ContextConfiguration +import org.springframework.test.context.TestPropertySource +import org.springframework.test.context.junit4.SpringRunner +import kotlin.test.assertNotNull + + +@RunWith(SpringRunner::class) +@ContextConfiguration(classes = [RestconfExecutorConfiguration::class, ComponentRestconfExecutor::class, + BlueprintJythonService::class, PythonExecutorProperty::class, BluePrintRestLibPropertyService::class, + BlueprintPropertyConfiguration::class,BluePrintProperties::class]) +@TestPropertySource(properties = +["server.port=9111", + "blueprintsprocessor.restconfEnabled=true", + "blueprintsprocessor.restclient.odlPrimary.type=basic-auth", + "blueprintsprocessor.restclient.odlPrimary.url=http://127.0.0.1:9111", + "blueprintsprocessor.restclient.odlPrimary.userId=sampleuser", + "blueprintsprocessor.restclient.odlPrimary.token=sampletoken"]) +class ComponentRestconfExecutorTest { + + @Autowired + lateinit var componentRestconfExecutor: ComponentRestconfExecutor + + @Test + fun `test Restconf Component Instance`() { + + assertNotNull(componentRestconfExecutor, "failed to get ComponentRestconfExecutor instance") + } + + +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml new file mode 100644 index 00000000..56ea7bb5 --- /dev/null +++ b/ms/blueprintsprocessor/functions/restconf-executor/src/test/resources/logback-test.xml @@ -0,0 +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.apps.blueprintsprocessor" level="info"/> + + <root level="warn"> + <appender-ref ref="STDOUT"/> + </root> + +</configuration> diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt index d5e27430..d6e5549a 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestPropertyPlaceHolderConfigurationTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/BluePrintRestLibPropertyServiceTest.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,7 +36,7 @@ import kotlin.test.assertNotNull "blueprintsprocessor.restclient.sample.url=http://localhost:8080", "blueprintsprocessor.restclient.sample.userId=sampleuser"]) -class RestPropertyPlaceHolderConfigurationTest { +class BluePrintRestLibPropertyServiceTest { @Autowired lateinit var bluePrintRestLibPropertyService: BluePrintRestLibPropertyService diff --git a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt index 1481406e..25821966 100644 --- a/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt +++ b/ms/blueprintsprocessor/modules/commons/rest-lib/src/test/kotlin/org/onap/ccsdk/apps/blueprintsprocessor/rest/service/RestClientServiceTest.kt @@ -37,7 +37,7 @@ import kotlin.test.assertNotNull @EnableAutoConfiguration(exclude = [DataSourceAutoConfiguration::class]) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT) @ContextConfiguration(classes = [BluePrintRestLibConfiguration::class, BlueprintPropertyConfiguration::class, - SampleController::class, BluePrintProperties::class]) + SampleController::class, BluePrintProperties::class, BluePrintProperties::class]) @TestPropertySource(properties = ["server.port=9111", "blueprintsprocessor.restclient.sample.type=basic-auth", diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index 685cf41d..5fe7641b 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -315,6 +315,11 @@ <artifactId>netconf-executor</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.onap.ccsdk.apps.blueprintsprocessor.functions</groupId> + <artifactId>restconf-executor</artifactId> + <version>${project.version}</version> + </dependency> <!-- Application Component Dependency --> <dependency> diff --git a/ms/controllerblueprints/distribution/pom.xml b/ms/controllerblueprints/distribution/pom.xml index 91d4bbca..c73d15b6 100755 --- a/ms/controllerblueprints/distribution/pom.xml +++ b/ms/controllerblueprints/distribution/pom.xml @@ -34,6 +34,8 @@ <docker.buildArg.https_proxy>${https_proxy}</docker.buildArg.https_proxy> <docker.push.phase>deploy</docker.push.phase> <docker.verbose>true</docker.verbose> + <ccsdk.project.version>${project.version}</ccsdk.project.version> + <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> </properties> <dependencies> @@ -120,22 +122,7 @@ <goal>execute</goal> </goals> <configuration> - <source> - println project.properties['ccsdk.project.version'] - def versionArray - if (project.properties['ccsdk.project.version'] != null ) { - versionArray = project.properties['ccsdk.project.version'].split('\\.') - } - - if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) - { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest" - } else { - project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest" - } - - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version'] - </source> + <source>${basedir}/../../../TagVersion.groovy</source> </configuration> </execution> </executions> @@ -162,9 +149,9 @@ <cleanup>try</cleanup> <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir> <tags> - <tag>${project.version}</tag> - <tag>${project.version}-STAGING-${maven.build.timestamp}</tag> - <tag>${project.docker.latesttag.version}</tag> + <tag>${project.docker.latestminortag.version}</tag> + <tag>${project.docker.latestfulltag.version}</tag> + <tag>${project.docker.latesttagtimestamp.version}</tag> </tags> </build> </image> diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt index a2101251..0c8209f4 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintConstants.kt @@ -44,6 +44,7 @@ object BluePrintConstants { const val DATA_TYPE_NULL: String = "null" const val DATA_TYPE_LIST: String = "list" const val DATA_TYPE_MAP: String = "map" + const val DATA_TYPE_JSON: String = "json" const val USER_SYSTEM: String = "System" diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt index 4509cccf..0889fddc 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/BluePrintTypes.kt @@ -1,5 +1,6 @@ /* * Copyright © 2017-2018 AT&T Intellectual Property. + * Modifications Copyright © 2018 IBM. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -109,6 +110,7 @@ object BluePrintTypes { validTypes.add(BluePrintConstants.DATA_TYPE_NULL) validTypes.add(BluePrintConstants.DATA_TYPE_LIST) validTypes.add(BluePrintConstants.DATA_TYPE_MAP) + validTypes.add(BluePrintConstants.DATA_TYPE_JSON) return validTypes } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt index 81b7acb5..cb75e2c2 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/PropertyAssignmentService.kt @@ -27,6 +27,7 @@ import org.onap.ccsdk.apps.controllerblueprints.core.BluePrintException import org.onap.ccsdk.apps.controllerblueprints.core.data.* import org.onap.ccsdk.apps.controllerblueprints.core.format import org.onap.ccsdk.apps.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.apps.controllerblueprints.core.utils.JsonParserUtils import org.onap.ccsdk.apps.controllerblueprints.core.utils.ResourceResolverUtils /** @@ -95,11 +96,11 @@ If Property Assignment is Expression. } /* - get_property: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, + get_attribute: [ <modelable_entity_name>, <optional_req_or_cap_name>, <property_name>, <nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] */ fun resolveAttributeExpression(nodeTemplateName: String, attributeExpression: AttributeExpression): JsonNode { - val valueNode: JsonNode + var valueNode: JsonNode val attributeName = attributeExpression.attributeName val subAttributeName: String? = attributeExpression.subAttributeName @@ -114,24 +115,20 @@ If Property Assignment is Expression. if (!attributeExpression.modelableEntityName.equals("SELF", true)) { attributeNodeTemplateName = attributeExpression.modelableEntityName } - /* Enable in ONAP Dublin Release - val nodeTemplateAttributeExpression = bluePrintContext.nodeTemplateByName(attributeNodeTemplateName).attributes?.get(attributeName) - ?: throw BluePrintException(format("failed to get attribute definitions for node template " + - "({})'s property name ({}) ", nodeTemplateName, attributeName)) - - var attributeDefinition: AttributeDefinition = bluePrintContext.nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName)!! - log.info("node template name ({}), property Name ({}) resolved value ({})", attributeNodeTemplateName, attributeName, nodeTemplateAttributeExpression) - */ + var attributeDefinition: AttributeDefinition = bluePrintContext + .nodeTemplateNodeType(attributeNodeTemplateName).attributes?.get(attributeName) + ?: throw BluePrintException("failed to get attribute definitions for node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ") valueNode = bluePrintRuntimeService.getNodeTemplateAttributeValue(attributeNodeTemplateName, attributeName) - ?: throw BluePrintException(format("failed to get node template ({})'s attribute ({}) ", nodeTemplateName, attributeName)) + ?: throw BluePrintException("failed to get node template ($attributeNodeTemplateName)'s attribute name ($attributeName) ") } } -// subPropertyName?.let { -// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) -// } + if (subAttributeName != null) { + if (valueNode.isObject || valueNode.isArray) + valueNode = JsonParserUtils.parse(valueNode, subAttributeName) + } return valueNode } @@ -140,7 +137,7 @@ If Property Assignment is Expression. <nested_property_name_or_index_1>, ..., <nested_property_name_or_index_n> ] */ fun resolvePropertyExpression(nodeTemplateName: String, propertyExpression: PropertyExpression): JsonNode { - val valueNode: JsonNode + var valueNode: JsonNode val propertyName = propertyExpression.propertyName val subPropertyName: String? = propertyExpression.subPropertyName @@ -160,9 +157,10 @@ If Property Assignment is Expression. // Check it it is a nested expression valueNode = resolveAssignmentExpression(propertyNodeTemplateName, propertyName, nodeTemplatePropertyExpression) -// subPropertyName?.let { -// valueNode = valueNode.at(JsonPointer.valueOf(subPropertyName)) -// } + if (subPropertyName != null) { + if (valueNode.isObject || valueNode.isArray) + valueNode = JsonParserUtils.parse(valueNode, subPropertyName) + } return valueNode } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt new file mode 100644 index 00000000..4bdaaa56 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/main/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtils.kt @@ -0,0 +1,60 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + + +import com.fasterxml.jackson.databind.JsonNode +import com.jayway.jsonpath.Configuration +import com.jayway.jsonpath.JsonPath +import com.jayway.jsonpath.Option +import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider +import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider + +class JsonParserUtils { + companion object { + + //TODO("Optimise this") + val JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder() + .mappingProvider(JacksonMappingProvider()).jsonProvider(JacksonJsonNodeJsonProvider()).build() + + val PATH_CONFIGURATION = Configuration.builder().options(Option.AS_PATH_LIST).build() + + fun paths(jsonContent: String, expression: String): List<String> { + return JsonPath.using(PATH_CONFIGURATION).parse(jsonContent).read(expression) + } + + fun paths(jsonNode: JsonNode, expression: String): List<String> { + return paths(jsonNode.toString(), expression) + } + + fun parse(jsonContent: String, expression: String): JsonNode { + return JsonPath.using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).read(expression) + } + + fun parse(jsonNode: JsonNode, expression: String): JsonNode { + return parse(jsonNode.toString(), expression) + } + + fun parseNSet(jsonContent: String, expression: String, value: JsonNode): JsonNode { + return JsonPath.using(JACKSON_JSON_NODE_CONFIGURATION).parse(jsonContent).set(expression, value).json() + } + + fun parseNSet(jsonNode: JsonNode, expression: String, valueNode: JsonNode): JsonNode { + return parseNSet(jsonNode.toString(), expression, valueNode) + } + } +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt index d0bd3cf3..92e9247a 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/service/BluePrintRuntimeServiceTest.kt @@ -65,10 +65,18 @@ class BluePrintRuntimeServiceTest { BluePrintRuntimeUtils.assignInputsFromClassPathFile(bluePrintRuntimeService.bluePrintContext(), "data/default-context.json", executionContext) + val assignmentParams = "{\n" + + " \"ipAddress\": \"127.0.0.1\",\n" + + " \"hostName\": \"vnf-host\"\n" + + " }" + + bluePrintRuntimeService.setNodeTemplateAttributeValue("resource-assignment", "assignment-params", + JacksonUtils.jsonNode(assignmentParams)) + val capProperties = bluePrintRuntimeService.resolveNodeTemplateCapabilityProperties("sample-netconf-device", "netconf") assertNotNull(capProperties, "Failed to populate capability property values") - assertEquals(capProperties["target-ip-address"], JacksonUtils.jsonNodeFromObject("localhost"), "Failed to populate parameter target-ip-address") + assertEquals(capProperties["target-ip-address"], "127.0.0.1".asJsonPrimitive(), "Failed to populate parameter target-ip-address") assertEquals(capProperties["port-number"], JacksonUtils.jsonNodeFromObject(830), "Failed to populate parameter port-number") } diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt new file mode 100644 index 00000000..1f003999 --- /dev/null +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/kotlin/org/onap/ccsdk/apps/controllerblueprints/core/utils/JsonParserUtilsTest.kt @@ -0,0 +1,33 @@ +/* + * Copyright © 2018 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. + */ + +package org.onap.ccsdk.apps.controllerblueprints.core.utils + +import org.junit.Test +import org.onap.ccsdk.apps.controllerblueprints.core.asJsonPrimitive +import kotlin.test.assertEquals + +class JsonParserUtilsTest { + + @Test + fun `test parse Node`() { + val dataNode = JacksonUtils.jsonNodeFromClassPathFile("data/default-context.json") + + val parsedNode = JsonParserUtils.parse(dataNode, "$.request-id") + + assertEquals(parsedNode, "12345".asJsonPrimitive(), "failed to parse json request-id") + } +}
\ No newline at end of file diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json index 3968626b..9f733f0f 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/data/default-context.json @@ -1,7 +1,7 @@ { - "request-id" : "12345", - "hostname" : "localhost", + "request-id": "12345", + "hostname": "localhost", "template_name": "baseconfiguration", "template_version": "1.0.0", - "action-name" : "sample-action" + "action-name": "sample-action" }
\ No newline at end of file diff --git a/ms/neng/pom.xml b/ms/neng/pom.xml index ed68afb4..fcd3f3d2 100644 --- a/ms/neng/pom.xml +++ b/ms/neng/pom.xml @@ -59,7 +59,9 @@ <ccsdk.project.version>${project.version}</ccsdk.project.version> <image.name>onap/ccsdk-apps-ms-neng</image.name> <timestamp>${maven.build.timestamp}</timestamp> - <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> + <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format> + <ccsdk.project.version>${project.version}</ccsdk.project.version> + <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> </properties> <profiles> @@ -198,9 +200,9 @@ <cleanup>try</cleanup> <dockerFileDir>${basedir}/target/docker-stage</dockerFileDir> <tags> - <tag>${project.version}</tag> - <tag>${project.docker.latesttag.version}</tag> - <tag>${project.version}-STAGING-${maven.build.timestamp}</tag> + <tag>${project.docker.latestminortag.version}</tag> + <tag>${project.docker.latestfulltag.version}</tag> + <tag>${project.docker.latesttagtimestamp.version}</tag> </tags> </build> </image> @@ -381,21 +383,7 @@ <goal>execute</goal> </goals> <configuration> - <source> - println project.properties['ccsdk.project.version']; - def versionArray; - if (project.properties['ccsdk.project.version'] != null) { - versionArray = project.properties['ccsdk.project.version'].split('\\.'); - } - - if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) { - project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; - } else { - project.properties['project.docker.latesttag.version'] = versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; - } - - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; - </source> + <source>${basedir}/../../TagVersion.groovy</source> </configuration> </execution> </executions> diff --git a/ms/vlantag-api/pom.xml b/ms/vlantag-api/pom.xml index ea461056..e2734703 100644 --- a/ms/vlantag-api/pom.xml +++ b/ms/vlantag-api/pom.xml @@ -1,5 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<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> <groupId>org.onap.ccsdk.apps.ms.vlantagapi</groupId> @@ -34,13 +36,14 @@ <docker.push.phase>deploy</docker.push.phase> <docker.verbose>true</docker.verbose> <ccsdk.project.version>${project.version}</ccsdk.project.version> + <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp> </properties> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.1-SNAPSHOT</version> - <relativePath/> + <relativePath /> </parent> @@ -116,22 +119,7 @@ <goal>execute</goal> </goals> <configuration> - <source> - println project.properties['ccsdk.project.version']; - def versionArray; - if (project.properties['ccsdk.project.version'] != null ) { - versionArray = project.properties['ccsdk.project.version'].split('\\.'); - } - - if (project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT")) - { - project.properties['project.docker.latesttag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest"; - } else { - project.properties['project.docker.latesttag.version']=versionArray[0]+'.' + versionArray[1]+"-STAGING-latest"; - } - - println 'New Tag for docker:' + project.properties['project.docker.latesttag.version']; - </source> + <source>${basedir}/../../TagVersion.groovy</source> </configuration> </execution> </executions> @@ -152,7 +140,7 @@ <artifactId>jacoco-maven-plugin</artifactId> <version>0.7.5.201505241946</version> <executions> - <!-- Prepares the property pointing to the JaCoCo runtime agent which + <!-- Prepares the property pointing to the JaCoCo runtime agent which is passed as VM argument when Maven the Surefire plugin is executed. --> <execution> <id>pre-unit-test</id> @@ -165,7 +153,7 @@ <propertyName>surefireArgLine</propertyName> </configuration> </execution> - <!-- Ensures that the code coverage report for unit tests is created + <!-- Ensures that the code coverage report for unit tests is created after unit tests have been run. --> <execution> <id>post-unit-test</id> @@ -234,8 +222,9 @@ <serverId>docker-hub</serverId> <registryUrl>https://${docker.registry}</registryUrl> <imageTags> - <imageTag>${project.version}</imageTag> - <imageTag>latest</imageTag> + <imageTag>${project.docker.latestminortag.version}</imageTag> + <imageTag>${project.docker.latestfulltag.version}</imageTag> + <imageTag>${project.docker.latesttagtimestamp.version}</imageTag> </imageTags> <forceTags>true</forceTags> <resources> |