Acumos Adapter updates to support v3 schema 76/126076/5 1.0.7-adapter-acumos
authorshabs2020 <shabnam.sultana@highstreet-technologies.com>
Mon, 6 Dec 2021 08:35:52 +0000 (09:35 +0100)
committershabs2020 <shabnam.sultana@highstreet-technologies.com>
Thu, 9 Dec 2021 17:52:48 +0000 (18:52 +0100)
Enhanced Adapter to support component spec v3 schema of Istanbul release

Additionally corrected config file for no_proxy variable

Issue-ID: DCAEGEN2-2877
Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com>
Change-Id: Ie6f2decb6afcd1e164fafab6fd943d6b6c8e7cf0
Signed-off-by: shabs2020 <shabnam.sultana@highstreet-technologies.com>
18 files changed:
adapter/acumos-deployment/resources/config/config.yaml
adapter/acumos/Changelog.md
adapter/acumos/Dockerfile
adapter/acumos/aoconversion/convert.py
adapter/acumos/aoconversion/docker_gen.py
adapter/acumos/aoconversion/scanner.py
adapter/acumos/aoconversion/spec_gen.py
adapter/acumos/pom.xml
adapter/acumos/setup.py
adapter/acumos/tests/conftest.py
adapter/acumos/tests/fixtures/config.yaml
adapter/acumos/tests/fixtures/models/ArgsList_1.0.0_dcae_data_format.json
adapter/acumos/tests/fixtures/models/SumOut_1.0.0_dcae_data_format.json
adapter/acumos/tests/fixtures/models/example-model-listofm/metadata.json
adapter/acumos/tests/fixtures/models/example-model/requirements.txt [new file with mode: 0644]
adapter/acumos/tests/test_docker.py
adapter/acumos/tests/test_spec.py
adapter/acumos/tox.ini

index e6dc4e3..8f42cc2 100644 (file)
@@ -9,6 +9,6 @@ dockeruser: {{ .Values.dockerUser }}
 dockerpass: '@/run/pass/dpass'
 http_proxy: {{ .Values.http_proxy }}
 https_proxy: {{ .Values.https_proxy }}
-no_proxy: {{ .Values.http_proxy }}
+no_proxy: {{ .Values.no_proxy }}
 {{ $firstPort := index .Values.service.ports 0 -}}
 port: {{ $firstPort.port }}
