diff options
36 files changed, 1133 insertions, 189 deletions
diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html index c69c511e6..fe322fada 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.html @@ -21,7 +21,12 @@ limitations under the License. <div style="border: 1px solid #3f51b5; padding: 1em;"> <i class="fa fa-exclamation-circle" style="color: #3f51b5" aria-hidden="true"></i> - + Disclaimer*: The Test CBA Certification page allow the testing/certification team with the certification + of the CBA workflow action. Workflow action may include various action and subaction that result in content + resolution (using mS such as naming , netbox , and etc.), content generation (Jinja/Velocity) and content + distribution (netconf, restconf etc.) . Once the certification is complete, it is the responsibility of the + testing/certification team to rollback all the resource assignment and network function configuration that has + been reserved and distributed during the certification. </div> <div class="testTemplateContainer"> <div class="editorContainer"> diff --git a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.scss b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.scss index 49d559933..b7ff037be 100644 --- a/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.scss +++ b/cds-ui/client/src/app/feature-modules/blueprint/test-template/test-template.component.scss @@ -34,9 +34,12 @@ limitations under the License. margin: 1em; background-color: #3f51b5; color: white; - border-radius: 2em; padding: 0.5em; min-width: 6em; + border-radius: 4px; + border: none; + line-height: none !important; + cursor: pointer; } .testTemplateContainer { diff --git a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json index d926aa3fc..b771d25f9 100644 --- a/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json +++ b/components/model-catalog/blueprint-model/test-blueprint/baseconfiguration/Definitions/resources_definition_types.json @@ -68,8 +68,9 @@ "primary-config-data": { "type": "source-rest", "properties": { + "verb": "GET", "type": "JSON", - "url-path": "config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", + "url-path": "/config/GENERIC-RESOURCE-API:services/service/$service-instance-id/service-data/vnfs/vnf/$vnf-id/vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name", "path": "/param/0/value", "input-key-mapping": { "service-instance-id": "service-instance-id", @@ -85,5 +86,92 @@ } } } + }, + "aai-get-resource": { + "tags": "aai-get", + "name": "aai-get-resource", + "property": { + "description": "primary aai data to get resource", + "type": "string" + }, + "updated-by": "Steve, Siani <steve.djissitchi@bell.ca>", + "sources": { + "primary-aai-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "verb": "GET", + "url-path": "/aai/v14/network/generic-vnfs/generic-vnf/$vnf-id", + "path": "", + "input-key-mapping": { + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + }, + "key-dependencies": [ + "vnf-id" + ] + } + } + } + }, + "aai-put-resource": { + "tags": "aai-put", + "name": "aai-put-resource", + "property": { + "description": "primary aai data to update resource", + "type": "string" + }, + "updated-by": "Steve, Siani <steve.djissitchi@bell.ca>", + "sources": { + "primary-aai-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "verb": "PUT", + "url-path": "/query?format=resource", + "path": "", + "payload": "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}", + + "input-key-mapping": { + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + }, + "key-dependencies": [ + "vnf-id" + ] + } + } + } + }, + "aai-post-resource": { + "tags": "aai-port", + "name": "aai-port-resource", + "property": { + "description": "primary aai data to create new resource", + "type": "string" + }, + "updated-by": "Steve, Siani <steve.djissitchi@bell.ca>", + "sources": { + "primary-aai-data": { + "type": "source-rest", + "properties": { + "type": "JSON", + "verb": "POST", + "url-path": "/aai/add/uri/here", + "path": "", + "payload": "", + "input-key-mapping": { + "vnf-id": "vnf-id" + }, + "output-key-mapping": { + }, + "key-dependencies": [ + "vnf-id" + ] + } + } + } } }
\ No newline at end of file diff --git a/docs/datadictionary/dbsystemcode.rst b/docs/datadictionary/dbsystemcode.rst new file mode 100644 index 000000000..5051d1e7d --- /dev/null +++ b/docs/datadictionary/dbsystemcode.rst @@ -0,0 +1,15 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Dbsystemcode +============ + +"dsl_definitions": { + "dynamic-db-source": { + "type": "maria-db", + "url": "jdbc:mysql://localhost:3306/sdnctl", + "username": "sdnctl", + "password": "sdnctl" + } +}
\ No newline at end of file diff --git a/docs/datadictionary/media/image0.JPG b/docs/datadictionary/image0.JPG Binary files differindex 074d20076..074d20076 100644 --- a/docs/datadictionary/media/image0.JPG +++ b/docs/datadictionary/image0.JPG diff --git a/docs/datadictionary/media/image1.JPG b/docs/datadictionary/image1.JPG Binary files differindex a27502a75..a27502a75 100644 --- a/docs/datadictionary/media/image1.JPG +++ b/docs/datadictionary/image1.JPG diff --git a/docs/datadictionary/index.rst b/docs/datadictionary/index.rst index a7e78564f..24050000e 100644 --- a/docs/datadictionary/index.rst +++ b/docs/datadictionary/index.rst @@ -9,22 +9,22 @@ Resource Definition Introduction: ============= -A data dictionary models the how a specific resource can be resolved. +A Resource definition models the how a specific resource can be resolved. A resource is a variable/parameter in the context of the service. It can be anything, but it should not be confused with SDC or Openstack resources. -A data dictionary can have multiple sources to handle resolution in different ways. +A Resource definition can have multiple sources to handle resolution in different ways. -The main goal of data dictionary is to define re-usable entity that could be shared. +The main goal of Resource definition is to define re-usable entity that could be shared. Creation of data dictionaries is a standalone activity, separated from the blueprint design. -As part of modelling a data dictionary entry, the following generic information should be provided: +As part of modelling a Resource definition entry, the following generic information should be provided: |image0| -.. |image0| image:: media/image0.jpg +.. |image0| image:: image0.jpg :width: 7.88889in :height: 4.43750in @@ -34,7 +34,7 @@ The modeling does allow for data translation between external capability and CDS |image1| -.. |image1| image:: media/image0.jpg +.. |image1| image:: image1.jpg :width: 7.88889in :height: 4.43750in @@ -45,7 +45,7 @@ vf-module-model-customization-uuid and vf-module-label are two data dictionaries Here is how input-key-mapping, output-key-mapping and key-dependencies can be used: -vf-module-label data dictionary +vf-module-label Resource definition { "name" : "vf-module-label", @@ -79,4 +79,14 @@ Resource source: Defines the contract to resolve a resource. -A resource source is modeled, following http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/csprd01/TOSCA-Simple-Profile-YAML-v1.0-csprd01.html#DEFN_ENTITY_NODE_TYPE, and derives from the https://wiki.onap.org/display/DW/Modeling+Concepts#ModelingConcepts-NodeResourceSource
\ No newline at end of file +A resource source is modeled, following TOSCA_ node type definition and derives from the Resource_ source. + +Also please click below for detailed resource source details + +.. toctree:: + :maxdepth: 1 + + resourcesource + +.. _TOSCA: http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.0/csprd01/TOSCA-Simple-Profile-YAML-v1.0-csprd01.html#DEFN_ENTITY_NODE_TYPE +.. _Resource_: https://wiki.onap.org/display/DW/Modeling+Concepts#ModelingConcepts-NodeResourceSource
\ No newline at end of file diff --git a/docs/datadictionary/resourcesource.rst b/docs/datadictionary/resourcesource.rst index fffeec313..2b60990ec 100644 --- a/docs/datadictionary/resourcesource.rst +++ b/docs/datadictionary/resourcesource.rst @@ -42,21 +42,21 @@ CDS is currently deployed along the side of SDNC, hence the primary database con |image0| -.. |image0| image:: image0.jpg +.. |image0| image:: sqltable.jpg :width: 7.88889in :height: 4.43750in .. toctree:: :maxdepth: 1 - sourceprimarydb + sourceprimarydbcode Connection to a specific database can be expressed through the endpoint-selector property, which refers to a macro defining the information about the database the connect to. Understand TOSCA Macro in the context of CDS. .. toctree:: :maxdepth: 1 - dbsystem + dbsystemcode REST: @@ -68,14 +68,14 @@ CDS is currently deployed along the side of SDNC, hence the default rest connect |image1| -.. |image1| image:: image1.jpg +.. |image1| image:: resttable.jpg :width: 7.88889in :height: 4.43750in .. toctree:: :maxdepth: 1 - rest + restsourcecode Connection to a specific REST system can be expressed through the endpoint-selector property, which refers to a macro defining the information about the REST system the connect to. Understand TOSCA Macro in the context of CDS. @@ -90,7 +90,7 @@ For source code of Authentication click below link: .. toctree:: :maxdepth: 1 - auth + restauth Capability: =========== @@ -99,7 +99,7 @@ Expects a script to be provided. |image2| -.. |image2| image:: image2.jpg +.. |image2| image:: capabilitytable.jpg :width: 7.88889in :height: 4.43750in @@ -107,4 +107,4 @@ Expects a script to be provided. .. toctree:: :maxdepth: 1 - source-capability + sourcecapabilitycode diff --git a/docs/datadictionary/restsourcecode.rst b/docs/datadictionary/restsourcecode.rst new file mode 100644 index 000000000..90b02986a --- /dev/null +++ b/docs/datadictionary/restsourcecode.rst @@ -0,0 +1,90 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Rest Source Code: +================= + +{ + "description": "This is Rest Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": false, + "type": "string", + "default": "JSON", + "constraints": [ + { + "valid_values": [ + "JSON" + ] + } + ] + }, + "verb": { + "required": false, + "type": "string", + "default": "GET", + "constraints": [ + { + "valid_values": [ + "GET", "POST", "DELETE", "PUT" + ] + } + ] + }, + "payload": { + "required": false, + "type": "string", + "default": "" + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "url-path": { + "required": true, + "type": "string" + }, + "path": { + "required": true, + "type": "string" + }, + "expression-type": { + "required": false, + "type": "string", + "default": "JSON_PATH", + "constraints": [ + { + "valid_values": [ + "JSON_PATH", + "JSON_POINTER" + ] + } + ] + }, + "input-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} + diff --git a/docs/datadictionary/sourcecapabilitycode.rst b/docs/datadictionary/sourcecapabilitycode.rst new file mode 100644 index 000000000..a91767678 --- /dev/null +++ b/docs/datadictionary/sourcecapabilitycode.rst @@ -0,0 +1,48 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Source Capability Code +====================== + +{ + "description": "This is Component Resource Source Node Type", + "version": "1.0.0", + "properties": { + "script-type": { + "required": true, + "type": "string", + "default": "kotlin", + "constraints": [ + { + "valid_values": [ + "kotlin", + "jython" + ] + } + ] + }, + "script-class-reference": { + "description": "Capability reference name for internal and kotlin, for jython script file path", + "required": true, + "type": "string" + }, + "instance-dependencies": { + "required": false, + "description": "Instance dependency Names to Inject to Kotlin / Jython Script.", + "type": "list", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "description": "Resource Resolution dependency dictionary names.", + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +} diff --git a/docs/datadictionary/sourcedefaultcode.rst b/docs/datadictionary/sourcedefaultcode.rst new file mode 100644 index 000000000..243f87f09 --- /dev/null +++ b/docs/datadictionary/sourcedefaultcode.rst @@ -0,0 +1,13 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Source Default code +=================== + +{ + "description": "This is Default Resource Source Node Type", + "version": "1.0.0", + "properties": {}, + "derived_from": "tosca.nodes.ResourceSource" +}
\ No newline at end of file diff --git a/docs/datadictionary/sourceinputcode.rst b/docs/datadictionary/sourceinputcode.rst new file mode 100644 index 000000000..b859272ea --- /dev/null +++ b/docs/datadictionary/sourceinputcode.rst @@ -0,0 +1,13 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Source Input code +================= + +{ + "description": "This is Input Resource Source Node Type", + "version": "1.0.0", + "properties": {}, + "derived_from": "tosca.nodes.ResourceSource" +}
\ No newline at end of file diff --git a/docs/datadictionary/sourceprimarydbcode.rst b/docs/datadictionary/sourceprimarydbcode.rst new file mode 100644 index 000000000..e2e0b2d76 --- /dev/null +++ b/docs/datadictionary/sourceprimarydbcode.rst @@ -0,0 +1,54 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Source Primary DB Code: +======================= + +{ + "description": "This is Database Resource Source Node Type", + "version": "1.0.0", + "properties": { + "type": { + "required": true, + "type": "string", + "constraints": [ + { + "valid_values": [ + "SQL" + ] + } + ] + }, + "endpoint-selector": { + "required": false, + "type": "string" + }, + "query": { + "required": true, + "type": "string" + }, + "input-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "output-key-mapping": { + "required": false, + "type": "map", + "entry_schema": { + "type": "string" + } + }, + "key-dependencies": { + "required": true, + "type": "list", + "entry_schema": { + "type": "string" + } + } + }, + "derived_from": "tosca.nodes.ResourceSource" +}
\ No newline at end of file diff --git a/docs/dynamicapi.rst b/docs/dynamicapi.rst new file mode 100644 index 000000000..eaf9987b7 --- /dev/null +++ b/docs/dynamicapi.rst @@ -0,0 +1,24 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Dynamic API +----------- + +The nature of the API request and response is meant to be model driven and dynamic. They both share the same definition. + +The actionName, under the actionIdentifiers refers to the name of a Workflow (see workflow) + +The content of the payload is what is fully dynamic / model driven. + +The first top level element will always be either $actionName-request for a request or $actionName-response for a response. + +Then the content within this element is fully based on the workflow input and output. + +Here is how the a generic request and response look like. + +|image0| + +.. |image0| image:: media/dynamicapi.jpg + :height: 4.43750in + :width: 7.88889in
\ No newline at end of file diff --git a/docs/flexibleplugin.rst b/docs/flexibleplugin.rst new file mode 100644 index 000000000..5c83ac9b7 --- /dev/null +++ b/docs/flexibleplugin.rst @@ -0,0 +1,17 @@ +.. This work is licensed under a Creative Commons Attribution 4.0 International License. +.. http://creativecommons.org/licenses/by/4.0 +.. Copyright (C) 2019 IBM. + +Flexible Plug-in +---------------- + +Interaction with external systems is made plug-able, removing development cycle to support new endpoint. + +Currently, REST or SQL external systems are supported. + +An external system might be used by multiple resources, or by multiple scripts. + +In order to share the external system information, TOSCA provides a way to create macros using dsl_definitions: + +http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/csd01/TOSCA-Simple-Profile-YAML-v1.2-csd01.html#_Toc494454160 +http://docs.oasis-open.org/tosca/TOSCA-Simple-Profile-YAML/v1.2/csd01/TOSCA-Simple-Profile-YAML-v1.2-csd01.html#_Toc494454173 diff --git a/docs/media/dyanmicapi.JPG b/docs/media/dyanmicapi.JPG Binary files differnew file mode 100644 index 000000000..3e00da3e8 --- /dev/null +++ b/docs/media/dyanmicapi.JPG diff --git a/docs/resourceassignment.rst b/docs/resourceassignment.rst index be8b08e25..f4fab4ee3 100644 --- a/docs/resourceassignment.rst +++ b/docs/resourceassignment.rst @@ -3,7 +3,7 @@ .. Copyright (C) 2019 IBM. Resource Assignment -=================== +------------------- .. toctree:: :maxdepth: 1 diff --git a/ms/blueprintsprocessor/functions/pom.xml b/ms/blueprintsprocessor/functions/pom.xml index 24cc352c9..3f948061f 100755 --- a/ms/blueprintsprocessor/functions/pom.xml +++ b/ms/blueprintsprocessor/functions/pom.xml @@ -47,6 +47,11 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.mock-server</groupId> + <artifactId>mockserver-netty</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito2</artifactId> <scope>test</scope> diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt index 9852e3438..2d726d487 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/main/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessor.kt @@ -101,7 +101,7 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS } } - private fun blueprintWebClientService(resourceAssignment: ResourceAssignment, + fun blueprintWebClientService(resourceAssignment: ResourceAssignment, restResourceSource: RestResourceSource): BlueprintWebClientService { return if (isNotEmpty(restResourceSource.endpointSelector)) { val restPropertiesJson = raRuntimeService.resolveDSLExpression(restResourceSource.endpointSelector!!) @@ -195,12 +195,8 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS checkNotEmpty(resourceAssignment.dictionaryName) { "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})" } - checkEquals(ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA, resourceAssignment.dictionarySource) { - "resource assignment source is not ${ResourceDictionaryConstants.SOURCE_PRIMARY_CONFIG_DATA} but it is " + - "${resourceAssignment.dictionarySource}" - } - checkNotEmpty(resourceAssignment.dictionaryName) { - "resource assignment dictionary name is not defined for template key (${resourceAssignment.name})" + checkNotEmpty(resourceAssignment.dictionarySource) { + "resource assignment dictionary source is not defined for template key (${resourceAssignment.name})" } } @@ -208,5 +204,4 @@ open class RestResourceResolutionProcessor(private val blueprintRestLibPropertyS raRuntimeService.getBluePrintError().addError(runtimeException.message!!) } - }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt index 3f251b104..9c2a100bc 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/ResourceResolutionServiceTest.kt @@ -128,7 +128,7 @@ class ResourceResolutionServiceTest { val artifactPrefix = "another" - // Velocity Artifact Definition Name + // Templating Artifact Definition Name val artifactTemplate = "$artifactPrefix-template" // Resource Assignment Artifact Definition Name val artifactMapping = "$artifactPrefix-mapping" diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt new file mode 100644 index 000000000..b79f48682 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintResLibPropertyService.kt @@ -0,0 +1,36 @@ +/* + * 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. + */ +package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock + +import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService + +class MockBluePrintRestLibPropertyService(bluePrintProperties: BluePrintProperties) : + BluePrintRestLibPropertyService(bluePrintProperties) { + + fun mockBlueprintWebClientService (selector: String): + MockBlueprintWebClientService { + val prefix = "blueprintsprocessor.restclient.$selector" + val restClientProperties = restClientProperties(prefix) + return mockBlueprintWebClientService(restClientProperties) + } + + private fun mockBlueprintWebClientService(restClientProperties: RestClientProperties): + MockBlueprintWebClientService { + return MockBlueprintWebClientService(restClientProperties) + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt new file mode 100644 index 000000000..c6ca41351 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockBlueprintWebClientService.kt @@ -0,0 +1,124 @@ +/* + * 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. + */ +package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock + +import org.apache.http.message.BasicHeader +import org.mockserver.integration.ClientAndServer +import org.mockserver.model.Header +import org.mockserver.model.HttpRequest.request +import org.mockserver.model.HttpResponse.response +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties +import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BlueprintWebClientService +import org.springframework.http.HttpHeaders +import org.springframework.http.MediaType +import java.nio.charset.Charset +import java.util.* + +class MockBlueprintWebClientService(private var restClientProperties: RestClientProperties): BlueprintWebClientService { + private var mockServer: ClientAndServer + private var port: String = if (restClientProperties.url.split(":")[2].isEmpty()) "8080" + else restClientProperties.url.split(":")[2] + private var headers: Map<String, String> + + init { + mockServer = ClientAndServer.startClientAndServer(port.toInt()) + headers = defaultHeaders() + + // Create expected requests and responses + setRequest("GET", "/aai/v14/network/generic-vnfs/generic-vnf/123456") + setRequest("GET", "/config/GENERIC-RESOURCE-API:services/service/10/service-data/vnfs/vnf/123456/" + + "vnf-data/vnf-topology/vnf-parameters-data/param/vnf_name") + setRequestWithPayload("PUT", "/query", + "{\r\n\"start\": \"\\/nodes\\/vf-modules?vf-module-name=vf-module-name\",\r\n\"query\": \"\\/query\\/related-to?startingNodeType=vf-module&relatedToNodeType=generic-vnf\"\r\n}") + } + + override fun defaultHeaders(): Map<String, String> { + val encodedCredentials = this.setBasicAuth("admin", "aaiTest") + return mapOf( + HttpHeaders.CONTENT_TYPE to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.ACCEPT to MediaType.APPLICATION_JSON_VALUE, + HttpHeaders.AUTHORIZATION to "Basic $encodedCredentials") + } + + override fun host(uri: String): String { + return restClientProperties.url + uri + } + + fun tearDown() { + mockServer.close() + } + + override fun exchangeResource(method: String, path: String, payload: String): String { + val header = arrayOf(BasicHeader(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION])) + return when (method) { + "POST" -> { + post(path, payload, header) + } + "PUT" -> { + put(path, payload, header) + } + else -> { + get(path, header) + } + } + } + + private fun setRequest(method: String, path: String) { + val requestResponse = when (method) { + "POST" -> { + "Post response" + } + "PUT" -> { + "Put response" + } + else -> { + "Get response" + } + + } + mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION])) + .withMethod(method) + .withPath(path) + ).respond(response().withStatusCode(200).withBody("{\"aai-resource\":\"$requestResponse\"}")) + } + + private fun setRequestWithPayload(method: String, path: String, payload: String) { + val requestResponse = when (method) { + "POST" -> { + "Post response" + } + "PUT" -> { + "Put response" + } + else -> { + "Get response" + } + + } + mockServer.`when`(request().withHeaders(Header(HttpHeaders.AUTHORIZATION, headers[HttpHeaders.AUTHORIZATION])) + .withMethod(method) + .withPath(path) + .withQueryStringParameter("format", "resource") + .withBody(payload) + ).respond(response().withStatusCode(200).withBody("{\"aai-resource\":\"$requestResponse\"}")) + } + + private fun setBasicAuth(username: String, password: String): String { + val credentialsString = "$username:$password" + return Base64.getEncoder().encodeToString( + credentialsString.toByteArray(Charset.defaultCharset())) + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt new file mode 100644 index 000000000..2c481dca3 --- /dev/null +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/mock/MockRestResourceResolutionProcessor.kt @@ -0,0 +1,159 @@ +/* + * 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. + */ +package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock + +import com.fasterxml.jackson.databind.node.ArrayNode +import com.fasterxml.jackson.databind.node.MissingNode +import org.apache.commons.collections.MapUtils +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceResolutionConstants +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.RestResourceSource +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor.ResourceAssignmentProcessor +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.controllerblueprints.core.* +import org.onap.ccsdk.cds.controllerblueprints.core.utils.JacksonUtils +import org.onap.ccsdk.cds.controllerblueprints.resource.dict.ResourceAssignment +import org.slf4j.LoggerFactory +import java.util.HashMap + +class MockRestResourceResolutionProcessor(private val blueprintRestLibPropertyService: + MockBluePrintRestLibPropertyService): ResourceAssignmentProcessor() { + + private val logger = LoggerFactory.getLogger(MockRestResourceResolutionProcessor::class.java) + + override fun resolveInputKeyMappingVariables(inputKeyMapping: Map<String, String>): Map<String, Any> { + val resolvedInputKeyMapping = HashMap<String, Any>() + if (MapUtils.isNotEmpty(inputKeyMapping)) { + resolvedInputKeyMapping["service-instance-id"] = "10" + resolvedInputKeyMapping["vnf_name"] = "vnf1" + resolvedInputKeyMapping["vnf-id"] = "123456" + } + return resolvedInputKeyMapping + } + + override fun getName(): String { + return "${ResourceResolutionConstants.PREFIX_RESOURCE_RESOLUTION_PROCESSOR}source-rest" + } + + override suspend fun processNB(executionRequest: ResourceAssignment) { + try { + // Check if It has Input + val value = getFromInput(executionRequest) + if (value == null || value is MissingNode) { + val dName = executionRequest.dictionaryName + val dSource = executionRequest.dictionarySource + val resourceDefinition = resourceDictionaries[dName] + + val resourceSource = resourceDefinition!!.sources[dSource] + + val resourceSourceProperties = resourceSource!!.properties + + val sourceProperties = + JacksonUtils.getInstanceFromMap(resourceSourceProperties!!, RestResourceSource::class.java) + + val path = nullToEmpty(sourceProperties.path) + val inputKeyMapping = sourceProperties.inputKeyMapping + + val resolvedInputKeyMapping = resolveInputKeyMappingVariables(inputKeyMapping!!).toMutableMap() + + // Resolving content Variables + val payload = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.payload), resolvedInputKeyMapping) + val urlPath = + resolveFromInputKeyMapping(checkNotNull(sourceProperties.urlPath), resolvedInputKeyMapping) + val verb = resolveFromInputKeyMapping(nullToEmpty(sourceProperties.verb), resolvedInputKeyMapping) + + logger.info("$dSource dictionary information : ($urlPath), ($inputKeyMapping), (${sourceProperties.outputKeyMapping})") + + // Get the Rest Client Service + val restClientService = blueprintWebClientService(executionRequest) + + val response = restClientService.exchangeResource(verb, urlPath, payload) + if (response.isEmpty()) { + logger.warn("Failed to get $dSource result for dictionary name ($dName) using urlPath ($urlPath)") + } else { + populateResource(executionRequest, sourceProperties, response, path) + restClientService.tearDown() + } + } + } catch (e: Exception) { + ResourceAssignmentUtils.setFailedResourceDataValue(executionRequest, e.message) + throw BluePrintProcessorException("Failed in template key ($executionRequest) assignments with: ${e.message}", + e) + } + } + + override suspend fun recoverNB(runtimeException: RuntimeException, executionRequest: ResourceAssignment) { + raRuntimeService.getBluePrintError().addError(runtimeException.message!!) + } + + private fun blueprintWebClientService(resourceAssignment: ResourceAssignment): MockBlueprintWebClientService { + return blueprintRestLibPropertyService.mockBlueprintWebClientService(resourceAssignment.dictionarySource!!) + } + + @Throws(BluePrintProcessorException::class) + private fun populateResource(resourceAssignment: ResourceAssignment, sourceProperties: RestResourceSource, + restResponse: String, path: String) { + val type = nullToEmpty(resourceAssignment.property?.type) + lateinit var entrySchemaType: String + + val outputKeyMapping = sourceProperties.outputKeyMapping + + val responseNode = JacksonUtils.jsonNode(restResponse).at(path) + + when (type) { + in BluePrintTypes.validPrimitiveTypes() -> { + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, responseNode) + } + in BluePrintTypes.validCollectionTypes() -> { + // Array Types + entrySchemaType = resourceAssignment.property!!.entrySchema!!.type + val arrayNode = responseNode as ArrayNode + + if (entrySchemaType !in BluePrintTypes.validPrimitiveTypes()) { + val responseArrayNode = responseNode.toList() + for (responseSingleJsonNode in responseArrayNode) { + + val arrayChildNode = JacksonUtils.objectMapper.createObjectNode() + + outputKeyMapping!!.map { + val responseKeyValue = responseSingleJsonNode.get(it.key) + val propertyTypeForDataType = ResourceAssignmentUtils + .getPropertyType(raRuntimeService, entrySchemaType, it.key) + + JacksonUtils.populateJsonNodeValues(it.value, + responseKeyValue, propertyTypeForDataType, arrayChildNode) + } + arrayNode.add(arrayChildNode) + } + } + // Set the List of Complex Values + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, arrayNode) + } + else -> { + // Complex Types + entrySchemaType = resourceAssignment.property!!.type + val objectNode = JacksonUtils.objectMapper.createObjectNode() + outputKeyMapping!!.map { + val responseKeyValue = responseNode.get(it.key) + val propertyTypeForDataType = ResourceAssignmentUtils + .getPropertyType(raRuntimeService, entrySchemaType, it.key) + JacksonUtils.populateJsonNodeValues(it.value, responseKeyValue, propertyTypeForDataType, objectNode) + } + // Set the List of Complex Values + ResourceAssignmentUtils.setResourceDataValue(resourceAssignment, raRuntimeService, objectNode) + } + } + } +}
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt index 2af15c2be..66fdd8ff8 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/CapabilityResourceResolutionProcessorTest.kt @@ -123,7 +123,6 @@ class CapabilityResourceResolutionProcessorTest { println(processorName) } } - } open class MockCapabilityService { diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt index 08174ed47..7e7e65635 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/kotlin/org/onap/ccsdk/cds/blueprintsprocessor/functions/resource/resolution/processor/RestResourceResolutionProcessorTest.kt @@ -16,13 +16,15 @@ package org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.processor import kotlinx.coroutines.runBlocking -import org.junit.Ignore import org.junit.Test import org.junit.runner.RunWith import org.onap.ccsdk.cds.blueprintsprocessor.core.BluePrintProperties import org.onap.ccsdk.cds.blueprintsprocessor.core.BlueprintPropertyConfiguration import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.ResourceAssignmentRuntimeService +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockBluePrintRestLibPropertyService +import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.mock.MockRestResourceResolutionProcessor import org.onap.ccsdk.cds.blueprintsprocessor.functions.resource.resolution.utils.ResourceAssignmentUtils +import org.onap.ccsdk.cds.blueprintsprocessor.rest.RestClientProperties import org.onap.ccsdk.cds.blueprintsprocessor.rest.service.BluePrintRestLibPropertyService import org.onap.ccsdk.cds.controllerblueprints.core.data.PropertyDefinition import org.onap.ccsdk.cds.controllerblueprints.core.utils.BluePrintMetadataUtils @@ -31,18 +33,25 @@ 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.AfterTest +import kotlin.test.BeforeTest import kotlin.test.assertNotNull @RunWith(SpringRunner::class) -@ContextConfiguration(classes = [RestResourceResolutionProcessor::class, BluePrintRestLibPropertyService::class, - BlueprintPropertyConfiguration::class, BluePrintProperties::class]) +@ContextConfiguration(classes = [MockRestResourceResolutionProcessor::class, MockBluePrintRestLibPropertyService::class, + BlueprintPropertyConfiguration::class, BluePrintProperties::class, RestClientProperties::class]) @TestPropertySource(locations = ["classpath:application-test.properties"]) class RestResourceResolutionProcessorTest { - @Autowired - lateinit var restResourceResolutionProcessor: RestResourceResolutionProcessor + lateinit var bluePrintRestLibPropertyService: MockBluePrintRestLibPropertyService + + private lateinit var restResourceResolutionProcessor: MockRestResourceResolutionProcessor + + @BeforeTest + fun init(){ + restResourceResolutionProcessor = MockRestResourceResolutionProcessor(bluePrintRestLibPropertyService) + } - @Ignore @Test fun `test rest resource resolution`() { runBlocking { @@ -55,7 +64,11 @@ class RestResourceResolutionProcessorTest { restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils .resourceDefinitions(bluePrintContext.rootPath) - //TODO ("Mock the dependency values and rest service.") + val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf() + scriptPropertyInstances["mock-service1"] = MockCapabilityService() + scriptPropertyInstances["mock-service2"] = MockCapabilityService() + + restResourceResolutionProcessor.scriptPropertyInstances = scriptPropertyInstances val resourceAssignment = ResourceAssignment().apply { name = "rr-name" @@ -71,4 +84,70 @@ class RestResourceResolutionProcessorTest { println(processorName) } } + + @Test + fun `test rest aai get resource resolution`() { + runBlocking { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) + + restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService + restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils + .resourceDefinitions(bluePrintContext.rootPath) + + val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf() + scriptPropertyInstances["mock-service1"] = MockCapabilityService() + scriptPropertyInstances["mock-service2"] = MockCapabilityService() + + restResourceResolutionProcessor.scriptPropertyInstances = scriptPropertyInstances + + val resourceAssignment = ResourceAssignment().apply { + name = "rr-aai" + dictionaryName = "aai-get-resource" + dictionarySource = "primary-aai-data" + property = PropertyDefinition().apply { + type = "string" + } + } + + val processorName = restResourceResolutionProcessor.applyNB(resourceAssignment) + assertNotNull(processorName, "couldn't get AAI Rest resource assignment processor name") + println(processorName) + } + } + + @Test + fun `test rest aai put resource resolution`() { + runBlocking { + val bluePrintContext = BluePrintMetadataUtils.getBluePrintContext( + "./../../../../components/model-catalog/blueprint-model/test-blueprint/baseconfiguration") + + val resourceAssignmentRuntimeService = ResourceAssignmentRuntimeService("1234", bluePrintContext) + + restResourceResolutionProcessor.raRuntimeService = resourceAssignmentRuntimeService + restResourceResolutionProcessor.resourceDictionaries = ResourceAssignmentUtils + .resourceDefinitions(bluePrintContext.rootPath) + + val scriptPropertyInstances: MutableMap<String, Any> = mutableMapOf() + scriptPropertyInstances["mock-service1"] = MockCapabilityService() + scriptPropertyInstances["mock-service2"] = MockCapabilityService() + + restResourceResolutionProcessor.scriptPropertyInstances = scriptPropertyInstances + + val resourceAssignment = ResourceAssignment().apply { + name = "rr-aai" + dictionaryName = "aai-put-resource" + dictionarySource = "primary-aai-data" + property = PropertyDefinition().apply { + type = "string" + } + } + + val processorName = restResourceResolutionProcessor.applyNB(resourceAssignment) + assertNotNull(processorName, "couldn't get AAI Rest resource assignment processor name") + println(processorName) + } + } }
\ No newline at end of file diff --git a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties index 071b27afc..5deea31e1 100644 --- a/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties +++ b/ms/blueprintsprocessor/functions/resource-resolution/src/test/resources/application-test.properties @@ -28,4 +28,14 @@ blueprintsprocessor.blueprintArchivePath=./target/blueprints/archive blueprintsprocessor.blueprintWorkingPath=./target/blueprints/work # Python executor blueprints.processor.functions.python.executor.executionPath=./../../../../components/scripts/python/ccsdk_blueprints -blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints
\ No newline at end of file +blueprints.processor.functions.python.executor.modulePaths=./../../../../components/scripts/python/ccsdk_blueprints + +blueprintsprocessor.restclient.primary-config-data.type=basic-auth +blueprintsprocessor.restclient.primary-config-data.url=http://127.0.0.1:9911 +blueprintsprocessor.restclient.primary-config-data.username=sampleuser +blueprintsprocessor.restclient.primary-config-data.password=sampletoken + +blueprintsprocessor.restclient.primary-aai-data.type=basic-auth +blueprintsprocessor.restclient.primary-aai-data.url=http://127.0.0.1:30800 +blueprintsprocessor.restclient.primary-aai-data.username=admin +blueprintsprocessor.restclient.primary-aai-data.password=aaiTest
\ No newline at end of file diff --git a/ms/blueprintsprocessor/parent/pom.xml b/ms/blueprintsprocessor/parent/pom.xml index e6901354a..42abbc51d 100755 --- a/ms/blueprintsprocessor/parent/pom.xml +++ b/ms/blueprintsprocessor/parent/pom.xml @@ -51,6 +51,7 @@ <mockk.version>1.9</mockk.version> <dmaap.client.version>1.1.5</dmaap.client.version> <jinja.version>2.5.0</jinja.version> + <mockkserver.version>5.5.1</mockkserver.version> </properties> <dependencyManagement> <dependencies> @@ -407,6 +408,12 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.mock-server</groupId> + <artifactId>mockserver-netty</artifactId> + <version>${mockkserver.version}</version> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.powermock</groupId> <artifactId>powermock-api-mockito2</artifactId> <version>${powermock.version}</version> diff --git a/ms/cds-sdc-listener/application/pom.xml b/ms/cds-sdc-listener/application/pom.xml index cbf8ca879..3f8e1a319 100644 --- a/ms/cds-sdc-listener/application/pom.xml +++ b/ms/cds-sdc-listener/application/pom.xml @@ -6,41 +6,42 @@ ~ proprietary to Bell Canada and are protected by trade secret or copyright law. ~ Unauthorized copying of this file, via any medium is strictly prohibited. --> -<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"> <parent> <groupId>org.onap.ccsdk.parent</groupId> - <artifactId>spring-boot-1-starter-parent</artifactId> + <artifactId>spring-boot-starter-parent</artifactId> <version>1.2.2-SNAPSHOT</version> - <relativePath/> </parent> - <modelVersion>4.0.0</modelVersion> <groupId>org.onap.ccsdk.cds</groupId> + <modelVersion>4.0.0</modelVersion> <artifactId>cds-sdc-listener-application</artifactId> <version>0.4.2-SNAPSHOT</version> - <name>CDS-SDC Listener Application </name> + <name>CDS-SDC Listener Application</name> <properties> <grpc.version>1.17.1</grpc.version> <protobuf.version>3.6.1</protobuf.version> + <image.name>onap/ccsdk-cds-sdc-listener</image.name> + <docker.push.phase>deploy</docker.push.phase> + <project.version>${parent.version}</project.version> + <!-- Start of Docker Related Properties --> + <docker.fabric.version>0.26.1</docker.fabric.version> + <ccsdk.project.version>${project.version}</ccsdk.project.version> </properties> <dependencies> <!-- Spring boot --> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-web</artifactId> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> <dependency> <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-devtools</artifactId> - <optional>true</optional> + <artifactId>spring-boot-starter-web</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> </dependency> <!-- SDC Distribution client dependency --> @@ -87,16 +88,15 @@ <dependency> <groupId>org.onap.ccsdk.cds.components</groupId> <artifactId>proto-definition</artifactId> - <version>0.4.2-SNAPSHOT</version> + <version>${project.version}</version> </dependency> - <!-- SDC Distribution client dependency --> <dependency> - <groupId>org.onap.sdc.sdc-distribution-client</groupId> - <artifactId>sdc-distribution-client</artifactId> - <version>1.3.0</version> + <groupId>io.projectreactor</groupId> + <artifactId>reactor-core</artifactId> + <version>3.2.6.RELEASE</version> + <scope>compile</scope> </dependency> - </dependencies> <build> @@ -113,7 +113,103 @@ </execution> </executions> </plugin> + <plugin> + <artifactId>maven-antrun-plugin</artifactId> + <version>1.8</version> + <executions> + <execution> + <id>copy</id> + <phase>package</phase> + <configuration> + <target> + <echo>ANT TASK - copying Docker files</echo> + <copy todir="${basedir}/target/docker-stage" overwrite="true" flatten="true"> + <fileset dir="${basedir}/src/main/docker"> + <include name="Dockerfile"/> + <include name="start.sh"/> + </fileset> + <fileset dir="${basedir}/target"> + <include name="*.jar"/> + </fileset> + <fileset dir="${basedir}/src/main/resources/"> + <include name="application.yml"/> + </fileset> + </copy> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.groovy.maven</groupId> + <artifactId>gmaven-plugin</artifactId> + <version>1.0</version> + <executions> + <execution> + <phase>validate</phase> + <goals> + <goal>execute</goal> + </goals> + <configuration> + <source>${basedir}/../../../TagVersion.groovy</source> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> + <profiles> + <profile> + <id>docker</id> + <build> + <plugins> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>${docker.fabric.version}</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> + <goals> + <goal>build</goal> + </goals> + </execution> + <execution> + <id>push-images</id> + <phase>${docker.push.phase}</phase> + <goals> + <goal>build</goal> + <goal>push</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + </project> diff --git a/ms/cds-sdc-listener/application/src/main/docker/Dockerfile b/ms/cds-sdc-listener/application/src/main/docker/Dockerfile new file mode 100644 index 000000000..062f65767 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/docker/Dockerfile @@ -0,0 +1,13 @@ +FROM openjdk:8-jdk-alpine + +ENV HTTP_PROXY ${HTTP_PROXY} +ENV HTTPS_PROXY ${HTTPS_PROXY} + +RUN mkdir -p /opt/app/onap/ /opt/app/onap/config +WORKDIR /opt/app/onap/ +COPY start.sh /opt/app/onap/ +COPY application.yml /opt/app/onap/config +RUN chmod 751 /opt/app/onap/start.sh +COPY cds-sdc-listener-application-0.4.2-SNAPSHOT.jar /opt/app/onap/cds-sdc-listener-distribution.jar +EXPOSE 9000 +ENTRYPOINT /opt/app/onap/start.sh diff --git a/ms/cds-sdc-listener/application/src/main/docker/docker-compose.yaml b/ms/cds-sdc-listener/application/src/main/docker/docker-compose.yaml new file mode 100644 index 000000000..1e7384744 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/docker/docker-compose.yaml @@ -0,0 +1,29 @@ +version: '3.3' + +services: + cds-sdc-listener: + image: onap/cdssdclistener:latest + container_name: cdssdclistener + restart: always + environment: + asdcAddress: localhost:8443 + messageBusAddress: localhost + sdcusername: vid + password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U + pollingInterval: 15 + pollingTimeout: 15 + relevantArtifactTypes: TOSCA_CSAR + consumerGroup: cds-id-local + environmentName: AUTO + consumerId: cds-id-local + keyStorePassword: + keyStorePath: + activateServerTLSAuth: "false" + isUseHttpsWithDmaap: "false" + archivePath: /opt/app/onap/cds-sdc-listener/ + grpcAddress: localhost + grpcPort: 9111 + authHeader: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== + #port needed by Liveness probe + healthcheckPort: "9000" + sprintWebListenerEnabled: "true" diff --git a/ms/cds-sdc-listener/application/src/main/docker/start.sh b/ms/cds-sdc-listener/application/src/main/docker/start.sh new file mode 100755 index 000000000..f24d15618 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/docker/start.sh @@ -0,0 +1,6 @@ +#!/bin/sh +extraArgs=$@ +java -jar /opt/app/onap/cds-sdc-listener-distribution.jar \ +-Dspring.config=/opt/app/onap/config/application.yml \ +-Djava.security.egd=file:/dev/./urandom \ +${extraArgs} diff --git a/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/controller/HealthCheck.java b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/controller/HealthCheck.java new file mode 100644 index 000000000..a1bb116bf --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/java/org/onap/ccsdk/cds/cdssdclistener/controller/HealthCheck.java @@ -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. + */ + +package org.onap.ccsdk.cds.cdssdclistener.controller; + +import org.springframework.http.MediaType; +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; +import reactor.core.publisher.Mono; + +@RestController +@RequestMapping("/api/v1/sdclistener") +public class HealthCheck { + + @RequestMapping(path = "/healthcheck", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) + public @ResponseBody + Mono<String> ping() { + return Mono.just("{\"status\":\"UP\"}"); + } +} diff --git a/ms/cds-sdc-listener/application/src/main/resources/application.yml b/ms/cds-sdc-listener/application/src/main/resources/application.yml index cb1b54c96..b3f8443eb 100644 --- a/ms/cds-sdc-listener/application/src/main/resources/application.yml +++ b/ms/cds-sdc-listener/application/src/main/resources/application.yml @@ -1,21 +1,27 @@ listenerservice: - config: - asdcAddress: localhost:8443 - messageBusAddress: localhost - user: vid - password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U - pollingInterval: 15 - pollingTimeout: 60 - relevantArtifactTypes: TOSCA_CSAR - consumerGroup: cds-id-local - environmentName: AUTO - consumerId: cds-id-local - keyStorePassword: - keyStorePath: - activateServerTLSAuth : false - isUseHttpsWithDmaap: false - archivePath: /opt/app/onap/cds-sdc-listener/ - grpcAddress: localhost - grpcPort: 9111 - authHeader: Basic Y2NzZGthcHBzOmNjc2RrYXBwcw== - + config: + asdcAddress: ${asdcAddress:localhost:8443} + messageBusAddress: ${messageBusAddress:localhost} + user: ${sdcusername:vid} + password: ${password:Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U} + pollingInterval: ${pollingInterval:15} + pollingTimeout: ${pollingTimeout:60} + relevantArtifactTypes: ${relevantArtifactTypes:TOSCA_CSAR} + consumerGroup: ${consumerGroup:cds-id-local} + environmentName: ${environmentName:AUTO} + consumerId: ${consumerId:cds-id-local} + keyStorePassword: ${keyStorePassword} + keyStorePath: ${keyStorePath} + activateServerTLSAuth : ${activateServerTLSAuth:false} + isUseHttpsWithDmaap: ${isUseHttpsWithDmaap:false} + archivePath: ${archivePath:/opt/app/onap/cds-sdc-listener/} + grpcAddress: ${grpcAddress:localhost} + grpcPort: ${grpcPort:9111} + authHeader: ${authHeader:Basic Y2NzZGthcHBzOmNjc2RrYXBwcw==} +#port needed by Liveness probe +server: + port: ${healthcheckPort:9000} +#set spring.main.web-environment=false if you want to NOT to open a port for healthcheck. +spring: + main: + web-environment: ${sprintWebListenerEnabled:true} diff --git a/ms/cds-sdc-listener/application/src/main/resources/logback.xml b/ms/cds-sdc-listener/application/src/main/resources/logback.xml new file mode 100644 index 000000000..b26cbcbe4 --- /dev/null +++ b/ms/cds-sdc-listener/application/src/main/resources/logback.xml @@ -0,0 +1,33 @@ +<!-- +Copyright (C) 2019 Bell Canada + +Unless otherwise specified, all software contained herein is licensed +under the Apache License, Version 2.0 (the License); +you may not use this software 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} [%thread] %-5level %logger{50} - %msg%n</pattern> + </encoder> + </appender> + + <root level="info"> + <appender-ref ref="STDOUT"/> + </root> + + <logger name="org.springframework" level="info"/> + <logger name="org.springframework.web" level="info"/> + <logger name="org.onap.ccsdk.cds" level="info"/> + +</configuration> diff --git a/ms/cds-sdc-listener/distribution/pom.xml b/ms/cds-sdc-listener/distribution/pom.xml deleted file mode 100644 index 59e3824d7..000000000 --- a/ms/cds-sdc-listener/distribution/pom.xml +++ /dev/null @@ -1,106 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - ~ Copyright (C) 2019 Bell Canada. All rights reserved. - ~ - ~ NOTICE: All the intellectual and technical concepts contained herein are - ~ proprietary to Bell Canada and are protected by trade secret or copyright law. - ~ Unauthorized copying of this file, via any medium is strictly prohibited. - --> -<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>cds-sdc-listener</artifactId> - <groupId>org.onap.ccsdk.cds</groupId> - <version>0.4.2-SNAPSHOT</version> - </parent> - - <modelVersion>4.0.0</modelVersion> - <groupId>org.onap.ccsdk.cds</groupId> - <artifactId>cds-sdc-listener-distribution</artifactId> - <name>CDS-SDC Listener Distribution</name> - - <properties> - <image.name>onap/ccsdk-cdssdclistener</image.name> - <docker.push.phase>deploy</docker.push.phase> - </properties> - - <build> - <plugins> - <plugin> - <artifactId>maven-resources-plugin</artifactId> - <version>2.6</version> - <executions> - <execution> - <id>copy-dockerfile</id> - <goals> - <goal>copy-resources</goal> - </goals> - <phase>validate</phase> - <configuration> - <outputDirectory>${basedir}/target/docker-stage</outputDirectory> - <resources> - <resource> - <directory>src/main/docker</directory> - <includes> - <include>*</include> - </includes> - <filtering>true</filtering> - </resource> - </resources> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> - - <profiles> - <profile> - <id>docker</id> - <build> - <plugins> - <plugin> - <!-- Maven plugin for managing docker images and containers --> - <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> - </tags> - </build> - </image> - </images> - <verbose>true</verbose> - </configuration> - <executions> - <execution> - <id>generate-images</id> - <phase>package</phase> - <goals> - <goal>build</goal> - </goals> - </execution> - <execution> - <id>push-images</id> - <phase>${docker.push.phase}</phase> - <goals> - <goal>build</goal> - <goal>push</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - </profile> - </profiles> - -</project> diff --git a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json index cac8770af..0e1f84278 100644 --- a/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json +++ b/ms/controllerblueprints/modules/blueprint-core/src/test/resources/dictionary/dictionary_schema.json @@ -51,8 +51,46 @@ "default": { "type": "any" }, - "aai": { - "type": "any" + "primary-aai-data": { + "type": "object", + "properties": { + "verb": { + "type": "string", + "required": true + }, + "path": { + "type": "string", + "required": true + }, + "url-path": { + "type": "string", + "required": true + }, + "payload": { + "type": "string", + "required": false + }, + "input-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "type": { + "type": "string", + "required": true + }, + "output-key-mapping": { + "type": "object", + "additionalProperties": { + "type": "string" + } + }, + "base": { + "type": "string", + "required": true + } + } }, "primary-config-data": { "type": "object", @@ -177,7 +215,7 @@ } } }, - "aai": { + "primary-aai-data": { "type": "object", "properties": { "names": { |