diff options
79 files changed, 4993 insertions, 372 deletions
diff --git a/adapter/acumos/aoconversion/spec_gen.py b/adapter/acumos/aoconversion/spec_gen.py index 1662872..4230f6d 100644 --- a/adapter/acumos/aoconversion/spec_gen.py +++ b/adapter/acumos/aoconversion/spec_gen.py @@ -29,7 +29,7 @@ from aoconversion import utils def _get_dcae_cs_schema(): res = requests.get( - "https://gerrit.onap.org/r/gitweb?p=dcaegen2/platform/cli.git;a=blob_plain;f=component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json;hb=HEAD" + "https://git.onap.org/dcaegen2/platform/plain/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json" ) return res.json() diff --git a/adapter/acumos/pom.xml b/adapter/acumos/pom.xml index 4d5facd..7d872ef 100644 --- a/adapter/acumos/pom.xml +++ b/adapter/acumos/pom.xml @@ -28,7 +28,7 @@ limitations under the License. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> - <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> + <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths> <sonar.language>py</sonar.language> <sonar.pluginname>python</sonar.pluginname> <sonar.inclusions>**/*.py</sonar.inclusions> diff --git a/adapter/acumos/tests/fixtures/dcae-cli-v2_component-spec-schema.json b/adapter/acumos/tests/fixtures/dcae-cli-v2_component-spec-schema.json index 1f1f75e..0fd68ec 100644 --- a/adapter/acumos/tests/fixtures/dcae-cli-v2_component-spec-schema.json +++ b/adapter/acumos/tests/fixtures/dcae-cli-v2_component-spec-schema.json @@ -102,6 +102,36 @@ "items": { "$ref": "#/definitions/artifact" } + }, + "policy_info": { + "type": "object", + "properties": { + "policy": + { + "type": "array", + "items": + { + "type": "object", + "properties": + { + "node_label": + { + "type": "string" + }, + "policy_id": + { + "type": "string" + }, + "policy_model_id": + { + "type": "string" + } + }, + "required": ["node_label", "policy_model_id"] + } + } + }, + "additionalProperties": false } }, "required": [ @@ -740,7 +770,7 @@ "type": "string" } }, - "logging": { + "log_info": { "description": "Component specific details for logging", "type": "object", "properties": { @@ -755,6 +785,34 @@ }, "additionalProperties": false }, + "tls_info": { + "description": "Component information to use tls certificates", + "type": "object", + "properties": { + "cert_directory": { + "description": "The path in the container where the component certificates will be placed by the init container", + "type": "string" + }, + "use_tls": { + "description": "Boolean flag to determine if the application is using tls certificates", + "type": "boolean" + } + }, + "required": [ + "cert_directory","use_tls" + ], + "additionalProperties": false + }, + "databases": { + "description": "The databases the application is connecting to using the pgaas", + "type": "object", + "additionalProperties": { + "type": "string", + "enum": [ + "postgres" + ] + } + }, "policy": { "properties": { "trigger_type": { diff --git a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml new file mode 100644 index 0000000..95961ee --- /dev/null +++ b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_with_dmaap.yaml @@ -0,0 +1,376 @@ +# ============LICENSE_START======================================================= +# org.onap.dcae +# ================================================================================ +# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +#description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR +#blueprint_version: 1.0.1 +--- +tosca_definitions_version: cloudify_dsl_1_3 +description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing + them and publishing them as PM files to local DMaaP DR +imports: +- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml +inputs: + DCAE-HELLO-WORLD-PUB-DR_DCAE-HELLO-WORLD-PUB-DR_feed_location: + type: string + DCAE-HELLO-WORLD-PUB-DR_feed_name: + type: string + DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_password: + type: string + DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_username: + type: string + DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_client_role: + type: string + DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_location: + type: string + DCAE-HELLO-WORLD-PUB-MR_topic_name: + type: string + DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_decompress: + type: string + DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_location: + type: string + DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_password: + type: string + DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_priviliged: + type: string + DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_username: + type: string + DCAE-HELLO-WORLD-SUB-DR_feed_name: + type: string + DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_password: + type: string + DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_username: + type: string + DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_client_role: + type: string + DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_location: + type: string + DCAE-HELLO-WORLD-SUB-MR_topic_name: + type: string + dcae.collectors.vcc.helloworld.pm_cpu_limit: + type: string + default: "250m" + dcae.collectors.vcc.helloworld.pm_cpu_request: + type: string + default: "250m" + dcae.collectors.vcc.helloworld.pm_memory_limit: + type: string + default: "128Mi" + dcae.collectors.vcc.helloworld.pm_memory_request: + type: string + default: "128Mi" + dcaes_database_name: + type: string + description: db name + default: "" + dcaes_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + dti_database_name: + type: string + description: db name + default: "" + dti_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + envs: + default: &envs {} + replicas: + type: integer + description: number of instances + default: 1 + repo_database_name: + type: string + description: db name + default: "" + repo_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + service_component_name_override: + type: string + default: "" + tag_version: + type: string + default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + tca_policy_00_policy_id: + type: string + description: policy_id + default: "" + tca_policy_11_policy_id: + type: string + description: policy_id + default: "tca_policy_id_11" + use_tls: + type: boolean + description: flag to indicate tls enable/disable + default: true + vcc_hello_name: + type: string + default: "fsdfa" +node_templates: + DCAE-HELLO-WORLD-PUB-DR_feed: + type: ccsdk.nodes.Feed + properties: + feed_name: + get_input: DCAE-HELLO-WORLD-PUB-DR_feed_name + DCAE-HELLO-WORLD-PUB-MR_topic: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: DCAE-HELLO-WORLD-PUB-MR_topic_name + DCAE-HELLO-WORLD-SUB-DR_feed: + type: ccsdk.nodes.Feed + properties: + feed_name: + get_input: DCAE-HELLO-WORLD-SUB-DR_feed_name + DCAE-HELLO-WORLD-SUB-MR_topic: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: DCAE-HELLO-WORLD-SUB-MR_topic_name + dcae.collectors.vcc.helloworld.pm: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + ports: [] + envs: + <<: *envs + DCAES_DB_NAME: + get_input: dcaes_database_name + DCAES_DB_ADMIN_HOST: + get_attribute: + - dcaes_pgaasdb + - admin + - host + DCAES_DB_ADMIN_USER: + get_attribute: + - dcaes_pgaasdb + - admin + - user + DCAES_DB_ADMIN_PASS: + get_attribute: + - dcaes_pgaasdb + - admin + - password + DTI_DB_NAME: + get_input: dti_database_name + DTI_DB_ADMIN_HOST: + get_attribute: + - dti_pgaasdb + - admin + - host + DTI_DB_ADMIN_USER: + get_attribute: + - dti_pgaasdb + - admin + - user + DTI_DB_ADMIN_PASS: + get_attribute: + - dti_pgaasdb + - admin + - password + REPO_DB_NAME: + get_input: repo_database_name + REPO_DB_ADMIN_HOST: + get_attribute: + - repo_pgaasdb + - admin + - host + REPO_DB_ADMIN_USER: + get_attribute: + - repo_pgaasdb + - admin + - user + REPO_DB_ADMIN_PASS: + get_attribute: + - repo_pgaasdb + - admin + - password + properties: + application_config: + service_calls: [] + streams_publishes: + DCAE-HELLO-WORLD-PUB-DR: + dmaap_info: <<DCAE-HELLO-WORLD-PUB-DR_feed>> + type: data_router + DCAE-HELLO-WORLD-PUB-MR: + dmaap_info: <<DCAE-HELLO-WORLD-PUB-MR_topic>> + type: message_router + pass: + get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_password + user: + get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_aaf_username + streams_subscribes: + DCAE-HELLO-WORLD-SUB-DR: + dmaap_info: <<DCAE-HELLO-WORLD-SUB-DR_feed>> + type: data_router + DCAE-HELLO-WORLD-SUB-MR: + dmaap_info: <<DCAE-HELLO-WORLD-SUB-MR_topic>> + type: message_router + pass: + get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_password + user: + get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_aaf_username + isSelfServeComponent: false + service_component_name_override: + get_input: service_component_name_override + useDtiConfig: false + vcc_hello_name: + get_input: vcc_hello_name + docker_config: + healthcheck: + interval: 60s + timeout: 20s + script: /opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh + type: docker + volumes: + - container: + bind: /opt/app/dcae-certificate + host: + path: /opt/app/dcae-certificate + - container: + bind: /opt/logs/DCAE/dmd/AGENT + host: + path: /opt/logs/DCAE/helloworldpm/dmd/AGENT + - container: + bind: /opt/logs/DCAE/dmd/WATCHER + host: + path: /opt/logs/DCAE/helloworldpm/dmd/WATCHER + - container: + bind: /opt/app/vcc/logs/DCAE + host: + path: /opt/logs/DCAE/helloworldpm/vcc-logs + - container: + bind: /opt/app/vcc/archive/data + host: + path: /opt/data/DCAE/helloworldpm/vcc-archive + image: + get_input: tag_version + service_component_type: dcae-collectors-vcc-helloworld-pm + log_info: + log_directory: /opt/app/VESCollector/logs/ecomp + replicas: + get_input: replicas + streams_publishes: + - name: DCAE-HELLO-WORLD-PUB-DR_feed + location: + get_input: DCAE-HELLO-WORLD-PUB-DR_DCAE-HELLO-WORLD-PUB-DR_feed_location + type: data_router + - name: DCAE-HELLO-WORLD-PUB-MR_topic + location: + get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_location + client_role: + get_input: DCAE-HELLO-WORLD-PUB-MR_DCAE-HELLO-WORLD-PUB-MR_topic_client_role + type: message_router + streams_subscribes: + - name: DCAE-HELLO-WORLD-SUB-MR_topic + location: + get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_location + client_role: + get_input: DCAE-HELLO-WORLD-SUB-MR_DCAE-HELLO-WORLD-SUB-MR_topic_client_role + type: message_router + - name: DCAE-HELLO-WORLD-SUB-DR_feed + location: + get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_location + type: data_router + username: + get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_username + password: + get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_password + privileged: + get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_priviliged + decompress: + get_input: DCAE-HELLO-WORLD-SUB-DR_DCAE-HELLO-WORLD-SUB-DR_feed_decompress + route: /DCAE-HELLO-WORLD-SUB-DR + scheme: https + tls_info: + cert_directory: /opt/app/dh/etc/cert + use_tls: + get_input: use_tls + resource_config: + limits: + cpu: + get_input: dcae.collectors.vcc.helloworld.pm_cpu_limit + memory: + get_input: dcae.collectors.vcc.helloworld.pm_memory_limit + requests: + cpu: + get_input: dcae.collectors.vcc.helloworld.pm_cpu_request + memory: + get_input: dcae.collectors.vcc.helloworld.pm_memory_request + relationships: + - type: ccsdk.relationships.publish_files + target: DCAE-HELLO-WORLD-PUB-DR_feed + - type: ccsdk.relationships.publish_events + target: DCAE-HELLO-WORLD-PUB-MR_topic + - type: ccsdk.relationships.subscribe_to_events + target: DCAE-HELLO-WORLD-SUB-MR_topic + - type: ccsdk.relationships.subscribe_to_files + target: DCAE-HELLO-WORLD-SUB-DR_feed + - type: cloudify.relationships.depends_on + target: tca_policy_00 + - type: cloudify.relationships.depends_on + target: tca_policy_11 + - type: cloudify.relationships.depends_on + target: dcaes_pgaasdb + - type: cloudify.relationships.depends_on + target: dti_pgaasdb + - type: cloudify.relationships.depends_on + target: repo_pgaasdb + dcaes_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: dcaes_database_writerfqdn + name: + get_input: dcaes_database_name + use_existing: true + dti_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: dti_database_writerfqdn + name: + get_input: dti_database_name + use_existing: true + repo_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: repo_database_writerfqdn + name: + get_input: repo_database_name + use_existing: true + tca_policy_00: + type: clamp.nodes.policy + properties: + policy_id: + get_input: tca_policy_00_policy_id + policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app + tca_policy_11: + type: clamp.nodes.policy + properties: + policy_id: + get_input: tca_policy_11_policy_id + policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml new file mode 100644 index 0000000..4e1f5b5 --- /dev/null +++ b/mod/bpgenerator/TestCases/helloworld/blueprint/helloworld_changed_without_dmaap_yaml.yaml @@ -0,0 +1,330 @@ +# ============LICENSE_START======================================================= +# org.onap.dcae +# ================================================================================ +# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +#description: Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR +#blueprint_version: 1.0.1 +--- +tosca_definitions_version: cloudify_dsl_1_3 +imports: +- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml +inputs: + DCAE-HELLO-WORLD-PUB-DR_delivery_url: + type: string + DCAE-HELLO-WORLD-PUB-DR_location: + type: string + DCAE-HELLO-WORLD-PUB-DR_password: + type: string + DCAE-HELLO-WORLD-PUB-DR_subscriber_id: + type: string + DCAE-HELLO-WORLD-PUB-DR_username: + type: string + DCAE-HELLO-WORLD-SUB-DR_delivery_url: + type: string + DCAE-HELLO-WORLD-SUB-DR_location: + type: string + DCAE-HELLO-WORLD-SUB-DR_password: + type: string + DCAE-HELLO-WORLD-SUB-DR_subscriber_id: + type: string + DCAE-HELLO-WORLD-SUB-DR_username: + type: string + DCAE_HELLO_WORLD_PUB_MR_publish_url: + type: string + DCAE_HELLO_WORLD_SUB_MR_subscribe_url: + type: string + always_pull_image: + type: boolean + description: Set to true if the image should always be pulled + default: true + dcae.collectors.vcc.helloworld.pm_cpu_limit: + type: string + default: "250m" + dcae.collectors.vcc.helloworld.pm_cpu_request: + type: string + default: "250m" + dcae.collectors.vcc.helloworld.pm_memory_limit: + type: string + default: "128Mi" + dcae.collectors.vcc.helloworld.pm_memory_request: + type: string + default: "128Mi" + dcaes_database_name: + type: string + description: db name + default: "" + dcaes_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + dti_database_name: + type: string + description: db name + default: "" + dti_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + envs: + default: &envs {} + image: + type: string + default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + location_id: + type: string + default: "" + replicas: + type: integer + description: number of instances + default: 1 + repo_database_name: + type: string + description: db name + default: "" + repo_database_writerfqdn: + type: string + description: db writerfqdn + default: "" + service_component_name_override: + type: string + default: "" + tca_policy_00_policy_id: + type: string + description: policy_id + default: "" + tca_policy_11_policy_id: + type: string + description: policy_id + default: "tca_policy_id_11" + use_tls: + type: boolean + description: flag to indicate tls enable/disable + default: true + vcc_hello_name: + type: string + default: "fsdfa" +node_templates: + dcae.collectors.vcc.helloworld.pm: + type: dcae.nodes.ContainerizedPlatformComponent + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + ports: [] + envs: + <<: *envs + DCAES_DB_NAME: + get_input: dcaes_database_name + DCAES_DB_ADMIN_HOST: + get_attribute: + - dcaes_pgaasdb + - admin + - host + DCAES_DB_ADMIN_USER: + get_attribute: + - dcaes_pgaasdb + - admin + - user + DCAES_DB_ADMIN_PASS: + get_attribute: + - dcaes_pgaasdb + - admin + - password + DTI_DB_NAME: + get_input: dti_database_name + DTI_DB_ADMIN_HOST: + get_attribute: + - dti_pgaasdb + - admin + - host + DTI_DB_ADMIN_USER: + get_attribute: + - dti_pgaasdb + - admin + - user + DTI_DB_ADMIN_PASS: + get_attribute: + - dti_pgaasdb + - admin + - password + REPO_DB_NAME: + get_input: repo_database_name + REPO_DB_ADMIN_HOST: + get_attribute: + - repo_pgaasdb + - admin + - host + REPO_DB_ADMIN_USER: + get_attribute: + - repo_pgaasdb + - admin + - user + REPO_DB_ADMIN_PASS: + get_attribute: + - repo_pgaasdb + - admin + - password + properties: + application_config: + service_calls: [] + streams_publishes: + DCAE-HELLO-WORLD-PUB-DR: + dmaap_info: + username: + get_input: DCAE-HELLO-WORLD-PUB-DR_username + password: + get_input: DCAE-HELLO-WORLD-PUB-DR_password + location: + get_input: DCAE-HELLO-WORLD-PUB-DR_location + delivery_url: + get_input: DCAE-HELLO-WORLD-PUB-DR_delivery_url + subscriber_id: + get_input: DCAE-HELLO-WORLD-PUB-DR_subscriber_id + type: data_router + DCAE-HELLO-WORLD-PUB-MR: + dmaap_info: + topic_url: + get_input: DCAE_HELLO_WORLD_PUB_MR_publish_url + type: message_router + streams_subscribes: + DCAE-HELLO-WORLD-SUB-DR: + dmaap_info: + username: + get_input: DCAE-HELLO-WORLD-SUB-DR_username + password: + get_input: DCAE-HELLO-WORLD-SUB-DR_password + location: + get_input: DCAE-HELLO-WORLD-SUB-DR_location + delivery_url: + get_input: DCAE-HELLO-WORLD-SUB-DR_delivery_url + subscriber_id: + get_input: DCAE-HELLO-WORLD-SUB-DR_subscriber_id + type: data_router + DCAE-HELLO-WORLD-SUB-MR: + dmaap_info: + topic_url: + get_input: DCAE_HELLO_WORLD_SUB_MR_subscribe_url + type: message_router + isSelfServeComponent: false + service_component_name_override: + get_input: service_component_name_override + useDtiConfig: false + vcc_hello_name: + get_input: vcc_hello_name + docker_config: + healthcheck: + interval: 60s + timeout: 20s + script: /opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh + type: docker + volumes: + - container: + bind: /opt/app/dcae-certificate + host: + path: /opt/app/dcae-certificate + - container: + bind: /opt/logs/DCAE/dmd/AGENT + host: + path: /opt/logs/DCAE/helloworldpm/dmd/AGENT + - container: + bind: /opt/logs/DCAE/dmd/WATCHER + host: + path: /opt/logs/DCAE/helloworldpm/dmd/WATCHER + - container: + bind: /opt/app/vcc/logs/DCAE + host: + path: /opt/logs/DCAE/helloworldpm/vcc-logs + - container: + bind: /opt/app/vcc/archive/data + host: + path: /opt/data/DCAE/helloworldpm/vcc-archive + image: + get_input: image + location_id: + get_input: location_id + log_info: + log_directory: /opt/app/VESCollector/logs/ecomp + dns_name: dcae.collectors.vcc.helloworld.pm + replicas: + get_input: replicas + name: dcae.collectors.vcc.helloworld.pm + tls_info: + cert_directory: /opt/app/dh/etc/cert + use_tls: + get_input: use_tls + resource_config: + limits: + cpu: + get_input: dcae.collectors.vcc.helloworld.pm_cpu_limit + memory: + get_input: dcae.collectors.vcc.helloworld.pm_memory_limit + requests: + cpu: + get_input: dcae.collectors.vcc.helloworld.pm_cpu_request + memory: + get_input: dcae.collectors.vcc.helloworld.pm_memory_request + always_pull_image: + get_input: always_pull_image + relationships: + - type: cloudify.relationships.depends_on + target: tca_policy_00 + - type: cloudify.relationships.depends_on + target: tca_policy_11 + - type: cloudify.relationships.depends_on + target: dcaes_pgaasdb + - type: cloudify.relationships.depends_on + target: dti_pgaasdb + - type: cloudify.relationships.depends_on + target: repo_pgaasdb + dcaes_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: dcaes_database_writerfqdn + name: + get_input: dcaes_database_name + use_existing: true + dti_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: dti_database_writerfqdn + name: + get_input: dti_database_name + use_existing: true + repo_pgaasdb: + type: dcae.nodes.pgaas.database + properties: + writerfqdn: + get_input: repo_database_writerfqdn + name: + get_input: repo_database_name + use_existing: true + tca_policy_00: + type: clamp.nodes.policy + properties: + policy_id: + get_input: tca_policy_00_policy_id + policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app + tca_policy_11: + type: clamp.nodes.policy + properties: + policy_id: + get_input: tca_policy_11_policy_id + policy_model_id: onap.policies.monitoring.cdap.tca.hi.lo.app
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json b/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json new file mode 100644 index 0000000..24d8491 --- /dev/null +++ b/mod/bpgenerator/TestCases/helloworld/compspec/hello-changed.json @@ -0,0 +1,154 @@ +{ + "self": { + "component_type": "docker", + "description": "Hello World mS for subscribing the data from local DMaaP, DR or MR, processing them and publishing them as PM files to local DMaaP DR", + "name": "dcae.collectors.vcc.helloworld.pm", + "version": "1.0.1" + }, + "services": { + "calls": [], + "provides": [] + }, + "streams": { + "publishes": [{ + "config_key": "DCAE-HELLO-WORLD-PUB-DR", + "format": "dataformat_Hello_World_PM", + "type": "data_router", + "version": "1.0.0" + }, + { + "config_key": "DCAE-HELLO-WORLD-PUB-MR", + "format": "dataformat_Hello_World_PM", + "type": "message_router", + "version": "1.0.0" + } + ], + "subscribes": [{ + "config_key": "DCAE-HELLO-WORLD-SUB-MR", + "format": "dataformat_Hello_World_PM", + "route": "/DCAE_HELLO_WORLD_SUB_MR", + "type": "message_router", + "version": "1.0.0" + }, + { + "config_key": "DCAE-HELLO-WORLD-SUB-DR", + "format": "dataformat_Hello_World_PM", + "route": "/DCAE-HELLO-WORLD-SUB-DR", + "type": "data_router", + "version": "1.0.0" + } + ] + }, + "parameters": + [ + { + "name": "vcc_hello_name", + "value": "fsdfa", + "description": "the name entered for specific person", + "sourced_at_deployment": true, + "designer_editable": true, + "policy_editable": false, + "type": "string" + }, + + { + "name": "useDtiConfig", + "value": false, + "description": "component depends on configuration from dti.", + "sourced_at_deployment": false, + "designer_editable": false, + "policy_editable": false, + "required" : true + }, + + { + "name": "isSelfServeComponent", + "value": false, + "description": "Is this used as self serve component.", + "sourced_at_deployment": false, + "designer_editable": false, + "policy_editable": false, + "required" : true, + "type": "string" + } + ], + "auxilary": { + "healthcheck": { + "interval": "60s", + "timeout": "20s", + "script": "/opt/app/vcc/bin/common/HealthCheck_HelloWorld.sh", + "type": "docker" + }, + "log_info": { + "log_directory": "/opt/app/VESCollector/logs/ecomp" + }, + "tls_info":{ + "cert_directory":"/opt/app/dh/etc/cert", + "use_tls":true + }, + "databases": { + "dcaes": "PgaaS", + "repo": "PgaaS", + "dti": "pgaas" + }, + "volumes": [ + { + "container": { + "bind": "/opt/app/dcae-certificate" + }, + "host": { + "path": "/opt/app/dcae-certificate" + } + }, + { + "container": { + "bind": "/opt/logs/DCAE/dmd/AGENT" + }, + "host": { + "path": "/opt/logs/DCAE/helloworldpm/dmd/AGENT" + } + }, + { + "container": { + "bind": "/opt/logs/DCAE/dmd/WATCHER" + }, + "host": { + "path": "/opt/logs/DCAE/helloworldpm/dmd/WATCHER" + } + }, + { + "container": { + "bind": "/opt/app/vcc/logs/DCAE" + }, + "host": { + "path": "/opt/logs/DCAE/helloworldpm/vcc-logs" + } + }, + { + "container": { + "bind": "/opt/app/vcc/archive/data" + }, + "host": { + "path": "/opt/data/DCAE/helloworldpm/vcc-archive" + } + } + ] + }, + "policy_info":{ + "policy":[ + { + "node_label":"tca_policy_00", + "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app" + }, + { + "node_label":"tca_policy_11", + "policy_id":"tca_policy_id_11", + "policy_model_id":"onap.policies.monitoring.cdap.tca.hi.lo.app" + } + ] + }, + "artifacts": [{ + "type": "docker image", + "uri": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + }] +}
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/blueprints/ves-no-change_yaml.yaml b/mod/bpgenerator/TestCases/ves/blueprints/ves-no-change_yaml.yaml new file mode 100644 index 0000000..b93f9c1 --- /dev/null +++ b/mod/bpgenerator/TestCases/ves/blueprints/ves-no-change_yaml.yaml @@ -0,0 +1,187 @@ +# ============LICENSE_START======================================================= +# org.onap.dcae +# ================================================================================ +# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# +# +#description: Collector for receiving VES events through restful interface +#blueprint_version: 1.5.0 +--- +tosca_definitions_version: cloudify_dsl_1_3 +imports: +- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml +inputs: + always_pull_image: + type: boolean + description: Set to true if the image should always be pulled + default: true + collector.dmaap.streamid: + type: string + default: "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary" + dcae-ves-collector_cpu_limit: + type: string + default: "250m" + dcae-ves-collector_cpu_request: + type: string + default: "250m" + dcae-ves-collector_memory_limit: + type: string + default: "128Mi" + dcae-ves-collector_memory_request: + type: string + default: "128Mi" + envs: + default: {} + external_port_0: + type: string + default: "8080" + external_port_1: + type: string + default: "8443" + header.authlist: + type: string + default: "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy" + image: + type: string + default: "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + location_id: + type: string + default: "" + replicas: + type: integer + description: number of instances + default: 1 + service_component_name_override: + type: string + default: "" + ves_fault_publish_url: + type: string + ves_heartbeat_secondary_publish_url: + type: string + ves_measurement_publish_url: + type: string + ves_notification_publish_url: + type: string + ves_other_publish_url: + type: string + ves_pnfRegistration_publish_url: + type: string +node_templates: + dcae-ves-collector: + type: dcae.nodes.ContainerizedPlatformComponent + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + ports: + - concat: ["8080:", {get_input: external_port_0}] + - concat: ["8443:", {get_input: external_port_1}] + envs: + get_input: envs + properties: + application_config: + service_calls: [] + streams_publishes: + ves-fault: + dmaap_info: + topic_url: + get_input: ves_fault_publish_url + type: message router + ves-heartbeat-secondary: + dmaap_info: + topic_url: + get_input: ves_heartbeat_secondary_publish_url + type: message router + ves-measurement: + dmaap_info: + topic_url: + get_input: ves_measurement_publish_url + type: message router + ves-notification: + dmaap_info: + topic_url: + get_input: ves_notification_publish_url + type: message router + ves-other: + dmaap_info: + topic_url: + get_input: ves_other_publish_url + type: message router + ves-pnfRegistration: + dmaap_info: + topic_url: + get_input: ves_pnfRegistration_publish_url + type: message router + streams_subscribes: {} + auth.method: noAuth + collector.dmaap.streamid: + get_input: collector.dmaap.streamid + collector.keystore.file.location: /opt/app/dcae-certificate/keystore.jks + collector.keystore.passwordfile: /opt/app/dcae-certificate/.password + collector.schema.checkflag: 1 + collector.schema.file: {"v1":"./etc/CommonEventFormat_27.2.json","v2":"./etc/CommonEventFormat_27.2.json","v3":"./etc/CommonEventFormat_27.2.json","v4":"./etc/CommonEventFormat_27.2.json","v5":"./etc/CommonEventFormat_28.4.1.json","v7":"./etc/CommonEventFormat_30.json"} + collector.service.port: 8080 + collector.service.secure.port: 8443 + collector.truststore.file.location: /opt/app/dcae-certificate/truststore.jks + collector.truststore.passwordfile: /opt/app/dcae-certificate/.trustpassword + event.transform.flag: 1 + header.authlist: + get_input: header.authlist + service_component_name_override: + get_input: service_component_name_override + tomcat.maxthreads: 200 + docker_config: + healthcheck: + interval: 15s + timeout: 1s + type: https + endpoint: /healthcheck + volumes: + - container: + bind: /opt/app/dcae-certificate + host: + path: /opt/app/dcae-certificate + - container: + bind: /opt/app/VESCollector/logs + host: + path: /opt/logs/DCAE/VESCollector/logs + - container: + bind: /opt/app/VESCollector/etc + host: + path: /opt/logs/DCAE/VESCollector/etc + image: + get_input: image + location_id: + get_input: location_id + dns_name: dcae-ves-collector + replicas: + get_input: replicas + name: dcae-ves-collector + resource_config: + limits: + cpu: + get_input: dcae-ves-collector_cpu_limit + memory: + get_input: dcae-ves-collector_memory_limit + requests: + cpu: + get_input: dcae-ves-collector_cpu_request + memory: + get_input: dcae-ves-collector_memory_request + always_pull_image: + get_input: always_pull_image + relationships: []
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/blueprints/ves-with-dmaap_yaml.yaml b/mod/bpgenerator/TestCases/ves/blueprints/ves-with-dmaap_yaml.yaml new file mode 100644 index 0000000..915411e --- /dev/null +++ b/mod/bpgenerator/TestCases/ves/blueprints/ves-with-dmaap_yaml.yaml @@ -0,0 +1,314 @@ +# ============LICENSE_START======================================================= +# org.onap.dcae +# ================================================================================ +# Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +#description: Collector for receiving VES events through restful interface +#blueprint_version: 1.5.0 +--- +tosca_definitions_version: cloudify_dsl_1_3 +description: Collector for receiving VES events through restful interface +imports: +- https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.1/k8splugin_types.yaml +- https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml +inputs: + collector.dmaap.streamid: + type: string + default: "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary" + dcae-ves-collector_cpu_limit: + type: string + default: "250m" + dcae-ves-collector_cpu_request: + type: string + default: "250m" + dcae-ves-collector_memory_limit: + type: string + default: "128Mi" + dcae-ves-collector_memory_request: + type: string + default: "128Mi" + envs: + default: {} + external_port_0: + type: string + default: "8080" + external_port_1: + type: string + default: "8443" + header.authlist: + type: string + default: "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy" + replicas: + type: integer + description: number of instances + default: 1 + service_component_name_override: + type: string + default: "" + tag_version: + type: string + default: "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + topic0_name: + type: string + topic1_name: + type: string + topic2_name: + type: string + topic3_name: + type: string + topic4_name: + type: string + topic5_name: + type: string + ves-fault_topic0_aaf_password: + type: string + ves-fault_topic0_aaf_username: + type: string + ves-fault_topic0_client_role: + type: string + ves-fault_topic0_location: + type: string + ves-heartbeat-secondary_topic3_aaf_password: + type: string + ves-heartbeat-secondary_topic3_aaf_username: + type: string + ves-heartbeat-secondary_topic3_client_role: + type: string + ves-heartbeat-secondary_topic3_location: + type: string + ves-measurement_topic1_aaf_password: + type: string + ves-measurement_topic1_aaf_username: + type: string + ves-measurement_topic1_client_role: + type: string + ves-measurement_topic1_location: + type: string + ves-notification_topic5_aaf_password: + type: string + ves-notification_topic5_aaf_username: + type: string + ves-notification_topic5_client_role: + type: string + ves-notification_topic5_location: + type: string + ves-other_topic2_aaf_password: + type: string + ves-other_topic2_aaf_username: + type: string + ves-other_topic2_client_role: + type: string + ves-other_topic2_location: + type: string + ves-pnfRegistration_topic4_aaf_password: + type: string + ves-pnfRegistration_topic4_aaf_username: + type: string + ves-pnfRegistration_topic4_client_role: + type: string + ves-pnfRegistration_topic4_location: + type: string +node_templates: + dcae-ves-collector: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + ports: + - concat: ["8080:", {get_input: external_port_0}] + - concat: ["8443:", {get_input: external_port_1}] + envs: + get_input: envs + properties: + application_config: + service_calls: [] + streams_publishes: + ves-fault: + dmaap_info: <<topic0>> + type: message router + pass: + get_input: ves-fault_topic0_aaf_password + user: + get_input: ves-fault_topic0_aaf_username + ves-heartbeat-secondary: + dmaap_info: <<topic3>> + type: message router + pass: + get_input: ves-heartbeat-secondary_topic3_aaf_password + user: + get_input: ves-heartbeat-secondary_topic3_aaf_username + ves-measurement: + dmaap_info: <<topic1>> + type: message router + pass: + get_input: ves-measurement_topic1_aaf_password + user: + get_input: ves-measurement_topic1_aaf_username + ves-notification: + dmaap_info: <<topic5>> + type: message router + pass: + get_input: ves-notification_topic5_aaf_password + user: + get_input: ves-notification_topic5_aaf_username + ves-other: + dmaap_info: <<topic2>> + type: message router + pass: + get_input: ves-other_topic2_aaf_password + user: + get_input: ves-other_topic2_aaf_username + ves-pnfRegistration: + dmaap_info: <<topic4>> + type: message router + pass: + get_input: ves-pnfRegistration_topic4_aaf_password + user: + get_input: ves-pnfRegistration_topic4_aaf_username + streams_subscribes: {} + auth.method: noAuth + collector.dmaap.streamid: + get_input: collector.dmaap.streamid + collector.keystore.file.location: /opt/app/dcae-certificate/keystore.jks + collector.keystore.passwordfile: /opt/app/dcae-certificate/.password + collector.schema.checkflag: 1 + collector.schema.file: {"v1":"./etc/CommonEventFormat_27.2.json","v2":"./etc/CommonEventFormat_27.2.json","v3":"./etc/CommonEventFormat_27.2.json","v4":"./etc/CommonEventFormat_27.2.json","v5":"./etc/CommonEventFormat_28.4.1.json","v7":"./etc/CommonEventFormat_30.json"} + collector.service.port: 8080 + collector.service.secure.port: 8443 + collector.truststore.file.location: /opt/app/dcae-certificate/truststore.jks + collector.truststore.passwordfile: /opt/app/dcae-certificate/.trustpassword + event.transform.flag: 1 + header.authlist: + get_input: header.authlist + service_component_name_override: + get_input: service_component_name_override + tomcat.maxthreads: 200 + docker_config: + healthcheck: + interval: 15s + timeout: 1s + type: http + endpoint: /healthcheck + volumes: + - container: + bind: /opt/app/dcae-certificate + host: + path: /opt/app/dcae-certificate + - container: + bind: /opt/app/VESCollector/logs + host: + path: /opt/logs/DCAE/VESCollector/logs + - container: + bind: /opt/app/VESCollector/etc + host: + path: /opt/logs/DCAE/VESCollector/etc + image: + get_input: tag_version + service_component_type: dcae-ves-collector + replicas: + get_input: replicas + streams_publishes: + - name: topic0 + location: + get_input: ves-fault_topic0_location + client_role: + get_input: ves-fault_topic0_client_role + type: message router + - name: topic1 + location: + get_input: ves-measurement_topic1_location + client_role: + get_input: ves-measurement_topic1_client_role + type: message router + - name: topic2 + location: + get_input: ves-other_topic2_location + client_role: + get_input: ves-other_topic2_client_role + type: message router + - name: topic3 + location: + get_input: ves-heartbeat-secondary_topic3_location + client_role: + get_input: ves-heartbeat-secondary_topic3_client_role + type: message router + - name: topic4 + location: + get_input: ves-pnfRegistration_topic4_location + client_role: + get_input: ves-pnfRegistration_topic4_client_role + type: message router + - name: topic5 + location: + get_input: ves-notification_topic5_location + client_role: + get_input: ves-notification_topic5_client_role + type: message router + resource_config: + limits: + cpu: + get_input: dcae-ves-collector_cpu_limit + memory: + get_input: dcae-ves-collector_memory_limit + requests: + cpu: + get_input: dcae-ves-collector_cpu_request + memory: + get_input: dcae-ves-collector_memory_request + relationships: + - type: ccsdk.relationships.publish_events + target: topic0 + - type: ccsdk.relationships.publish_events + target: topic1 + - type: ccsdk.relationships.publish_events + target: topic2 + - type: ccsdk.relationships.publish_events + target: topic3 + - type: ccsdk.relationships.publish_events + target: topic4 + - type: ccsdk.relationships.publish_events + target: topic5 + topic0: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic0_name + topic1: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic1_name + topic2: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic2_name + topic3: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic3_name + topic4: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic4_name + topic5: + type: ccsdk.nodes.Topic + properties: + topic_name: + get_input: topic5_name
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json b/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json new file mode 100644 index 0000000..6812347 --- /dev/null +++ b/mod/bpgenerator/TestCases/ves/componentSpecs/ves.json @@ -0,0 +1,276 @@ +{ + "self": { + "version": "1.5.0", + "name": "dcae-ves-collector", + "description": "Collector for receiving VES events through restful interface", + "component_type": "docker" + }, + "streams": { + "subscribes": [], + "publishes": [ + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-fault" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-measurement" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-other" + }, + { + "format": "VES_specification", + "version": "5.28.4", + "type": "message router", + "config_key": "ves-heartbeat-secondary" + }, + { + "format": "VES_specification", + "version": "7.30.0", + "type": "message router", + "config_key": "ves-pnfRegistration" + }, + { + "format": "VES_specification", + "version": "7.30.0", + "type": "message router", + "config_key": "ves-notification" + } + ] + }, + "services": { + "calls": [], + "provides": [ + { + "route": "/eventListener/v1", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v2", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v3", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v4", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "4.27.2" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v5", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "5.28.4" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + }, + { + "route": "/eventListener/v7", + "verb": "POST", + "request": { + "format": "VES_specification", + "version": "7.30.0" + }, + "response": { + "format": "ves.coll.response", + "version": "1.0.0" + } + } + ] + }, + "parameters": [ + { + "name": "collector.service.port", + "value": 8080, + "description": "standard http port collector will open for listening;", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.service.secure.port", + "value": 8443, + "description": "secure http port collector will open for listening ", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": true + }, + { + "name": "collector.keystore.file.location", + "value": "/opt/app/dcae-certificate/keystore.jks", + "description": "fs location of keystore file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.keystore.passwordfile", + "value": "/opt/app/dcae-certificate/.password", + "description": "location of keystore password file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.truststore.file.location", + "value": "/opt/app/dcae-certificate/truststore.jks", + "description": "fs location of truststore file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.truststore.passwordfile", + "value": "/opt/app/dcae-certificate/.trustpassword", + "description": "location of truststore password file in vm", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.dmaap.streamid", + "value": "fault=ves-fault,ves-fault-secondary|syslog=ves-syslog,ves-syslog-secondary|heartbeat=ves-heartbeat,ves-heartbeat-secondary|measurementsForVfScaling=ves-measurement,ves-measurement-secondary|mobileFlow=ves-mobileflow,ves-mobileflow-secondary|other=ves-other,ves-other-secondary|stateChange=ves-statechange,ves-statechange-secondary|thresholdCrossingAlert=ves-thresholdCrossingAlert,ves-thresholdCrossingAlert-secondary|voiceQuality=ves-voicequality,ves-voicequality-secondary|sipSignaling=ves-sipsignaling,ves-sipsignaling-secondary|notification=ves-notification,ves-notification-secondary|pnfRegistration=ves-pnfRegistration,ves-pnfRegistration-secondary", + "description": "domain-to-streamid mapping used by VESCollector to distributes events based on domain. Both primary and secondary config_key are included for resilency (multiple streamid can be included commma separated). The streamids MUST match to topic config_keys. For single site without resiliency deployment - configkeys with -secondary suffix can be removed", + "sourced_at_deployment": true, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "auth.method", + "value": "noAuth", + "description": "Property to manage application mode, possible configurations: noAuth - default option - no security (http) , certOnly - auth by certificate (https), basicAuth - auth by basic auth username and password (https),certBasicAuth - auth by certificate and basic auth username / password (https),", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "header.authlist", + "value": "sample1,$2a$10$pgjaxDzSuc6XVFEeqvxQ5u90DKJnM/u7TJTcinAlFJVaavXMWf/Zi|userid1,$2a$10$61gNubgJJl9lh3nvQvY9X.x4e5ETWJJ7ao7ZhJEvmfJigov26Z6uq|userid2,$2a$10$G52y/3uhuhWAMy.bx9Se8uzWinmbJa.dlm1LW6bYPdPkkywLDPLiy", + "description": "List of id and base 64 encoded password.For each onboarding VNF - unique userid and password should be assigned and communicated to VNF owner. Password value should be base64 encoded in config here", + "policy_editable": false, + "sourced_at_deployment": true, + "designer_editable": true + }, + { + "name": "collector.schema.checkflag", + "value": 1, + "description": "Schema check validation flag. When enabled, collector will validate input VES events against VES Schema defined on collector.schema.file ", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "collector.schema.file", + "value": "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\",\"v7\":\"./etc/CommonEventFormat_30.json\"}", + "description": "VES schema file name per version used for validation", + "designer_editable": true, + "sourced_at_deployment": false, + "policy_editable": false + }, + { + "name": "event.transform.flag", + "value": 1, + "description": "flag to enable tranformation rules defined under eventTransform.json; this is applicable when event tranformation rules preset should be activated for transforming <VES5.4 events to 5.4", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + }, + { + "name": "tomcat.maxthreads", + "value": "200", + "description": "Tomcat control for concurrent request", + "sourced_at_deployment": false, + "policy_editable": false, + "designer_editable": false + } + ], + "auxilary": { + "healthcheck": { + "type": "http", + "interval": "15s", + "timeout": "1s", + "endpoint": "/healthcheck" + }, + "volumes": [ + { + "container": { + "bind": "/opt/app/dcae-certificate" + }, + "host": { + "path": "/opt/app/dcae-certificate" + } + }, + { + "container": { + "bind": "/opt/app/VESCollector/logs" + }, + "host": { + "path": "/opt/logs/DCAE/VESCollector/logs" + } + }, + { + "container": { + "bind": "/opt/app/VESCollector/etc" + }, + "host": { + "path": "/opt/logs/DCAE/VESCollector/etc" + } + } + ], + "ports": [ + "8080:8080", + "8443:8443" + ] + }, + "artifacts": [ + { + "type": "docker image", + "uri": "nexus.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:latest" + } + ] +}
\ No newline at end of file diff --git a/mod/bpgenerator/TestCases/ves/inputFiles/ves_nodmaap.json b/mod/bpgenerator/TestCases/ves/inputFiles/ves_nodmaap.json new file mode 100644 index 0000000..720ce5f --- /dev/null +++ b/mod/bpgenerator/TestCases/ves/inputFiles/ves_nodmaap.json @@ -0,0 +1,11 @@ +{ + "ves_other_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.SEC_OTHER_OUTPUT", + "ves_heartbeat_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.SEC_HEARTBEAT_OUTPUT", + "ves_fault_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.SEC_FAULT_OUTPUT", + "ves_measurement_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_MEASUREMENT_OUTPUT", + "ves_notification_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_NOTIFICATION_OUTPUT", + "ves_pnfRegistration_publish_url":"http://message-router.onap.svc.cluster.local:3904/events/unauthenticated.VES_PNFREG_OUTPUT", + "external_port_0":"30235", + "external_port_1": "30417", + "image": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.collectors.ves.vescollector:1.3.1" +}
\ No newline at end of file diff --git a/mod/bpgenerator/pom.xml b/mod/bpgenerator/pom.xml index d63b9c9..6255329 100644 --- a/mod/bpgenerator/pom.xml +++ b/mod/bpgenerator/pom.xml @@ -23,13 +23,13 @@ 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.oparent</groupId> - <artifactId>oparent</artifactId> - <version>2.0.0</version> + <groupId>org.onap.oparent</groupId> + <artifactId>oparent</artifactId> + <version>2.0.0</version> </parent> <groupId>org.onap.dcaegen2.platform.mod</groupId> <artifactId>blueprint-generator</artifactId> - <version>1.2.1-SNAPSHOT</version> + <version>1.3.1-SNAPSHOT</version> <properties> <maven.compiler.source>1.6</maven.compiler.source> <maven.compiler.target>1.6</maven.compiler.target> @@ -39,7 +39,7 @@ <sonar.java.coveragePlugin>cobertura</sonar.java.coveragePlugin> <sonar.junit.reportsPath>${project.basedir}/target/surefire-reports</sonar.junit.reportsPath> <sonar.surefire.reportsPath>${project.basedir}/target/surefire-reports</sonar.surefire.reportsPath> - <sonar.cobertura.reportPath>${project.basedir}/target/site/cobertura/coverage.xml</sonar.cobertura.reportPath> + <sonar.cobertura.reportPaths>${project.basedir}/target/site/cobertura/coverage.xml</sonar.cobertura.reportPaths> <shade.main>org.onap.blueprintgenerator.core.App</shade.main> <shade.transformer>org.apache.maven.plugins.shade.resource.ManifestResourceTransformer</shade.transformer> </properties> diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java index cbff42b..3a4b457 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/Fixes.java @@ -29,6 +29,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; +import java.util.List; public class Fixes { private static ArrayList<String> lines = new ArrayList<String>(); @@ -40,6 +41,7 @@ public class Fixes { FileReader fr = new FileReader(translateFile); BufferedReader br = new BufferedReader(fr); while((line = br.readLine()) != null) { +// lines.add(ensureNoSingleQuotes(line)); if(line.contains("'")) { line = line.replace("'", ""); } @@ -67,4 +69,36 @@ public class Fixes { throw new RuntimeException(e); } } + + /** + * Remove single quotes from a line from a blueprint + */ + private static String ensureNoSingleQuotes(String line) { + // TODO: Should probably use regex instead + // REVIEW: The condition under which to remove the single quotes + if ((line.contains("concat") || line.contains("default: ")) && line.contains("'")) { + return line.replace("'", ""); + } else { + return line; + } + } + + /** + * Takes in an entire blueprint (YAML) in a string buffer and post processes it to apply + * "fixes" like removing unwanted single quotes. + */ + public static String applyFixes(String bp) { + List<String> lines = new ArrayList<String>(); + + String[] linesPre = bp.split("\n"); + System.out.println(String.format("To post-processing #lines: %d", linesPre.length)); + + for (String line : linesPre) { + lines.add(ensureNoSingleQuotes(line)); + } + + return String.join("\n", lines); + } + + } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java new file mode 100644 index 0000000..a22d588 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PgaasNodeBuilder.java @@ -0,0 +1,130 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.core; + +import org.onap.blueprintgenerator.exception.DatabasesNotFoundException; +import org.onap.blueprintgenerator.models.GetAttribute; +import org.onap.blueprintgenerator.models.blueprint.GetInput; +import org.onap.blueprintgenerator.models.blueprint.Node; +import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNode; +import org.onap.blueprintgenerator.models.blueprint.pgaas.PgaasNodeProperties; +import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; + +import java.util.*; + +public class PgaasNodeBuilder { + + private static final String PGAAS_NODE_TYPE = "dcae.nodes.pgaas.database"; + private static final String PGAAS_NODE_NAME_POSTFIX = "_pgaasdb"; + private static final String WRITER_FQDN_POSTFIX = "_database_writerfqdn"; + private static final String NAME_POSTFIX = "_database_name"; + private static final boolean USE_EXISTING = true; + private static final String DB_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; + + + + public static void addPgaasNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate, TreeMap<String, LinkedHashMap<String, Object>> inps) { + TreeMap<String, String> databases = cs.getAuxilary().getDatabases(); + if(databases == null){ + throw new DatabasesNotFoundException("databases section not found in componentspec"); + } + for(Map.Entry<String, String> database : databases.entrySet()){ + addPgaasNode(database, nodeTemplate); + addPgaasInputs(database, inps); + } + } + + private static void addPgaasInputs(Map.Entry<String, String> database, TreeMap<String, LinkedHashMap<String, Object>> inps) { + inps.put(database.getKey() + NAME_POSTFIX, getInputValue("string", "db name", "")); + inps.put(database.getKey() + WRITER_FQDN_POSTFIX, getInputValue("string", "db writerfqdn", "")); + } + + private static LinkedHashMap<String, Object> getInputValue(String type, String description, Object defaultValue) { + LinkedHashMap<String, Object> inputValueMap = new LinkedHashMap(); + inputValueMap.put("type", type); + inputValueMap.put("description", description); + inputValueMap.put("default", defaultValue); + return inputValueMap; + } + + private static void addPgaasNode(Map.Entry<String, String> database, TreeMap<String, Node> nodeTemplate) { + PgaasNode pgaasNode = new PgaasNode(); + String dbName = database.getKey(); + pgaasNode.setType(PGAAS_NODE_TYPE); + pgaasNode.setPgaasNodeProperties(buildPgaasNodeProperties(dbName)); + nodeTemplate.put(dbName + PGAAS_NODE_NAME_POSTFIX , pgaasNode); + } + + private static PgaasNodeProperties buildPgaasNodeProperties(String dbName) { + PgaasNodeProperties pgaasNodeProperties = new PgaasNodeProperties(); + + GetInput nameValue = new GetInput(); + nameValue.setGet_input(dbName + NAME_POSTFIX); + pgaasNodeProperties.setName(nameValue); + + GetInput writerfqdnValue = new GetInput(); + writerfqdnValue.setGet_input(dbName + WRITER_FQDN_POSTFIX); + pgaasNodeProperties.setWriterfqdn(writerfqdnValue); + + pgaasNodeProperties.setUseExisting(USE_EXISTING); + + return pgaasNodeProperties; + } + + public static ArrayList<LinkedHashMap<String, String>> getPgaasNodeRelationships(ComponentSpec cs) { + ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>(); + for(Map.Entry<String, String> database : cs.getAuxilary().getDatabases().entrySet()){ + LinkedHashMap<String, String> relationship = new LinkedHashMap<>(); + relationship.put("type", DB_RELATIONSHIP_TYPE); + relationship.put("target", database.getKey() + PGAAS_NODE_NAME_POSTFIX); + relationships.add(relationship); + } + return relationships; + } + + public static LinkedHashMap<String, Object> getEnvVariables(TreeMap<String, String> databases) { + LinkedHashMap<String, Object> envVariables = new LinkedHashMap<String, Object>(); + for(Map.Entry<String, String> database : databases.entrySet()){ + String name = database.getKey().toUpperCase(); + + envVariables.put("<<", "*envs"); + + GetInput nameValue = new GetInput(); + nameValue.setGet_input(name.toLowerCase() + NAME_POSTFIX); + envVariables.put(name + "_DB_NAME", nameValue); + + GetAttribute adminHostValue = buildGetAttributeValue(name.toLowerCase(), "admin", "host"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_HOST", adminHostValue); + + GetAttribute adminUserValue = buildGetAttributeValue(name.toLowerCase(), "admin", "user"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_USER", adminUserValue); + + GetAttribute adminPasswordValue = buildGetAttributeValue(name.toLowerCase(), "admin", "password"); + envVariables.put( name.toUpperCase() + "_DB_ADMIN_PASS", adminPasswordValue); + } + return envVariables; + } + + private static GetAttribute buildGetAttributeValue(String dbName, String owner, String type) { + GetAttribute attribute = new GetAttribute(); + attribute.setAttribute(Arrays.asList(dbName + PGAAS_NODE_NAME_POSTFIX, owner, type)); + return attribute; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java new file mode 100644 index 0000000..a947ab7 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/core/PolicyNodeBuilder.java @@ -0,0 +1,90 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.core; + +import org.onap.blueprintgenerator.models.blueprint.GetInput; +import org.onap.blueprintgenerator.models.blueprint.Node; +import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNode; +import org.onap.blueprintgenerator.models.blueprint.policy.PolicyNodeProperties; +import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; +import org.onap.blueprintgenerator.models.componentspec.policy_info.TypePolicy; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.TreeMap; + +public class PolicyNodeBuilder { + + private static final String POLICY_NODE_TYPE = "clamp.nodes.policy"; + private static final String POLICY_RELATIONSHIP_TYPE = "cloudify.relationships.depends_on"; + + public static void addPolicyNodesAndInputs(ComponentSpec cs, TreeMap<String, Node> nodeTemplate, TreeMap<String, LinkedHashMap<String, Object>> inps) { + List<TypePolicy> policyList = cs.getPolicyInfo().getTypePolicyList(); + for(TypePolicy policy: policyList){ + addPolicyNodesToNodeTemplate(policy, nodeTemplate); + addPolicyInputs(policy, inps); + } + } + + private static void addPolicyInputs(TypePolicy policy, TreeMap<String, LinkedHashMap<String, Object>> inps) { + String defaultValue = policy.getPolicy_id() != null ? policy.getPolicy_id() : ""; + inps.put(policy.getNode_label() + "_policy_id", getInputValue("string", "policy_id", defaultValue)); + } + + private static LinkedHashMap<String, Object> getInputValue(String type, String description, Object defaultValue) { + LinkedHashMap<String, Object> inputValueMap = new LinkedHashMap(); + inputValueMap.put("type", type); + inputValueMap.put("description", description); + inputValueMap.put("default", defaultValue); + return inputValueMap; + } + + private static void addPolicyNodesToNodeTemplate(TypePolicy policy, TreeMap<String, Node> nodeTemplate) { + PolicyNode policyNode = new PolicyNode(); + policyNode.setType(POLICY_NODE_TYPE); + policyNode.setPolicyNodeProperties(getPolicyNodeProperties(policy)); + nodeTemplate.put(policy.getNode_label(), policyNode); + } + + private static PolicyNodeProperties getPolicyNodeProperties(TypePolicy policy) { + PolicyNodeProperties policyNodeProperties = new PolicyNodeProperties(); + + GetInput policyIdGetInput = new GetInput(); + policyIdGetInput.setGet_input(policy.getNode_label() + "_policy_id"); + policyNodeProperties.setPolicyId(policyIdGetInput); + + policyNodeProperties.setPolicyModelId(policy.getPolicy_model_id()); + + return policyNodeProperties; + } + + public static ArrayList<LinkedHashMap<String, String>> getPolicyRelationships(ComponentSpec cs) { + ArrayList<LinkedHashMap<String, String>> relationships = new ArrayList<>(); + List<TypePolicy> policyList = cs.getPolicyInfo().getTypePolicyList(); + for(TypePolicy policy: policyList){ + LinkedHashMap<String, String> relationship = new LinkedHashMap<>(); + relationship.put("type", POLICY_RELATIONSHIP_TYPE); + relationship.put("target", policy.getNode_label()); + relationships.add(relationship); + } + return relationships; + } +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java new file mode 100644 index 0000000..c9b2149 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/exception/DatabasesNotFoundException.java @@ -0,0 +1,24 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.exception; + +public class DatabasesNotFoundException extends RuntimeException { + public DatabasesNotFoundException(String message) { super(message);} +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java new file mode 100644 index 0000000..56184ff --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/GetAttribute.java @@ -0,0 +1,34 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class GetAttribute { + + @JsonProperty("get_attribute") + private Object attribute; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java index 6d5b7d7..04745dc 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Appconfig.java @@ -48,7 +48,8 @@ public class Appconfig { return params; } - public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) { + public TreeMap<String, LinkedHashMap<String, Object>> createAppconfig(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override, + boolean isDmaap) { TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); retInputs = inps; @@ -58,26 +59,24 @@ public class Appconfig { //set the stream publishes TreeMap<String, DmaapObj> streamPublishes = new TreeMap<String, DmaapObj>(); - int counter = 0; if(cs.getStreams().getPublishes().length != 0) { for(Publishes p: cs.getStreams().getPublishes()) { if(p.getType().equals("data_router") || p.getType().equals("data router")) { //in this case the data router information gets added to the params so for now leave it alone String config = p.getConfig_key(); DmaapObj pub = new DmaapObj(); - String name = "feed" + counter; - retInputs = pub.createOnapDmaapDRObj(retInputs, config, 'p', "feed" + counter, name); + String name = p.getConfig_key() +"_feed"; + retInputs = pub.createOnapDmaapDRObj(retInputs, config, 'p', name, name, isDmaap); pub.setType(p.getType()); streamPublishes.put(config, pub); } else if(p.getType().equals("message_router") || p.getType().equals("message router")) { String config = p.getConfig_key(); DmaapObj pub = new DmaapObj(); - String name = "topic" + counter; - retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p', "topic" + counter, name); + String name = p.getConfig_key() + "_topic"; + retInputs = pub.createOnapDmaapMRObj(retInputs, config, 'p', name, name, isDmaap); pub.setType(p.getType()); streamPublishes.put(config, pub); } - counter++; } } @@ -90,19 +89,18 @@ public class Appconfig { //in this case the data router information gets added to the params so for now leave it alone String config = s.getConfig_key(); DmaapObj sub = new DmaapObj(); - String name = "feed" + counter; - retInputs = sub.createOnapDmaapDRObj(retInputs, config, 'p', "feed" + counter, name); + String name = s.getConfig_key() + "_feed"; + retInputs = sub.createOnapDmaapDRObj(retInputs, config, 'p', name, name, isDmaap); sub.setType(s.getType()); streamSubscribes.put(config, sub); } else if(s.getType().equals("message_router") || s.getType().equals("message router")) { String config = s.getConfig_key(); DmaapObj sub = new DmaapObj(); - String name = "topic" + counter; - retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's', "topic" + counter, name); + String name = s.getConfig_key() + "_topic"; + retInputs = sub.createOnapDmaapMRObj(retInputs, config, 's', name, name, isDmaap); sub.setType(s.getType()); streamSubscribes.put(config, sub); } - counter++; } } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java index 06c42c5..c043a9e 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Blueprint.java @@ -20,11 +20,7 @@ package org.onap.blueprintgenerator.models.blueprint; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileWriter; -import java.io.IOException; -import java.io.PrintWriter; +import java.io.*; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; @@ -50,7 +46,7 @@ import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; - +import org.yaml.snakeyaml.Yaml; @Getter @Setter @@ -84,17 +80,21 @@ public class Blueprint { } return bp; } + public Blueprint setQuotations(Blueprint bp) { for(String s: bp.getInputs().keySet()) { LinkedHashMap<String, Object> temp = bp.getInputs().get(s); if(temp.get("type") == "string") { String def = (String) temp.get("default"); + if(def != null){ + def = def.replaceAll("\"$", "").replaceAll("^\"", ""); + } def = '"' + def + '"'; temp.replace("default", def); bp.getInputs().replace(s, temp); } } - + return bp; } @@ -194,7 +194,6 @@ public class Blueprint { System.out.println("Blueprint created"); } - public String blueprintToString() { String ret = ""; @@ -205,7 +204,6 @@ public class Blueprint { throw new RuntimeException(e); } - - return ret; + return Fixes.applyFixes(ret); } } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java index 10092c8..7d78e3d 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/DmaapObj.java @@ -23,8 +23,6 @@ package org.onap.blueprintgenerator.models.blueprint; import java.util.LinkedHashMap; import java.util.TreeMap; -import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; - import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -32,12 +30,13 @@ import lombok.Getter; import lombok.Setter; @JsonInclude(value=Include.NON_NULL) @Getter @Setter public class DmaapObj { - private String dmaap_info; + private Object dmaap_info; private String type; private GetInput pass; private GetInput user; - public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num) { + public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapMRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, + String config, char type, String n, String num, boolean isDmaap) { TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); LinkedHashMap<String, Object> stringType = new LinkedHashMap(); stringType.put("type", "string"); @@ -45,31 +44,41 @@ public class DmaapObj { //set the dmaapinfo DmaapInfo info = new DmaapInfo(); - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); - - //set username - GetInput u = new GetInput(); - u.setGet_input(config + "_" + num +"_aaf_username"); - this.setUser(u); - retInputs.put(config + "_" + num +"_aaf_username", stringType); - - //set password - GetInput p = new GetInput(); - p.setGet_input(config + "_" + num +"_aaf_password"); - this.setPass(p); - retInputs.put(config + "_" + num +"_aaf_password", stringType); + if(!isDmaap){ + info.createOnapDmaapMRInfo(inps, config, type); + this.setDmaap_info(info); + } + else{ + String infoType = "<<" + n + ">>"; + this.setDmaap_info(infoType); + //set username + GetInput u = new GetInput(); + u.setGet_input(config + "_" + num +"_aaf_username"); + this.setUser(u); + retInputs.put(config + "_" + num +"_aaf_username", stringType); + //set password + GetInput p = new GetInput(); + p.setGet_input(config + "_" + num +"_aaf_password"); + this.setPass(p); + retInputs.put(config + "_" + num +"_aaf_password", stringType); + } return retInputs; } - public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num) { + public TreeMap<String, LinkedHashMap<String, Object>> createOnapDmaapDRObj(TreeMap<String, LinkedHashMap<String, Object>> inps, String config, char type, String n, String num, boolean isDmaap) { TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); retInputs = inps; //set the dmaapinfo DmaapInfo info = new DmaapInfo(); - String infoType = "<<" + n + ">>"; - this.setDmaap_info(infoType); + if(!isDmaap){ + info.createOnapDmaapDRInfo(inps, config, type); + this.setDmaap_info(info); + } + else { + String infoType = "<<" + n + ">>"; + this.setDmaap_info(infoType); + } return retInputs; } } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java index 25c4c53..31df9c3 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/Properties.java @@ -26,12 +26,9 @@ import java.util.TreeMap; import org.onap.blueprintgenerator.models.componentspec.Auxilary; import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; -import org.onap.blueprintgenerator.models.componentspec.HealthCheck; import org.onap.blueprintgenerator.models.componentspec.Publishes; import org.onap.blueprintgenerator.models.componentspec.Subscribes; -import org.onap.blueprintgenerator.models.componentspec.Volumes; import org.onap.blueprintgenerator.models.dmaapbp.DmaapStreams; -import org.onap.blueprintgenerator.models.onapbp.LogDirectory; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; @@ -54,8 +51,9 @@ public class Properties { private GetInput feed_name; ArrayList<DmaapStreams> streams_publishes; ArrayList<DmaapStreams> streams_subscribes; - private TreeMap<String, Object> tls_info; + private TlsInfo tls_info; private ResourceConfig resource_config; + private GetInput always_pull_image; //private boolean useExisting; public TreeMap<String, LinkedHashMap<String, Object>> createOnapProperties(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) { @@ -77,18 +75,11 @@ public class Properties { this.setLocation_id(location); LinkedHashMap<String, Object> locMap = new LinkedHashMap(); locMap.put("type", "string"); - locMap.put("default", "central"); + locMap.put("default", ""); + retInputs.put("location_id", locMap); //set the log info - GetInput logD = new GetInput(); - logD.setGet_input("log_directory"); - TreeMap<String, Object> l = new TreeMap(); - l.put("log_directory", logD); - this.setLog_info(l); - LinkedHashMap<String, Object> logMap = new LinkedHashMap(); - logMap.put("type", "string"); - logMap.put("default", "''"); - retInputs.put("log_directory", logMap); + this.setLog_info(cs.getAuxilary().getLog_info()); //set the replicas GetInput replica = new GetInput(); @@ -108,35 +99,29 @@ public class Properties { //set the docker config Auxilary aux = cs.getAuxilary(); - if(aux.getPorts() != null) { - retInputs = aux.createPorts(retInputs); - } +// if(aux.getPorts() != null) { +// retInputs = aux.createPorts(retInputs); +// } this.setDocker_config(aux); //set the app config Appconfig app = new Appconfig(); - retInputs = app.createAppconfig(retInputs, cs, override); + retInputs = app.createAppconfig(retInputs, cs, override, false); this.setApplication_config(app); - //set the tls info - GetInput tls = new GetInput(); - tls.setGet_input("use_tls"); - GetInput cert = new GetInput(); - cert.setGet_input("cert_directory"); - TreeMap<String, Object> tlsInfo = new TreeMap(); - tlsInfo.put("cert_directory", cert); - tlsInfo.put("use_tls", tls); - this.setTls_info(tlsInfo); - - LinkedHashMap<String, Object> certMap = new LinkedHashMap(); - certMap.put("type", "string"); - certMap.put("default", "''"); - retInputs.put("cert_directory", certMap); + // set always_pull_image + this.always_pull_image = new GetInput(); + this.always_pull_image.setGet_input("always_pull_image"); + LinkedHashMap<String, Object> inputAlwaysPullImage = new LinkedHashMap<String, Object>(); + inputAlwaysPullImage.put("type", "boolean"); + inputAlwaysPullImage.put("description", "Set to true if the image should always be pulled"); + inputAlwaysPullImage.put("default", true); + retInputs.put("always_pull_image", inputAlwaysPullImage); - LinkedHashMap<String, Object> useMap = new LinkedHashMap(); - useMap.put("type", "boolean"); - useMap.put("default", false); - retInputs.put("use_tls", useMap); + //set the tls info + if(cs.getAuxilary().getTls_info() != null){ + addTlsInfo(cs,retInputs); + } //set the reource config ResourceConfig resource = new ResourceConfig(); @@ -160,15 +145,7 @@ public class Properties { retInputs.put("tag_version", img); //set the log info - GetInput logD = new GetInput(); - logD.setGet_input("log_directory"); - TreeMap<String, Object> l = new TreeMap(); - l.put("log_directory", logD); - this.setLog_info(l); - LinkedHashMap<String, Object> logMap = new LinkedHashMap(); - logMap.put("type", "string"); - logMap.put("default", "''"); - retInputs.put("log_directory", logMap); + this.setLog_info(cs.getAuxilary().getLog_info()); //set service component type String sType = cs.getSelf().getName(); @@ -176,24 +153,9 @@ public class Properties { this.setService_component_type(sType); //set the tls info - GetInput tls = new GetInput(); - tls.setGet_input("use_tls"); - GetInput cert = new GetInput(); - cert.setGet_input("cert_directory"); - TreeMap<String, Object> tlsInfo = new TreeMap(); - tlsInfo.put("cert_directory", cert); - tlsInfo.put("use_tls", tls); - this.setTls_info(tlsInfo); - - LinkedHashMap<String, Object> certMap = new LinkedHashMap(); - certMap.put("type", "string"); - certMap.put("default", "''"); - retInputs.put("cert_directory", certMap); - - LinkedHashMap<String, Object> useMap = new LinkedHashMap(); - useMap.put("type", "boolean"); - useMap.put("default", false); - retInputs.put("use_tls", useMap); + if(cs.getAuxilary().getTls_info() != null){ + addTlsInfo(cs,retInputs); + } //set the replicas GetInput replica = new GetInput(); @@ -213,34 +175,32 @@ public class Properties { //set the docker config Auxilary aux = cs.getAuxilary(); - if(aux.getPorts() != null) { - retInputs = aux.createPorts(retInputs); - } +// if(aux.getPorts() != null) { +// retInputs = aux.createPorts(retInputs); +// } this.setDocker_config(aux); //set the appconfig Appconfig app = new Appconfig(); - retInputs = app.createAppconfig(retInputs, cs, override); + retInputs = app.createAppconfig(retInputs, cs, override, true); this.setApplication_config(app); //set the stream publishes ArrayList<DmaapStreams> pubStreams = new ArrayList(); - int counter = 0; if(cs.getStreams().getPublishes() != null) { for(Publishes p: cs.getStreams().getPublishes()) { if(p.getType().equals("message_router") || p.getType().equals("message router")) { - String topic = "topic" + counter; + String topic = p.getConfig_key() + "_topic"; DmaapStreams mrStreams = new DmaapStreams(); retInputs = mrStreams.createStreams(inps, cs, topic, p.getType(), p.getConfig_key(), p.getRoute(), 'p'); pubStreams.add(mrStreams); } else if(p.getType().equals("data_router") || p.getType().equals("data router")){ - String feed = "feed" + counter; + String feed = p.getConfig_key() + "_feed"; DmaapStreams drStreams = new DmaapStreams(); retInputs = drStreams.createStreams(inps, cs, feed, p.getType(), p.getConfig_key(), p.getRoute(), 'p'); pubStreams.add(drStreams); } - counter++; } } @@ -249,18 +209,17 @@ public class Properties { if(cs.getStreams().getSubscribes() != null) { for(Subscribes s: cs.getStreams().getSubscribes()) { if(s.getType().equals("message_router") || s.getType().equals("message router")) { - String topic = "topic" + counter; + String topic = s.getConfig_key() + "_topic"; DmaapStreams mrStreams = new DmaapStreams(); retInputs = mrStreams.createStreams(inps, cs, topic, s.getType(), s.getConfig_key(), s.getRoute(), 's'); subStreams.add(mrStreams); } else if(s.getType().equals("data_router") || s.getType().equals("data router")){ - String feed = "feed" + counter; + String feed = s.getConfig_key() + "_feed"; DmaapStreams drStreams = new DmaapStreams(); retInputs = drStreams.createStreams(inps, cs, feed, s.getType(), s.getConfig_key(), s.getRoute(), 's'); subStreams.add(drStreams); } - counter++; } } @@ -279,4 +238,18 @@ public class Properties { return retInputs; } + + private void addTlsInfo(ComponentSpec cs, TreeMap<String, LinkedHashMap<String, Object>> retInputs) { + TlsInfo tlsInfo = new TlsInfo(); + tlsInfo.setCertDirectory((String) cs.getAuxilary().getTls_info().get("cert_directory")); + GetInput useTLSFlag = new GetInput(); + useTLSFlag.setGet_input("use_tls"); + tlsInfo.setUseTls(useTLSFlag); + this.setTls_info(tlsInfo); + LinkedHashMap<String, Object> useTlsFlagInput = new LinkedHashMap<String, Object>(); + useTlsFlagInput.put("type", "boolean"); + useTlsFlagInput.put("description", "flag to indicate tls enable/disable"); + useTlsFlagInput.put("default", cs.getAuxilary().getTls_info().get("use_tls")); + retInputs.put("use_tls", useTlsFlagInput); + } } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java index 1c1cf6c..f81bf9a 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/StartInputs.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; +import org.onap.blueprintgenerator.core.PgaasNodeBuilder; +import org.onap.blueprintgenerator.models.componentspec.Auxilary; import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; import com.fasterxml.jackson.annotation.JsonInclude; @@ -34,14 +36,36 @@ import lombok.Getter; import lombok.Setter; @Getter @Setter @JsonInclude(value=Include.NON_NULL) public class StartInputs { - //private ArrayList<String> ports; - private GetInput envs; + private ArrayList<String> ports; + private Object envs; public TreeMap<String, LinkedHashMap<String, Object>> createOnapStartInputs(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs){ - TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); - retInputs = inps; - LinkedHashMap<String, Object> stringType = new LinkedHashMap<String, Object>(); + TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; + int count = 0; + ArrayList<String> portList = new ArrayList(); + Auxilary aux = cs.getAuxilary(); + + if (aux.getPorts() != null) { + + for(Object p : aux.getPorts()) { + String[] ports = p.toString().split(":"); + String internal + = String.format("concat: [\"%s:\", {get_input: external_port_%d}]" + , ports[0], count); + portList.add(internal); + + LinkedHashMap<String, Object> portType = new LinkedHashMap(); + portType.put("type", "string"); + portType.put("default", ports[1]); + retInputs.put("external_port_" + count, portType); + + count++; + } + + } + + this.setPorts(portList); // ArrayList<String> port = new ArrayList<String>(); // String external = ""; // if(cs.getAuxilary().getPorts() != null) { @@ -73,13 +97,22 @@ public class StartInputs { // } //set the envs - GetInput env = new GetInput(); - env.setGet_input("envs"); - this.setEnvs(env); LinkedHashMap<String, Object> eMap = new LinkedHashMap(); - eMap.put("default", "{}"); + if(cs.getAuxilary().getDatabases() != null){ + //set db env variables + LinkedHashMap<String, Object> envVars = PgaasNodeBuilder.getEnvVariables(cs.getAuxilary().getDatabases()); + this.setEnvs(envVars); + eMap.put("default", "&envs {}"); + } + else { + GetInput env = new GetInput(); + env.setGet_input("envs"); + this.setEnvs(env); + eMap.put("default", "{}"); + } retInputs.put("envs", eMap); + return retInputs; } } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java new file mode 100644 index 0000000..2130fe3 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/TlsInfo.java @@ -0,0 +1,37 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.blueprint; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class TlsInfo { + + @JsonProperty("cert_directory") + private String certDirectory; + + @JsonProperty("use_tls") + private GetInput useTls; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java new file mode 100644 index 0000000..35f958e --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNode.java @@ -0,0 +1,35 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.blueprint.pgaas; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.blueprintgenerator.models.blueprint.Node; + +@Getter +@Setter +@NoArgsConstructor +public class PgaasNode extends Node { + + @JsonProperty("properties") + private PgaasNodeProperties pgaasNodeProperties; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java new file mode 100644 index 0000000..709c66e --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/pgaas/PgaasNodeProperties.java @@ -0,0 +1,40 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.blueprint.pgaas; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.blueprintgenerator.models.blueprint.GetInput; + +@Getter @Setter +@NoArgsConstructor +public class PgaasNodeProperties { + + @JsonProperty("writerfqdn") + private GetInput writerfqdn; + + @JsonProperty("name") + private GetInput name; + + @JsonProperty("use_existing") + private boolean useExisting; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java new file mode 100644 index 0000000..b4740df --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNode.java @@ -0,0 +1,34 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.blueprint.policy; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.blueprintgenerator.models.blueprint.Node; + +@Getter @Setter +@NoArgsConstructor +public class PolicyNode extends Node { + + @JsonProperty("properties") + private PolicyNodeProperties policyNodeProperties; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java new file mode 100644 index 0000000..6d23b23 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/blueprint/policy/PolicyNodeProperties.java @@ -0,0 +1,37 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.blueprint.policy; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import org.onap.blueprintgenerator.models.blueprint.GetInput; + +@Getter @Setter +@NoArgsConstructor +public class PolicyNodeProperties { + + @JsonProperty("policy_id") + private GetInput policyId; + + @JsonProperty("policy_model_id") + private String policyModelId; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java index 01844f9..73acda8 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/Auxilary.java @@ -67,6 +67,15 @@ public class Auxilary { /** The healthcheck. */ private HealthCheck healthcheck; + + /**log-directory**/ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private TreeMap<String, Object> log_info; + + /**tls-info**/ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + private TreeMap<String, Object> tls_info; + /** The volumes. */ private Volumes[] volumes; @@ -74,6 +83,7 @@ public class Auxilary { private Policy policy; /** The ports. */ + @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) private ArrayList<Object> ports; /** The reconfigs. */ @@ -84,35 +94,35 @@ public class Auxilary { private TreeMap<String, String> databases; - public TreeMap<String, LinkedHashMap<String, Object>> createPorts(TreeMap<String, LinkedHashMap<String, Object>> inps) { - TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; - LinkedHashMap<String, Object> portType = new LinkedHashMap(); - portType.put("type", "string"); - - ArrayList<Object> ports = new ArrayList(); - String external = ""; - boolean foundPort = false; - for(Object o: this.getPorts()) { - String internal = ""; - String p = o.toString(); - for(int i = 0; i < p.length(); i++) { - if(p.charAt(i) == ':') { - internal = '"' + internal + '"'; - internal = "concat: ['" + internal + "', {get_input: external_port}]"; - ports.add(internal); - } - if(p.charAt(i) == ':' && !foundPort) { - external = p.substring(i); - portType.put("default", external); - retInputs.put("external_port", portType); - - } - internal = internal + p.charAt(i); - - } - } - - this.setPorts(ports); - return retInputs; - } +// public TreeMap<String, LinkedHashMap<String, Object>> createPorts(TreeMap<String, LinkedHashMap<String, Object>> inps) { +// TreeMap<String, LinkedHashMap<String, Object>> retInputs = inps; +// LinkedHashMap<String, Object> portType = new LinkedHashMap(); +// portType.put("type", "string"); +// +// ArrayList<Object> ports = new ArrayList(); +// String external = ""; +// boolean foundPort = false; +// for(Object o: this.getPorts()) { +// String internal = ""; +// String p = o.toString(); +// for(int i = 0; i < p.length(); i++) { +// if(p.charAt(i) == ':') { +// internal = '"' + internal + '"'; +// internal = "concat: ['" + internal + "', {get_input: external_port}]"; +// ports.add(internal); +// } +// if(p.charAt(i) == ':' && !foundPort) { +// external = p.substring(i); +// portType.put("default", external); +// retInputs.put("external_port", portType); +// +// } +// internal = internal + p.charAt(i); +// +// } +// } +// +// this.setPorts(ports); +// return retInputs; +// } }
\ No newline at end of file diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java index b6bc0a1..3876b53 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/ComponentSpec.java @@ -22,23 +22,17 @@ package org.onap.blueprintgenerator.models.componentspec; import java.io.File; import java.io.IOException; -import java.util.Map; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; +import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import lombok.NoArgsConstructor; +import org.onap.blueprintgenerator.models.componentspec.policy_info.PolicyInfo; // TODO: Auto-generated Javadoc /** @@ -90,6 +84,9 @@ public class ComponentSpec { /** The auxilary. */ private Auxilary auxilary; + + @JsonProperty("policy_info") + private PolicyInfo policyInfo; /** The artifacts. */ private Artifacts[] artifacts; @@ -119,6 +116,7 @@ public class ComponentSpec { this.setParameters(cs.getParameters()); this.setServices(cs.getServices()); this.setStreams(cs.getStreams()); + this.setPolicyInfo(cs.getPolicyInfo()); } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java new file mode 100644 index 0000000..da746a7 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/PolicyInfo.java @@ -0,0 +1,35 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ +package org.onap.blueprintgenerator.models.componentspec.policy_info; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +import java.util.List; + +@Getter @Setter +@NoArgsConstructor +public class PolicyInfo { + + @JsonProperty("policy") + private List<TypePolicy> typePolicyList; +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java new file mode 100644 index 0000000..038c601 --- /dev/null +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/componentspec/policy_info/TypePolicy.java @@ -0,0 +1,36 @@ +/**============LICENSE_START======================================================= + org.onap.dcae + ================================================================================ + Copyright (c) 2019-2020 AT&T Intellectual Property. All rights reserved. + ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + ============LICENSE_END========================================================= + + */ + +package org.onap.blueprintgenerator.models.componentspec.policy_info; + +import com.fasterxml.jackson.annotation.JsonCreator; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter @Setter +@NoArgsConstructor +public class TypePolicy { + + private String node_label; + private String policy_id; + private String policy_model_id; + +} diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java index d3cff67..21eabf0 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapBlueprint.java @@ -20,15 +20,14 @@ package org.onap.blueprintgenerator.models.dmaapbp; -import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; +import org.onap.blueprintgenerator.core.PgaasNodeBuilder; +import org.onap.blueprintgenerator.core.PolicyNodeBuilder; import org.onap.blueprintgenerator.models.blueprint.Blueprint; import org.onap.blueprintgenerator.models.blueprint.Imports; -import org.onap.blueprintgenerator.models.blueprint.Interfaces; import org.onap.blueprintgenerator.models.blueprint.Node; -import org.onap.blueprintgenerator.models.blueprint.Properties; import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; import org.onap.blueprintgenerator.models.componentspec.Publishes; import org.onap.blueprintgenerator.models.componentspec.Subscribes; @@ -68,41 +67,48 @@ public class DmaapBlueprint extends Blueprint{ //create and add the topic/feed nodes //go through the streams publishes - int counter = 0; if(cs.getStreams().getPublishes() != null) { for(Publishes p: cs.getStreams().getPublishes()) { if(p.getType().equals("message_router") || p.getType().equals("message router")) { - String topic = "topic" + counter; + String topic = p.getConfig_key() + "_topic"; DmaapNode topicNode = new DmaapNode(); inps = topicNode.createTopicNode(cs, inps, topic); nodeTemplate.put(topic, topicNode); } else if(p.getType().equals("data_router") || p.getType().equals("data router")) { - String feed = "feed" + counter; + String feed = p.getConfig_key() + "_feed"; DmaapNode feedNode = new DmaapNode(); inps = feedNode.createFeedNode(cs, inps, feed); nodeTemplate.put(feed, feedNode); } - counter++; } } //go through the stream subscribes if(cs.getStreams().getSubscribes() != null) { for(Subscribes s: cs.getStreams().getSubscribes()) { if(s.getType().equals("message_router") || s.getType().equals("message router")) { - String topic = "topic" + counter; + String topic = s.getConfig_key() + "_topic"; DmaapNode topicNode = new DmaapNode(); inps = topicNode.createTopicNode(cs, inps, topic); nodeTemplate.put(topic, topicNode); } else if(s.getType().equals("data_router") || s.getType().equals("data router")) { - String feed = "feed" + counter; + String feed = s.getConfig_key() + "_feed"; DmaapNode feedNode = new DmaapNode(); inps = feedNode.createFeedNode(cs, inps, feed); nodeTemplate.put(feed, feedNode); } - counter++; } } + //if present in component spec, populate policyNodes information in the blueprint + if(cs.getPolicyInfo() != null){ + PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inps); + } + + //if present in component spec, populate pgaasNodes information in the blueprint + if(cs.getAuxilary().getDatabases() != null){ + PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inps); + } + bp.setNode_templates(nodeTemplate); bp.setInputs(inps); diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java index bfa7ae9..6c74347 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapNode.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; +import org.onap.blueprintgenerator.core.PgaasNodeBuilder; +import org.onap.blueprintgenerator.core.PolicyNodeBuilder; import org.onap.blueprintgenerator.models.blueprint.GetInput; import org.onap.blueprintgenerator.models.blueprint.Interfaces; import org.onap.blueprintgenerator.models.blueprint.Node; @@ -71,19 +73,17 @@ public class DmaapNode extends Node{ ArrayList<LinkedHashMap<String, String>> rets = new ArrayList(); //go through the streams publishes - int counter = 0; if(cs.getStreams().getPublishes() != null) { for(Publishes p: cs.getStreams().getPublishes()) { LinkedHashMap<String, String> pubRelations = new LinkedHashMap(); if(p.getType().equals("message_router") || p.getType().equals("message router")) { pubRelations.put("type", "ccsdk.relationships.publish_events"); - pubRelations.put("target", "topic" + counter); + pubRelations.put("target", p.getConfig_key() + "_topic"); } else if(p.getType().equals("data_router") || p.getType().equals("data router")) { pubRelations.put("type", "ccsdk.relationships.publish_files"); - pubRelations.put("target", "feed" + counter); + pubRelations.put("target", p.getConfig_key() + "_feed"); } rets.add(pubRelations); - counter++; } } //go through the stream subscribes @@ -92,15 +92,26 @@ public class DmaapNode extends Node{ LinkedHashMap<String, String> subRelations = new LinkedHashMap(); if(s.getType().equals("message_router") || s.getType().equals("message router")) { subRelations.put("type", "ccsdk.relationships.subscribe_to_events"); - subRelations.put("target", "topic" + counter); + subRelations.put("target", s.getConfig_key() + "_topic"); } else if(s.getType().equals("data_router") || s.getType().equals("data router")) { subRelations.put("type", "ccsdk.relationships.subscribe_to_files"); - subRelations.put("target", "feed" + counter); + subRelations.put("target", s.getConfig_key() + "_feed"); } rets.add(subRelations); - counter++; } } + + //add relationship for policy if exist + if(cs.getPolicyInfo() != null){ + ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs); + rets.addAll(policyRelationshipsList); + } + + //add relationships and env_variables for pgaas dbs if exist + if(cs.getAuxilary().getDatabases() != null){ + ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs); + rets.addAll(pgaasRelationshipsList); + } this.setRelationships(rets); diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java index 1640a6e..b26d45d 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/dmaapbp/DmaapStreams.java @@ -46,6 +46,10 @@ public class DmaapStreams { private GetInput username; private GetInput password; //private GetInput delivery_url; + + private GetInput privileged; + private GetInput decompress; + private String route; private String scheme; @@ -81,6 +85,18 @@ public class DmaapStreams { this.setPassword(password); retInputs.put(key + "_" + name + "_password", stringType); + //set privileged + GetInput priviliged = new GetInput(); + priviliged.setGet_input(key + "_" + name + "_priviliged"); + this.setPrivileged(priviliged); + retInputs.put(key + "_" + name + "_priviliged", stringType); + + //set decompress + GetInput decompress = new GetInput(); + decompress.setGet_input(key + "_" + name + "_decompress"); + this.setDecompress(decompress); + retInputs.put(key + "_" + name + "_decompress", stringType); + this.setRoute(route); this.setScheme("https"); } diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java index 8342020..c0ef8b3 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapBlueprint.java @@ -24,6 +24,8 @@ import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; +import org.onap.blueprintgenerator.core.PgaasNodeBuilder; +import org.onap.blueprintgenerator.core.PolicyNodeBuilder; import org.onap.blueprintgenerator.models.blueprint.Blueprint; import org.onap.blueprintgenerator.models.blueprint.Imports; import org.onap.blueprintgenerator.models.blueprint.Node; @@ -69,9 +71,20 @@ public class OnapBlueprint extends Blueprint{ nodeTemplate.put(nodeName, node); this.setNode_templates(nodeTemplate); + //if present in component spec, populate policyNode information in the blueprint + if(cs.getPolicyInfo() != null){ + PolicyNodeBuilder.addPolicyNodesAndInputs(cs, nodeTemplate, inputs); + } + + //if present in component spec, populate pgaasNodes information in the blueprint + if(cs.getAuxilary().getDatabases() != null){ + PgaasNodeBuilder.addPgaasNodesAndInputs(cs, nodeTemplate, inputs); + } + //set the inputs this.setInputs(inputs); + Blueprint bp = new Blueprint(); bp.setImports(this.getImports()); bp.setInputs(this.getInputs()); diff --git a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java index 2b0b8c0..a3d8e3e 100644 --- a/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java +++ b/mod/bpgenerator/src/main/java/org/onap/blueprintgenerator/models/onapbp/OnapNode.java @@ -20,9 +20,12 @@ package org.onap.blueprintgenerator.models.onapbp; +import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.TreeMap; +import org.onap.blueprintgenerator.core.PgaasNodeBuilder; +import org.onap.blueprintgenerator.core.PolicyNodeBuilder; import org.onap.blueprintgenerator.models.blueprint.Interfaces; import org.onap.blueprintgenerator.models.blueprint.Node; import org.onap.blueprintgenerator.models.blueprint.Properties; @@ -47,6 +50,8 @@ import lombok.NoArgsConstructor; public class OnapNode extends Node{ private TreeMap<String, Interfaces> interfaces; private Properties properties; + private ArrayList<LinkedHashMap<String, String>> relationships; + public TreeMap<String, LinkedHashMap<String, Object>> createOnapNode(TreeMap<String, LinkedHashMap<String, Object>> inps, ComponentSpec cs, String override) { TreeMap<String, LinkedHashMap<String, Object>> retInputs = new TreeMap<String, LinkedHashMap<String, Object>>(); retInputs = inps; @@ -61,6 +66,23 @@ public class OnapNode extends Node{ //set the type this.setType("dcae.nodes.ContainerizedPlatformComponent"); + //create and set the relationships + ArrayList<LinkedHashMap<String, String>> rets = new ArrayList(); + + //add relationship for policy if exist + if(cs.getPolicyInfo() != null){ + ArrayList<LinkedHashMap<String, String>> policyRelationshipsList = PolicyNodeBuilder.getPolicyRelationships(cs); + rets.addAll(policyRelationshipsList); + } + + //add relationships and env_variables for pgaas dbs if exist + if(cs.getAuxilary().getDatabases() != null){ + ArrayList<LinkedHashMap<String, String>> pgaasRelationshipsList = PgaasNodeBuilder.getPgaasNodeRelationships(cs); + rets.addAll(pgaasRelationshipsList); + } + + this.setRelationships(rets); + //set the properties Properties props = new Properties(); retInputs = props.createOnapProperties(retInputs, cs, override); diff --git a/mod/bpgenerator/version.properties b/mod/bpgenerator/version.properties index 755adf7..fee4928 100644 --- a/mod/bpgenerator/version.properties +++ b/mod/bpgenerator/version.properties @@ -1,5 +1,5 @@ major=1 -minor=2 +minor=3 patch=1 base_version=${major}.${minor}.${patch} release_version=${base_version} diff --git a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json index 1f1f75e..0fd68ec 100644 --- a/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json +++ b/mod/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json @@ -102,6 +102,36 @@ "items": { "$ref": "#/definitions/artifact" } + }, + "policy_info": { + "type": "object", + "properties": { + "policy": + { + "type": "array", + "items": + { + "type": "object", + "properties": + { + "node_label": + { + "type": "string" + }, + "policy_id": + { + "type": "string" + }, + "policy_model_id": + { + "type": "string" + } + }, + "required": ["node_label", "policy_model_id"] + } + } + }, + "additionalProperties": false } }, "required": [ @@ -740,7 +770,7 @@ "type": "string" } }, - "logging": { + "log_info": { "description": "Component specific details for logging", "type": "object", "properties": { @@ -755,6 +785,34 @@ }, "additionalProperties": false }, + "tls_info": { + "description": "Component information to use tls certificates", + "type": "object", + "properties": { + "cert_directory": { + "description": "The path in the container where the component certificates will be placed by the init container", + "type": "string" + }, + "use_tls": { + "description": "Boolean flag to determine if the application is using tls certificates", + "type": "boolean" + } + }, + "required": [ + "cert_directory","use_tls" + ], + "additionalProperties": false + }, + "databases": { + "description": "The databases the application is connecting to using the pgaas", + "type": "object", + "additionalProperties": { + "type": "string", + "enum": [ + "postgres" + ] + } + }, "policy": { "properties": { "trigger_type": { diff --git a/mod/designtool/mod-registry/pom.xml b/mod/designtool/mod-registry/pom.xml new file mode 100644 index 0000000..fbd3ba2 --- /dev/null +++ b/mod/designtool/mod-registry/pom.xml @@ -0,0 +1,108 @@ +<?xml version="1.0"?> +<!-- +================================================================================ +Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. +================================================================================ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +============LICENSE_END========================================================= + +--> +<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.dcaegen2.platform.mod</groupId> + <artifactId>designtool</artifactId> + <version>1.0.0-SNAPSHOT</version> + </parent> + <artifactId>mod-registry</artifactId> + <name>dcaegen2-platform-mod-registry</name> + <properties> + <postgresql.version>42.2.6</postgresql.version> + <nifi.registry.version>0.5.0</nifi.registry.version> + </properties> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <version>3.1.1</version> + <executions> + <execution> + <id>copy</id> + <phase>compile</phase> + <goals> + <goal>copy</goal> + </goals> + </execution> + </executions> + <configuration> + <artifactItems> + <artifactItem> + <groupId>org.postgresql</groupId> + <artifactId>postgresql</artifactId> + <version>${postgresql.version}</version> + <overWrite>false</overWrite> + </artifactItem> + </artifactItems> + <outputDirectory>${project.build.directory}</outputDirectory> + </configuration> + </plugin> + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <version>${docker.fabric.version}</version> + <configuration> + <verbose>true</verbose> + <pullRegistry>${docker.pull.registry}</pullRegistry> + <pushRegistry>${docker.push.registry}</pushRegistry> + <images> + <image> + <name>onap/${project.groupId}.${project.artifactId}</name> + <registry>${onap.nexus.dockerregistry.daily}</registry> + <build> + <from>apache/nifi-registry:${nifi.registry.version}</from> + <tags> + <tag>latest</tag> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}Z</tag> + </tags> + <assembly> + <targetDir>/opt/drivers</targetDir> + <inline> + <files> + <file> + <source>${project.build.directory}/postgresql-${postgresql.version}.jar</source> + </file> + </files> + </inline> + </assembly> + <env> + <NIFI_REGISTRY_DB_CLASS>org.postgresql.Driver</NIFI_REGISTRY_DB_CLASS> + <NIFI_REGISTRY_DB_DIR>/opt/drivers</NIFI_REGISTRY_DB_DIR> + </env> + </build> + </image> + </images> + </configuration> + <executions> + <execution> + <goals> + <goal>build</goal> + <goal>push</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> diff --git a/mod/designtool/pom.xml b/mod/designtool/pom.xml index 9d34bda..f53de0d 100644 --- a/mod/designtool/pom.xml +++ b/mod/designtool/pom.xml @@ -45,6 +45,7 @@ limitations under the License. <modules> <module>nifi-war-to-jar</module> <module>designtool-web</module> + <module>mod-registry</module> </modules> <build> <plugins> diff --git a/mod/distributorapi/pom.xml b/mod/distributorapi/pom.xml index 6f080f6..3cfd949 100644 --- a/mod/distributorapi/pom.xml +++ b/mod/distributorapi/pom.xml @@ -28,7 +28,7 @@ limitations under the License. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> - <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> + <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths> <sonar.language>py</sonar.language> <sonar.pluginname>python</sonar.pluginname> <sonar.inclusions>**/*.py</sonar.inclusions> diff --git a/mod/distributorapi/setup.py b/mod/distributorapi/setup.py index 3d0acfd..4a09471 100644 --- a/mod/distributorapi/setup.py +++ b/mod/distributorapi/setup.py @@ -34,6 +34,7 @@ setup( start-distributor-api=distributor.http:start_http_server """, install_requires=[ + "Werkzeug==0.16.1", "flask-restplus" , "Flask-Cors" , "requests" diff --git a/mod/genprocessor/pom.xml b/mod/genprocessor/pom.xml index a784ec5..6afc9de 100644 --- a/mod/genprocessor/pom.xml +++ b/mod/genprocessor/pom.xml @@ -152,7 +152,7 @@ limitations under the License. <name>onap/${project.groupId}.${project.artifactId}-job</name> <registry>${onap.nexus.dockerregistry.daily}</registry> <build> - <from>openjdk:8-jre-alpine</from> + <from>openjdk:8</from> <tags> <tag>latest</tag> <tag>${project.version}</tag> diff --git a/mod/onboardingapi/ChangeLog.md b/mod/onboardingapi/ChangeLog.md index 675184d..21d0f0c 100644 --- a/mod/onboardingapi/ChangeLog.md +++ b/mod/onboardingapi/ChangeLog.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). * Enhance Docker image creation to generate the dcae-cli configuration at runtime rather than at build time * Fix format_description to handle no description case * Add filtering by name, version for GET /components +* Modify server url in start.sh to point to new spec file +* Change dcae cli version in start.sh to 2.12.0 +* Change werkzeug dependency version in setup.py ## [2.11.3] diff --git a/mod/onboardingapi/pom.xml b/mod/onboardingapi/pom.xml index 9b1c4f0..588a9b2 100644 --- a/mod/onboardingapi/pom.xml +++ b/mod/onboardingapi/pom.xml @@ -28,7 +28,7 @@ limitations under the License. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> - <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> + <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths> <sonar.language>py</sonar.language> <sonar.pluginName>Python</sonar.pluginName> <sonar.inclusions>**/*.py</sonar.inclusions> diff --git a/mod/onboardingapi/setup.py b/mod/onboardingapi/setup.py index 438732c..6ad35a7 100644 --- a/mod/onboardingapi/setup.py +++ b/mod/onboardingapi/setup.py @@ -42,7 +42,9 @@ setup( dcae_cli=dcae_cli.cli:cli """, setup_requires=['pytest-runner'], - install_requires=['python-consul<1.0.0', + install_requires=[ + 'Werkzeug==0.16.1', + 'python-consul<1.0.0', 'six', 'sqlalchemy', 'SQLAlchemy-Utils', diff --git a/mod/onboardingapi/start.sh b/mod/onboardingapi/start.sh index 8b3978d..6d7d9e5 100755 --- a/mod/onboardingapi/start.sh +++ b/mod/onboardingapi/start.sh @@ -9,7 +9,7 @@ fi if [ ! -f ~/.config/dcae-cli/config.json ]; then echo "Creating dcae-cli config" # TODO: Make this into a variable that gets fed in via docker run - echo "{\"server_url\": \"https://git.onap.org/dcaegen2/platform/cli/plain\", \"user\": \"api\", \"db_url\": \"$PG_CONN\", \"cli_version\": \"2.11.1\", \"path_component_spec\": \"/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json\", \"path_data_format\": \"/component-json-schemas/data-format/dcae-cli-v1/data-format-schema.json\"}" > ~/.config/dcae-cli/config.json + echo "{\"server_url\": \"https://git.onap.org/dcaegen2/platform/plain/mod\", \"user\": \"api\", \"db_url\": \"$PG_CONN\", \"cli_version\": \"2.12.0\", \"path_component_spec\": \"/component-json-schemas/component-specification/dcae-cli-v2/component-spec-schema.json\", \"path_data_format\": \"/component-json-schemas/data-format/dcae-cli-v1/data-format-schema.json\"}" > ~/.config/dcae-cli/config.json fi dcae_cli http --live diff --git a/mod/runtimeapi/pom.xml b/mod/runtimeapi/pom.xml index e951d94..f9919c5 100644 --- a/mod/runtimeapi/pom.xml +++ b/mod/runtimeapi/pom.xml @@ -16,7 +16,8 @@ See the License for the specific language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +<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> <packaging>pom</packaging> @@ -31,36 +32,62 @@ limitations under the License. </parent> <groupId>org.onap.dcaegen2.platform.mod</groupId> <artifactId>runtimeapi</artifactId> - <version>1.0.0</version> + <version>1.0.1</version> <name>dcaegen2-platform-mod-runtimeapi</name> <description>MOD Runtime API</description> <properties> + <maven.compiler.source>1.8</maven.compiler.source> + <maven.compiler.target>1.8</maven.compiler.target> + <maven.deploy.skip>true</maven.deploy.skip> <java.version>1.8</java.version> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml - </sonar.coverage.jacoco.xmlReportPaths> + </sonar.coverage.jacoco.xmlReportPaths> </properties> <build> - <plugins> - <!-- support sonar in multi-module project --> - <plugin> - <groupId>org.sonarsource.scanner.maven</groupId> - <artifactId>sonar-maven-plugin</artifactId> - <version>3.6.0.1398</version> - </plugin> - </plugins> + <plugins> + <!-- support sonar in multi-module project --> + <plugin> + <groupId>org.sonarsource.scanner.maven</groupId> + <artifactId>sonar-maven-plugin</artifactId> + <version>3.6.0.1398</version> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <version>1.4.1</version> + <executions> + <execution> + <id>enforce-no-snapshots</id> + <goals> + <goal>enforce</goal> + </goals> + <configuration> + <rules> + <requireReleaseDeps> + <message>No Snapshots Allowed!</message> + </requireReleaseDeps> + </rules> + <fail>false</fail> + </configuration> + </execution> + </executions> + </plugin> + + </plugins> </build> <dependencyManagement> - <dependencies> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>2.1.7.RELEASE</version> - <type>pom</type> - <scope>import</scope> - </dependency> - </dependencies> + <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.1.7.RELEASE</version> + <type>pom</type> + <scope>import</scope> + </dependency> + </dependencies> </dependencyManagement> </project> diff --git a/mod/runtimeapi/runtime-core/pom.xml b/mod/runtimeapi/runtime-core/pom.xml index dd5d10b..7add43b 100644 --- a/mod/runtimeapi/runtime-core/pom.xml +++ b/mod/runtimeapi/runtime-core/pom.xml @@ -23,11 +23,12 @@ limitations under the License. <parent> <artifactId>runtimeapi</artifactId> <groupId>org.onap.dcaegen2.platform.mod</groupId> - <version>1.0.0</version> + <version>1.0.1</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactId>runtime-core</artifactId> + <version>1.0.1</version> <dependencies> <dependency> @@ -41,9 +42,9 @@ limitations under the License. <version>28.0-jre</version> </dependency> <dependency> - <groupId>org.onap.dcaegen2.platform.cli</groupId> + <groupId>org.onap.dcaegen2.platform.mod</groupId> <artifactId>blueprint-generator</artifactId> - <version>1.0.0</version> + <version>1.3.1</version> </dependency> <dependency> <groupId>org.json</groupId> diff --git a/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/blueprint_creator/BlueprintCreatorOnapDublin.java b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/blueprint_creator/BlueprintCreatorOnap.java index 2225971..7e11b10 100644 --- a/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/blueprint_creator/BlueprintCreatorOnapDublin.java +++ b/mod/runtimeapi/runtime-core/src/main/java/org/onap/dcae/runtime/core/blueprint_creator/BlueprintCreatorOnap.java @@ -17,15 +17,17 @@ */ package org.onap.dcae.runtime.core.blueprint_creator; +import org.onap.blueprintgenerator.core.Fixes; import org.onap.dcae.runtime.core.Node; import org.onap.blueprintgenerator.models.blueprint.Blueprint; import org.onap.blueprintgenerator.models.componentspec.ComponentSpec; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; +import java.util.LinkedHashMap; import java.util.Map; -public class BlueprintCreatorOnapDublin implements BlueprintCreator{ +public class BlueprintCreatorOnap implements BlueprintCreator{ private String topicUrl; private String importFilePath; @@ -42,7 +44,7 @@ public class BlueprintCreatorOnapDublin implements BlueprintCreator{ public String createBlueprint(String componentSpecString) { ComponentSpec componentSpec = new ComponentSpec(); componentSpec.createComponentSpecFromString(componentSpecString); - Blueprint blueprint = new Blueprint().createBlueprint(componentSpec,"",'o',importFilePath); + Blueprint blueprint = new Blueprint().createBlueprint(componentSpec,"",'o',importFilePath,""); return blueprint.blueprintToString(); } @@ -57,12 +59,27 @@ public class BlueprintCreatorOnapDublin implements BlueprintCreator{ Map<String,Object> obj = yaml.load(blueprintContent); Map<String,Object> inputsObj = (Map<String, Object>) obj.get("inputs"); for(Map.Entry<String,Object> entry: inputsObj.entrySet()){ + LinkedHashMap<String, Object> modified = retainQuotesForDefault(entry.getValue()); + entry.setValue(modified); if(entry.getKey().matches(locationPort+".*url")) { Map<String,String> inputValue = (Map<String, String>) entry.getValue(); inputValue.put("default",topicUrl + "/" + dmaapEntityName); } } - node.getBlueprintData().setBlueprint_content(yaml.dump(obj)); + node.getBlueprintData().setBlueprint_content(Fixes.applyFixes(yaml.dump(obj))); + } + + private LinkedHashMap<String, Object> retainQuotesForDefault(Object valueOfInputObject) { + LinkedHashMap<String, Object> temp = (LinkedHashMap<String, Object>) valueOfInputObject; + if(temp.containsKey("type") && temp.get("type").equals("string")) { + String def = (String) temp.get("default"); + if(def != null){ + def = def.replaceAll("\"$", "").replaceAll("^\"", ""); + } + def = '"' + def + '"'; + temp.replace("default", def); + } + return temp; } private Yaml getYamlInstance() { diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java index 8412133..25e3e54 100644 --- a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java +++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestFlowGraphParser.java @@ -26,7 +26,7 @@ import org.junit.Rule; import org.junit.rules.TemporaryFolder; import org.junit.Test; import static org.junit.Assert.assertEquals; -import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnapDublin; +import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnap; public class TestFlowGraphParser { @@ -47,7 +47,7 @@ public class TestFlowGraphParser { } FlowGraph<Node, Edge> mainFlowGraph = new FlowGraph<>("1234", "nifi-main", true, "mock graph"); mainFlowGraph.addNode(new Node("dummy_id", "dummy_name", "dummy_compspec")); - BlueprintCreatorOnapDublin bcod = new BlueprintCreatorOnapDublin(); + BlueprintCreatorOnap bcod = new BlueprintCreatorOnap(); bcod.setTopicUrl("u.r.l"); bcod.setImportFilePath(importsfile.getAbsolutePath()); FlowGraphParser flowGraphParser = new FlowGraphParser(bcod); diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestIntegeration.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestIntegeration.java index 612f9f0..615993a 100644 --- a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestIntegeration.java +++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestIntegeration.java @@ -21,7 +21,7 @@ import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreator; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnapDublin; +import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnap; public class TestIntegeration { @@ -33,7 +33,7 @@ public class TestIntegeration { FlowGraph<Node, Edge> flowGraph = Helper.prepareFlowGraph(); //2. Inject graph in FlowGraphParser - BlueprintCreator blueprintCreator = new BlueprintCreatorOnapDublin(); + BlueprintCreator blueprintCreator = new BlueprintCreatorOnap(); flowGraphParser = new FlowGraphParser(blueprintCreator); flowGraphParser.parse(flowGraph); } diff --git a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestOnapBpGen.java b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestOnapBpGen.java index f717022..60ba323 100644 --- a/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestOnapBpGen.java +++ b/mod/runtimeapi/runtime-core/src/test/java/org/onap/dcae/runtime/core/TestOnapBpGen.java @@ -29,7 +29,7 @@ public class TestOnapBpGen { componentSpec.createComponentSpecFromString(Helper.loadFileContent( "src/test/data/compspecs/componentSpec_hello_world_only_MR.json")); - Blueprint bp = new Blueprint().createBlueprint(componentSpec,"",'d',""); + Blueprint bp = new Blueprint().createBlueprint(componentSpec,"",'d',"",""); System.out.println(bp.getInputs()); } } diff --git a/mod/runtimeapi/runtime-web/data/imports/onapDublinImports.yaml b/mod/runtimeapi/runtime-web/data/imports/onapDublinImports.yaml deleted file mode 100644 index 9b9a203..0000000 --- a/mod/runtimeapi/runtime-web/data/imports/onapDublinImports.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: ['http://www.getcloudify.org/spec/cloudify/3.4/types.yaml', 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml', - 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml'] diff --git a/mod/runtimeapi/runtime-web/data/imports/onapImports.yaml b/mod/runtimeapi/runtime-web/data/imports/onapImports.yaml new file mode 100644 index 0000000..b164a8d --- /dev/null +++ b/mod/runtimeapi/runtime-web/data/imports/onapImports.yaml @@ -0,0 +1,5 @@ +imports: ['https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml', 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml', + 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml', + 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/pgaas/1.1.0/pgaas_types.yaml', + 'https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/clamppolicyplugin/1.1.0/clamppolicyplugin_types.yaml', + 'https://nexus.onap.org/content/repositories/raw/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml'] diff --git a/mod/runtimeapi/runtime-web/pom.xml b/mod/runtimeapi/runtime-web/pom.xml index 413ff9f..ff08ac1 100644 --- a/mod/runtimeapi/runtime-web/pom.xml +++ b/mod/runtimeapi/runtime-web/pom.xml @@ -22,10 +22,10 @@ limitations under the License. <parent> <groupId>org.onap.dcaegen2.platform.mod</groupId> <artifactId>runtimeapi</artifactId> - <version>1.0.0</version> + <version>1.0.1</version> </parent> <artifactId>runtime-web</artifactId> - <version>1.0.0</version> + <version>1.0.1</version> <packaging>jar</packaging> <name>runtime-web</name> <description>MOD Runtime Web Module</description> @@ -33,7 +33,7 @@ limitations under the License. <dependency> <groupId>org.onap.dcaegen2.platform.mod</groupId> <artifactId>runtime-core</artifactId> - <version>1.0.0</version> + <version>1.0.1</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> diff --git a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java index 8c535c7..11622e6 100644 --- a/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java +++ b/mod/runtimeapi/runtime-web/src/main/java/org/onap/dcae/runtime/web/configuration/BlueprintCreatorConfig.java @@ -18,7 +18,7 @@ package org.onap.dcae.runtime.web.configuration; import org.onap.dcae.runtime.core.FlowGraphParser; -import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnapDublin; +import org.onap.dcae.runtime.core.blueprint_creator.BlueprintCreatorOnap; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; @@ -43,28 +43,36 @@ public class BlueprintCreatorConfig { @Autowired Environment env; - - @Value("${onapDublin.topicUrl}") + + @Value("${onap.topicUrl}") String onapDublinTopicUrl; - @Value("${onapDublin.import.cloudifyPlugin}") + @Value("${onap.import.cloudifyPlugin}") String onapDublinImportCloudifyPlugin; - @Value("${onapDublin.import.k8sPlugin}") + @Value("${onap.import.k8sPlugin}") String onapDublinImportK8sPlugin; - @Value("${onapDublin.import.policyPlugin}") + @Value("${onap.import.policyPlugin}") String onapDublinImportPolicyPlugin; - - @Profile("onap_dublin") + @Value("${onap.import.postgresPlugin}") + String onapDublinImportPostgresPlugin; + + @Value("${onap.import.clampPlugin}") + String onapDublinImportClampPlugin; + + @Value("${onap.import.dmaapPlugin}") + String onapDublinImportDmaapPlugin; + + + @Profile("onap") @Primary @Bean public FlowGraphParser getFlowGraphParserForOnapDublin(){ - BlueprintCreatorOnapDublin blueprintCreatorOnapDublin = new BlueprintCreatorOnapDublin(); - blueprintCreatorOnapDublin.setTopicUrl(onapDublinTopicUrl); - blueprintCreatorOnapDublin.setImportFilePath(writeImportsTofile()); - FlowGraphParser flowGraphParser = new FlowGraphParser(blueprintCreatorOnapDublin); + BlueprintCreatorOnap blueprintCreatorOnap = new BlueprintCreatorOnap(); + blueprintCreatorOnap.setImportFilePath(writeImportsTofile()); + FlowGraphParser flowGraphParser = new FlowGraphParser(blueprintCreatorOnap); return flowGraphParser; } @@ -84,17 +92,17 @@ public class BlueprintCreatorConfig { private Path createDataImportDirAndImportFile() { Path importDirPath = Paths.get("./data/imports").toAbsolutePath().normalize(); - Path onapDublinImportFilePath = Paths.get("./data/imports/onapDublinImports.yaml").toAbsolutePath().normalize(); + Path onapImportFilePath = Paths.get("./data/imports/onapImports.yaml").toAbsolutePath().normalize(); try { Files.createDirectories(importDirPath); - Files.createFile(onapDublinImportFilePath); + Files.createFile(onapImportFilePath); } catch (FileAlreadyExistsException ignored){ } catch (IOException e) { e.printStackTrace(); } - return onapDublinImportFilePath; + return onapImportFilePath; } private String getContentToWrite() { @@ -103,6 +111,13 @@ public class BlueprintCreatorConfig { importList.add(onapDublinImportCloudifyPlugin); importList.add(onapDublinImportK8sPlugin); importList.add(onapDublinImportPolicyPlugin); + + importList.add(onapDublinImportPostgresPlugin); + importList.add(onapDublinImportClampPlugin); + importList.add(onapDublinImportDmaapPlugin); + + + result.put("imports",importList); return new Yaml().dump(result); } diff --git a/mod/runtimeapi/runtime-web/src/main/resources/application.properties b/mod/runtimeapi/runtime-web/src/main/resources/application.properties index 0cd7e03..dccce98 100644 --- a/mod/runtimeapi/runtime-web/src/main/resources/application.properties +++ b/mod/runtimeapi/runtime-web/src/main/resources/application.properties @@ -1,17 +1,24 @@ server.port=9090 #BlueprintGenerator profile -spring.profiles.active=onap_dublin +spring.profiles.active=onap #Dashboard/Inventory configs -dashboard.url=https://oom-dashboard/ccsdk-app/api-if +dashboard.url=https://dashboard/ccsdk-app/nb-api dashboard.username= dashboard.password= #Onap Dublin BlueprintGenerator configs -onapDublin.topicUrl=https://url:9999 +onap.topicUrl=https://url:9999 -onapDublin.import.cloudifyPlugin=http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -onapDublin.import.k8sPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.5/k8splugin_types.yaml -onapDublin.import.policyPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml +onap.import.cloudifyPlugin=https://www.getcloudify.org/spec/cloudify/4.5.5/types.yaml +onap.import.k8sPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/k8splugin/1.7.2/k8splugin_types.yaml + +onap.import.policyPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/dcaepolicyplugin/2.4.0/dcaepolicyplugin_types.yaml + +onap.import.postgresPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.ccsdk.platform.plugins/type_files/pgaas/1.1.0/pgaas_types.yaml + +onap.import.clampPlugin=https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R6/clamppolicyplugin/1.1.0/clamppolicyplugin_types.yaml + +onap.import.dmaapPlugin= https://nexus.onap.org/content/repositories/raw/org.onap.ccsdk.platform.plugins/type_files/dmaap/dmaap.yaml
\ No newline at end of file diff --git a/mod/runtimeapi/runtime-web/src/main/resources/imports/OnapDublinImports.yaml b/mod/runtimeapi/runtime-web/src/main/resources/imports/OnapImports.yaml index dc7c45c..dc7c45c 100644 --- a/mod/runtimeapi/runtime-web/src/main/resources/imports/OnapDublinImports.yaml +++ b/mod/runtimeapi/runtime-web/src/main/resources/imports/OnapImports.yaml diff --git a/oti/event-handler/otihandler/cfy_client.py b/oti/event-handler/otihandler/cfy_client.py index c823340..4e3de87 100644 --- a/oti/event-handler/otihandler/cfy_client.py +++ b/oti/event-handler/otihandler/cfy_client.py @@ -168,7 +168,7 @@ class CfyClient(object): if not password: raise CfyClientConsulError("{} value is missing 'cloudify.password'".format(source)) - b64_encoded_str = base64.b64encode(bytes("{}:{}".format(username, password), 'utf-8')).decode("utf-8") + b64_encoded_str = base64.b64encode(bytes("{}:{}".format(username, password), "utf-8")).decode("utf-8") headers = {'Authorization': 'Basic ' + b64_encoded_str.rstrip('\n')} #headers = {'Authorization': 'Basic ' + '{}:{}'.format(username, password).encode("base64").rstrip('\n')} @@ -416,8 +416,8 @@ class CfyClient(object): continue # Check if the collector supports this VNF Type - # scn:dti Consul key is authoritative for vnfTypes that a collector supports (not docker_config) - dti_key = scn + ':dti' + # scn:oti Consul key is authoritative for vnfTypes that a collector supports (not docker_config) + dti_key = scn + ':oti' try: obj = ConsulClient.get_value(dti_key) except Exception as e: @@ -531,8 +531,8 @@ class CfyClient(object): continue # Check if the collector supports this VNF Type - # scn:dti Consul key is authoritative for vnfTypes that a collector supports (not docker_config) - dti_key = scn + ':dti' + # scn:oti Consul key is authoritative for vnfTypes that a collector supports (not docker_config) + dti_key = scn + ':oti' try: obj = ConsulClient.get_value(dti_key) except Exception as e: diff --git a/oti/event-handler/otihandler/config.py b/oti/event-handler/otihandler/config.py index d5149cc..5c87f43 100644 --- a/oti/event-handler/otihandler/config.py +++ b/oti/event-handler/otihandler/config.py @@ -24,6 +24,7 @@ import os from otihandler.consul_client import ConsulClient +os.makedirs('logs', exist_ok=True) logging.basicConfig( filename='logs/oti_handler.log', \ format='%(asctime)s.%(msecs)03d %(levelname)+8s ' + \ diff --git a/oti/event-handler/otihandler/consul_client.py b/oti/event-handler/otihandler/consul_client.py index d26d3a1..1b25f3e 100644 --- a/oti/event-handler/otihandler/consul_client.py +++ b/oti/event-handler/otihandler/consul_client.py @@ -410,7 +410,7 @@ class ConsulClient(object): # key = urllib.quote(key) # can't use urllib.quote() because it kills ':' in the key if value: - return {"KV": {"Verb": verb, "Key": key, "Value": base64.b64encode(value)}} + return {"KV": {"Verb": verb, "Key": key, "Value": base64.b64encode(bytes(value, "utf-8")).decode("utf-8")}} return {"KV": {"Verb": verb, "Key": key}} @@ -450,7 +450,7 @@ class ConsulClient(object): """put kvs into consul-kv""" if not kvs: - ConsulClient._logger.warn("kvs not supplied to store_kvs()") + ConsulClient._logger.warning("kvs not supplied to store_kvs()") return store_kvs = [ @@ -474,7 +474,7 @@ class ConsulClient(object): """delete key from consul-kv""" if not key: - ConsulClient._logger.warn("key not supplied to delete_key()") + ConsulClient._logger.warning("key not supplied to delete_key()") return delete_key = [ @@ -488,7 +488,7 @@ class ConsulClient(object): """delete key from consul-kv""" if not key: - ConsulClient._logger.warn("key not supplied to delete_kvs()") + ConsulClient._logger.warning("key not supplied to delete_kvs()") return delete_kvs = [ @@ -555,16 +555,16 @@ class ConsulClient(object): @staticmethod def add_vnf_id(scn, vnf_type, vnf_id, dti_dict): """ - Add VNF instance to Consul scn:dti key. + Add VNF instance to Consul scn:oti key. Treat its value as a JSON string representing a dict. Extend the dict by adding a dti_dict for vnf_id under vnf_type. Turn the resulting extended dict into a JSON string. - Store the string back into Consul under scn:dti key. + Store the string back into Consul under scn:oti key. Watch out for conflicting concurrent updates. """ - key = scn + ':dti' + key = scn + ':oti' lc_vnf_type = vnf_type.lower() while True: # do until update succeeds (mod_index, v) = ConsulClient.get_value(key, get_index=True) @@ -583,16 +583,16 @@ class ConsulClient(object): @staticmethod def delete_vnf_id(scn, vnf_type, vnf_id): """ - Delete VNF instance from Consul scn:dti key. + Delete VNF instance from Consul scn:oti key. Treat its value as a JSON string representing a dict. Modify the dict by deleting the vnf_id key entry from under vnf_type. Turn the resulting extended dict into a JSON string. - Store the string back into Consul under scn:dti key. + Store the string back into Consul under scn:oti key. Watch out for conflicting concurrent updates. """ - key = scn + ':dti' + key = scn + ':oti' lc_vnf_type = vnf_type.lower() while True: # do until update succeeds (mod_index, v) = ConsulClient.get_value(key, get_index=True) diff --git a/oti/event-handler/otihandler/dti_processor.py b/oti/event-handler/otihandler/dti_processor.py index 970e020..5802233 100644 --- a/oti/event-handler/otihandler/dti_processor.py +++ b/oti/event-handler/otihandler/dti_processor.py @@ -36,51 +36,51 @@ lock = Lock() K8S_CLUSTER_PROXY_NODE_PORT = '30132' -def notify_docker(args_tuple): - """ - event notification executor inside a process pool to communicate with docker container - interacts with docker client library - """ - (dti_event, db_access, ack_item) = args_tuple - try: - dcae_service_action = dti_event.get('dcae_service_action') - component_scn = ack_item.service_component - deployment_id = ack_item.deployment_id - container_id = ack_item.container_id - docker_host = ack_item.docker_host - reconfig_script = ack_item.reconfig_script - container_type = 'docker' - except Exception as e: - return ( - "ERROR", "dti_processor.notify_docker processing args got exception {}: {!s}".format(type(e).__name__, e)) - what = "" - try: - what = "{} in {} container {} on {} that was deployed by {}".format( - reconfig_script, container_type, container_id, docker_host, deployment_id) - if dcae_service_action == 'add': - add_action = {"dcae_service_action": "deploy"} - dti_event.update(add_action) - - if dcae_service_action == 'delete': - add_action = {"dcae_service_action": "undeploy"} - dti_event.update(add_action) - - # dkr = DockerClient(docker_host, reauth=False) - result = '' - # result = dkr.notify_for_reconfiguration(container_id, [ reconfig_script, "dti", json.dumps(dti_event) ]) - if dti_event.get('dcae_service_action') == 'undeploy': - # delete from dti_event_ack table - try: - db_access.deleteDomainObject(ack_item) - except Exception as e: - msg = "trying to delete event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) - return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) - else: - return (component_scn, "ran {}, got: {!s}".format(what, result)) - - except Exception as e: - return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) +# def notify_docker(args_tuple): +# """ +# event notification executor inside a process pool to communicate with docker container +# interacts with docker client library +# """ +# (dti_event, db_access, ack_item) = args_tuple +# try: +# dcae_service_action = dti_event.get('dcae_service_action') +# component_scn = ack_item.service_component +# deployment_id = ack_item.deployment_id +# container_id = ack_item.container_id +# docker_host = ack_item.docker_host +# reconfig_script = ack_item.reconfig_script +# container_type = 'docker' +# except Exception as e: +# return ( +# "ERROR", "dti_processor.notify_docker() processing args got exception {}: {!s}".format(type(e).__name__, e)) +# what = "" +# try: +# what = "{} in {} container {} on {} that was deployed by {}".format( +# reconfig_script, container_type, container_id, docker_host, deployment_id) +# if dcae_service_action == 'add': +# add_action = {"dcae_service_action": "deploy"} +# dti_event.update(add_action) +# +# if dcae_service_action == 'delete': +# add_action = {"dcae_service_action": "undeploy"} +# dti_event.update(add_action) +# +# # dkr = DockerClient(docker_host, reauth=False) +# result = '' +# # result = dkr.notify_for_reconfiguration(container_id, [ reconfig_script, "dti", json.dumps(dti_event) ]) +# if dti_event.get('dcae_service_action') == 'undeploy': +# # delete from dti_event_ack table +# try: +# db_access.deleteDomainObject(ack_item) +# except Exception as e: +# msg = "trying to delete event ack record, got exception {}: {!s}".format(type(e).__name__, e) +# DTIProcessor.logger.warning(msg) +# return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) +# else: +# return (component_scn, "ran {}, got: {!s}".format(what, result)) +# +# except Exception as e: +# return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) def notify_svc(args_tuple): @@ -103,7 +103,7 @@ def notify_svc(args_tuple): reconfig_script = res_tuple[7] container_type = res_tuple[8] except Exception as e: - return ("ERROR", "oti_processor.notify processing args got exception {}: {!s}".format(type(e).__name__, e)) + return ("ERROR", "dti_processor.notify_svc() processing args got exception {}: {!s}".format(type(e).__name__, e)) what = "" if container_type == "docker": @@ -136,7 +136,7 @@ def notify_svc(args_tuple): db_access.saveDomainObject(upd_evt_ack) except Exception as e: msg = "trying to update event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) else: DTIProcessor.logger.debug("running {}".format(what)) @@ -152,39 +152,39 @@ def notify_svc(args_tuple): db_access.saveDomainObject(add_evt_ack) except Exception as e: msg = "trying to store event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) else: # remove from dtih_event_ack if present - if curr_evt is not None: + if curr_evt: try: del_evt_ack = db_access.query_event_info_docker(curr_evt, component_scn, deployment_id, container_id) db_access.deleteDomainObject(del_evt_ack) except Exception as e: msg = "trying to delete event ack record for docker service, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) except Exception as e: return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) return (component_scn, "ran {}, got: {!s}".format(what, result)) elif container_type == "k8s": - DTIProcessor.logger.debug("DTIProcessor.notify_svc() handling k8s component") + DTIProcessor.logger.debug("dti_processor.notify_svc() handling k8s component") # if action is 'update', check if k8s pod info exists already for this event in app db if dcae_service_action == 'add': - DTIProcessor.logger.debug("DTIProcessor.notify_svc() in k8s for add action") + DTIProcessor.logger.debug("dti_processor.notify_svc() in k8s for add action") return notify_k8s((dti_event, db_access, curr_evt, res_tuple)) elif dcae_service_action == 'update': # handle update for pods being tracked and handle add for new pods k8s_scn_result = db_access.query_event_data_k8s_pod(curr_evt, component_scn) - if k8s_scn_result is not None: + if k8s_scn_result: # update - DTIProcessor.logger.debug("DTIProcessor.notify_svc() in k8s for update action") + DTIProcessor.logger.debug("dti_processor.notify_svc() in k8s for update action") return notify_k8s_pod((dti_event, db_access, k8s_scn_result)) else: # add - DTIProcessor.logger.debug("DTIProcessor.notify_svc(), convert update to add action in k8s ") + DTIProcessor.logger.debug("dti_processor.notify_svc(), convert update to add action in k8s ") add_action = {"dcae_service_action": "add"} dti_event.update(add_action) return notify_k8s((dti_event, db_access, curr_evt, res_tuple)) @@ -248,7 +248,7 @@ def notify_k8s(args_tuple): return (component_scn, "ran {}, got: {!s}".format(what, event_ack_info)) except Exception as e: msg = "trying to store event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) @@ -304,7 +304,7 @@ def notify_pods(args_tuple): notify_response_arr.append((pod_id, "ran {}, got: {!s}".format(what, event_ack_info))) except Exception as e: with lock: - notify_response_arr.append (("ERROR", "dti_processor.notify() processing args got exception {}: {!s}".format(type(e).__name__, e))) + notify_response_arr.append (("ERROR", "dti_processor.notify_pods() processing args got exception {}: {!s}".format(type(e).__name__, e))) def notify_k8s_pod(args_tuple): """ @@ -339,7 +339,7 @@ def notify_k8s_pod(args_tuple): db_access.deleteDomainObject(ack_item) except Exception as e: msg = "trying to delete event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) else: try: @@ -347,7 +347,7 @@ def notify_k8s_pod(args_tuple): db_access.saveDomainObject(ack_item) except Exception as e: msg = "trying to update event ack record, got exception {}: {!s}".format(type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) return (component_scn, "exception {}: {!s} running {}".format(type(e).__name__, e, what)) return (component_scn, "ran {}, got: {!s}".format(what, response.json())) @@ -448,12 +448,12 @@ class DTIProcessor(object): result = ConsulClient.delete_key(key) except Exception as e: msg = "trying to delete Consul history key {}, got exception {}: {!s}".format(key, type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg else: if not result: msg = "VNF instance {} was not in Consul dti_events historical folder".format(self.target_name) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg def deploy(self): @@ -467,7 +467,7 @@ class DTIProcessor(object): result = ConsulClient.store_kvs({dep_key: self.event}) except Exception as e: msg = "trying to store Consul history key {}, got exception {}: {!s}".format(key, type(e).__name__, e) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg def add(self): @@ -484,7 +484,7 @@ class DTIProcessor(object): self.db_access.saveDomainObject(self.prim_db_event) except Exception as e: msg = "trying to store event, got exception {}: {!s}".format(type(e).__name__, e.args) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['ERROR'] = msg raise Exception(msg) else: @@ -546,7 +546,7 @@ class DTIProcessor(object): dcae_service_location=self.event_clli)) )) except Exception as e: - msg = "DTIProcessor._add() running pool.map() got exception {}: {!s}".format(type(e).__name__, e) + msg = "DTIProcessor.add_replay() running pool.map() got exception {}: {!s}".format(type(e).__name__, e) DTIProcessor.logger.error(msg) self._result['ERROR'] = msg return res_dict @@ -564,7 +564,7 @@ class DTIProcessor(object): try: msg = "processing delete event for {}/{} to relate with any docker hosts".format( self.target_type, self.target_name) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) res_dict_docker = dict(self.docker_pool.map(notify_svc, ((self.event, self.db_access, self.prim_db_event, tp) for tp @@ -581,8 +581,8 @@ class DTIProcessor(object): try: msg = "processing delete event for {}/{} to relate with any k8s hosts".format( self.target_type, self.target_name) - DTIProcessor.logger.warn(msg) - if self.prim_db_event is not None: + DTIProcessor.logger.warning(msg) + if self.prim_db_event: result = self.db_access.query_event_data_k8s(self.target_type, self.target_name) res_dict_k8s = dict(self.k8s_pool.map(notify_k8s_pod, ( ((self.event, self.db_access, ack_item) for ack_item in result)))) @@ -592,21 +592,21 @@ class DTIProcessor(object): self._result['ERROR'] = msg try: - if self.prim_db_event is not None: + if self.prim_db_event: self.db_access.deleteDomainObject(self.prim_db_event) except Exception as e: msg = "trying to delete event from database, got exception {}: {!s}".format(type(e).__name__, e.args) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['ERROR'] = msg except Exception as e: msg = "trying to process delete event, got exception {}: {!s}".format(type(e).__name__, e.args) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['ERROR'] = msg - if res_dict_k8s is not None: + if res_dict_k8s: utils.update_dict(res_dict, res_dict_k8s) - if res_dict_docker is not None: + if res_dict_docker: utils.update_dict(res_dict, res_dict_docker) return res_dict @@ -622,14 +622,14 @@ class DTIProcessor(object): if self.is_notify: try: self.prim_db_event = self.db_access.query_event_item(self.target_type, self.target_name) - if self.prim_db_event is not None: + if self.prim_db_event: self.db_access.update_event_item(self.event, self.target_type, self.target_name) result = self.db_access.query_event_data(self.target_type, self.target_name) if len(result) == 0: msg = "processing update event for {}/{}, but event distribution info is not found in database, " \ "replaying this event to cluster if required". \ format(self.target_type, self.target_name) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg res_dict = self.add_replay() else: @@ -654,7 +654,7 @@ class DTIProcessor(object): # event is new for the handler msg = "processing update event for {}/{}, but current event info is not found in database, " \ "executing add event".format(self.target_type, self.target_name) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg res_dict = self.add() except Exception as e: @@ -662,10 +662,10 @@ class DTIProcessor(object): DTIProcessor.logger.error(msg) self._result['ERROR'] = msg - if res_dict_k8s is not None: + if res_dict_k8s: utils.update_dict(res_dict, res_dict_k8s) - if res_dict_docker is not None: + if res_dict_docker: utils.update_dict(res_dict, res_dict_docker) return res_dict @@ -678,7 +678,7 @@ class DTIProcessor(object): res_dict = {} try: self.prim_db_event = self.db_access.query_event_item(self.target_type, self.target_name) - if self.prim_db_event is not None: + if self.prim_db_event: self.db_access.update_event_item(self.event, self.target_type, self.target_name) else: self.prim_db_event = Event(event=self.event, target_name=self.target_name, target_type=self.target_type, @@ -686,7 +686,7 @@ class DTIProcessor(object): self.db_access.saveDomainObject(self.prim_db_event) except Exception as e: msg = "trying to store notify event, got exception {}: {!s}".format(type(e).__name__, e.args) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['ERROR'] = msg try: @@ -696,7 +696,7 @@ class DTIProcessor(object): res_dict[k] = v except Exception as e: msg = "trying to run notify event, got exception {}: {!s}".format(type(e).__name__, e.args) - DTIProcessor.logger.warn(msg) + DTIProcessor.logger.warning(msg) self._result['WARNING'] = msg return res_dict @@ -785,7 +785,7 @@ class DTIProcessor(object): pass try: - supported_types = ConsulClient.get_value(service_name + ":dti") + supported_types = ConsulClient.get_value(service_name + ":oti") except: return r_dict else: diff --git a/oti/event-handler/otihandler/onap/CommonLogger.py b/oti/event-handler/otihandler/onap/CommonLogger.py index 644534d..3b5b477 100644 --- a/oti/event-handler/otihandler/onap/CommonLogger.py +++ b/oti/event-handler/otihandler/onap/CommonLogger.py @@ -781,7 +781,7 @@ class CommonLogger: print("error creating %s directory to hold %s logfile: %s" %(folder, filename, str(err))) sys.exit(2) -if __name__ == "__main__": +if __name__ == "__main__": # pragma: no cover def __checkOneTime(line): format = r'[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}[+]00:00[|]' diff --git a/oti/event-handler/otihandler/web_server.py b/oti/event-handler/otihandler/web_server.py index f3eb071..45c407f 100644 --- a/oti/event-handler/otihandler/web_server.py +++ b/oti/event-handler/otihandler/web_server.py @@ -180,6 +180,8 @@ class _DTIWeb(object): if cherrypy.request.method != "POST": raise cherrypy.HTTPError(404, "unexpected method {}".format(cherrypy.request.method)) + msg = "" + dti_event = cherrypy.request.json or {} str_dti_event = json.dumps(dti_event) @@ -192,38 +194,38 @@ class _DTIWeb(object): dcae_service_action = dti_event.get('dcae_service_action') if not dcae_service_action: msg = 'dcae_service_action is missing' - DTIWeb.logger.error(msg) - raise cherrypy.HTTPError(400, msg) elif dcae_service_action.lower() not in self.VALID_EVENT_TYPES: msg = 'dcae_service_action is invalid' - DTIWeb.logger.error(msg) - raise cherrypy.HTTPError(400,msg) dcae_target_name = dti_event.get('dcae_target_name') - if not dcae_target_name: + if not msg and not dcae_target_name: msg = 'dcae_target_name is missing' - DTIWeb.logger.error(msg) - raise cherrypy.HTTPError(400, msg) dcae_target_type = dti_event.get('dcae_target_type', '') - if not dcae_target_type: + if not msg and not dcae_target_type: msg = 'dcae_target_type is missing' - DTIWeb.logger.error(msg) - raise cherrypy.HTTPError(400, msg) - send_notification = True - if (isinstance(notify, bool) and not notify) or \ - (isinstance(notify, str) and notify.lower() in [ "f", "false", "n", "no" ]): - send_notification = False + if msg: + result = {"ERROR": msg} + + DTIWeb.logger.error("%s: dti_event=%s result=%s", \ + req_info, str_dti_event, json.dumps(result)) + else: + send_notification = True + if (isinstance(notify, bool) and not notify) or \ + (isinstance(notify, str) and notify.lower() in [ "f", "false", "n", "no" ]): + send_notification = False - prc = DTIProcessor(dti_event, send_notification=send_notification) - result = prc.get_result() + prc = DTIProcessor(dti_event, send_notification=send_notification) + result = prc.get_result() - DTIWeb.logger.info("%s: dti_event=%s result=%s", \ - req_info, str_dti_event, json.dumps(result)) + DTIWeb.logger.info("%s: dti_event=%s result=%s", \ + req_info, str_dti_event, json.dumps(result)) success, http_status_code, _ = audit.audit_done(result=json.dumps(result)) - if not success: + if msg: + cherrypy.response.status = "400 Bad Request" + elif not success: cherrypy.response.status = http_status_code return result @@ -537,7 +539,7 @@ class _DTIWeb(object): req_info, service_name, json.dumps(cherrypy.request.headers)) try: - result = CBSRest.get_dti(service_name=service_name, vnf_type=vnf_type, vnf_id=vnf_id, service_location=service_location) + result = CBSRest.get_oti(service_name=service_name, vnf_type=vnf_type, vnf_id=vnf_id, service_location=service_location) except Exception as e: result = {"ERROR": "exception {}: {!s}".format(type(e).__name__, e)} audit.set_http_status_code(404) diff --git a/oti/event-handler/pom.xml b/oti/event-handler/pom.xml index 962d742..06f6f21 100644 --- a/oti/event-handler/pom.xml +++ b/oti/event-handler/pom.xml @@ -28,7 +28,7 @@ limitations under the License. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <sonar.sources>.</sonar.sources> <sonar.junit.reportsPath>xunit-results.xml</sonar.junit.reportsPath> - <sonar.python.coverage.reportPath>coverage.xml</sonar.python.coverage.reportPath> + <sonar.python.coverage.reportPaths>coverage.xml</sonar.python.coverage.reportPaths> <sonar.language>py</sonar.language> <sonar.pluginname>python</sonar.pluginname> <sonar.inclusions>**/*.py</sonar.inclusions> diff --git a/oti/event-handler/tests/__init__.py b/oti/event-handler/tests/__init__.py new file mode 100644 index 0000000..bfa3da1 --- /dev/null +++ b/oti/event-handler/tests/__init__.py @@ -0,0 +1,20 @@ +# ================================================================================ +# Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + + +# empty __init__.py so that pytest can add correct path to coverage report, -- per pytest +# best practice guideline diff --git a/oti/event-handler/tests/test_otihandler.py b/oti/event-handler/tests/test_otihandler.py new file mode 100755 index 0000000..6f99638 --- /dev/null +++ b/oti/event-handler/tests/test_otihandler.py @@ -0,0 +1,1894 @@ +# ============LICENSE_START======================================================= +# Copyright (c) 2020 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============LICENSE_END========================================================= +# + +"""test otihandler package of DCAE-Controller""" + +import base64 +import copy +import json +import logging +import os +import re +import sys +import time +import uuid +# from urlparse import urlparse, parse_qsl +from datetime import datetime + +import pytest +import cherrypy +from cherrypy.test import helper + +from otihandler.config import Config +from otihandler.consul_client import (ConsulClient, + ConsulClientConnectionError, ConsulClientServiceNotFoundError, + ConsulClientKVEntryNotFoundError) +from otihandler.onap.audit import (Audit, AuditHttpCode) +from otihandler.__main__ import LogWriter +from otihandler.web_server import _DTIWeb + +OTIHANDLER_VERSION = "1.0.0" + +false = False +true = True +null = None + +class Settings(object): + """init all locals""" + + logger = None + RUN_TS = datetime.utcnow().isoformat()[:-3] + 'Z' + discovered_config = None + + @staticmethod + def init(): + """init locals""" + + os.environ["CLOUDIFY"] = '{"cloudify":{"protocol":"https","user":"XXXXX","password":"XXXX","address":"cloudify.bogus.com","port":"443"}}' + os.environ["CONSUL_URL"] = "http://consul:8500" + os.environ["OTI_HANDLER_URL"] = "https://oti_handler:8443" + + Config.load_from_file() + + with open("etc/config.json", 'r') as config_json: + Settings.discovered_config = json.load(config_json) + + Config.load_from_file("etc/config.json") + + Settings.logger = logging.getLogger("otihandler.unit_test") + sys.stdout = LogWriter(Settings.logger.info) + sys.stderr = LogWriter(Settings.logger.error) + + print("print ========== run_otihandler ==========") + Settings.logger.info("========== run_otihandler ==========") + Audit.init(Config.get_system_name(), OTIHANDLER_VERSION, Config.LOGGER_CONFIG_FILE_PATH) + + Settings.logger.info("starting otihandler with config:") + Settings.logger.info(Audit.log_json_dumps(Config.config)) + +Settings.init() + + +class MonkeyHttpResponse(object): + """Monkey http response""" + + def __init__(self, headers): + """init locals""" + + self.headers = headers or {} + +class MonkeyRequestsResponse(object): + """Monkey response""" + + def __init__(self, full_path, res_json, json_body=None, headers=None, status_code=200): + """init locals""" + + self.full_path = full_path + self.req_json = json_body or {} + self.status_code = status_code + self.request = MonkeyHttpResponse(headers) + self.res = res_json + self.text = json.dumps(self.res) + + def json(self): + """returns json of response""" + + return self.res + + def raise_for_status(self): + """ignoring""" + + if self.status_code == 200: + return + else: + Settings.logger.warning("raise_for_status found status_code: {}".format(self.status_code)) + +def kv_encode(key, value): + """helper function to encode a consul key value""" + + rtn = { + "LockIndex": 0, + "Key": key, + "Flags": 0, + "Value": base64.b64encode(bytes(value, "utf-8")).decode("utf-8"), + "CreateIndex": 19, + "ModifyIndex": 99999 + } + return rtn + +def monkey_consul_client_get(full_path, **kwargs): + """monkeypatch for GET from consul""" + + rv = None + res_json = {} + if full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "cloudify_manager"): + res_json = [{ + "ID": "048ec7c9-aa2e-bfad-34c7-6755e0007c9c", + "Node": "zldcdyh1adcc1orcl00.novalocal", + "Address": "192.168.1.13", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "192.168.1.13", + "wan": "192.168.1.13" + }, + "NodeMeta": {}, + "ServiceID": "cloudify_manager", + "ServiceName": "cloudify_manager", + "ServiceTags": [], + "ServiceAddress": "1.1.1.1", + "ServicePort": 80, + "ServiceEnableTagOverride": false, + "CreateIndex": 1569262, + "ModifyIndex": 1569262 + }] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_handler"): + res_json = [{ + "ID": "476991b8-7f40-e3c2-9d5e-f936c2aeaf56", + "Node": "zldcdyh1adcc1dokr00", + "Address": "32.68.15.149", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "32.68.15.149", + "wan": "32.68.15.149" + }, + "NodeMeta": { + "fqdn": "oti_handler" + }, + "ServiceID": "58a417002f89:oti_handler:8443", + "ServiceName": "oti_handler", + "ServiceTags": [ + "oti_handler", + "oti_handler" + ], + "ServiceAddress": "1.1.1.2", + "ServicePort": 8443, + "ServiceEnableTagOverride": false, + "CreateIndex": 1161355, + "ModifyIndex": 1161355 + }] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "deployment_handler"): + res_json = [{ + "ID": "476991b8-7f40-e3c2-9d5e-f936c2aeaf56", + "Node": "zldcdyh1adcc1dokr00", + "Address": "32.68.15.149", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "32.68.15.149", + "wan": "32.68.15.149" + }, + "NodeMeta": { + "fqdn": "deployment_handler:8188" + }, + "ServiceID": "58a417002f89:deployment_handler:8188", + "ServiceName": "deployment_handler", + "ServiceTags": [ + "deployment_handler", + "deployment_handler" + ], + "ServiceAddress": "1.1.1.2", + "ServicePort": 8188, + "ServiceEnableTagOverride": false, + "CreateIndex": 1502800, + "ModifyIndex": 1502800 + }] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "zldcdyh1adcc1-component-dockerhost-1"): + res_json = [{ + "ID": "4ffed53d-7601-7d47-df93-c091ea66fb45", + "Node": "zldcdyh1adcc1dokr02", + "Address": "32.68.15.163", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "32.68.15.163", + "wan": "32.68.15.163" + }, + "NodeMeta": { + "fqdn": "zldcdyh1adcc1dokr02.bogus.com" + }, + "ServiceID": "zldcdyh1adcc1-component-dockerhost-1", + "ServiceName": "zldcdyh1adcc1-component-dockerhost-1", + "ServiceTags": [ + "LSLEILAA", + "MDTWNJC1" + ], + "ServiceAddress": "1.1.1.5", + "ServicePort": 2376, + "ServiceEnableTagOverride": false, + "CreateIndex": 1704211, + "ModifyIndex": 1704211 + }] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), Config.get_system_name()): + res_json = copy.deepcopy(Settings.discovered_config) + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "cloudify_manager"): + res_json = [kv_encode("cloudify_manager", json.dumps( + {"cloudify":{"protocol" : "http", "user": "admin", "password":"XXXX"}} + ))] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_2:oti"): + res_json = [ + kv_encode("SCN_2:oti", json.dumps( + { + "anot-her": { + "another01ems003": {"dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_target_name": "another01ems003", "dcae_target_collection": "true", "event": {}, "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV"} + } + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "docker_plugin/docker_logins"): + res_json = [ + kv_encode("docker_plugin/docker_logins", json.dumps( + [{"username": "fake_user", "password": "fake_password", + "registry": "registry.bogus.com:5100" }] + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/") \ + or full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/"): + res_json = [ + kv_encode("oti_events/anot-her/another01ems003", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems003", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )), + kv_encode("oti_events/anot-her/another01ems042", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.42", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems042", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )), + kv_encode("oti_events/anot-her/another01ems044", json.dumps( + {"dcae_service_location": "MDTWNJC1", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.42", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems044", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/birth-day/"): + res_json = [ + kv_encode("oti_events/birth-day/birthdy01ems055", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "birth-day", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "birthdy01ems055", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"birthdy01ems055_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "birthdy01ems055"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/new-type/"): + res_json = [ + kv_encode("oti_events/new-type/newtype01ems084", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "new-type", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "newtype01ems084", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"newtype01ems084_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "newtype01ems084"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/pcrf-oam/"): + res_json = [ + kv_encode("oti_events/pcrf-oam/pcrfoam01ems009", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "pcrf-oam", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "pcrfoam01ems009", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"pcrfoam01ems009_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "pcrfoam01ems009"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/pnga-xxx/"): + res_json = [ + kv_encode("oti_events/pnga-xxx/pngaxxx01ems007", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "pnga-xxx", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "pngaxxx01ems007", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"pngaxxx01ems007_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "pngaxxx01ems007"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/vhss-ems/"): + res_json = [ + kv_encode("oti_events/vhss-ems/vhssems01ems019", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "vhss-ems", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "vhssems01ems019", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"vhssems01ems019_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "vhssems01ems019"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems003"): + res_json = [ + kv_encode("oti_events/anot-her/another01ems003", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.3", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems003", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems042"): + res_json = [ + kv_encode("oti_events/anot-her/another01ems042", json.dumps( + {"dcae_service_location": "LSLEILAA", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.42", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems042", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "oti_events/anot-her/another01ems044"): + res_json = [ + kv_encode("oti_events/anot-her/another01ems044", json.dumps( + {"dcae_service_location": "MDTWNJC1", + "dcae_target_type": "ANOT-her", + "dcae_service_action": "deploy", + "dcae_service-instance_model-version-id": "1", + "dcae_target_collection_ip": "107.239.85.42", + "dcae_target_is-closed-loop-disabled": "false", + "dcae_target_in-maint": "false", + "dcae_target_name": "another01ems044", + "dcae_target_collection": "true", + "event": {}, + "dcae_snmp_version": "2c", + "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"serviceType": "MOB-VHSS", "nodeType": "VHSS", "description": "VHSS Data Collection", "priority": 1, "nodeSubtype": "", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroupId": "g1", "serverGroup": [{"isPrimary": "true", "remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044"}]}}, "protocol": "sftp", "collectionInterval": "300"}}}, + "dcae_snmp_community_string": "my_first_community", + "dcae_generic-vnf_model-version-id": "1", + "dcae_target_prov-status": "PROV" + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"): + res_json = [ + kv_encode("SCN_1", json.dumps( + {"dcae_target_type": ["pnga-xxx"]} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:oti"): + res_json = [ + kv_encode("SCN_1:oti", json.dumps( + {"new-type": {}, "pnga-xxx": {}, "birth-day": {}, "anot-her": {}, "vhss-ems": {}, "pcrf-oam": {}} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:dmaap"): + res_json = [ + kv_encode("SCN_1:dmaap", json.dumps( + {"topic0": { + "topic_url": "https://dcae-mrtr.bogus.com:3005/events/com.bogus.HelloWorld-PubTopic", + "client_role": "com.bogus.member", + "location": "loc-1", + "client_id": "1575649224792" + }, + "topic1": { + "topic_url": "https://dcae-mrtr.bogus.com:3005/events/com.bogus.HelloWorld-PubTopic", + "client_role": "com.bogus.member", + "location": "loc-1", + "client_id": "1575649221094" + } + } + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:rel"): + res_json = [ + kv_encode("SCN_1:rel", json.dumps( + {"who-knows", "what this content might look like?"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"): + res_json = [ + kv_encode("SCN_1", json.dumps( + {"dcae_target_type": ["pnga-xxx"]} + )), + kv_encode("SCN_1:oti", json.dumps( + {"new-type": {}, "pnga-xxx": {}, "birth-day": {}, "anot-her": {}, "vhss-ems": {}, "pcrf-oam": {}} + )), + kv_encode("SCN_1:policies/event", json.dumps( + {"action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "policies_count": 3} + )), + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"} + )), + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"} + )), + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps( + {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KVS_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/"): + res_json = [ + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"} + )), + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"} + )), + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps( + {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors"): + res_json = [ + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Collectors", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "type": "JSON", "property": null, "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "package_type": "plastic", "polling_frequency": "30m"}, "policyVersion": "1"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific"): + res_json = [ + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific", json.dumps( + {"policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "type": "JSON", "property": null, "config": {"conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy", "preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel"}, "policyVersion": "5"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1:policies/items/DCAE_FTL3B.Config_In_Service"): + res_json = [ + kv_encode("SCN_1:policies/items/DCAE_FTL3B.Config_In_Service", json.dumps( + {"policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyConfigStatus": "CONFIG_RETRIEVED", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "type": "JSON", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyVersion": "1"} + )) + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "bogus:oti"): + res_json = None + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == "{}/v1/catalog/services".format(os.environ.get("CONSUL_URL").rstrip("/")): + res_json = { + "OTITopologyVM": [], + "apihandler": [], + "cloudify_manager": [], + "config_binding_service": [], + "consul": [], + "dashboard": [], + "deployment_handler": [ + "deployment_handler" + ], + "dmaap_bus_controller": [], + "dmrb": [], + "oti_handler": [ + "oti_handler" + ], + "http_dmaap_bus_controller_api": [], + "https_dmaap_bus_controller_api": [], + "inventory": [ + "inventory" + ], + "pgda-readonly": [], + "pgda-service": [], + "pgda-write": [], + "policy_handler": [ + "policy_handler" + ], + "pstg-readonly": [], + "pstg-service": [], + "pstg-write": [], + "service-change-handler": [ + "service-change-handler" + ], + "zldcdyh1adcc1-component-dockerhost-1": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adcc1-component-dockerhost-2": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adcc1-component-dockerhost-3": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adcc1-component-dockerhost-4": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adcc1-platform-dockerhost-1": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adcc1-platform-dockerhost-2": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-component-dockerhost-1": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-component-dockerhost-2": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-component-dockerhost-3": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-component-dockerhost-4": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-platform-dockerhost-1": [ + "LSLEILAA", + "MDTWNJC1" + ], + "zldcdyh1adce1-platform-dockerhost-2": [ + "LSLEILAA", + "MDTWNJC1" + ] + } + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "SCN_1"): + res_json = [ + { + "ID": "966d0ef5-7ca2-1b25-d587-2f0541a6ef78", + "Node": "node_1", + "Address": "10.1.14.15", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "10.1.14.15", + "wan": "10.1.14.15" + }, + "NodeMeta": { + "consul-network-segment": "", + "fqdn": "kpma00.897658.bogus.com" + }, + "ServiceKind": "", + "ServiceID": "scn-1-service-301", + "ServiceName": "scn-1-service", + "ServiceTags": [ + "com-bogus-dcae-controller" + ], + "ServiceAddress": "scn-1.bogus.com", + "ServiceWeights": { + "Passing": 1, + "Warning": 1 + }, + "ServiceMeta": { + "proto": "http" + }, + "ServicePort": 301, + "ServiceEnableTagOverride": false, + "ServiceProxyDestination": "", + "ServiceProxy": {}, + "ServiceConnect": {}, + "CreateIndex": 30535167, + "ModifyIndex": 30535167 + } + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == ConsulClient.CONSUL_SERVICE_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), "bogus"): + res_json = [ + ] + rv = MonkeyRequestsResponse(full_path, res_json) + + elif full_path == "{}/v1/catalog/node/node_1".format(os.environ.get("CONSUL_URL").rstrip("/")): + res_json = { + "Node": { + "ID": "966d0ef5-7ca2-1b25-d587-2f0541a6ef78", + "Node": "node_1", + "Address": "10.1.14.15", + "Datacenter": "zldcdyh1adcc1", + "TaggedAddresses": { + "lan": "10.1.14.15", + "wan": "10.1.14.15" + }, + "Meta": { + "consul-network-segment": "", + "fqdn": "kpma00.897658.bogus.com" + }, + "CreateIndex": 28443495, + "ModifyIndex": 28443495 + }, + "Services": { + "apple-320": { + "ID": "apple-320", + "Service": "apple", + "Tags": [ + "com-bogus-controller-mgmt" + ], + "Address": "apple.bogus.com", + "Meta": { + "proto": "" + }, + "Port": 320, + "Weights": { + "Passing": 1, + "Warning": 1 + }, + "EnableTagOverride": false, + "ProxyDestination": "", + "Proxy": {}, + "Connect": {}, + "CreateIndex": 28598335, + "ModifyIndex": 28598335 + }, + "banana-service-301": { + "ID": "banana-service-301", + "Service": "banana-service", + "Tags": [ + "com-bogus-controller-dev" + ], + "Address": "banana.bogus.com", + "Meta": { + "proto": "http" + }, + "Port": 301, + "Weights": { + "Passing": 1, + "Warning": 1 + }, + "EnableTagOverride": false, + "ProxyDestination": "", + "Proxy": {}, + "Connect": {}, + "CreateIndex": 30535167, + "ModifyIndex": 30535167 + }, + "d3_kp_platform_kubernetes_master": { + "ID": "d3_kp_platform_kubernetes_master", + "Service": "d3_kp_platform_kubernetes_master", + "Tags": [ + "KGMTNC20" + ], + "Address": "10.1.14.15", + "Meta": null, + "Port": 6443, + "Weights": { + "Passing": 1, + "Warning": 1 + }, + "EnableTagOverride": false, + "ProxyDestination": "", + "Proxy": {}, + "Connect": {}, + "CreateIndex": 28443495, + "ModifyIndex": 28443495 + } + } + } + rv = MonkeyRequestsResponse(full_path, res_json) + + else: + Settings.logger.error("monkey_consul_client_get had no mock for {}".format(full_path)) + res_json = None + rv = MonkeyRequestsResponse(full_path, res_json, status_code=404) + + return rv + +def monkey_consul_client_put(full_path, **kwargs): + """monkeypatch for PUT from consul""" + + Settings.logger.info("monkey_consul_client called with full_path={}, kwargs={}".format(full_path, kwargs)) + rv = False + res_json = {} + if full_path == ConsulClient.CONSUL_TRANSACTION_URL.format(os.environ.get("CONSUL_URL").rstrip("/")): + txn = {} + if 'json' in kwargs: + Settings.logger.info("monkey_consul_client called with txn={}".format(str(kwargs.get('json')))) + txn = kwargs.get('json')[0] + r_dict = { + "Results": [ + { + "KV": { + "LockIndex": 99999, + "Key": txn.get('Key'), + "Flags": 0, + "Value": None, + "CreateIndex": 99999, + "ModifyIndex": 99999 + } + } + ], + "Errors": [ + ] + } + status_code = 200 + KV = txn.get('KV') + if KV and KV.get('Verb') == 'delete' and KV.get('Key') == 'oti_events/anot-her/bogus': + status_code = 409 + r_dict["Errors"].append({ + "OpIndex": 99, + "What": "That KV does not exist." + }) + res_json = [ r_dict ] + Settings.logger.info("monkey_consul_client produced res_json={} with status_code={}".format(json.dumps(res_json), status_code)) + rv = MonkeyRequestsResponse(full_path, res_json, status_code=status_code) + + elif full_path.startswith(ConsulClient.CONSUL_KV_MASK.format(os.environ.get("CONSUL_URL").rstrip("/"), '')): # wants to write + # parse_url = urlparse(url) + # query_dict = dict(parse_qsl(parse_url.query)) + + res_json = True + Settings.logger.info("monkey_consul_client produced res_json={}".format(json.dumps(res_json))) + rv = MonkeyRequestsResponse(full_path, res_json) + + else: + Settings.logger.error("monkey_consul_client_put had no mock for {}".format(full_path)) + + return rv + +class MonkeyCloudifyNode(object): + """fake cloudify node_instance""" + + def __init__(self, **kwargs): + """init locals""" + + self.runtime_properties = kwargs.get('runtime_properties', {}) + self.deployment_id = kwargs.get('deployment_id') + self.node_id = kwargs.get('node_id') + self.id = kwargs.get('id') + self.state = kwargs.get('state') + +class MonkeyCloudifyClient(object): + """monkeypatch for CloudifyClient""" + + def __init__(self, **kwargs): + """init locals""" + + Settings.logger.info("MonkeyCloudifyClient called with kwargs={}".format(json.dumps(kwargs))) + self._host = kwargs.get('host') + self._port = kwargs.get('port') + self._protocol = kwargs.get('protocol') + self._headers = kwargs.get('headers') + + self.node_instances = self + + def list(self, **kwargs): + """list node_instances""" + + Settings.logger.info("MonkeyCloudifyClient.list() called with kwargs={}".format(json.dumps(kwargs))) + rval = [] + deployment_id = kwargs.get('deployment_id') + sort_field = kwargs.get('_sort') + if deployment_id or sort_field: + rval = [ + MonkeyCloudifyNode( + runtime_properties={ + "container_id": "container_1", + "dti_reconfig_script": "dti_reconfig_script_1", + "docker_config": { + "reconfigs": { + "dti": "dti_reconfig_script_1", + "app": "app_reconfig_script_1", + "special": "special_reconfig_script_1" + } + }, + "service_component_name": "SCN_1", + "selected_container_destination": "zldcdyh1adcc1-component-dockerhost-1", + "service_component_type": "SCType_1" + }, + deployment_id = 'deployment_id_1', + node_id = 'node_id_1', + id = 'id_1', + state = 'state_1' + ), + MonkeyCloudifyNode( + runtime_properties={ + "container_id": "container_2", + "dti_reconfig_script": "dti_reconfig_script_2", + "docker_config": { + "reconfigs": { + "dti": "dti_reconfig_script_2", + "app": "app_reconfig_script_2", + "special": "special_reconfig_script_2" + } + }, + "service_component_name": "SCN_2", + "selected_container_destination": "zldcdyh1adcc1-component-dockerhost-1", + "service_component_type": "SCType_2" + }, + deployment_id = 'deployment_id_2', + node_id = 'node_id_2', + id = 'id_2', + state = 'state_2' + ) + ] + + return rval + +class MonkeyEventDbAccess(object): + """monkdypatch for otihandler.dbclient.apis.EventDbAccess()""" + + def __init__(self, **kwargs): + """init locals""" + Settings.logger.info("MonkeyEventDbAccess called with kwargs={}".format(json.dumps(kwargs))) + + def saveDomainObject(self, obj): + return None + + def deleteDomainObject(self, obj): + return None + + def query_event_item(self, target_type, target_name): + Settings.logger.info("MonkeyEventDbAccess.query_event_item({}, {})".format(target_type, target_name)) + return None + + def query_event_data(self, target_type, target_name): + Settings.logger.info("MonkeyEventDbAccess.query_event_data({}, {})".format(target_type, target_name)) + return [] + + def query_event_data_k8s(self, target_type, target_name): + Settings.logger.info("MonkeyEventDbAccess.query_event_data_k8s({}, {})".format(target_type, target_name)) + return [] + + def query_event_info_docker(self, curr_evt, component_scn, deployment_id, container_id): + Settings.logger.info("MonkeyEventDbAccess.query_event_info_docker({}, {}, {}, {})".format(curr_evt, component_scn, deployment_id, container_id)) + return None + + def update_event_item(self, event, target_type, target_name): + Settings.logger.info("MonkeyEventDbAccess.update_event_item({}, {}, {})".format(event, target_type, target_name)) + return None + + def query_raw_k8_events(self, cluster, pod, namespace): + Settings.logger.info("MonkeyEventDbAccess.query_raw_k8_events({}, {}, {})".format(cluster, pod, namespace)) + return [] + + def query_raw_docker_events(self, target_types, locations): + Settings.logger.info("MonkeyEventDbAccess.query_raw_docker_events({}, {})".format(target_types, locations)) + return [] + + def query_event_data_k8s_pod(self, curr_evt, component_scn): + Settings.logger.info("MonkeyEventDbAccess.query_event_k8s_pod({}, {})".format(curr_evt, component_scn)) + return None + +class MonkeyDockerClient(object): + """monkeypatch for docker.APIClient()""" + + def __init__(self, **kwargs): + """init locals""" + + Settings.logger.info("MonkeyDockerClient called with kwargs={}".format(json.dumps(kwargs))) + self._base_url = kwargs.get('base_url') + self._timeout = kwargs.get('timeout') + + def exec_create(self, **kwargs): + """monkey exec_create""" + + return {"Id": "fake_container_ID"} + + def exec_start(self, **kwargs): + """monkey exec_create""" + + return "component reconfigured successfully" + + def login(self, **kwargs): + """monkey login""" + + pass + +@pytest.fixture() +def fix_external_interfaces(monkeypatch): + """monkey consul_client request.get""" + + Settings.logger.info("setup fix_external_interfaces") + monkeypatch.setattr('otihandler.consul_client.requests.get', monkey_consul_client_get) + monkeypatch.setattr('otihandler.consul_client.requests.put', monkey_consul_client_put) + + monkeypatch.setattr('otihandler.cfy_client.CloudifyClient', MonkeyCloudifyClient) + + monkeypatch.setattr('otihandler.docker_client.docker.APIClient', MonkeyDockerClient) + + monkeypatch.setattr('otihandler.dti_processor.EventDbAccess', MonkeyEventDbAccess) + + yield fix_external_interfaces # provide the fixture value + Settings.logger.info("teardown fix_external_interfaces") + + +def monkey_cherrypy_engine_exit(): + """monkeypatch for cherrypy exit""" + + Settings.logger.info("monkey_cherrypy_engine_exit()") + +@pytest.fixture() +def fix_cherrypy_engine_exit(monkeypatch): + """monkey cherrypy.engine.exit()""" + + Settings.logger.info("setup fix_cherrypy_engine_exit") + monkeypatch.setattr('otihandler.web_server.cherrypy.engine.exit', + monkey_cherrypy_engine_exit) + yield fix_cherrypy_engine_exit # provide the fixture value + Settings.logger.info("teardown fix_cherrypy_engine_exit") + + +#----- Tests ---------------------------------------------------------------------------- + +def test_healthcheck(): + """test /healthcheck""" + + Settings.logger.info("=====> test_healthcheck") + audit = Audit(req_message="get /healthcheck") + audit.metrics_start("test /healthcheck") + time.sleep(0.1) + + audit.metrics("test /healthcheck") + health = Audit.health() or {} + audit.audit_done(result=json.dumps(health)) + + Settings.logger.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + +def test_healthcheck_with_error(): + """test /healthcheck""" + + Settings.logger.info("=====> test_healthcheck_with_error") + audit = Audit(req_message="get /healthcheck") + audit.metrics_start("test /healthcheck") + time.sleep(0.2) + audit.error("error from test_healthcheck_with_error") + audit.fatal("fatal from test_healthcheck_with_error") + audit.debug("debug from test_healthcheck_with_error") + audit.warn("warn from test_healthcheck_with_error") + audit.info_requested("info_requested from test_healthcheck_with_error") + if audit.is_success(): + audit.set_http_status_code(AuditHttpCode.DATA_NOT_FOUND_ERROR.value) + audit.set_http_status_code(AuditHttpCode.SERVER_INTERNAL_ERROR.value) + audit.metrics("test /healthcheck") + + health = Audit.health() or {} + audit.audit_done(result=json.dumps(health)) + + Settings.logger.info("healthcheck: %s", json.dumps(health)) + assert bool(health) + +def test_consul_client_lookup_service_bogus(): + """test consul_client.lookup_service with bogus service_name""" + + Settings.logger.info("=====> test_consul_client_lookup_service_bogus") + with pytest.raises(ConsulClientConnectionError, match=r'lookup_service(.*) requests.get(.*)'): + ConsulClient.lookup_service("bogus") + +def test_consul_client_get_service_fqdn_port_none(): + """test consul_client.get_service_fqdn_port with no service_name""" + + Settings.logger.info("=====> test_consul_client_get_service_fqdn_port_none") + with pytest.raises(ConsulClientConnectionError): + rv = ConsulClient.get_service_fqdn_port(None) + assert (rv == None) + +def test_consul_client_store_kvs_none(): + """test consul_client.store_kvs with no key""" + + Settings.logger.info("=====> test_consul_client_store_kvs_none") + rv = ConsulClient.store_kvs(None) + assert (rv == None) + +def test_consul_client_delete_key_none(): + """test consul_client.delete_key with no key""" + + Settings.logger.info("=====> test_consul_client_delete_key_none") + rv = ConsulClient.delete_key(None) + assert (rv == None) + +def test_consul_client_delete_kvs_none(): + """test consul_client.delete_kvs with no key""" + + Settings.logger.info("=====> test_consul_client_delete_kvs_none") + rv = ConsulClient.delete_kvs(None) + assert (rv == None) + +def test_consul_client_delete_kvs_bogus(): + """test consul_client.delete_kvs with bogus key""" + + Settings.logger.info("=====> test_consul_client_delete_kvs_bogus") + rv = ConsulClient.delete_kvs("bogus") + assert (rv == None) + +def test_consul_client_get_value_none(): + """test consul_client.get_value with no key""" + + Settings.logger.info("=====> test_consul_client_get_value_none") + with pytest.raises(ConsulClientConnectionError, match=r'get_value(.*) requests.get(.*)'): + ConsulClient.get_value(None) + +def test_consul_client_get_kvs_none(): + """test consul_client.get_kvs with no prefix""" + + Settings.logger.info("=====> test_consul_client_get_kvs_none") + with pytest.raises(ConsulClientConnectionError, match=r'get_kvs(.*) requests.get(.*)'): + ConsulClient.get_kvs(None) + +def test_consul_client_run_transaction_invalid(): + """test consul_client._run_transaction with invalid operation""" + + Settings.logger.info("=====> test_consul_client_run_transaction_invalid") + rv = ConsulClient._run_transaction("invalid", {"bogus": "bad"}) + assert (rv == None) + +class TestsBase(helper.CPWebCase): + + helper.CPWebCase.interactive = False + +@pytest.mark.usefixtures("fix_external_interfaces") +class WebServerTest(TestsBase): + """testing the web-server - runs tests in alphabetical order of method names""" + + def setup_server(): + """setup the web-server""" + + cherrypy.tree.mount(_DTIWeb(), '/') + + setup_server = staticmethod(setup_server) + + def test_web_healthcheck(self): + """test /healthcheck""" + + Settings.logger.info("=====> test_web_healthcheck") + result = self.getPage("/healthcheck") + Settings.logger.info("got healthcheck: %s", self.body) + self.assertStatus('200 OK') + + def test_web_events_get(self): + """test GET /events -- wrong method""" + + Settings.logger.info("=====> test_web_events_get") + result = self.getPage("/events") + self.assertStatus(404) + + def test_web_events_missing_dcae_service_action(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_missing_dcae_service_action") + body = json.dumps({}) + expected_result = {"ERROR": "dcae_service_action is missing"} + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('400 Bad Request') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_invalid_dcae_service_action(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_invalid_dcae_service_action") + body = json.dumps({"dcae_service_action": "bogus"}) + expected_result = {"ERROR": "dcae_service_action is invalid"} + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('400 Bad Request') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_missing_dcae_target_name(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_missing_dcae_target_name") + body = json.dumps({"dcae_service_action": "deploy"}) + expected_result = {"ERROR": "dcae_target_name is missing"} + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('400 Bad Request') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_missing_dcae_target_type(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_missing_dcae_target_type") + body = json.dumps({"dcae_service_action": "deploy", + "dcae_target_name": "another01ems003" + }) + expected_result = {"ERROR": "dcae_target_type is missing"} + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('400 Bad Request') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_deploy(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_deploy") + body = json.dumps({"dcae_service_action": "deploy", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully" + } + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_undeploy(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_undeploy") + body = json.dumps({"dcae_service_action": "undeploy", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_add(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_add") + body = json.dumps({"dcae_service_action": "add", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully" + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_delete(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_delete") + body = json.dumps({"dcae_service_action": "delete", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully" + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_update(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_update") + body = json.dumps({"dcae_service_action": "update", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully", + "WARNING": "processing update event for anot-her/another01ems003, but current event info is not found in database, executing add event" + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_notify(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_notify") + body = json.dumps({"dcae_service_action": "notify", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_location(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_location") + body = json.dumps({"dcae_service_action": "deploy", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her", + "dcae_service_location": "LSLEILAA" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully" + } + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_undeploy_bad(self): + """test POST /events < <dti_event> -- bad dcae_target_name""" + + Settings.logger.info("=====> test_web_events_undeploy_bad") + body = json.dumps({"dcae_service_action": "undeploy", + "dcae_target_name": "bogus", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully", + "WARNING": "VNF instance bogus was not in Consul oti_events historical folder" + } + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_events_undeploy(self): + """test POST /events < <dti_event>""" + + Settings.logger.info("=====> test_web_events_undeploy") + body = json.dumps({"dcae_service_action": "undeploy", + "dcae_target_name": "another01ems003", + "dcae_target_type": "ANOT-her" + }) + expected_result = { + "SCN_1": "ran dti_reconfig_script_1 in docker container container_1 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_1 node node_id_1, got: component reconfigured successfully", + "SCN_2": "ran dti_reconfig_script_2 in docker container container_2 on zldcdyh1adcc1-component-dockerhost-1 that was deployed by deployment_id_2 node node_id_2, got: component reconfigured successfully" + } + expected_result = { + } + result = self.getPage("/events", method='POST', body=body, + headers=[ + ("Content-Type", "application/json"), + ('Content-Length', str(len(body))) + ]) + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_mockevents(self): + """test GET /mockevents""" + + Settings.logger.info("=====> test_web_mockevents") + expected_result = {"KubeNamespace":"com-my-dcae-test", "KubePod":"pod-0", "KubeServiceName":"pod-0.service.local", "KubeServicePort":"8880", "KubeClusterFqdn":"fqdn-1"} + result = self.getPage("/mockevents") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events_put(self): + """test PUT /dti_docker_events?service=SCN_1""" + + Settings.logger.info("=====> test_web_dti_docker_events_put") + result = self.getPage("/dti_docker_events?service=SCN_1", method='PUT') + self.assertStatus(404) + + def test_web_dti_docker_events_bad_service(self): + """test GET /dti_docker_events?service=bogus""" + + Settings.logger.info("=====> test_web_dti_docker_events_bad_service") + expected_result = {} + result = self.getPage("/dti_docker_events?service=bogus") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events(self): + """test GET /dti_docker_events?service=SCN_1""" + + Settings.logger.info("=====> test_web_dti_docker_events") + expected_result = {} + result = self.getPage("/dti_docker_events?service=SCN_1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events_bad_location(self): + """test GET /dti_docker_events?service=SCN_1&location=bogus""" + + Settings.logger.info("=====> test_web_dti_docker_events_bad_location") + expected_result = {} + result = self.getPage("/dti_docker_events?service=SCN_1&location=bogus") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events_location(self): + """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA""" + + Settings.logger.info("=====> test_web_dti_docker_events_location") + expected_result = {} + result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events_locations(self): + """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1""" + + Settings.logger.info("=====> test_web_dti_docker_events_locations") + expected_result = {} + result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_docker_events_bad_locations(self): + """test GET /dti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1""" + + Settings.logger.info("=====> test_web_dti_docker_events_bad_locations") + expected_result = {} + result = self.getPage("/dti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events_put(self): + """test PUT /oti_docker_events?service=SCN_1""" + + Settings.logger.info("=====> test_web_oti_docker_events_put") + result = self.getPage("/oti_docker_events?service=SCN_1", method='PUT') + self.assertStatus(404) + + def test_web_oti_docker_events_bad_service(self): + """test GET /oti_docker_events?service=bogus""" + + Settings.logger.info("=====> test_web_oti_docker_events_bad_service") + expected_result = {} + result = self.getPage("/oti_docker_events?service=bogus") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events(self): + """test GET /oti_docker_events?service=SCN_1""" + + Settings.logger.info("=====> test_web_oti_docker_events") + expected_result = {} + result = self.getPage("/oti_docker_events?service=SCN_1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events_bad_location(self): + """test GET /oti_docker_events?service=SCN_1&location=bogus""" + + Settings.logger.info("=====> test_web_oti_docker_events_bad_location") + expected_result = {} + result = self.getPage("/oti_docker_events?service=SCN_1&location=bogus") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events_location(self): + """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA""" + + Settings.logger.info("=====> test_web_oti_docker_events_location") + expected_result = {} + result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events_locations(self): + """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1""" + + Settings.logger.info("=====> test_web_oti_docker_events_locations") + expected_result = {} + result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA,MDTWNJC1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_oti_docker_events_bad_locations(self): + """test GET /oti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1""" + + Settings.logger.info("=====> test_web_oti_docker_events_bad_locations") + expected_result = {} + result = self.getPage("/oti_docker_events?service=SCN_1&location=LSLEILAA,bogus,MDTWNJC1") + self.assertStatus('200 OK') + Settings.logger.info("got result: %s", self.body) + assert ( json.loads(self.body) == expected_result ) + + def test_web_reconfig_put(self): + """test PUT /reconfig -- wrong method""" + + Settings.logger.info("=====> test_web_reconfig_put") + result = self.getPage("/reconfig/deployment_id_1", method='PUT') + self.assertStatus(404) + + def test_web_dti_put(self): + """test PUT /dti -- wrong method""" + + Settings.logger.info("=====> test_web_dti_put") + result = self.getPage("/dti", method='PUT') + self.assertStatus(404) + + def test_web_dti(self): + """test GET /dti""" + + Settings.logger.info("=====> test_web_dti") + result = self.getPage("/dti") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "anot-her": { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_bogus(self): + """test GET /dti/<service_name> -- bogus SCN""" + + Settings.logger.info("=====> test_web_dti_SCN_bogus") + result = self.getPage("/dti/SCN_bogus") + self.assertStatus(404) + + def test_web_dti_SCN(self): + """test GET /dti/<service_name>""" + + Settings.logger.info("=====> test_web_dti_SCN") + result = self.getPage("/dti/SCN_1") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "anot-her": { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_type(self): + """test GET /dti/<service_name>?vnf_type=<vnf_type>""" + + Settings.logger.info("=====> test_web_dti_SCN_type") + result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_types(self): + """test GET /dti?vnf_type=<vnf_types>""" + + Settings.logger.info("=====> test_web_dti_types") + result = self.getPage("/dti?vnf_type=ANOT-her,new-type") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "anot-her": { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_type_miss(self): + """test GET /dti/<service_name>?vnf_type=<vnf_type>""" + + Settings.logger.info("=====> test_web_dti_SCN_type_miss") + result = self.getPage("/dti/SCN_1?vnf_type=NO-match") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {} + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_type_vnf_id(self): + """test GET /dti/<service_name>?vnf_type=<vnf_type>;vnf_id=<vnf_id>""" + + Settings.logger.info("=====> test_web_dti_SCN_type_vnf_id") + result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her;vnf_id=another01ems003") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_type_vnf_id_location(self): + """test GET /dti/<service_name>?vnf_type=<vnf_type>;vnf_id=<vnf_id>;service_location=<service_location>""" + + Settings.logger.info("=====> test_web_dti_SCN_type_vnf_id_location") + result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her;vnf_id=another01ems003;service_location=LSLEILAA") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_SCN_types_location(self): + """test GET /dti/<service_name>?vnf_type=<vnf_types>;service_location=<service_location>""" + + Settings.logger.info("=====> test_web_dti_SCN_types_location") + result = self.getPage("/dti/SCN_1?vnf_type=ANOT-her,new-type;service_location=MDTWNJC1") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "anot-her": { + "another01ems044": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems044", "dcae_service_location": "MDTWNJC1", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems044", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_location(self): + """test GET /dti?service_location=<service_location>""" + + Settings.logger.info("=====> test_web_dti_location") + result = self.getPage("/dti?service_location=LSLEILAA") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "anot-her": { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_dti_type_location(self): + """test GET /dti?vnf_type=<vnf_type>;service_location=<service_location>""" + + Settings.logger.info("=====> test_web_dti_type_location") + result = self.getPage("/dti?vnf_type=ANOT-her;service_location=LSLEILAA") + Settings.logger.info("got dti: %s", self.body) + self.assertStatus('200 OK') + + expected_result = { + "another01ems003": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems003", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.3", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "remoteServerName": "another01ems003", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}}, + "another01ems042": {"dcae_service_action": "deploy", "dcae_service-instance_model-version-id": "1", "dcae_target_name": "another01ems042", "dcae_service_location": "LSLEILAA", "dcae_target_type": "ANOT-her", "dcae_target_collection": "true", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_in-maint": "false", "dcae_snmp_community_string": "my_first_community", "dcae_generic-vnf_model-version-id": "1", "dcae_target_collection_ip": "107.239.85.42", "dcae_snmp_version": "2c", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"nodeType": "VHSS", "description": "VHSS Data Collection", "protocol": "sftp", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "priority": 1, "nodeSubtype": "", "collectionInterval": "300", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "remoteServerName": "another01ems042", "isPrimary": "true"}], "serverGroupId": "g1"}}}}}, "dcae_target_prov-status": "PROV", "event": {}} + } + assert ( json.loads(self.body) == expected_result ) + + def test_web_service_component_put(self): + """test PUT /service_component -- wrong method""" + + Settings.logger.info("=====> test_web_service_component_put") + result = self.getPage("/service_component/SCN_1", method='PUT') + self.assertStatus(404) + + def test_web_service_component_bogus(self): + """test GET /service_component/<service_name> -- bogus SCN""" + + Settings.logger.info("=====> test_web_service_component_bogus") + result = self.getPage("/service_component/SCN_bogus") + self.assertStatus(404) + + def test_web_service_component(self): + """test GET /service_component/<service_name>""" + + Settings.logger.info("=====> test_web_service_component") + result = self.getPage("/service_component/SCN_1") + Settings.logger.info("got service_component: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"dcae_target_type": ["pnga-xxx"]} + assert ( json.loads(self.body) == expected_result ) + + def test_web_service_component_all_put(self): + """test PUT /service_component_all -- wrong method""" + + Settings.logger.info("=====> test_web_service_component_all_put") + result = self.getPage("/service_component_all/SCN_1", method='PUT') + self.assertStatus(404) + + def test_web_service_component_all_bogus(self): + """test GET /service_component_all/<service_name> -- bogus SCN""" + + Settings.logger.info("=====> test_web_service_component_all_bogus") + result = self.getPage("/service_component_all/SCN_bogus") + self.assertStatus(404) + + def test_web_service_component_all(self): + """test GET /service_component_all/<service_name>""" + + Settings.logger.info("=====> test_web_service_component_all") + result = self.getPage("/service_component_all/SCN_1") + Settings.logger.info("got service_component_all: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"oti": {"anot-her": {"another01ems003": {"dcae_target_name": "another01ems003", "dcae_target_collection_ip": "107.239.85.3", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "LSLEILAA", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems003_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.3", "isPrimary": "true", "remoteServerName": "another01ems003"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}, "another01ems042": {"dcae_target_name": "another01ems042", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "LSLEILAA", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems042_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems042"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}, "another01ems044": {"dcae_target_name": "another01ems044", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "MDTWNJC1", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems044"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}}}, "policies": {"event": {"update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "policies_count": 3}, "items": {"DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel", "conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "5", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_Green_Collectors": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "polling_frequency": "30m", "package_type": "plastic"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Collectors", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_In_Service": {"property": null, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "In_Service", "ECOMPName": "dcae"}}}}, "config": {"dcae_target_type": ["pnga-xxx"]}} + assert ( json.loads(self.body) == expected_result ) + + def test_web_service_component_all_location(self): + """test GET /service_component_all/<service_name>?service_location=<service_location>""" + + Settings.logger.info("=====> test_web_service_component_all_location") + result = self.getPage("/service_component_all/SCN_1?service_location=MDTWNJC1") + Settings.logger.info("got service_component_all: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"oti": {"anot-her": {"another01ems044": {"dcae_target_name": "another01ems044", "dcae_target_collection_ip": "107.239.85.42", "event": {}, "dcae_service-instance_model-version-id": "1", "dcae_service_location": "MDTWNJC1", "dcae_target_in-maint": "false", "dcae_service_action": "deploy", "dcae_target_is-closed-loop-disabled": "false", "dcae_target_collection": "true", "aai_additional_info": {"TasksItems": {"another01ems044_2PMOBATTHSSEMS0165": {"collectionInterval": "300", "serviceType": "MOB-VHSS", "vnfType": "VHSS", "taskId": "2PMOBATTHSSEMS0165", "remoteServerGroups": {"g1": {"serverGroup": [{"remoteServerIp": "107.239.85.42", "isPrimary": "true", "remoteServerName": "another01ems044"}], "serverGroupId": "g1"}}, "nodeType": "VHSS", "protocol": "sftp", "nodeSubtype": "", "priority": 1, "description": "VHSS Data Collection"}}}, "dcae_generic-vnf_model-version-id": "1", "dcae_target_prov-status": "PROV", "dcae_target_type": "ANOT-her", "dcae_snmp_community_string": "my_first_community", "dcae_snmp_version": "2c"}}}, "policies": {"event": {"update_id": "e6102aab-3079-435a-ae0d-0397a2cb3c4d", "action": "updated", "timestamp": "2018-07-16T15:11:44.845Z", "policies_count": 3}, "items": {"DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"preparation": "scrambled", "egg_color": "green", "bread": "pumpernickel", "conflicting_key": "green_eggs_and_ham_are_better", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "bacon": "soft, not crispy"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "5", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_Green_Collectors": {"property": null, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"power_source": "lemmings", "conflicting_key": "green_collectors_wins", "polling_frequency": "30m", "package_type": "plastic"}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "Green_Collectors", "ECOMPName": "dcae"}}, "DCAE_FTL3B.Config_In_Service": {"property": null, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml", "policyConfigStatus": "CONFIG_RETRIEVED", "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "responseAttributes": {}, "type": "JSON", "policyVersion": "1", "policyConfigMessage": "Config Retrieved! ", "matchingConditions": {"ONAPName": "dcae", "ConfigName": "In_Service", "ECOMPName": "dcae"}}}}, "config": {"dcae_target_type": ["pnga-xxx"]}} + assert ( json.loads(self.body) == expected_result ) + + def test_web_policies_put(self): + """test PUT /policies/<service_name> -- wrong method""" + + Settings.logger.info("=====> test_web_policies_put") + result = self.getPage("/policies/SCN_1", method='PUT') + self.assertStatus(404) + + def test_web_policies_bogus(self): + """test GET /policies/<service_name> -- bogus SCN""" + + Settings.logger.info("=====> test_web_policies_bogus") + result = self.getPage("/policies/SCN_bogus") + self.assertStatus(404) + + def test_web_policies(self): + """test GET /policies/<service_name>""" + + Settings.logger.info("=====> test_web_policies") + result = self.getPage("/policies/SCN_1") + Settings.logger.info("got policies: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"DCAE_FTL3B.Config_In_Service": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "1", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "In_Service"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"conflicting_key": "in_service_trumps!", "in_service": true}, "policyName": "DCAE_FTL3B.Config_In_Service.1.xml"}, "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "5", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"preparation": "scrambled", "bread": "pumpernickel", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "conflicting_key": "green_eggs_and_ham_are_better", "egg_color": "green", "bacon": "soft, not crispy"}, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml"}, "DCAE_FTL3B.Config_Green_Collectors": {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "1", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Collectors"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"conflicting_key": "green_collectors_wins", "package_type": "plastic", "power_source": "lemmings", "polling_frequency": "30m"}, "policyName": "DCAE_FTL3B.Config_Green_Collectors.1.xml"}} + assert ( json.loads(self.body) == expected_result ) + + def test_web_policies_policy(self): + """test GET /policies/<service_name>?policy_id=<policy_id>""" + + Settings.logger.info("=====> test_web_policies_policy") + result = self.getPage("/policies/SCN_1?policy_id=DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific") + Settings.logger.info("got policies: %s", self.body) + self.assertStatus('200 OK') + + expected_result = {"type": "JSON", "policyConfigMessage": "Config Retrieved! ", "responseAttributes": {}, "policyVersion": "5", "matchingConditions": {"ONAPName": "dcae", "ECOMPName": "dcae", "ConfigName": "Green_Eggs_and_Ham_specific"}, "policyConfigStatus": "CONFIG_RETRIEVED", "property": null, "config": {"preparation": "scrambled", "bread": "pumpernickel", "dcae_target_type": ["pnga-xxx", "pcrf-oam", "vhss-ems", "anot-her", "new-type"], "conflicting_key": "green_eggs_and_ham_are_better", "egg_color": "green", "bacon": "soft, not crispy"}, "policyName": "DCAE_FTL3B.Config_Green_Eggs_and_Ham_specific.5.xml"} + assert ( json.loads(self.body) == expected_result ) + + @pytest.mark.usefixtures("fix_cherrypy_engine_exit") + def test_zzz_web_shutdown(self): + """test /shutdown""" + + Settings.logger.info("=====> test_zzz_web_shutdown") + Settings.logger.info("sleep before shutdown...") + time.sleep(1) + + result = self.getPage("/shutdown") + Settings.logger.info("shutdown result: %s", result) + self.assertStatus('200 OK') + Settings.logger.info("got shutdown: %s", self.body) + self.assertInBody('goodbye! shutdown requested ') + time.sleep(1) diff --git a/oti/event-handler/tox-local.ini b/oti/event-handler/tox-local.ini new file mode 100644 index 0000000..fdfa4fc --- /dev/null +++ b/oti/event-handler/tox-local.ini @@ -0,0 +1,16 @@ +# tox -c tox-local.ini +[tox] +envlist = py36 +skip_missing_interpreters = true + +[testenv] +deps= + -rrequirements.txt + pytest + coverage + pytest-cov +setenv = + PYTHONPATH={toxinidir} +recreate = True +commands= + pytest --cov otihandler --cov-report=html --cov-report=term --verbose tests diff --git a/oti/event-handler/tox.ini b/oti/event-handler/tox.ini index 2532eb9..b801f95 100644 --- a/oti/event-handler/tox.ini +++ b/oti/event-handler/tox.ini @@ -1,4 +1,16 @@ +# tox [tox] envlist = py36 +skip_missing_interpreters = true [testenv] +deps= + -rrequirements.txt + pytest + coverage + pytest-cov +setenv = + PYTHONPATH={toxinidir} +recreate = True +commands= + pytest --cov otihandler --cov-report=xml --cov-report=term --verbose tests diff --git a/releases/1.0.0-acumos-adapter-container.yaml b/releases/1.0.0-acumos-adapter-container.yaml new file mode 100644 index 0000000..76f6b1b --- /dev/null +++ b/releases/1.0.0-acumos-adapter-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-adapter-acumos-docker-merge-master/3' +ref: 4da2d08fc132367b38c3ec555f931a175cfcbfcd +containers: + - name: 'org.onap.dcaegen2.platform.adapter.acumos' + version: '1.0.0-SNAPSHOT-20200303T215210Z'
\ No newline at end of file diff --git a/releases/1.0.0-designtool-container.yaml b/releases/1.0.0-designtool-container.yaml new file mode 100644 index 0000000..28974dd --- /dev/null +++ b/releases/1.0.0-designtool-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-designtool-merge-java/2' +ref: 747ca040f85851b33a2be7abb58426dd25008d2e +containers: + - name: 'org.onap.dcaegen2.platform.mod.designtool-web' + version: '1.0.0-SNAPSHOT-20200217T165545Z' diff --git a/releases/1.0.0-distributorapi-container.yaml b/releases/1.0.0-distributorapi-container.yaml new file mode 100644 index 0000000..76870c4 --- /dev/null +++ b/releases/1.0.0-distributorapi-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-distributorapi-docker-merge-master/4' +ref: 34b776928e1a0fa029d2de13a020873bff8a601f +containers: + - name: 'org.onap.dcaegen2.platform.mod.distributorapi' + version: '1.0.0-SNAPSHOT-20200226T234626Z'
\ No newline at end of file diff --git a/releases/1.0.0-genprocessor-container.yaml b/releases/1.0.0-genprocessor-container.yaml new file mode 100644 index 0000000..f2bbcdf --- /dev/null +++ b/releases/1.0.0-genprocessor-container.yaml @@ -0,0 +1,10 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-genprocessor-merge-java/8' +ref: 534f8a3b979ae78a21ec3b7b8ffdb1cd3e425f1a +containers: + - name: 'org.onap.dcaegen2.platform.mod.genprocessor-job' + version: '1.0.0-20200217T215940Z' + - name: 'org.onap.dcaegen2.platform.mod.genprocessor-http' + version: '1.0.0-20200217T215940Z'
\ No newline at end of file diff --git a/releases/1.0.0-mod-nifi-registry-container.yaml b/releases/1.0.0-mod-nifi-registry-container.yaml new file mode 100644 index 0000000..f7a1bfc --- /dev/null +++ b/releases/1.0.0-mod-nifi-registry-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-designtool-merge-java/2' +ref: 747ca040f85851b33a2be7abb58426dd25008d2e +containers: + - name: 'org.onap.dcaegen2.platform.mod.mod-registry' + version: '1.0.0-SNAPSHOT-20200217T165545Z'
\ No newline at end of file diff --git a/releases/1.0.0-runtimeapi-container.yaml b/releases/1.0.0-runtimeapi-container.yaml new file mode 100644 index 0000000..a96424a --- /dev/null +++ b/releases/1.0.0-runtimeapi-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/9' +ref: 7666d2a36849f88e917d87abec2e177dac500191 +containers: + - name: 'org.onap.dcaegen2.platform.mod.runtime-web' + version: '1.0.0-20200228T221655Z'
\ No newline at end of file diff --git a/releases/1.0.1-runtimeapi-container.yaml b/releases/1.0.1-runtimeapi-container.yaml new file mode 100644 index 0000000..b2ade95 --- /dev/null +++ b/releases/1.0.1-runtimeapi-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '1.0.1' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-master-runtimeapi-merge-java/12' +ref: fbd213549e76250132ff6c0b1361c998fda0b4ea +containers: + - name: 'org.onap.dcaegen2.platform.mod.runtime-web' + version: '1.0.1-20200317T180212Z'
\ No newline at end of file diff --git a/releases/1.3.0-blueprint-generator.yaml b/releases/1.3.0-blueprint-generator.yaml new file mode 100644 index 0000000..eb2c900 --- /dev/null +++ b/releases/1.3.0-blueprint-generator.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '1.3.0' +project: 'dcaegen2/platform' +log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/1' diff --git a/releases/1.3.1-blueprint-generator.yaml b/releases/1.3.1-blueprint-generator.yaml new file mode 100644 index 0000000..9359463 --- /dev/null +++ b/releases/1.3.1-blueprint-generator.yaml @@ -0,0 +1,4 @@ +distribution_type: 'maven' +version: '1.3.1' +project: 'dcaegen2/platform' +log_dir: 'dcaegen2-platform-mod-bpgenerator-maven-stage-master/18' diff --git a/releases/2.12.0-onboardingapi-container.yaml b/releases/2.12.0-onboardingapi-container.yaml new file mode 100644 index 0000000..35db855 --- /dev/null +++ b/releases/2.12.0-onboardingapi-container.yaml @@ -0,0 +1,8 @@ +distribution_type: 'container' +container_release_tag: '2.12.0' +project: 'dcaegen2-platform' +log_dir: 'dcaegen2-platform-mod-onboardingapi-docker-merge-master/4' +ref: 56c650139f899f1a6d271ed80780a9b576d7ff22 +containers: + - name: 'org.onap.dcaegen2.platform.mod.onboardingapi' + version: '2.12.0-SNAPSHOT-20200228T144346Z'
\ No newline at end of file |