index 2f8d7a3..8199078 100644 (file)
@@ -4,17 +4,19 @@ All notable changes to this project will be documented in this file.
 The format is based on [Keep a Changelog](http://keepachangelog.com/)
 and this project adheres to [Semantic Versioning](http://semver.org/).
 
-## [1.0.6] - 6/04/2021
+## [1.0.7] - 2021/12/01
+    * Customize DCAE adapter to support the v3 component spec (DCAEGEN2-2877)
+## [1.0.6] - 2021/06/04
     * Adapt DCAE adapter to work with Acumos Demeter's metadata structure change
-## [1.0.5] - 5/05/2021
+## [1.0.5] - 2021/05/05
     * Enhance adapter to also work behind proxy.
-## [1.0.4] - 1/07/2021
+## [1.0.4] - 2021/01/07
     * Select metadata.json with additional name search in case of multiple json artifacts (Fix for DCAEGEN2-2578)
-## [1.0.3] - 7/28/2020
+## [1.0.3] - 2020/07/28
     * Fetch json schemas during image build
-## [1.0.2] - 3/26/2020
+## [1.0.2] - 2020/03/26
     * Run as non-root
-## [1.0.1] - 3/20/2020
+## [1.0.1] - 2020/03/20
     * Adjust URL paths for consistency with DCAE GEN design tool
-## [1.0.0] - 11/13/2019
+## [1.0.0] - 2019/11/13
     * Onboard models from Acumos - initial version
index 4f1bea2..135bce8 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -27,7 +28,7 @@ RUN apt-get update && \
     npm install -g protobuf-jsonschema && \
     mkdir schemas && \
     wget -O schemas/schema.json 'https://json-schema.org/draft-04/schema#' && \
-    wget -O schemas/compspec.json https://git.onap.org/dcaegen2/platform/plain/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json && \
+    wget -O schemas/compspec.json https://git.onap.org/dcaegen2/platform/plain/mod/component-json-schemas/component-specification/dcae-cli-v3/component-spec-schema.json && \
     wget -O schemas/dataformat.json https://git.onap.org/dcaegen2/platform/plain/mod/component-json-schemas/data-format/dcae-cli-v1/data-format-schema.json && \
     cd /tmp/build/ && \
     python setup.py install && \
index e41820a..305dd37 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -29,5 +30,5 @@ def gen_dcae_artifacts_for_model(config, model_name, model_version="latest"):
     model_repo_path = config.tmpdir
     docker_uri = docker_gen.build_and_push_docker(config, model_name, model_version)
     data_formats = dataformat_gen.generate_dcae_data_formats(model_repo_path, model_name)
-    spec = spec_gen.generate_spec(model_repo_path, model_name, data_formats, docker_uri)
+    spec = spec_gen.generate_spec(model_repo_path, model_name, data_formats, model_version)
     return docker_uri, data_formats, spec
index 07cc9d7..5f497c9 100644 (file)
@@ -2,7 +2,6 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
-# =============================================================================
 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,7 +43,8 @@ def _generate_dockerfile(meta, model_name, http_proxy, https_proxy, no_proxy):
     ENV no_proxy={no_proxy}
     ENV NO_PROXY={no_proxy}
     RUN pip install -r /app/requirements.txt && \
-        pip install acumos_dcae_model_runner
+        pip install acumos_dcae_model_runner && \
+        pip install pyyaml
 
     ENV DCAEPORT=10000
     EXPOSE $DCAEPORT
index 18dd701..f8b4531 100644 (file)
@@ -2,7 +2,6 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
-# =============================================================================
 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
index a08b720..e3f2c82 100644 (file)
@@ -21,7 +21,6 @@
 Generates DCAE component specs
 """
 
-
 import json
 from jsonschema import validate
 from aoconversion import utils
@@ -38,12 +37,12 @@ def _get_format_version(target_name, data_formats):
             return df["self"]["version"]
 
 
-def _generate_spec(model_name, meta, dcae_cs_schema, data_formats, docker_uri):
+def _generate_spec(model_name, meta, dcae_cs_schema, data_formats, model_version):
     """
     Function that generates the component spec from the model metadata and docker info
     Broken out to be unit-testable.
     """
-
+    docker_uri = "{}:{}".format(model_name, model_version)
     spec = {
         "self": {
             "version": "1.0.0",  # hopefully we get this from somewhere and not hardcode this
@@ -54,7 +53,13 @@ def _generate_spec(model_name, meta, dcae_cs_schema, data_formats, docker_uri):
         "services": {"calls": [], "provides": []},
         "streams": {"subscribes": [], "publishes": []},
         "parameters": [],
-        "auxilary": {"healthcheck": {"type": "http", "endpoint": "/healthcheck"}},
+        "auxilary": {"helm": {"service": {"type": "ClusterIP",
+                                          "name": model_name,
+                                          "has_internal_only_ports": "true",
+                                          "ports": [{"name": "http", "port": 8443, "plain_port": 8080,
+                                                     "port_protocol": "http"}]}},
+                     "healthcheck": {"type": "HTTP", "interval": "15s", "timeout": "1s", "port": 8080,
+                                     "endpoint": "/healthcheck"}},
         "artifacts": [{"type": "docker image", "uri": docker_uri}],
     }
 
@@ -62,7 +67,6 @@ def _generate_spec(model_name, meta, dcae_cs_schema, data_formats, docker_uri):
     # each model method gets a subscruber and a publisher, using the methood name
     pstype = "message_router"
     for method in meta["methods"]:
-
         df_in_name = utils.validate_format(meta, method, "input")
         subscriber = {
             "config_key": "{0}_subscriber".format(method),
@@ -82,21 +86,48 @@ def _generate_spec(model_name, meta, dcae_cs_schema, data_formats, docker_uri):
             "type": pstype,
         }
 
+        publisher = {
+            "config_key": "{0}_publisher".format(method),
+            "format": df_out_name,
+            "version": _get_format_version(df_out_name, data_formats),
+            "type": pstype,
+        }
+        parameter_subscriber = {
+            "name": "streams_subscribes",
+            "value": "{{\"{0}_subscriber\":{{\"dmaap_info\":{{\"topic_url\":\"http://message-router:3904/events/unauthenticated.{1}_In\"}},\"type\":\"message_router\"}}}}".format(
+                method, model_name),
+
+            "description": "standard http port collector will open for listening;",
+            "sourced_at_deployment": False,
+            "policy_editable": False,
+            "designer_editable": False
+        }
+        paramter_publisher = {
+            "name": "streams_publishes",
+            "value": "{{\"{0}_publisher\":{{\"dmaap_info\":{{\"topic_url\":\"http://message-router:3904/events/unauthenticated.{1}_Out\"}},\"type\":\"message_router\"}}}}".format(
+                method, model_name),
+            "description": "standard http port collector will open for listening;",
+            "sourced_at_deployment": False,
+            "policy_editable": False,
+            "designer_editable": False
+        }
         spec["streams"]["publishes"].append(publisher)
+        spec["parameters"].append(parameter_subscriber)
+        spec["parameters"].append(paramter_publisher)
 
     # Validate that we have a valid spec
     validate(instance=spec, schema=dcae_cs_schema)
-
     return spec
 
 
-def generate_spec(model_repo_path, model_name, data_formats, docker_uri):
+def generate_spec(model_repo_path, model_name, data_formats, model_version):
     """
     Generate and write the component spec to disk
     Returns the spec
     """
     spec = _generate_spec(
-        model_name, utils.get_metadata(model_repo_path, model_name), utils.component_schema.get(), data_formats, docker_uri
+        model_name, utils.get_metadata(model_repo_path, model_name), utils.component_schema.get(), data_formats,
+        model_version
     )
     fname = "{0}_dcae_component_specification.json".format(model_name)
     with open("{0}/{1}".format(model_repo_path, fname), "w") as f:
index eec4777..c160103 100644 (file)
@@ -4,7 +4,6 @@
 org.onap.dcae
 ================================================================================
 Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
-================================================================================
 Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 =============================================================================
 Licensed under the Apache License, Version 2.0 (the "License");
@@ -25,7 +24,7 @@ limitations under the License.
        <modelVersion>4.0.0</modelVersion>
        <groupId>org.onap.dcaegen2.platform.adapter</groupId>
        <artifactId>dcaegen2-platform-adapter-acumos</artifactId>
-       <version>1.0.6-SNAPSHOT</version>
+       <version>1.0.7</version>
        <properties>
                <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                <sonar.sources>.</sonar.sources>
index ae56ca1..ba32a0c 100644 (file)
@@ -2,7 +2,6 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
-# =============================================================================
 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,7 +21,7 @@ from setuptools import setup, find_packages
 
 setup(
     name="aoconversion",
-    version="1.0.6-SNAPSHOT",
+    version="1.0.7",
     packages=find_packages(exclude=["tests.*", "tests"]),
     author="Tommy Carpenter, Andrew Gauld",
     author_email="tommy@research.att.com, agauld@att.com",
index 4219f66..8fef707 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -28,7 +29,7 @@ from tests import testing_helpers
 def mock_schemas(monkeypatch):
     cwd = os.getcwd()
     schemadir = cwd[:cwd.find('/adapter/acumos')] + '/mod/component-json-schemas'
-    monkeypatch.setattr(aoconversion.utils.component_schema, 'path', schemadir + '/component-specification/dcae-cli-v2/component-spec-schema.json')
+    monkeypatch.setattr(aoconversion.utils.component_schema, 'path', schemadir + '/component-specification/dcae-cli-v3/component-spec-schema.json')
     monkeypatch.setattr(aoconversion.utils.dataformat_schema, 'path', schemadir + '/data-format/dcae-cli-v1/data-format-schema.json')
     monkeypatch.setattr(aoconversion.utils.schema_schema, 'ret', requests.get('https://json-schema.org/draft-04/schema#').json())
 
index 207fe0c..b347258 100644 (file)
@@ -7,4 +7,4 @@ certfile: /run/certs/cert.pem
 dockerregistry: 'dockerregistry'
 dockeruser: 'dockeruser'
 dockerpass: 'dockerpass'
-port: '90'
\ No newline at end of file
+port: '90'
index 56b6e6e..ce874e4 100644 (file)
@@ -1 +1 @@
-{"self": {"name": "ArgsList", "version": "1.0.0"}, "dataformatversion": "1.0.1", "jsonschema": {"title": "ArgsList", "type": "object", "properties": {"args": {"type": "array", "items": {"$ref": "#/definitions/Args"}}}, "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {"Args": {"title": "Args", "type": "object", "properties": {"x": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}, "y": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}}}}}}
\ No newline at end of file
+{"self": {"name": "ArgsList", "version": "1.0.0"}, "dataformatversion": "1.0.1", "jsonschema": {"title": "ArgsList", "type": "object", "properties": {"args": {"type": "array", "items": {"$ref": "#/definitions/Args"}}}, "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {"Args": {"title": "Args", "type": "object", "properties": {"x": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}, "y": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}}}}}}
index 3f7cdca..fb27276 100644 (file)
@@ -1 +1 @@
-{"self": {"name": "SumOut", "version": "1.0.0"}, "dataformatversion": "1.0.1", "jsonschema": {"title": "SumOut", "type": "object", "properties": {"value": {"type": "array", "items": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}}}, "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}}}
\ No newline at end of file
+{"self": {"name": "SumOut", "version": "1.0.0"}, "dataformatversion": "1.0.1", "jsonschema": {"title": "SumOut", "type": "object", "properties": {"value": {"type": "array", "items": {"type": "integer", "minimum": -9007199254740991, "maximum": 9007199254740991}}}, "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}}}
index e9df2bd..5826015 100644 (file)
@@ -1 +1 @@
-{"schema": "acumos.schema.model:0.4.0", "runtime": {"name": "python", "encoding": "protobuf", "version": "3.6.8", "dependencies": {"pip": {"indexes": [], "requirements": [{"name": "dill", "version": "0.3.0"}, {"name": "acumos", "version": "0.8.0"}]}, "conda": {"channels": [], "requirements": []}}}, "name": "example-model", "methods": {"sum": {"input": "ArgsList", "output": "SumOut", "description": ""}}}
\ No newline at end of file
+{"schema": "acumos.schema.model:0.4.0", "runtime": {"name": "python", "encoding": "protobuf", "version": "3.6.8", "dependencies": {"pip": {"indexes": [], "requirements": [{"name": "dill", "version": "0.3.0"}, {"name": "acumos", "version": "0.8.0"}]}, "conda": {"channels": [], "requirements": []}}}, "name": "example-model", "methods": {"sum": {"input": "ArgsList", "output": "SumOut", "description": ""}}}
diff --git a/adapter/acumos/tests/fixtures/models/example-model/requirements.txt b/adapter/acumos/tests/fixtures/models/example-model/requirements.txt
new file mode 100644 (file)
index 0000000..033b24c
--- /dev/null
@@ -0,0 +1,2 @@
+dill==0.3.0
+acumos==0.8.0
index bee53a0..37a2e39 100644 (file)
@@ -2,7 +2,6 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
-# =============================================================================
 # Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
@@ -44,7 +43,8 @@ def test_generate_dockerfile():
     ENV no_proxy=
     ENV NO_PROXY=
     RUN pip install -r /app/requirements.txt && \
-        pip install acumos_dcae_model_runner
+        pip install acumos_dcae_model_runner && \
+        pip install pyyaml
 
     ENV DCAEPORT=10000
     EXPOSE $DCAEPORT
index 4771a1c..2b610b7 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -27,26 +28,63 @@ def test_generate_spec(mock_schemas):
     Test generating data formats from the protobuf
     """
     test_proto_path = get_fixture_path("models/example-model/model.proto")
-    data_formats = dataformat_gen._generate_dcae_data_formats(test_proto_path, TEST_META, utils.dataformat_schema.get(), utils.schema_schema.get())
+    data_formats = dataformat_gen._generate_dcae_data_formats(test_proto_path, TEST_META, utils.dataformat_schema.get(),
+                                                              utils.schema_schema.get())
     assert spec_gen._generate_spec(
-        "example-model", TEST_META, utils.component_schema.get(), data_formats, "nexus01.fake.com:18443/example-model:latest"
+        "example-model", TEST_META, utils.component_schema.get(), data_formats,
+        "latest"
     ) == {
-        "self": {
-            "version": "1.0.0",
-            "name": "example-model",
-            "description": "Automatically generated from Acumos model",
-            "component_type": "docker",
-        },
-        "services": {"calls": [], "provides": []},
-        "streams": {
-            "subscribes": [
-                {"config_key": "add_subscriber", "format": "NumbersIn", "version": "1.0.0", "type": "message_router"}
-            ],
-            "publishes": [
-                {"config_key": "add_publisher", "format": "NumberOut", "version": "1.0.0", "type": "message_router"}
-            ],
-        },
-        "parameters": [],
-        "auxilary": {"healthcheck": {"type": "http", "endpoint": "/healthcheck"}},
-        "artifacts": [{"type": "docker image", "uri": "nexus01.fake.com:18443/example-model:latest"}],
-    }
+               "self": {
+                   "version": "1.0.0",
+                   "name": "example-model",
+                   "description": "Automatically generated from Acumos model",
+                   "component_type": "docker",
+               },
+               "services": {"calls": [], "provides": []},
+               "streams": {
+                   "subscribes": [
+                       {"config_key": "add_subscriber", "format": "NumbersIn", "version": "1.0.0",
+                        "type": "message_router"}
+                   ],
+                   "publishes": [
+                       {"config_key": "add_publisher", "format": "NumberOut", "version": "1.0.0",
+                        "type": "message_router"}
+                   ],
+               },
+               "parameters": [
+                   {
+                       "name": "streams_subscribes",
+                       "value": "{\"add_subscriber\":{\"dmaap_info\":{\"topic_url\":\"http://message-router:3904/events/unauthenticated.example-model_In\"},\"type\":\"message_router\"}}",
+                       "description": "standard http port collector will open for listening;",
+                       "sourced_at_deployment": False,
+                       "policy_editable": False,
+                       "designer_editable": False
+                   },
+                   {
+                       "name": "streams_publishes",
+                       "value": "{\"add_publisher\":{\"dmaap_info\":{\"topic_url\":\"http://message-router:3904/events/unauthenticated.example-model_Out\"},\"type\":\"message_router\"}}",
+                       "description": "standard http port collector will open for listening;",
+                       "sourced_at_deployment": False,
+                       "policy_editable": False,
+                       "designer_editable": False
+                   }
+               ],
+               "auxilary": {
+                   "helm": {
+                       "service": {
+                           "type": "ClusterIP",
+                           "name": "example-model",
+                           "has_internal_only_ports": "true",
+                           "ports": [{
+                               "name": "http",
+                               "port": 8443,
+                               "plain_port": 8080,
+                               "port_protocol": "http"
+                           }
+                           ]
+                       }
+                   },
+                   "healthcheck": {"type": "HTTP", "interval": "15s", "timeout": "1s", "port": 8080,
+                                   "endpoint": "/healthcheck"}},
+               "artifacts": [{"type": "docker image", "uri": "example-model:latest"}],
+           }
index deebf3b..ea7a24e 100644 (file)
@@ -2,6 +2,7 @@
 # org.onap.dcae
 # =============================================================================
 # Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2021 highstreet technologies GmbH. All rights reserved.
 # =============================================================================
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -17,7 +18,7 @@
 # ============LICENSE_END======================================================
 
 [tox]
-envlist = py37,flake8
+envlist = py39,flake8
 
 [testenv]
 whitelist_externals =
@@ -35,7 +36,7 @@ commands=
     pytest --verbose --junitxml xunit-results.xml --cov aoconversion  --cov-report xml --cov-report html --cov-report term
 
 [testenv:flake8]
-basepython = python3.7
+basepython = python3.9
 skip_install = true
 deps = flake8
 commands = flake8 setup.py aoconversion tests