From 5d03e8b55ff7780079085184f6d30a4d0a26a4a7 Mon Sep 17 00:00:00 2001 From: sebdet Date: Mon, 3 Feb 2020 20:27:59 +0100 Subject: [PATCH] Get policy in CsarInstaller Get the policies on the PEF engine when installing the CSAR (if needed) Issue-ID: CLAMP-518 Change-Id: I2cca157821c22ef63dc748984140287667cc4663 Signed-off-by: sebdet --- extra/docker/clamp/clamp.env | 2 +- extra/docker/heat/clamp.env | 2 +- extra/sql/bulkload/create-tables.sql | 2 +- extra/sql/dump/test-data.sql | 22 +- .../clamp/clds/client/PolicyEngineServices.java | 110 ++ .../onap/clamp/clds/config/ClampProperties.java | 65 +- .../clamp/clds/config/PolicyConfiguration.java | 133 --- .../config/spring/SdcControllerConfiguration.java | 4 +- .../sdc/controller/BlueprintParserException.java | 54 + .../clamp/clds/model/dcae/DcaeInventoryCache.java | 2 +- .../clds/sdc/controller/SdcSingleController.java | 5 + ...icroService.java => BlueprintMicroService.java} | 44 +- .../sdc/controller/installer/BlueprintParser.java | 161 +-- .../sdc/controller/installer/ChainGenerator.java | 24 +- .../clamp/clds/util/drawing/ClampGraphBuilder.java | 8 +- .../org/onap/clamp/clds/util/drawing/Painter.java | 10 +- .../onap/clamp/clds/util/drawing/SvgFacade.java | 4 +- .../java/org/onap/clamp/loop/CsarInstaller.java | 69 +- .../onap/clamp/loop/template/LoopElementModel.java | 2 +- .../org/onap/clamp/loop/template/PolicyModel.java | 10 +- .../clamp/policy/downloader/PolicyDownloader.java | 61 ++ src/main/resources/application-noaaf.properties | 22 +- src/main/resources/application.properties | 30 +- .../resources/clds/camel/routes/policy-flows.xml | 1075 +++++++++++--------- .../clamp/clds/it/PolicyConfigurationItCase.java | 71 -- .../it/config/CldsReferencePropertiesItCase.java | 33 +- .../config/SdcControllersConfigurationItCase.java | 2 +- .../controller/installer/BlueprintParserTest.java | 94 +- .../controller/installer/ChainGeneratorTest.java | 39 +- .../org/onap/clamp/clds/util/CryptoUtilsTest.java | 2 +- .../clds/util/drawing/ClampGraphBuilderTest.java | 16 +- .../org/onap/clamp/loop/CsarInstallerItCase.java | 22 +- .../onap/clamp/loop/PolicyModelServiceItCase.java | 17 +- src/test/resources/application.properties | 29 +- ...OperationalPolicyRepresentationBuilderTest.java | 52 - .../resources/clds/blueprint-parser-mapping.json | 18 - .../clds/blueprint-with-microservice-chain.yaml | 238 +++-- .../resources/clds/camel/rest/clamp-api-v2.xml | 42 + .../resources/clds/camel/routes/policy-flows.xml | 1075 +++++++++++--------- src/test/resources/clds/holmes-old-style-ms.yaml | 117 --- ...l => single-microservice-fragment-invalid.yaml} | 0 ...e-microservice-fragment-valid-with-version.yaml | 21 + src/test/resources/clds/tca-old-style-ms.yaml | 169 --- .../example/sdc/blueprint-dcae/holmes.yaml | 174 ---- .../example/sdc/blueprint-dcae/not-recognized.yaml | 130 --- .../sdc/blueprint-dcae/prop-text-for-tca-2.json | 48 - .../sdc/blueprint-dcae/prop-text-for-tca-3.json | 48 - .../sdc/blueprint-dcae/prop-text-for-tca.json | 36 - src/test/resources/logback.xml | 91 +- src/test/resources/tosca/dcea_blueprint.yml | 170 ---- 50 files changed, 2026 insertions(+), 2649 deletions(-) create mode 100644 src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java delete mode 100644 src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java create mode 100644 src/main/java/org/onap/clamp/clds/exception/sdc/controller/BlueprintParserException.java rename src/main/java/org/onap/clamp/clds/sdc/controller/installer/{MicroService.java => BlueprintMicroService.java} (67%) create mode 100644 src/main/java/org/onap/clamp/policy/downloader/PolicyDownloader.java delete mode 100644 src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java delete mode 100644 src/test/resources/clds/OperationalPolicyRepresentationBuilderTest.java delete mode 100644 src/test/resources/clds/blueprint-parser-mapping.json delete mode 100644 src/test/resources/clds/holmes-old-style-ms.yaml rename src/test/resources/clds/{single-microservice-fragment-valid.yaml => single-microservice-fragment-invalid.yaml} (100%) create mode 100644 src/test/resources/clds/single-microservice-fragment-valid-with-version.yaml delete mode 100644 src/test/resources/clds/tca-old-style-ms.yaml delete mode 100644 src/test/resources/example/sdc/blueprint-dcae/holmes.yaml delete mode 100644 src/test/resources/example/sdc/blueprint-dcae/not-recognized.yaml delete mode 100644 src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json delete mode 100644 src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json delete mode 100644 src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json delete mode 100644 src/test/resources/tosca/dcea_blueprint.yml diff --git a/extra/docker/clamp/clamp.env b/extra/docker/clamp/clamp.env index 06381f94..3270db2c 100644 --- a/extra/docker/clamp/clamp.env +++ b/extra/docker/clamp/clamp.env @@ -1,2 +1,2 @@ ### Be careful, this must be in one line only ### -SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","spring.profiles.active":"clamp-default,clamp-default-user,clamp-sdc-controller-new,clamp-ssl-config","clamp.config.policy.api.url":"http4://third-party-proxy:8085","clamp.config.policy.pap.url":"http4://third-party-proxy:8085","clamp.config.dcae.inventory.url":"http://third-party-proxy:8085","clamp.config.dcae.deployment.url":"http4://third-party-proxy:8085"} +SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","spring.profiles.active":"clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config","clamp.config.policy.api.url":"http4://third-party-proxy:8085","clamp.config.policy.pap.url":"http4://third-party-proxy:8085","clamp.config.dcae.inventory.url":"http://third-party-proxy:8085","clamp.config.dcae.deployment.url":"http4://third-party-proxy:8085"} diff --git a/extra/docker/heat/clamp.env b/extra/docker/heat/clamp.env index abca2676..a06e45b2 100644 --- a/extra/docker/heat/clamp.env +++ b/extra/docker/heat/clamp.env @@ -1,2 +1,2 @@ ### Be careful, this must be in one line only ### -SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3","clamp.config.policy.pdpUrl1":"https://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123","clamp.config.policy.pdpUrl2":"https://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123","clamp.config.policy.papUrl":"https://policy.api.simpledemo.onap.org:9091/pap/ , testpap, alpha123"} +SPRING_APPLICATION_JSON={"spring.datasource.cldsdb.url":"jdbc:mariadb:sequential://db:3306/cldsdb4?autoReconnect=true&connectTimeout=10000&socketTimeout=10000&retriesAllDown=3"} diff --git a/extra/sql/bulkload/create-tables.sql b/extra/sql/bulkload/create-tables.sql index 819d9259..4edb4691 100644 --- a/extra/sql/bulkload/create-tables.sql +++ b/extra/sql/bulkload/create-tables.sql @@ -36,7 +36,7 @@ created_timestamp datetime(6) not null, updated_by varchar(255), updated_timestamp datetime(6) not null, - blueprint_yaml MEDIUMTEXT not null, + blueprint_yaml MEDIUMTEXT, dcae_blueprint_id varchar(255), loop_element_type varchar(255) not null, primary key (name) diff --git a/extra/sql/dump/test-data.sql b/extra/sql/dump/test-data.sql index 08d3ca50..629ce652 100644 --- a/extra/sql/dump/test-data.sql +++ b/extra/sql/dump/test-data.sql @@ -44,7 +44,7 @@ UNLOCK TABLES; LOCK TABLES `hibernate_sequence` WRITE; /*!40000 ALTER TABLE `hibernate_sequence` DISABLE KEYS */; -INSERT INTO `hibernate_sequence` VALUES (6); +INSERT INTO `hibernate_sequence` VALUES (10); /*!40000 ALTER TABLE `hibernate_sequence` ENABLE KEYS */; UNLOCK TABLES; @@ -54,7 +54,7 @@ UNLOCK TABLES; LOCK TABLES `loop_element_models` WRITE; /*!40000 ALTER TABLE `loop_element_models` DISABLE KEYS */; -INSERT INTO `loop_element_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app',NULL,'2020-01-30 15:21:59.168542','','2020-01-30 15:21:59.460129','tosca_definitions_version: cloudify_dsl_1_3\nimports:\n- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/docker/2.2.0/node-type.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml\n- http://onap.org:8081/repository/solutioning01-mte2-raw/type_files/dmaap/dmaap_mr.yaml\ninputs:\n location_id:\n type: string\n service_id:\n type: string\n policy_id:\n type: string\nnode_templates:\n policy_0:\n type: dcae.nodes.policy\n properties:\n policy_id: \n get_input: policy_id\n policy_model_id: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n cdap_host_host:\n type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure\n properties:\n location_id:\n get_input: location_id\n scn_override: cdap_broker.solutioning-central.dcae.onap.org\n interfaces:\n cloudify.interfaces.lifecycle: {\n }\n tca_tca:\n type: dcae.nodes.MicroService.cdap\n properties:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n publisherContentType: application/json\n publisherHostName: mrlocal-mtnjftle01.onap.org\n publisherHostPort: \'3905\'\n publisherMaxBatchSize: \'10\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: https\n publisherTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub\n publisherUserName: test@tca.af.dcae.onap.org\n publisherUserPassword: password\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName: mrlocal-mtnjftle01.onap.org\n subscriberHostPort: \'3905\'\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'20000\'\n subscriberProtocol: https\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub\n subscriberUserName: test@tca.af.dcae.onap.org\n subscriberUserPassword: password\n tca_policy: null\n artifact_name: dcae-analytics-tca\n artifact_version: 1.0.0\n connections:\n streams_publishes: [\n ]\n streams_subscribes: [\n ]\n jar_url: http://somejar\n location_id:\n get_input: location_id\n namespace: cdap_tca_hi_lo\n programs:\n - program_id: TCAVESCollectorFlow\n program_type: flows\n - program_id: TCADMaaPMRSubscriberWorker\n program_type: workers\n - program_id: TCADMaaPMRPublisherWorker\n program_type: workers\n service_component_type: cdap_app_tca\n service_id:\n get_input: service_id\n streamname: TCASubscriberOutputStream\n relationships:\n - target: topic0\n type: dcae.relationships.subscribe_to_events\n - target: topic1\n type: dcae.relationships.publish_events\n - target: cdap_host_host\n type: dcae.relationships.component_contained_in\n - target: policy_0\n type: dcae.relationships.depends_on\n topic0:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n topic1:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n \n',NULL,'CONFIG_POLICY'); +INSERT INTO `loop_element_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app',NULL,'2020-02-10 17:03:33.661538','','2020-02-10 17:03:34.923034',NULL,NULL,'CONFIG_POLICY'); /*!40000 ALTER TABLE `loop_element_models` ENABLE KEYS */; UNLOCK TABLES; @@ -73,9 +73,9 @@ UNLOCK TABLES; LOCK TABLES `loop_templates` WRITE; /*!40000 ALTER TABLE `loop_templates` DISABLE KEYS */; -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName1_tca','','2020-01-30 15:21:59.434409','','2020-01-30 15:21:59.434409','tosca_definitions_version: cloudify_dsl_1_3\nimports:\n- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/docker/2.2.0/node-type.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml\n- http://onap.org:8081/repository/solutioning01-mte2-raw/type_files/dmaap/dmaap_mr.yaml\ninputs:\n location_id:\n type: string\n service_id:\n type: string\n policy_id:\n type: string\nnode_templates:\n policy_0:\n type: dcae.nodes.policy\n properties:\n policy_id: \n get_input: policy_id\n policy_model_id: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n cdap_host_host:\n type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure\n properties:\n location_id:\n get_input: location_id\n scn_override: cdap_broker.solutioning-central.dcae.onap.org\n interfaces:\n cloudify.interfaces.lifecycle: {\n }\n tca_tca:\n type: dcae.nodes.MicroService.cdap\n properties:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n publisherContentType: application/json\n publisherHostName: mrlocal-mtnjftle01.onap.org\n publisherHostPort: \'3905\'\n publisherMaxBatchSize: \'10\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: https\n publisherTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub\n publisherUserName: test@tca.af.dcae.onap.org\n publisherUserPassword: password\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName: mrlocal-mtnjftle01.onap.org\n subscriberHostPort: \'3905\'\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'20000\'\n subscriberProtocol: https\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub\n subscriberUserName: test@tca.af.dcae.onap.org\n subscriberUserPassword: password\n tca_policy: null\n artifact_name: dcae-analytics-tca\n artifact_version: 1.0.0\n connections:\n streams_publishes: [\n ]\n streams_subscribes: [\n ]\n jar_url: http://somejar\n location_id:\n get_input: location_id\n namespace: cdap_tca_hi_lo\n programs:\n - program_id: TCAVESCollectorFlow\n program_type: flows\n - program_id: TCADMaaPMRSubscriberWorker\n program_type: workers\n - program_id: TCADMaaPMRPublisherWorker\n program_type: workers\n service_component_type: cdap_app_tca\n service_id:\n get_input: service_id\n streamname: TCASubscriberOutputStream\n relationships:\n - target: topic0\n type: dcae.relationships.subscribe_to_events\n - target: topic1\n type: dcae.relationships.publish_events\n - target: cdap_host_host\n type: dcae.relationships.component_contained_in\n - target: policy_0\n type: dcae.relationships.depends_on\n topic0:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n topic1:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n \n','typeId-3369cc54-4ce8-4539-9493-d983c7823d66',0,'VESTCAOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName1_tca_3','','2020-01-30 15:21:59.294006','','2020-01-30 15:21:59.294006','tosca_definitions_version: cloudify_dsl_1_3\n\ndescription: >\n This blueprint deploys/manages the TCA module as a Docker container\n\nimports:\n - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\ninputs:\n aaiEnrichmentHost:\n type: string\n default: \"aai.onap.svc.cluster.local\"\n aaiEnrichmentPort:\n type: string\n default: \"8443\"\n enableAAIEnrichment:\n type: string\n default: true\n dmaap_host:\n type: string\n default: message-router.onap.svc.cluster.local\n dmaap_port:\n type: string\n default: \"3904\"\n enableRedisCaching:\n type: string\n default: false\n redisHosts:\n type: string\n default: dcae-redis.onap.svc.cluster.local:6379\n tag_version:\n type: string\n default: \"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest\"\n consul_host:\n type: string\n default: consul-server.onap.svc.cluster.local\n consul_port:\n type: string\n default: \"8500\"\n cbs_host:\n type: string\n default: \"config-binding-service.dcae.svc.cluster.local\"\n cbs_port:\n type: string\n default: \"10000\"\n policy_id:\n type: string\n default: \"none\"\n external_port:\n type: string\n description: Kubernetes node port on which CDAPgui is exposed\n default: \"32012\"\n policy_model_id:\n type: string\n default: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n\nnode_templates:\n tca_k8s:\n type: dcae.nodes.ContainerizedServiceComponent\n relationships:\n - target: tca_policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: \'dcaegen2-analytics-tca\'\n application_config: {}\n docker_config: {}\n image:\n get_input: tag_version\n log_info:\n log_directory: \"/opt/app/TCAnalytics/logs\"\n application_config:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\n tcaAlertsAbatementTableTTLSeconds: \'1728000\'\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n aaiEnrichmentHost:\n get_input: aaiEnrichmentHost\n aaiEnrichmentIgnoreSSLCertificateErrors: \'true\'\n aaiEnrichmentPortNumber: \'8443\'\n aaiEnrichmentProtocol: https\n aaiEnrichmentUserName: dcae@dcae.onap.org\n aaiEnrichmentUserPassword: demo123456!\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\n enableAAIEnrichment:\n get_input: enableAAIEnrichment\n enableRedisCaching:\n get_input: enableRedisCaching\n redisHosts:\n get_input: redisHosts\n enableAlertCEFFormat: \'false\'\n publisherContentType: application/json\n publisherHostName:\n get_input: dmaap_host\n publisherHostPort:\n get_input: dmaap_port\n publisherMaxBatchSize: \'1\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: http\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName:\n get_input: dmaap_host\n subscriberHostPort:\n get_input: dmaap_port\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'30000\'\n subscriberProtocol: http\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT\n tca_policy: \'\'\n service_component_type: dcaegen2-analytics_tca\n interfaces:\n cloudify.interfaces.lifecycle:\n start:\n inputs:\n envs:\n DMAAPHOST:\n { get_input: dmaap_host }\n DMAAPPORT:\n { get_input: dmaap_port }\n DMAAPPUBTOPIC: \"unauthenticated.DCAE_CL_OUTPUT\"\n DMAAPSUBTOPIC: \"unauthenticated.VES_MEASUREMENT_OUTPUT\"\n AAIHOST:\n { get_input: aaiEnrichmentHost }\n AAIPORT:\n { get_input: aaiEnrichmentPort }\n CONSUL_HOST:\n { get_input: consul_host }\n CONSUL_PORT:\n { get_input: consul_port }\n CBS_HOST:\n { get_input: cbs_host }\n CBS_PORT:\n { get_input: cbs_port }\n CONFIG_BINDING_SERVICE: \"config_binding_service\"\n ports:\n - concat: [\"11011:\", { get_input: external_port }]\n tca_policy:\n type: dcae.nodes.policy\n properties:\n policy_id:\n get_input: policy_id\n policy_model_id: \n get_input: policy_model_id\n','typeId-5b5d899d-819d-4813-bfd7-c5c1cdb9b2fc',0,'VEStca_k8sOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName2_tca_2','','2020-01-30 15:21:59.154059','','2020-01-30 15:21:59.154059','#\n# ============LICENSE_START====================================================\n# =============================================================================\n# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.\n# =============================================================================\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ============LICENSE_END======================================================\n\ntosca_definitions_version: cloudify_dsl_1_3\n\ndescription: >\n This blueprint deploys/manages the TCA module as a Docker container\n\nimports:\n - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml\n# - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/clamppolicyplugin/1.0.0/clamppolicyplugin_types.yaml\ninputs:\n aaiEnrichmentHost:\n type: string\n default: \"aai.onap.svc.cluster.local\"\n aaiEnrichmentPort:\n type: string\n default: \"8443\"\n enableAAIEnrichment:\n type: string\n default: true\n dmaap_host:\n type: string\n default: message-router.onap\n dmaap_port:\n type: string\n default: \"3904\"\n enableRedisCaching:\n type: string\n default: false\n redisHosts:\n type: string\n default: dcae-redis.onap.svc.cluster.local:6379\n tag_version:\n type: string\n default: \"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1\"\n consul_host:\n type: string\n default: consul-server.onap\n consul_port:\n type: string\n default: \"8500\"\n cbs_host:\n type: string\n default: \"config-binding-servicel\"\n cbs_port:\n type: string\n default: \"10000\"\n policy_id:\n type: string\n default: \"onap.restart.tca\"\n external_port:\n type: string\n description: Kubernetes node port on which CDAPgui is exposed\n default: \"32012\"\n policy_model_id:\n type: string\n default: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\nnode_templates:\n tca_k8s:\n type: dcae.nodes.ContainerizedServiceComponent\n relationships:\n - target: tca_policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: \'dcaegen2-analytics-tca\'\n application_config: {}\n docker_config: {}\n image:\n get_input: tag_version\n log_info:\n log_directory: \"/opt/app/TCAnalytics/logs\"\n application_config:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\n tcaAlertsAbatementTableTTLSeconds: \'1728000\'\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n aaiEnrichmentHost:\n get_input: aaiEnrichmentHost\n aaiEnrichmentIgnoreSSLCertificateErrors: \'true\'\n aaiEnrichmentPortNumber: \'8443\'\n aaiEnrichmentProtocol: https\n aaiEnrichmentUserName: dcae@dcae.onap.org\n aaiEnrichmentUserPassword: demo123456!\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\n enableAAIEnrichment:\n get_input: enableAAIEnrichment\n enableRedisCaching:\n get_input: enableRedisCaching\n redisHosts:\n get_input: redisHosts\n enableAlertCEFFormat: \'false\'\n publisherContentType: application/json\n publisherHostName:\n get_input: dmaap_host\n publisherHostPort:\n get_input: dmaap_port\n publisherMaxBatchSize: \'1\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: http\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\n subscriberConsumerGroup: OpenDCAE-clamp\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName:\n get_input: dmaap_host\n subscriberHostPort:\n get_input: dmaap_port\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'30000\'\n subscriberProtocol: http\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT\n# tca_policy: \'{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ONSET\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}\'\n service_component_type: dcaegen2-analytics_tca\n interfaces:\n cloudify.interfaces.lifecycle:\n start:\n inputs:\n envs:\n DMAAPHOST:\n { get_input: dmaap_host }\n DMAAPPORT:\n { get_input: dmaap_port }\n DMAAPPUBTOPIC: \"unauthenticated.DCAE_CL_OUTPUT\"\n DMAAPSUBTOPIC: \"unauthenticated.VES_MEASUREMENT_OUTPUT\"\n AAIHOST:\n { get_input: aaiEnrichmentHost }\n AAIPORT:\n { get_input: aaiEnrichmentPort }\n CONSUL_HOST:\n { get_input: consul_host }\n CONSUL_PORT:\n { get_input: consul_port }\n CBS_HOST:\n { get_input: cbs_host }\n CBS_PORT:\n { get_input: cbs_port }\n CONFIG_BINDING_SERVICE: \"config_binding_service\"\n ports:\n - concat: [\"11011:\", { get_input: external_port }]\n tca_policy:\n type: clamp.nodes.policy\n properties:\n policy_id:\n get_input: policy_id\n policy_model_id: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n','typeId-c12c1f86-295b-44a6-bbcf-2bbe40d70f2f',0,'VEStca_k8sOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName1_tca','','2020-02-10 17:03:34.815508','','2020-02-10 17:03:34.815508','tosca_definitions_version: cloudify_dsl_1_3\nimports:\n- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/docker/2.2.0/node-type.yaml\n- https://onap.org:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml\n- http://onap.org:8081/repository/solutioning01-mte2-raw/type_files/dmaap/dmaap_mr.yaml\ninputs:\n location_id:\n type: string\n service_id:\n type: string\n policy_id:\n type: string\nnode_templates:\n policy_0:\n type: dcae.nodes.policy\n properties:\n policy_id: \n get_input: policy_id\n policy_model_id: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n cdap_host_host:\n type: dcae.nodes.StreamingAnalytics.SelectedCDAPInfrastructure\n properties:\n location_id:\n get_input: location_id\n scn_override: cdap_broker.solutioning-central.dcae.onap.org\n interfaces:\n cloudify.interfaces.lifecycle: {\n }\n tca_tca:\n type: dcae.nodes.MicroService.cdap\n properties:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n publisherContentType: application/json\n publisherHostName: mrlocal-mtnjftle01.onap.org\n publisherHostPort: \'3905\'\n publisherMaxBatchSize: \'10\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: https\n publisherTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESPub\n publisherUserName: test@tca.af.dcae.onap.org\n publisherUserPassword: password\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName: mrlocal-mtnjftle01.onap.org\n subscriberHostPort: \'3905\'\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'20000\'\n subscriberProtocol: https\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: org.onap.dcae.dmaap.mtnje2.DcaeTestVESSub\n subscriberUserName: test@tca.af.dcae.onap.org\n subscriberUserPassword: password\n tca_policy: null\n artifact_name: dcae-analytics-tca\n artifact_version: 1.0.0\n connections:\n streams_publishes: [\n ]\n streams_subscribes: [\n ]\n jar_url: http://somejar\n location_id:\n get_input: location_id\n namespace: cdap_tca_hi_lo\n programs:\n - program_id: TCAVESCollectorFlow\n program_type: flows\n - program_id: TCADMaaPMRSubscriberWorker\n program_type: workers\n - program_id: TCADMaaPMRPublisherWorker\n program_type: workers\n service_component_type: cdap_app_tca\n service_id:\n get_input: service_id\n streamname: TCASubscriberOutputStream\n relationships:\n - target: topic0\n type: dcae.relationships.subscribe_to_events\n - target: topic1\n type: dcae.relationships.publish_events\n - target: cdap_host_host\n type: dcae.relationships.component_contained_in\n - target: policy_0\n type: dcae.relationships.depends_on\n topic0:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n topic1:\n type: dcae.nodes.Topic\n properties:\n topic_name: \'\'\n \n','typeId-a733c5f2-9113-4747-a2d2-4f9a9da9901b',0,'VEStca_tcaOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName1_tca_3','','2020-02-10 17:03:34.343090','','2020-02-10 17:03:34.343090','tosca_definitions_version: cloudify_dsl_1_3\n\ndescription: >\n This blueprint deploys/manages the TCA module as a Docker container\n\nimports:\n - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\ninputs:\n aaiEnrichmentHost:\n type: string\n default: \"aai.onap.svc.cluster.local\"\n aaiEnrichmentPort:\n type: string\n default: \"8443\"\n enableAAIEnrichment:\n type: string\n default: true\n dmaap_host:\n type: string\n default: message-router.onap.svc.cluster.local\n dmaap_port:\n type: string\n default: \"3904\"\n enableRedisCaching:\n type: string\n default: false\n redisHosts:\n type: string\n default: dcae-redis.onap.svc.cluster.local:6379\n tag_version:\n type: string\n default: \"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest\"\n consul_host:\n type: string\n default: consul-server.onap.svc.cluster.local\n consul_port:\n type: string\n default: \"8500\"\n cbs_host:\n type: string\n default: \"config-binding-service.dcae.svc.cluster.local\"\n cbs_port:\n type: string\n default: \"10000\"\n policy_id:\n type: string\n default: \"none\"\n external_port:\n type: string\n description: Kubernetes node port on which CDAPgui is exposed\n default: \"32012\"\n policy_model_id:\n type: string\n default: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n\nnode_templates:\n tca_k8s:\n type: dcae.nodes.ContainerizedServiceComponent\n relationships:\n - target: tca_policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: \'dcaegen2-analytics-tca\'\n application_config: {}\n docker_config: {}\n image:\n get_input: tag_version\n log_info:\n log_directory: \"/opt/app/TCAnalytics/logs\"\n application_config:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\n tcaAlertsAbatementTableTTLSeconds: \'1728000\'\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n aaiEnrichmentHost:\n get_input: aaiEnrichmentHost\n aaiEnrichmentIgnoreSSLCertificateErrors: \'true\'\n aaiEnrichmentPortNumber: \'8443\'\n aaiEnrichmentProtocol: https\n aaiEnrichmentUserName: dcae@dcae.onap.org\n aaiEnrichmentUserPassword: demo123456!\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\n enableAAIEnrichment:\n get_input: enableAAIEnrichment\n enableRedisCaching:\n get_input: enableRedisCaching\n redisHosts:\n get_input: redisHosts\n enableAlertCEFFormat: \'false\'\n publisherContentType: application/json\n publisherHostName:\n get_input: dmaap_host\n publisherHostPort:\n get_input: dmaap_port\n publisherMaxBatchSize: \'1\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: http\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\n subscriberConsumerGroup: OpenDCAE-c12\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName:\n get_input: dmaap_host\n subscriberHostPort:\n get_input: dmaap_port\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'30000\'\n subscriberProtocol: http\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT\n tca_policy: \'\'\n service_component_type: dcaegen2-analytics_tca\n interfaces:\n cloudify.interfaces.lifecycle:\n start:\n inputs:\n envs:\n DMAAPHOST:\n { get_input: dmaap_host }\n DMAAPPORT:\n { get_input: dmaap_port }\n DMAAPPUBTOPIC: \"unauthenticated.DCAE_CL_OUTPUT\"\n DMAAPSUBTOPIC: \"unauthenticated.VES_MEASUREMENT_OUTPUT\"\n AAIHOST:\n { get_input: aaiEnrichmentHost }\n AAIPORT:\n { get_input: aaiEnrichmentPort }\n CONSUL_HOST:\n { get_input: consul_host }\n CONSUL_PORT:\n { get_input: consul_port }\n CBS_HOST:\n { get_input: cbs_host }\n CBS_PORT:\n { get_input: cbs_port }\n CONFIG_BINDING_SERVICE: \"config_binding_service\"\n ports:\n - concat: [\"11011:\", { get_input: external_port }]\n tca_policy:\n type: dcae.nodes.policy\n properties:\n policy_id:\n get_input: policy_id\n policy_model_id: \n get_input: policy_model_id\n','typeId-8003bdb0-7171-404d-8ea4-fbe3cfd34589',0,'VEStca_k8sOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName2_tca_2','','2020-02-10 17:03:33.619163','','2020-02-10 17:03:33.619163','#\n# ============LICENSE_START====================================================\n# =============================================================================\n# Copyright (c) 2019 AT&T Intellectual Property. All rights reserved.\n# =============================================================================\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n# http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n# ============LICENSE_END======================================================\n\ntosca_definitions_version: cloudify_dsl_1_3\n\ndescription: >\n This blueprint deploys/manages the TCA module as a Docker container\n\nimports:\n - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/k8splugin_types.yaml\n# - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml\n - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/clamppolicyplugin/1.0.0/clamppolicyplugin_types.yaml\ninputs:\n aaiEnrichmentHost:\n type: string\n default: \"aai.onap.svc.cluster.local\"\n aaiEnrichmentPort:\n type: string\n default: \"8443\"\n enableAAIEnrichment:\n type: string\n default: true\n dmaap_host:\n type: string\n default: message-router.onap\n dmaap_port:\n type: string\n default: \"3904\"\n enableRedisCaching:\n type: string\n default: false\n redisHosts:\n type: string\n default: dcae-redis.onap.svc.cluster.local:6379\n tag_version:\n type: string\n default: \"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1\"\n consul_host:\n type: string\n default: consul-server.onap\n consul_port:\n type: string\n default: \"8500\"\n cbs_host:\n type: string\n default: \"config-binding-servicel\"\n cbs_port:\n type: string\n default: \"10000\"\n policy_id:\n type: string\n default: \"onap.restart.tca\"\n external_port:\n type: string\n description: Kubernetes node port on which CDAPgui is exposed\n default: \"32012\"\n policy_model_id:\n type: string\n default: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\nnode_templates:\n tca_k8s:\n type: dcae.nodes.ContainerizedServiceComponent\n relationships:\n - target: tca_policy\n type: cloudify.relationships.depends_on\n properties:\n service_component_type: \'dcaegen2-analytics-tca\'\n application_config: {}\n docker_config: {}\n image:\n get_input: tag_version\n log_info:\n log_directory: \"/opt/app/TCAnalytics/logs\"\n application_config:\n app_config:\n appDescription: DCAE Analytics Threshold Crossing Alert Application\n appName: dcae-tca\n tcaAlertsAbatementTableName: TCAAlertsAbatementTable\n tcaAlertsAbatementTableTTLSeconds: \'1728000\'\n tcaSubscriberOutputStreamName: TCASubscriberOutputStream\n tcaVESAlertsTableName: TCAVESAlertsTable\n tcaVESAlertsTableTTLSeconds: \'1728000\'\n tcaVESMessageStatusTableName: TCAVESMessageStatusTable\n tcaVESMessageStatusTableTTLSeconds: \'86400\'\n thresholdCalculatorFlowletInstances: \'2\'\n app_preferences:\n aaiEnrichmentHost:\n get_input: aaiEnrichmentHost\n aaiEnrichmentIgnoreSSLCertificateErrors: \'true\'\n aaiEnrichmentPortNumber: \'8443\'\n aaiEnrichmentProtocol: https\n aaiEnrichmentUserName: dcae@dcae.onap.org\n aaiEnrichmentUserPassword: demo123456!\n aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query\n aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf\n enableAAIEnrichment:\n get_input: enableAAIEnrichment\n enableRedisCaching:\n get_input: enableRedisCaching\n redisHosts:\n get_input: redisHosts\n enableAlertCEFFormat: \'false\'\n publisherContentType: application/json\n publisherHostName:\n get_input: dmaap_host\n publisherHostPort:\n get_input: dmaap_port\n publisherMaxBatchSize: \'1\'\n publisherMaxRecoveryQueueSize: \'100000\'\n publisherPollingInterval: \'20000\'\n publisherProtocol: http\n publisherTopicName: unauthenticated.DCAE_CL_OUTPUT\n subscriberConsumerGroup: OpenDCAE-clamp\n subscriberConsumerId: c12\n subscriberContentType: application/json\n subscriberHostName:\n get_input: dmaap_host\n subscriberHostPort:\n get_input: dmaap_port\n subscriberMessageLimit: \'-1\'\n subscriberPollingInterval: \'30000\'\n subscriberProtocol: http\n subscriberTimeoutMS: \'-1\'\n subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT\n# tca_policy: \'{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ONSET\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}\'\n service_component_type: dcaegen2-analytics_tca\n interfaces:\n cloudify.interfaces.lifecycle:\n start:\n inputs:\n envs:\n DMAAPHOST:\n { get_input: dmaap_host }\n DMAAPPORT:\n { get_input: dmaap_port }\n DMAAPPUBTOPIC: \"unauthenticated.DCAE_CL_OUTPUT\"\n DMAAPSUBTOPIC: \"unauthenticated.VES_MEASUREMENT_OUTPUT\"\n AAIHOST:\n { get_input: aaiEnrichmentHost }\n AAIPORT:\n { get_input: aaiEnrichmentPort }\n CONSUL_HOST:\n { get_input: consul_host }\n CONSUL_PORT:\n { get_input: consul_port }\n CBS_HOST:\n { get_input: cbs_host }\n CBS_PORT:\n { get_input: cbs_port }\n CONFIG_BINDING_SERVICE: \"config_binding_service\"\n ports:\n - concat: [\"11011:\", { get_input: external_port }]\n tca_policy:\n type: clamp.nodes.policy\n properties:\n policy_id:\n get_input: policy_id\n policy_model_id: \"onap.policies.monitoring.cdap.tca.hi.lo.app\"\n','typeId-d7711567-0d72-4206-8705-c4258f2dc4c6',0,'VEStca_k8sOperationalPolicy','63cac700-ab9a-4115-a74f-7eac85e3fce0'); /*!40000 ALTER TABLE `loop_templates` ENABLE KEYS */; UNLOCK TABLES; @@ -85,7 +85,7 @@ UNLOCK TABLES; LOCK TABLES `loopelementmodels_to_policymodels` WRITE; /*!40000 ALTER TABLE `loopelementmodels_to_policymodels` DISABLE KEYS */; -INSERT INTO `loopelementmodels_to_policymodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','onap.policies.monitoring.cdap.tca.hi.lo.app','1.0'); +INSERT INTO `loopelementmodels_to_policymodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0'); /*!40000 ALTER TABLE `loopelementmodels_to_policymodels` ENABLE KEYS */; UNLOCK TABLES; @@ -113,9 +113,9 @@ UNLOCK TABLES; LOCK TABLES `looptemplates_to_loopelementmodels` WRITE; /*!40000 ALTER TABLE `looptemplates_to_loopelementmodels` DISABLE KEYS */; -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName1_tca',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName1_tca_3',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_srIFK_v1_0_ResourceInstanceName2_tca_2',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName1_tca',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName1_tca_3',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_GDC6j_v1_0_ResourceInstanceName2_tca_2',0); /*!40000 ALTER TABLE `looptemplates_to_loopelementmodels` ENABLE KEYS */; UNLOCK TABLES; @@ -143,7 +143,7 @@ UNLOCK TABLES; LOCK TABLES `policy_models` WRITE; /*!40000 ALTER TABLE `policy_models` DISABLE KEYS */; -INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0',NULL,'2020-01-30 15:21:59.176333','','2020-01-30 15:21:59.461713','app','tosca_definitions_version: tosca_simple_yaml_1_0_0\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n description: a base policy type for all policies that governs monitoring provisioning\n onap.policies.monitoring.cdap.tca.hi.lo.app:\n derived_from: onap.policies.Monitoring\n version: 1.0.0\n properties:\n tca_policy:\n type: map\n description: TCA Policy JSON\n entry_schema:\n type: onap.datatypes.monitoring.tca_policy\ndata_types:\n onap.datatypes.monitoring.metricsPerEventName:\n derived_from: tosca.datatypes.Root\n properties:\n controlLoopSchemaType:\n type: string\n required: true\n description: Specifies Control Loop Schema Type for the event Name e.g. VNF, VM\n constraints:\n - valid_values:\n - VM\n - VNF\n eventName:\n type: string\n required: true\n description: Event name to which thresholds need to be applied\n policyName:\n type: string\n required: true\n description: TCA Policy Scope Name\n policyScope:\n type: string\n required: true\n description: TCA Policy Scope\n policyVersion:\n type: string\n required: true\n description: TCA Policy Scope Version\n thresholds:\n type: list\n required: true\n description: Thresholds associated with eventName\n entry_schema:\n type: onap.datatypes.monitoring.thresholds\n onap.datatypes.monitoring.tca_policy:\n derived_from: tosca.datatypes.Root\n properties:\n domain:\n type: string\n required: true\n description: Domain name to which TCA needs to be applied\n default: measurementsForVfScaling\n constraints:\n - equal: measurementsForVfScaling\n metricsPerEventName:\n type: list\n required: true\n description: Contains eventName and threshold details that need to be applied to given eventName\n entry_schema:\n type: onap.datatypes.monitoring.metricsPerEventName\n onap.datatypes.monitoring.thresholds:\n derived_from: tosca.datatypes.Root\n properties:\n closedLoopControlName:\n type: string\n required: true\n description: Closed Loop Control Name associated with the threshold\n closedLoopEventStatus:\n type: string\n required: true\n description: Closed Loop Event Status of the threshold\n constraints:\n - valid_values:\n - ONSET\n - ABATED\n direction:\n type: string\n required: true\n description: Direction of the threshold\n constraints:\n - valid_values:\n - LESS\n - LESS_OR_EQUAL\n - GREATER\n - GREATER_OR_EQUAL\n - EQUAL\n fieldPath:\n type: string\n required: true\n description: Json field Path as per CEF message which needs to be analyzed for TCA\n constraints:\n - valid_values:\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated\n - $.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait\n - $.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage\n - $.event.measurementsForVfScalingFields.meanRequestLatency\n - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered\n - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached\n - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured\n - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree\n - $.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed\n - $.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value\n severity:\n type: string\n required: true\n description: Threshold Event Severity\n constraints:\n - valid_values:\n - CRITICAL\n - MAJOR\n - MINOR\n - WARNING\n - NORMAL\n thresholdValue:\n type: integer\n required: true\n description: Threshold value for the field Path inside CEF message\n version:\n type: string\n required: true\n description: Version number associated with the threshold\n'); +INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0','','2020-02-10 17:03:33.698994','','2020-02-10 17:03:33.698994','app','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); /*!40000 ALTER TABLE `policy_models` ENABLE KEYS */; UNLOCK TABLES; @@ -165,4 +165,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-01-30 14:23:27 +-- Dump completed on 2020-02-10 16:04:53 diff --git a/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java new file mode 100644 index 00000000..d99e9b56 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/client/PolicyEngineServices.java @@ -0,0 +1,110 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.client; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.builder.ExchangeBuilder; +import org.onap.clamp.clds.config.ClampProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * The class implements the communication with the Policy Engine to retrieve + * policy models (tosca). It mainly delegates the physical calls to Camel + * engine. + * + */ +@Component +public class PolicyEngineServices { + private final CamelContext camelContext; + + private final ClampProperties refProp; + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyEngineServices.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + public static final String POLICY_RETRY_INTERVAL = "policy.retry.interval"; + public static final String POLICY_RETRY_LIMIT = "policy.retry.limit"; + + @Autowired + public PolicyEngineServices(CamelContext camelContext, ClampProperties refProp) { + this.refProp = refProp; + this.camelContext = camelContext; + } + + private void downloadAllPolicies() { + /* + * Exchange myCamelExchange = ExchangeBuilder.anExchange(camelContext) + * .withProperty("blueprintResourceId", + * resourceUuid).withProperty("blueprintServiceId", serviceUuid) + * .withProperty("blueprintName", artifactName).build(); + * metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory"); + * + * Exchange exchangeResponse = + * camelContext.createProducerTemplate().send("direct:get-all-policy-models", + * myCamelExchange); + */ + } + + /** + * This method can be used to download a policy tosca model on the engine. + * + * @param policyType The policy type (id) + * @param policyVersion The policy version + * @return A string with the whole policy tosca model + * @throws InterruptedException in case of issue when sleeping during the retry + */ + public String downloadOnePolicy(String policyType, String policyVersion) throws InterruptedException { + int retryInterval = 0; + int retryLimit = 1; + if (refProp.getStringValue(POLICY_RETRY_LIMIT) != null) { + retryLimit = Integer.valueOf(refProp.getStringValue(POLICY_RETRY_LIMIT)); + } + if (refProp.getStringValue(POLICY_RETRY_INTERVAL) != null) { + retryInterval = Integer.valueOf(refProp.getStringValue(POLICY_RETRY_INTERVAL)); + } + for (int i = 0; i < retryLimit; i++) { + Exchange paramExchange = ExchangeBuilder.anExchange(camelContext) + .withProperty("policyModelName", policyType).withProperty("policyModelVersion", policyVersion) + .build(); + + Exchange exchangeResponse = camelContext.createProducerTemplate().send("direct:get-policy-model", + paramExchange); + + if (Integer.valueOf(200).equals(exchangeResponse.getIn().getHeader("CamelHttpResponseCode"))) { + return (String) exchangeResponse.getIn().getBody(); + } else { + logger.info("Policy " + retryInterval + "ms before retrying ..."); + // wait for a while and try to connect to DCAE again + Thread.sleep(retryInterval); + } + } + return ""; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/config/ClampProperties.java b/src/main/java/org/onap/clamp/clds/config/ClampProperties.java index 9905585d..8eae9066 100644 --- a/src/main/java/org/onap/clamp/clds/config/ClampProperties.java +++ b/src/main/java/org/onap/clamp/clds/config/ClampProperties.java @@ -23,13 +23,11 @@ package org.onap.clamp.clds.config; -import com.google.common.base.Splitter; - import com.google.gson.JsonElement; + import java.io.IOException; import java.net.URL; import java.nio.charset.StandardCharsets; -import java.util.List; import org.apache.commons.io.IOUtils; import org.onap.clamp.clds.util.JsonUtils; @@ -53,8 +51,7 @@ public class ClampProperties { /** * get property value. * - * @param key - * The first key + * @param key The first key * @return The string with the value */ public String getStringValue(String key) { @@ -65,10 +62,8 @@ public class ClampProperties { * get property value for a combo key (key1 + "." + key2). If not found just use * key1. * - * @param key1 - * The first key - * @param key2 - * The second key after a dot + * @param key1 The first key + * @param key2 The second key after a dot * @return The string with the value */ public String getStringValue(String key1, String key2) { @@ -83,17 +78,15 @@ public class ClampProperties { * Return json as objects that can be updated. The value obtained from the * clds-reference file will be used as a filename. * - * @param key - * The key that will be used to access the clds-reference file + * @param key The key that will be used to access the clds-reference file * @return A jsonNode - * @throws IOException - * In case of issues with the JSON parser + * @throws IOException In case of issues with the JSON parser */ public JsonElement getJsonTemplate(String key) throws IOException { String fileReference = getStringValue(key); return (fileReference != null) - ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class) - : null; + ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class) + : null; } /** @@ -101,30 +94,25 @@ public class ClampProperties { * "." + key2), otherwise default to just key1. The value obtained from the * clds-reference file will be used as a filename. * - * @param key1 - * The first key - * @param key2 - * The second key after a dot + * @param key1 The first key + * @param key2 The second key after a dot * @return A JsonNode - * @throws IOException - * In case of issues with the JSON parser + * @throws IOException In case of issues with the JSON parser */ public JsonElement getJsonTemplate(String key1, String key2) throws IOException { String fileReference = getStringValue(key1, key2); return (fileReference != null) - ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class) - : null; + ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class) + : null; } /** * Return the file content. The value obtained from the clds-reference file will * be used as a filename. * - * @param key - * The key that will be used to access the clds-reference file + * @param key The key that will be used to access the clds-reference file * @return File content in String - * @throws IOException - * In case of issues with the JSON parser + * @throws IOException In case of issues with the JSON parser */ public String getFileContent(String key) throws IOException { String fileReference = getStringValue(key); @@ -136,13 +124,10 @@ public class ClampProperties { * otherwise default to just key1. The value obtained from the clds-reference * file will be used as a filename. * - * @param key1 - * The first key - * @param key2 - * The second key after a dot + * @param key1 The first key + * @param key2 The second key after a dot * @return File content in String - * @throws IOException - * In case of issues with the JSON parser + * @throws IOException In case of issues with the JSON parser */ public String getFileContent(String key1, String key2) throws IOException { String fileReference = getStringValue(key1, key2); @@ -153,18 +138,4 @@ public class ClampProperties { URL url = appContext.getResource(filepath).getURL(); return IOUtils.toString(url, StandardCharsets.UTF_8); } - - /** - * Returns the list of strings split with separator. - * - * @param key - * property key - * @param separator - * property value separator - * @return List of Strings split with a separator - */ - public List getStringList(String key, String separator) { - return Splitter.on(separator).trimResults().omitEmptyStrings() - .splitToList(env.getProperty(CONFIG_PREFIX + key)); - } } diff --git a/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java b/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java deleted file mode 100644 index a4f37e8b..00000000 --- a/src/main/java/org/onap/clamp/clds/config/PolicyConfiguration.java +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2018 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.clamp.clds.config; - -import java.util.Properties; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "clamp.config.policy") -public class PolicyConfiguration { - - public static final String PDP_URL1 = "PDP_URL1"; - public static final String PDP_URL2 = "PDP_URL2"; - public static final String PAP_URL = "PAP_URL"; - public static final String NOTIFICATION_TYPE = "NOTIFICATION_TYPE"; - public static final String NOTIFICATION_UEB_SERVERS = "NOTIFICATION_UEB_SERVERS"; - public static final String CLIENT_ID = "CLIENT_ID"; - public static final String CLIENT_KEY = "CLIENT_KEY"; - public static final String ENVIRONMENT = "ENVIRONMENT"; - private String pdpUrl1; - private String pdpUrl2; - private String papUrl; - private String notificationType; - private String notificationUebServers; - private String clientId; - private String clientKey; - private String policyEnvironment; - - public String getPdpUrl1() { - return pdpUrl1; - } - - public void setPdpUrl1(String pdpUrl1) { - this.pdpUrl1 = pdpUrl1; - } - - public String getPdpUrl2() { - return pdpUrl2; - } - - public void setPdpUrl2(String pdpUrl2) { - this.pdpUrl2 = pdpUrl2; - } - - public String getPapUrl() { - return papUrl; - } - - public void setPapUrl(String papUrl) { - this.papUrl = papUrl; - } - - public String getNotificationType() { - return notificationType; - } - - public void setNotificationType(String notificationType) { - this.notificationType = notificationType; - } - - public String getNotificationUebServers() { - return notificationUebServers; - } - - public void setNotificationUebServers(String notificationUebServers) { - this.notificationUebServers = notificationUebServers; - } - - public String getClientId() { - return clientId; - } - - public void setClientId(String clientId) { - this.clientId = clientId; - } - - public String getClientKey() { - return clientKey; - } - - public void setClientKey(String clientKey) { - this.clientKey = clientKey; - } - - public String getPolicyEnvironment() { - return policyEnvironment; - } - - public void setPolicyEnvironment(String environment) { - this.policyEnvironment = environment; - } - - /** - * Returns policy configuration properties. - * - * @return policy configuration properties - */ - public Properties getProperties() { - Properties prop = new Properties(); - prop.put(PDP_URL1, pdpUrl1); - prop.put(PDP_URL2, pdpUrl2); - prop.put(PAP_URL, papUrl); - prop.put(NOTIFICATION_TYPE, notificationType); - prop.put(NOTIFICATION_UEB_SERVERS, notificationUebServers); - prop.put(CLIENT_ID, clientId); - prop.put(CLIENT_KEY, clientKey); - prop.put(ENVIRONMENT, policyEnvironment); - return prop; - } -} diff --git a/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java b/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java index 5a3e22a3..eca45d66 100644 --- a/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/spring/SdcControllerConfiguration.java @@ -41,14 +41,12 @@ import org.onap.clamp.loop.CsarInstaller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Profile; import org.springframework.scheduling.annotation.Scheduled; @Configuration -@ComponentScan(basePackages = { "org.onap.clamp.loop", "org.onap.clamp.clds.config" }) -@Profile("clamp-sdc-controller-new") +@Profile("clamp-sdc-controller") public class SdcControllerConfiguration { private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcControllerConfiguration.class); diff --git a/src/main/java/org/onap/clamp/clds/exception/sdc/controller/BlueprintParserException.java b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/BlueprintParserException.java new file mode 100644 index 00000000..7257fd8a --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/exception/sdc/controller/BlueprintParserException.java @@ -0,0 +1,54 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.clds.exception.sdc.controller; + +/** + * Exception during blueprint parsing. + */ +public class BlueprintParserException extends Exception { + + /** + * Serial ID. + */ + private static final long serialVersionUID = -3044162346353623199L; + + /** + * This constructor can be used to create a new SdcDownloadException. + * + * @param message The message to dump + */ + public BlueprintParserException(final String message) { + super(message); + } + + /** + * This constructor can be used to create a new SdcDownloadException. + * + * @param message The message to dump + * @param cause The Throwable cause object + */ + public BlueprintParserException(final String message, final Throwable cause) { + super(message, cause); + } +} diff --git a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java index 19bc23d5..fc2ca5ca 100644 --- a/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java +++ b/src/main/java/org/onap/clamp/clds/model/dcae/DcaeInventoryCache.java @@ -46,7 +46,7 @@ public class DcaeInventoryCache { public void addDcaeInventoryResponse(DcaeInventoryResponse inventoryResponse) { Set responsesSet = blueprintsMap.get(inventoryResponse.getAsdcServiceId()); if (responsesSet == null) { - responsesSet = new TreeSet(); + responsesSet = new TreeSet<>(); blueprintsMap.put(inventoryResponse.getAsdcServiceId(), responsesSet); } responsesSet.add(inventoryResponse); diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java index bd18baea..fbb37d52 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/SdcSingleController.java @@ -33,6 +33,7 @@ import java.util.concurrent.ThreadLocalRandom; import org.onap.clamp.clds.config.ClampProperties; import org.onap.clamp.clds.config.sdc.SdcSingleControllerConfiguration; +import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.exception.sdc.controller.SdcControllerException; @@ -290,6 +291,10 @@ public class SdcSingleController { sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, DistributionStatusEnum.DEPLOY_ERROR, e.getMessage()); Thread.currentThread().interrupt(); + } catch (BlueprintParserException e) { + logger.error("BlueprintParser exception caught during the notification processing", e); + sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, + DistributionStatusEnum.DEPLOY_ERROR, e.getMessage()); } catch (RuntimeException e) { logger.error("Unexpected exception caught during the notification processing", e); sendAllNotificationForCsarHandler(notificationData, csar, NotificationType.DEPLOY, diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintMicroService.java similarity index 67% rename from src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java rename to src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintMicroService.java index 68ac842c..e00ce943 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/MicroService.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintMicroService.java @@ -17,7 +17,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END============================================ - * Modifications copyright (c) 2019 AT&T + * Modifications copyright (c) 2019-2020 AT&T * =================================================================== * */ @@ -26,25 +26,24 @@ package org.onap.clamp.clds.sdc.controller.installer; import java.util.Objects; -public class MicroService { +public class BlueprintMicroService { private final String name; private final String modelType; private final String inputFrom; - private String mappedNameJpa; + private final String modelVersion; /** * The Micro service constructor. * - * @param name The name in String - * @param modelType The model type - * @param inputFrom Comes from (single chained) - * @param mappedNameJpa Name in database + * @param name The name in String + * @param modelType The model type + * @param inputFrom Comes from (single chained) */ - public MicroService(String name, String modelType, String inputFrom, String mappedNameJpa) { + public BlueprintMicroService(String name, String modelType, String inputFrom, String modelVersion) { this.name = name; this.inputFrom = inputFrom; - this.mappedNameJpa = mappedNameJpa; this.modelType = modelType; + this.modelVersion = modelVersion; } public String getName() { @@ -59,18 +58,19 @@ public class MicroService { return inputFrom; } - @Override - public String toString() { - return "MicroService{" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='" - + inputFrom + '\'' + ", mappedNameJpa='" + mappedNameJpa + '\'' + '}'; - } - - public String getMappedNameJpa() { - return mappedNameJpa; + /** + * modelVerrsion getter. + * + * @return the modelVersion + */ + public String getModelVersion() { + return modelVersion; } - public void setMappedNameJpa(String mappedNameJpa) { - this.mappedNameJpa = mappedNameJpa; + @Override + public String toString() { + return "MicroService {" + "name='" + name + '\'' + ", modelType='" + modelType + '\'' + ", inputFrom='" + + inputFrom + '\'' + ", modelVersion='" + modelVersion + '\'' + '}'; } @Override @@ -81,13 +81,13 @@ public class MicroService { if (obj == null || getClass() != obj.getClass()) { return false; } - MicroService that = (MicroService) obj; + BlueprintMicroService that = (BlueprintMicroService) obj; return name.equals(that.name) && modelType.equals(that.modelType) && inputFrom.equals(that.inputFrom) - && mappedNameJpa.equals(that.mappedNameJpa); + && modelVersion.equals(that.modelVersion); } @Override public int hashCode() { - return Objects.hash(name, modelType, inputFrom, mappedNameJpa); + return Objects.hash(name, modelType, inputFrom, modelVersion); } } diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java index 0dd231f0..981a2041 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java @@ -24,6 +24,8 @@ package org.onap.clamp.clds.sdc.controller.installer; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -38,76 +40,74 @@ import java.util.Map.Entry; import java.util.Set; import org.json.JSONObject; -import org.springframework.stereotype.Component; +import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; import org.yaml.snakeyaml.Yaml; -@Component public class BlueprintParser { static final String TCA = "TCA"; - static final String HOLMES = "Holmes"; - private static final String TCA_POLICY = "tca_policy"; - private static final String HOLMES_PREFIX = "holmes"; private static final String NODE_TEMPLATES = "node_templates"; private static final String DCAE_NODES = "dcae.nodes."; + private static final String DCAE_NODES_POLICY = "dcae.nodes.policy"; private static final String TYPE = "type"; private static final String PROPERTIES = "properties"; private static final String NAME = "name"; private static final String INPUT = "inputs"; private static final String GET_INPUT = "get_input"; - private static final String POLICY_MODELID = "policy_model_id"; + private static final String POLICY_MODEL_ID = "policy_model_id"; + private static final String POLICY_MODEL_VERSION = "policy_model_version"; private static final String RELATIONSHIPS = "relationships"; private static final String CLAMP_NODE_RELATIONSHIPS_GETS_INPUT_FROM = "clamp_node.relationships.gets_input_from"; private static final String TARGET = "target"; + public static final String DEFAULT_VERSION = "1.0.0"; + + private static final EELFLogger logger = EELFManager.getInstance().getLogger(BlueprintParser.class); + + private BlueprintParser() { + + } /** * Get all micro services from blueprint. * * @param blueprintString the blueprint in a String * @return A set of MircoService + * @throws BlueprintParserException In case of issues with the parsing */ - public Set getMicroServices(String blueprintString) { - Set microServices = new HashSet<>(); + public static Set getMicroServices(String blueprintString) throws BlueprintParserException { + Set microServices = new HashSet<>(); JsonObject blueprintJson = BlueprintParser.convertToJson(blueprintString); JsonObject nodeTemplateList = blueprintJson.get(NODE_TEMPLATES).getAsJsonObject(); JsonObject inputList = blueprintJson.get(INPUT).getAsJsonObject(); for (Entry entry : nodeTemplateList.entrySet()) { JsonObject nodeTemplate = entry.getValue().getAsJsonObject(); - if (nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) { - MicroService microService = getNodeRepresentation(entry, nodeTemplateList, inputList); - microServices.add(microService); + if (!nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES_POLICY) + && nodeTemplate.get(TYPE).getAsString().contains(DCAE_NODES)) { + BlueprintMicroService microService = getNodeRepresentation(entry, nodeTemplateList, inputList); + if (!microService.getModelType().isBlank()) { + microServices.add(microService); + } else { + logger.warn("Microservice " + microService.getName() + + " will NOT be used by CLAMP as the model type is not defined or has not been found"); + } } } - microServices.removeIf(ms -> TCA_POLICY.equals(ms.getName())); + logger.debug("Those microservices have been found in the blueprint:" + microServices); return microServices; } /** - * Does a fallback to TCA or Holmes. + * Does a fallback to TCA. * - * @param blueprintString the blueprint in a String * @return The list of microservices */ - public List fallbackToOneMicroService(String blueprintString) { - JsonObject jsonObject = BlueprintParser.convertToJson(blueprintString); - JsonObject results = jsonObject.get(NODE_TEMPLATES).getAsJsonObject(); - String theBiggestMicroServiceContent = ""; - String theBiggestMicroServiceKey = ""; - for (Entry entry : results.entrySet()) { - String msAsString = entry.getValue().toString(); - int len = msAsString.length(); - if (len > theBiggestMicroServiceContent.length()) { - theBiggestMicroServiceContent = msAsString; - theBiggestMicroServiceKey = entry.getKey(); - } - } - String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA; - return Collections - .singletonList(new MicroService(msName, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", "")); + public static List fallbackToOneMicroService() { + return Collections.singletonList( + new BlueprintMicroService(TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", DEFAULT_VERSION)); } - String getName(Entry entry) { + static String getName(Entry entry) { String microServiceYamlName = entry.getKey(); JsonObject ob = entry.getValue().getAsJsonObject(); if (ob.has(PROPERTIES)) { @@ -119,7 +119,7 @@ public class BlueprintParser { return microServiceYamlName; } - String getInput(Entry entry) { + static String getInput(Entry entry) { JsonObject ob = entry.getValue().getAsJsonObject(); if (ob.has(RELATIONSHIPS)) { JsonArray relationships = ob.getAsJsonArray(RELATIONSHIPS); @@ -133,51 +133,81 @@ public class BlueprintParser { return ""; } - String findModelTypeInTargetArray(JsonArray jsonArray, JsonObject nodeTemplateList, JsonObject inputList) { - for (JsonElement elem : jsonArray) { - String modelType = getModelType( - new AbstractMap.SimpleEntry(elem.getAsJsonObject().get(TARGET).getAsString(), - nodeTemplateList.get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()), - nodeTemplateList, inputList); - if (!modelType.isEmpty()) { - return modelType; + static String findPropertyInRelationshipsArray(String propertyName, JsonArray relationshipsArray, + JsonObject blueprintNodeTemplateList, JsonObject blueprintInputList) throws BlueprintParserException { + for (JsonElement elem : relationshipsArray) { + if (blueprintNodeTemplateList.get(elem.getAsJsonObject().get(TARGET).getAsString()) == null) { + throw new BlueprintParserException( + "The Target mentioned in the blueprint is not a known entry in the blueprint: " + + elem.getAsJsonObject().get(TARGET).getAsString()); + } else { + String property = getPropertyValue(propertyName, + new AbstractMap.SimpleEntry( + elem.getAsJsonObject().get(TARGET).getAsString(), blueprintNodeTemplateList + .get(elem.getAsJsonObject().get(TARGET).getAsString()).getAsJsonObject()), + blueprintNodeTemplateList, blueprintInputList); + if (!property.isEmpty()) { + return property; + } } } return ""; } - String getModelType(Entry entry, JsonObject nodeTemplateList, JsonObject inputList) { - JsonObject ob = entry.getValue().getAsJsonObject(); + static String getDirectOrInputPropertyValue(String propertyName, JsonObject blueprintInputList, + JsonObject nodeTemplateContent) { + JsonObject properties = nodeTemplateContent.get(PROPERTIES).getAsJsonObject(); + if (properties.has(propertyName)) { + if (properties.get(propertyName).isJsonObject()) { + // it's a blueprint parameter + return blueprintInputList + .get(properties.get(propertyName).getAsJsonObject().get(GET_INPUT).getAsString()) + .getAsJsonObject().get("default").getAsString(); + } else { + // It's a direct value + return properties.get(propertyName).getAsString(); + } + } + return ""; + } + + static String getPropertyValue(String propertyName, Entry nodeTemplateEntry, + JsonObject blueprintNodeTemplateList, JsonObject blueprintIputList) throws BlueprintParserException { + JsonObject nodeTemplateContent = nodeTemplateEntry.getValue().getAsJsonObject(); // Search first in this node template - if (ob.has(PROPERTIES)) { - JsonObject properties = ob.get(PROPERTIES).getAsJsonObject(); - if (properties.has(POLICY_MODELID)) { - if (properties.get(POLICY_MODELID).isJsonObject()) { - // it's a blueprint parameter - return inputList.get(properties.get(POLICY_MODELID).getAsJsonObject().get(GET_INPUT).getAsString()) - .getAsJsonObject().get("default").getAsString(); - } else { - // It's a direct value - return properties.get(POLICY_MODELID).getAsString(); - } + if (nodeTemplateContent.has(PROPERTIES)) { + String propValue = getDirectOrInputPropertyValue(propertyName, blueprintIputList, nodeTemplateContent); + if (!propValue.isBlank()) { + return propValue; } } // Or it's may be defined in a relationship - if (ob.has(RELATIONSHIPS)) { - return findModelTypeInTargetArray(ob.get(RELATIONSHIPS).getAsJsonArray(), nodeTemplateList, inputList); + if (nodeTemplateContent.has(RELATIONSHIPS)) { + return findPropertyInRelationshipsArray(propertyName, + nodeTemplateContent.get(RELATIONSHIPS).getAsJsonArray(), blueprintNodeTemplateList, + blueprintIputList); } return ""; } - MicroService getNodeRepresentation(Entry entry, JsonObject nodeTemplateList, - JsonObject inputList) { - String name = getName(entry); - String getInputFrom = getInput(entry); - String modelType = getModelType(entry, nodeTemplateList, inputList); - return new MicroService(name, modelType, getInputFrom, ""); + static BlueprintMicroService getNodeRepresentation(Entry nodeTemplateEntry, + JsonObject blueprintNodeTemplateList, JsonObject blueprintInputList) throws BlueprintParserException { + String modelIdFound = getPropertyValue(POLICY_MODEL_ID, nodeTemplateEntry, blueprintNodeTemplateList, + blueprintInputList); + String versionFound = getPropertyValue(POLICY_MODEL_VERSION, nodeTemplateEntry, blueprintNodeTemplateList, + blueprintInputList); + if (modelIdFound.isBlank()) { + logger.warn("policy_model_id is not defined for the node template:" + nodeTemplateEntry.getKey()); + } + if (versionFound.isBlank()) { + logger.warn("policy_model_version is not defined (setting it to a default value) for the node template:" + + nodeTemplateEntry.getKey()); + } + return new BlueprintMicroService(getName(nodeTemplateEntry), modelIdFound, getInput(nodeTemplateEntry), + !versionFound.isBlank() ? versionFound : DEFAULT_VERSION); } - private String getTarget(JsonObject elementObject) { + private static String getTarget(JsonObject elementObject) { if (elementObject.has(TYPE) && elementObject.has(TARGET) && elementObject.get(TYPE).getAsString().equals(CLAMP_NODE_RELATIONSHIPS_GETS_INPUT_FROM)) { return elementObject.get(TARGET).getAsString(); @@ -186,10 +216,7 @@ public class BlueprintParser { } private static JsonObject convertToJson(String yamlString) { - Yaml yaml = new Yaml(); - Map map = yaml.load(yamlString); - - JSONObject jsonObject = new JSONObject(map); - return new Gson().fromJson(jsonObject.toString(), JsonObject.class); + Map map = new Yaml().load(yamlString); + return new Gson().fromJson(new JSONObject(map).toString(), JsonObject.class); } } diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java index 9e76cc93..2bd259c2 100644 --- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java +++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/ChainGenerator.java @@ -42,11 +42,11 @@ public class ChainGenerator { * @param input A set of microservices * @return The list of microservice chained */ - public List getChainOfMicroServices(Set input) { - LinkedList returnList = new LinkedList<>(); + public List getChainOfMicroServices(Set input) { + LinkedList returnList = new LinkedList<>(); if (preValidate(input)) { - LinkedList theList = new LinkedList<>(); - for (MicroService ms : input) { + LinkedList theList = new LinkedList<>(); + for (BlueprintMicroService ms : input) { insertNodeTemplateIntoChain(ms, theList); } if (postValidate(theList)) { @@ -56,16 +56,16 @@ public class ChainGenerator { return returnList; } - private boolean preValidate(Set input) { - List noInputs = input.stream().filter(ms -> "".equals(ms.getInputFrom())) + private boolean preValidate(Set input) { + List noInputs = input.stream().filter(ms -> "".equals(ms.getInputFrom())) .collect(Collectors.toList()); return noInputs.size() == 1; } - private boolean postValidate(LinkedList microServices) { + private boolean postValidate(LinkedList microServices) { for (int i = 1; i < microServices.size() - 1; i++) { - MicroService prev = microServices.get(i - 1); - MicroService current = microServices.get(i); + BlueprintMicroService prev = microServices.get(i - 1); + BlueprintMicroService current = microServices.get(i); if (!current.getInputFrom().equals(prev.getName())) { return false; } @@ -73,11 +73,11 @@ public class ChainGenerator { return true; } - private void insertNodeTemplateIntoChain(MicroService microServicetoInsert, - LinkedList chainOfMicroServices) { + private void insertNodeTemplateIntoChain(BlueprintMicroService microServicetoInsert, + LinkedList chainOfMicroServices) { int insertIndex = 0; for (int i = 0; i < chainOfMicroServices.size(); i++) { - MicroService current = chainOfMicroServices.get(i); + BlueprintMicroService current = chainOfMicroServices.get(i); if (microServicetoInsert.getName().equals(current.getInputFrom())) { insertIndex = i; break; diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java index 8ded0cb8..6ce89873 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java @@ -28,12 +28,12 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import org.onap.clamp.clds.sdc.controller.installer.MicroService; +import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; public class ClampGraphBuilder { private String policy; private String collector; - private List microServices = new ArrayList<>(); + private List microServices = new ArrayList<>(); private final Painter painter; public ClampGraphBuilder(Painter painter) { @@ -50,12 +50,12 @@ public class ClampGraphBuilder { return this; } - public ClampGraphBuilder addMicroService(MicroService ms) { + public ClampGraphBuilder addMicroService(BlueprintMicroService ms) { microServices.add(ms); return this; } - public ClampGraphBuilder addAllMicroServices(List msList) { + public ClampGraphBuilder addAllMicroServices(List msList) { microServices.addAll(msList); return this; } diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java index af6caf93..d96c9e53 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java @@ -31,7 +31,7 @@ import java.awt.RenderingHints; import java.util.List; import org.apache.batik.svggen.SVGGraphics2D; -import org.onap.clamp.clds.sdc.controller.installer.MicroService; +import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; public class Painter { private final int canvasSize; @@ -57,7 +57,7 @@ public class Painter { this.canvasSize = DEFALUT_CANVAS_SIZE; } - DocumentBuilder doPaint(String collector, List microServices, String policy) { + DocumentBuilder doPaint(String collector, List microServices, String policy) { int numOfRectangles = 2 + microServices.size(); int numOfArrows = numOfRectangles + 1; int baseLength = (canvasSize - 2 * CIRCLE_RADIUS) / (numOfArrows + numOfRectangles); @@ -76,12 +76,12 @@ public class Painter { return ib.getDocumentBuilder(); } - private void doTheActualDrawing(String collector, List microServices, String policy, + private void doTheActualDrawing(String collector, List microServices, String policy, ImageBuilder ib) { ib.circle("start-circle", SLIM_LINE).arrow().rectangle(collector, RectTypes.COLECTOR, collector); - for (MicroService ms : microServices) { - ib.arrow().rectangle(ms.getMappedNameJpa(), RectTypes.MICROSERVICE, ms.getName()); + for (BlueprintMicroService ms : microServices) { + ib.arrow().rectangle(ms.getModelType(), RectTypes.MICROSERVICE, ms.getName()); } ib.arrow().rectangle(policy, RectTypes.POLICY, policy).arrow().circle("stop-circle", THICK_LINE); diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java index ae0c1729..251f4886 100644 --- a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java @@ -27,7 +27,7 @@ package org.onap.clamp.clds.util.drawing; import java.util.List; import org.apache.batik.svggen.SVGGraphics2D; -import org.onap.clamp.clds.sdc.controller.installer.MicroService; +import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; import org.onap.clamp.clds.util.XmlTools; import org.springframework.stereotype.Component; import org.w3c.dom.Document; @@ -40,7 +40,7 @@ public class SvgFacade { * @param microServicesChain THe chain of microservices * @return A String containing the SVG */ - public String getSvgImage(List microServicesChain) { + public String getSvgImage(List microServicesChain) { SVGGraphics2D svgGraphics2D = new SVGGraphics2D(XmlTools.createEmptySvgDocument()); Document document = XmlTools.createEmptySvgDocument(); DocumentBuilder dp = new DocumentBuilder(document, svgGraphics2D.getDOMFactory()); diff --git a/src/main/java/org/onap/clamp/loop/CsarInstaller.java b/src/main/java/org/onap/clamp/loop/CsarInstaller.java index 013d3419..022b0e28 100644 --- a/src/main/java/org/onap/clamp/loop/CsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/CsarInstaller.java @@ -33,13 +33,15 @@ import java.util.Map.Entry; import org.json.simple.parser.ParseException; import org.onap.clamp.clds.client.DcaeInventoryServices; +import org.onap.clamp.clds.client.PolicyEngineServices; +import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse; import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; +import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; import org.onap.clamp.clds.sdc.controller.installer.BlueprintParser; import org.onap.clamp.clds.sdc.controller.installer.ChainGenerator; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; -import org.onap.clamp.clds.sdc.controller.installer.MicroService; import org.onap.clamp.clds.util.drawing.SvgFacade; import org.onap.clamp.loop.service.CsarServiceInstaller; import org.onap.clamp.loop.service.Service; @@ -47,6 +49,8 @@ import org.onap.clamp.loop.template.LoopElementModel; import org.onap.clamp.loop.template.LoopTemplate; import org.onap.clamp.loop.template.LoopTemplatesRepository; import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelId; +import org.onap.clamp.loop.template.PolicyModelsRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; @@ -61,31 +65,27 @@ import org.springframework.stereotype.Component; public class CsarInstaller { private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarInstaller.class); - public static final String CONTROL_NAME_PREFIX = "ClosedLoop-"; - public static final String GET_INPUT_BLUEPRINT_PARAM = "get_input"; - // This will be used later as the policy scope - public static final String MODEL_NAME_PREFIX = "Loop_"; @Autowired - LoopsRepository loopRepository; + private PolicyModelsRepository policyModelsRepository; @Autowired - LoopTemplatesRepository loopTemplatesRepository; + private LoopTemplatesRepository loopTemplatesRepository; @Autowired - BlueprintParser blueprintParser; + private ChainGenerator chainGenerator; @Autowired - ChainGenerator chainGenerator; + private DcaeInventoryServices dcaeInventoryService; @Autowired - DcaeInventoryServices dcaeInventoryService; + private SvgFacade svgFacade; @Autowired - private SvgFacade svgFacade; + private CsarServiceInstaller csarServiceInstaller; @Autowired - CsarServiceInstaller csarServiceInstaller; + private PolicyEngineServices policyEngineServices; /** * Verify whether Csar is deployed. @@ -113,8 +113,11 @@ public class CsarInstaller { * @param csar The Csar Handler * @throws SdcArtifactInstallerException The SdcArtifactInstallerException * @throws InterruptedException The InterruptedException + * @throws BlueprintParserException In case of issues with the blueprint + * parsing */ - public void installTheCsar(CsarHandler csar) throws SdcArtifactInstallerException, InterruptedException { + public void installTheCsar(CsarHandler csar) + throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException { logger.info("Installing the CSAR " + csar.getFilePath()); installTheLoopTemplates(csar, csarServiceInstaller.installTheService(csar)); logger.info("Successfully installed the CSAR " + csar.getFilePath()); @@ -127,9 +130,11 @@ public class CsarInstaller { * @param service The service object that is related to the loop * @throws SdcArtifactInstallerException The SdcArtifactInstallerException * @throws InterruptedException The InterruptedException + * @throws BlueprintParserException In case of issues with the blueprint + * parsing */ public void installTheLoopTemplates(CsarHandler csar, Service service) - throws SdcArtifactInstallerException, InterruptedException { + throws SdcArtifactInstallerException, InterruptedException, BlueprintParserException { try { logger.info("Installing the Loops"); for (Entry blueprint : csar.getMapOfBlueprints().entrySet()) { @@ -145,20 +150,20 @@ public class CsarInstaller { } private LoopTemplate createLoopTemplateFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact, - Service service) throws IOException, ParseException, InterruptedException { + Service service) throws IOException, ParseException, InterruptedException, BlueprintParserException { LoopTemplate newLoopTemplate = new LoopTemplate(); newLoopTemplate.setBlueprint(blueprintArtifact.getDcaeBlueprint()); newLoopTemplate.setName(LoopTemplate.generateLoopTemplateName(csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(), blueprintArtifact.getResourceAttached().getResourceInstanceName(), blueprintArtifact.getBlueprintArtifactName())); - List microServicesChain = chainGenerator - .getChainOfMicroServices(blueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())); + List microServicesChain = chainGenerator + .getChainOfMicroServices(BlueprintParser.getMicroServices(blueprintArtifact.getDcaeBlueprint())); if (microServicesChain.isEmpty()) { - microServicesChain = blueprintParser.fallbackToOneMicroService(blueprintArtifact.getDcaeBlueprint()); + microServicesChain = BlueprintParser.fallbackToOneMicroService(); } newLoopTemplate.setModelService(service); - newLoopTemplate.addLoopElementModels(createMicroServiceModels(microServicesChain, csar, blueprintArtifact)); + newLoopTemplate.addLoopElementModels(createMicroServiceModels(microServicesChain)); newLoopTemplate.setMaximumInstancesAllowed(0); newLoopTemplate.setSvgRepresentation(svgFacade.getSvgImage(microServicesChain)); DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact); @@ -166,14 +171,14 @@ public class CsarInstaller { return newLoopTemplate; } - private HashSet createMicroServiceModels(List microServicesChain, CsarHandler csar, - BlueprintArtifact blueprintArtifact) throws IOException { + private HashSet createMicroServiceModels(List microServicesChain) + throws InterruptedException { HashSet newSet = new HashSet<>(); - for (MicroService microService : microServicesChain) { + for (BlueprintMicroService microService : microServicesChain) { LoopElementModel loopElementModel = new LoopElementModel(microService.getModelType(), "CONFIG_POLICY", - blueprintArtifact.getDcaeBlueprint()); + null); newSet.add(loopElementModel); - loopElementModel.addPolicyModel(createPolicyModel(microService, csar)); + loopElementModel.addPolicyModel(getPolicyModel(microService)); } return newSet; } @@ -183,14 +188,20 @@ public class CsarInstaller { return policyNameArray[policyNameArray.length - 1]; } - private PolicyModel createPolicyModel(MicroService microService, CsarHandler csar) throws IOException { - return new PolicyModel(microService.getModelType(), csar.getPolicyModelYaml().orElse(""), "1.0", - createPolicyAcronym(microService.getModelType())); + private PolicyModel createPolicyModel(BlueprintMicroService microService) throws InterruptedException { + return new PolicyModel(microService.getModelType(), + policyEngineServices.downloadOnePolicy(microService.getModelType(), microService.getModelVersion()), + microService.getModelVersion(), createPolicyAcronym(microService.getModelType())); + } + + private PolicyModel getPolicyModel(BlueprintMicroService microService) throws InterruptedException { + return policyModelsRepository + .findById(new PolicyModelId(microService.getModelType(), microService.getModelVersion())) + .orElse(createPolicyModel(microService)); } /** - * ll get the latest version of the artifact (version can be specified to DCAE - * call). + * Get the service blueprint Id in the Dcae inventory using the SDC UUID. * * @return The DcaeInventoryResponse object containing the dcae values */ diff --git a/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java index e3f05a01..0a0831bb 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java @@ -70,7 +70,7 @@ public class LoopElementModel extends AuditEntity implements Serializable { /** * Here we store the blueprint coming from DCAE. */ - @Column(columnDefinition = "MEDIUMTEXT", nullable = false, name = "blueprint_yaml") + @Column(columnDefinition = "MEDIUMTEXT", name = "blueprint_yaml") private String blueprint; /** diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java index 886e8c80..53539fcc 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java @@ -224,7 +224,13 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable @Override public int compareTo(PolicyModel arg0) { - // Reverse it, so that by default we have the latest - return SemanticVersioning.compare(arg0.getVersion(), this.version); + + if (this.getPolicyModelType().equals(arg0.getPolicyModelType())) { + // Reverse it, so that by default we have the latest in they are same model type + return SemanticVersioning.compare(arg0.getVersion(), this.version); + } else { + return this.getPolicyModelType().compareTo(arg0.getPolicyModelType()); + } + } } diff --git a/src/main/java/org/onap/clamp/policy/downloader/PolicyDownloader.java b/src/main/java/org/onap/clamp/policy/downloader/PolicyDownloader.java new file mode 100644 index 00000000..b712dc3f --- /dev/null +++ b/src/main/java/org/onap/clamp/policy/downloader/PolicyDownloader.java @@ -0,0 +1,61 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * 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============================================ + * =================================================================== + * + */ + +package org.onap.clamp.policy.downloader; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.apache.camel.CamelContext; +import org.onap.clamp.clds.client.DcaeInventoryServices; +import org.onap.clamp.clds.config.ClampProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +/** + * This class implements a periodic job that is done in the background to + * synchronize policy models available on the policy engine and the clamp + * database table PolicyModel. + */ +@Configuration +@Profile("clamp-policy-controller") +public class PolicyDownloader { + + protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class); + protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); + protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger(); + public static final String POLICY_RETRY_INTERVAL = "policy.retry.interval"; + public static final String POLICY_RETRY_LIMIT = "policy.retry.limit"; + + private final CamelContext camelContext; + + private final ClampProperties refProp; + + @Autowired + public PolicyDownloader(CamelContext camelContext, ClampProperties refProp) { + this.refProp = refProp; + this.camelContext = camelContext; + } + +} diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index d389b211..b9af1b47 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -73,7 +73,7 @@ clamp.config.keyFile=classpath:/clds/aaf/org.onap.clamp.keyfile server.servlet.context-path=/ #Modified engine-rest applicationpath -spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller-new,clamp-ssl-config +spring.profiles.active=clamp-default,clamp-default-user,clamp-sdc-controller,clamp-ssl-config spring.http.converters.preferred-json-mapper=gson #The max number of active threads in this pool @@ -160,26 +160,6 @@ clamp.config.policy.pap.url=http4://localhost:8085 clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 - -clamp.config.policy.clientKey=dGVzdA== -#DEVL for development -#TEST for Test environments -#PROD for prod environments -clamp.config.policy.policyEnvironment=TEST -# General Policy request properties -# -clamp.config.policy.onap.name=DCAE -clamp.config.policy.pdp.group=default -clamp.config.policy.ms.type=MicroService -clamp.config.policy.ms.policyNamePrefix=Config_MS_ -clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_ -clamp.config.policy.base.policyNamePrefix=Config_ -clamp.config.policy.op.type=BRMS_Param - -clamp.config.import.tosca.model=true -clamp.config.tosca.policyTypes=tca -clamp.config.tosca.filePath=/tmp/tosca-models - # TCA MicroService Policy request build properties # clamp.config.tca.policyid.prefix=DCAE.Config_ diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index b97d6436..e4568995 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -78,7 +78,7 @@ server.ssl.trust-store-password=enc:iDnPBBLq_EMidXlMa1FEuBR8TZzYxrCg66vq_XfLHdJ server.servlet.context-path=/ #Modified engine-rest applicationpath -spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller-new,clamp-ssl-config +spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller,clamp-ssl-config spring.http.converters.preferred-json-mapper=gson #The max number of active threads in this pool @@ -163,34 +163,6 @@ clamp.config.policy.pap.url=http4://policy.api.simpledemo.onap.org:6969 clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 -clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 -clamp.config.policy.pdpUrl2=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 -clamp.config.policy.papUrl=http://policy.api.simpledemo.onap.org:8081/pap/ , testpap, alpha123 -clamp.config.policy.notificationType=websocket -clamp.config.policy.notificationUebServers=localhost -clamp.config.policy.notificationTopic=PDPD-CONFIGURATION -clamp.config.policy.clientId=python -# base64 encoding - -clamp.config.policy.clientKey=dGVzdA== -#DEVL for development -#TEST for Test environments -#PROD for prod environments -clamp.config.policy.policyEnvironment=TEST -# General Policy request properties -# -clamp.config.policy.onap.name=DCAE -clamp.config.policy.pdp.group=default -clamp.config.policy.ms.type=MicroService -clamp.config.policy.ms.policyNamePrefix=Config_MS_ -clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_ -clamp.config.policy.base.policyNamePrefix=Config_ -clamp.config.policy.op.type=BRMS_Param - -clamp.config.import.tosca.model=true -clamp.config.tosca.policyTypes=tca -clamp.config.tosca.filePath=/tmp/tosca-models - # TCA MicroService Policy request build properties # clamp.config.tca.policyid.prefix=DCAE.Config_ diff --git a/src/main/resources/clds/camel/routes/policy-flows.xml b/src/main/resources/clds/camel/routes/policy-flows.xml index 97416a6c..ce24b27c 100644 --- a/src/main/resources/clds/camel/routes/policy-flows.xml +++ b/src/main/resources/clds/camel/routes/policy-flows.xml @@ -1,520 +1,587 @@ - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - ${exchangeProperty[policyComponent].computeState(*)} - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET - Policy status - - - - POLICY - - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET Policy deployment - status - - - - POLICY + + + + false - - - - - - - - - - - ${exchangeProperty[microServicePolicy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[microServicePolicy].getName()} creation - status - + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + false - - POLICY + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + ${exchangeProperty[policyComponent].computeState(*)} - - - - + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET + Policy status + + + + POLICY + + + + + - - - - - ${exchangeProperty[microServicePolicy].getName()} removal - status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET Policy deployment + status + + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + ${exchangeProperty[microServicePolicy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[microServicePolicy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[operationalPolicy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[operationalPolicy].getName()} creation - status - - - - POLICY - - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[operationalPolicy].getName()} removal - status - - - - POLICY - - - - - + + + + + ${exchangeProperty[microServicePolicy].getName()} removal + status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[guardPolicy].getValue()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[guardPolicy].getKey()} creation status - - - - POLICY - - - - - + + + + + + + ${exchangeProperty[operationalPolicy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[operationalPolicy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[operationalPolicy].getName()} removal + status + + + + POLICY + + + + + - - - - - ${exchangeProperty[guardPolicy].getKey()} removal status - - - - POLICY - - - - - + + + + + + + ${exchangeProperty[guardPolicy].getValue()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[guardPolicy].getKey()} creation status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group push ALL status - - - POLICY - - - - - + + + + + ${exchangeProperty[guardPolicy].getKey()} removal status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])} - - - ${body} - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - ${exchangeProperty[policyName]} PDP Group removal status - - - - POLICY - - - - - java.lang.Exception - - false - - - PDP Group removal, Error reported: ${exception} - - - POLICY - - - - - - - - - + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + PDP Group push ALL status + + + POLICY + + + + + + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])} + + + ${body} + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + ${exchangeProperty[policyName]} PDP Group removal status + + + + POLICY + + + + + java.lang.Exception + + false + + + PDP Group removal, Error reported: ${exception} + + + POLICY + + + + + + + + + \ No newline at end of file diff --git a/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java deleted file mode 100644 index fd20e360..00000000 --- a/src/test/java/org/onap/clamp/clds/it/PolicyConfigurationItCase.java +++ /dev/null @@ -1,71 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2017-2018 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.clamp.clds.it; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.clamp.clds.config.PolicyConfiguration; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -/** - * Test Config Policy read from application.properties. - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class PolicyConfigurationItCase { - - @Autowired - private PolicyConfiguration policyConfiguration; - - @Test - public void testPolicyConfiguration() { - assertNotNull(policyConfiguration.getPdpUrl1()); - assertNotNull(policyConfiguration.getPdpUrl2()); - assertNotNull(policyConfiguration.getPapUrl()); - assertNotNull(policyConfiguration.getPolicyEnvironment()); - assertNotNull(policyConfiguration.getClientId()); - assertNotNull(policyConfiguration.getClientKey()); - assertNotNull(policyConfiguration.getNotificationType()); - assertNotNull(policyConfiguration.getNotificationUebServers()); - assertEquals(8, policyConfiguration.getProperties().size()); - assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PDP_URL1)) - .contains("/pdp/ , testpdp, alpha123")); - assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PDP_URL2)) - .contains("/pdp/ , testpdp, alpha123")); - assertTrue(((String) policyConfiguration.getProperties().get(PolicyConfiguration.PAP_URL)) - .contains("/pap/ , testpap, alpha123")); - assertEquals("websocket", policyConfiguration.getProperties().get(PolicyConfiguration.NOTIFICATION_TYPE)); - assertEquals("localhost", - policyConfiguration.getProperties().get(PolicyConfiguration.NOTIFICATION_UEB_SERVERS)); - assertEquals("python", policyConfiguration.getProperties().get(PolicyConfiguration.CLIENT_ID)); - assertEquals("dGVzdA==", policyConfiguration.getProperties().get(PolicyConfiguration.CLIENT_KEY)); - assertEquals("DEVL", policyConfiguration.getProperties().get(PolicyConfiguration.ENVIRONMENT)); - } -} diff --git a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java index d3404203..c25415ec 100644 --- a/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java @@ -28,10 +28,9 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; - import com.google.gson.JsonElement; + import java.io.IOException; -import java.util.List; import org.junit.Test; import org.junit.runner.RunWith; @@ -55,19 +54,15 @@ public class CldsReferencePropertiesItCase { */ @Test public void testGetStringValue() { - assertEquals("DCAE", refProp.getStringValue("policy.onap.name")); - assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", "")); - assertEquals("Config_MS_", refProp.getStringValue("policy.ms.policyNamePrefix", "testos")); - assertEquals("Config_MS_", refProp.getStringValue("policy.ms", "policyNamePrefix")); - assertNull(refProp.getStringValue("does.not.exist")); + assertEquals("healthcheck", refProp.getStringValue("policy.api.userName")); } @Test public void shouldReturnJsonFromTemplate() throws IOException { - //when + // when JsonElement root = refProp.getJsonTemplate("ui.location.default"); - //then + // then assertNotNull(root); assertTrue(root.isJsonObject()); assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString()); @@ -75,10 +70,10 @@ public class CldsReferencePropertiesItCase { @Test public void shouldReturnJsonFromTemplate_2() throws IOException { - //when + // when JsonElement root = refProp.getJsonTemplate("ui.location", "default"); - //then + // then assertNotNull(root); assertTrue(root.isJsonObject()); assertEquals("Data Center 1", root.getAsJsonObject().get("DC1").getAsString()); @@ -86,18 +81,17 @@ public class CldsReferencePropertiesItCase { @Test public void shouldReturnNullIfPropertyNotFound() throws IOException { - //when + // when JsonElement root = refProp.getJsonTemplate("ui.location", ""); - //then + // then assertNull(root); } /** * Test getting prop value as a JSON Node / template. * - * @throws IOException - * when JSON parsing fails + * @throws IOException when JSON parsing fails */ @Test public void testGetFileContent() throws IOException { @@ -109,13 +103,4 @@ public class CldsReferencePropertiesItCase { content = refProp.getFileContent("ui.location", "default"); assertEquals(location, content); } - - @Test - public void testGetStringList() { - List profileList = refProp.getStringList("policy.pdpUrl1", ","); - assertEquals(3, profileList.size()); - assertTrue(profileList.get(0).trim().startsWith("http://localhost:")); - assertEquals("testpdp", profileList.get(1).trim()); - assertEquals("alpha123", profileList.get(2).trim()); - } } diff --git a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java index 7c520a25..7ef73453 100644 --- a/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java +++ b/src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java @@ -45,7 +45,7 @@ import org.springframework.test.util.ReflectionTestUtils; */ @RunWith(SpringRunner.class) @SpringBootTest -@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new") +@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller") public class SdcControllersConfigurationItCase { @Autowired diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java index e48bfc44..9efb6898 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParserTest.java @@ -44,6 +44,7 @@ import org.json.JSONObject; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; import org.onap.clamp.clds.util.ResourceFileUtil; import org.yaml.snakeyaml.Yaml; @@ -53,17 +54,16 @@ public class BlueprintParserTest { private static final String SECOND_APPP = "second_app"; private static final String THIRD_APPP = "third_app"; private static final String MODEL_TYPE1 = "type1"; - private static final String MODEL_TYPE2 = "type2"; - private static final String MODEL_TYPE3 = "type3"; + private static final String MODEL_TYPE_TCA = "onap.policies.monitoring.cdap.tca.hi.lo.app"; + private static final String VERSION = "1.0.0"; private static String microServiceTheWholeBlueprintValid; - private static String microServiceBlueprintOldStyleTCA; - private static String microServiceBlueprintOldStyleHolmes; private static String newMicroServiceBlueprint; - private static JsonObject jsonObjectBlueprintValid; + private static JsonObject jsonObjectBlueprintInvalid; private static JsonObject jsonObjectBlueprintWithoutName; private static JsonObject jsonObjectBlueprintWithoutProperties; private static JsonObject jsonObjectBlueprintWithoutRelationships; + private static JsonObject jsonObjectBlueprintValidWithVersion; /** * Method to load Blueprints before all test. @@ -74,20 +74,21 @@ public class BlueprintParserTest { public static void loadBlueprints() throws IOException { microServiceTheWholeBlueprintValid = ResourceFileUtil .getResourceAsString("clds/blueprint-with-microservice-chain.yaml"); - microServiceBlueprintOldStyleTCA = ResourceFileUtil.getResourceAsString("clds/tca-old-style-ms.yaml"); + newMicroServiceBlueprint = ResourceFileUtil.getResourceAsString("clds/new-microservice.yaml"); - microServiceBlueprintOldStyleHolmes = ResourceFileUtil.getResourceAsString("clds/holmes-old-style-ms.yaml"); - String microServiceBlueprintValid = ResourceFileUtil - .getResourceAsString("clds/single-microservice-fragment-valid.yaml"); + String microServiceBlueprintInvalid = ResourceFileUtil + .getResourceAsString("clds/single-microservice-fragment-invalid.yaml"); + jsonObjectBlueprintInvalid = yamlToJson(microServiceBlueprintInvalid); String microServiceBlueprintWithoutName = ResourceFileUtil .getResourceAsString("clds/single-microservice-fragment-without-name.yaml"); + jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName); String microServiceBlueprintWithoutProperties = ResourceFileUtil .getResourceAsString("clds/single-microservice-fragment-without-properties.yaml"); - - jsonObjectBlueprintValid = yamlToJson(microServiceBlueprintValid); - jsonObjectBlueprintWithoutName = yamlToJson(microServiceBlueprintWithoutName); jsonObjectBlueprintWithoutProperties = yamlToJson(microServiceBlueprintWithoutProperties); + String microServiceBlueprintValidWithVersion = ResourceFileUtil + .getResourceAsString("clds/single-microservice-fragment-valid-with-version.yaml"); + jsonObjectBlueprintValidWithVersion = yamlToJson(microServiceBlueprintValidWithVersion); String microServiceBlueprintWithoutRelationships = ResourceFileUtil .getResourceAsString("clds/single-microservice-fragment-without-relationships.yaml"); @@ -97,11 +98,11 @@ public class BlueprintParserTest { @Test public void getNameShouldReturnDefinedName() { - final JsonObject jsonObject = jsonObjectBlueprintValid; + final JsonObject jsonObject = jsonObjectBlueprintInvalid; String expectedName = jsonObject.get(jsonObject.keySet().iterator().next()).getAsJsonObject().get("properties") .getAsJsonObject().get("name").getAsString(); Entry entry = jsonObject.entrySet().iterator().next(); - String actualName = new BlueprintParser().getName(entry); + String actualName = BlueprintParser.getName(entry); Assert.assertEquals(expectedName, actualName); } @@ -112,7 +113,7 @@ public class BlueprintParserTest { String expectedName = jsonObject.keySet().iterator().next(); Entry entry = jsonObject.entrySet().iterator().next(); - String actualName = new BlueprintParser().getName(entry); + String actualName = BlueprintParser.getName(entry); Assert.assertEquals(expectedName, actualName); } @@ -123,18 +124,18 @@ public class BlueprintParserTest { String expectedName = jsonObject.keySet().iterator().next(); Entry entry = jsonObject.entrySet().iterator().next(); - String actualName = new BlueprintParser().getName(entry); + String actualName = BlueprintParser.getName(entry); Assert.assertEquals(expectedName, actualName); } @Test public void getInputShouldReturnInputWhenPresent() { - final JsonObject jsonObject = jsonObjectBlueprintValid; + final JsonObject jsonObject = jsonObjectBlueprintInvalid; String expected = FIRST_APPP; Entry entry = jsonObject.entrySet().iterator().next(); - String actual = new BlueprintParser().getInput(entry); + String actual = BlueprintParser.getInput(entry); Assert.assertEquals(expected, actual); } @@ -145,63 +146,56 @@ public class BlueprintParserTest { String expected = ""; Entry entry = jsonObject.entrySet().iterator().next(); - String actual = new BlueprintParser().getInput(entry); + String actual = BlueprintParser.getInput(entry); Assert.assertEquals(expected, actual); } - @Test - public void getNodeRepresentationFromCompleteYaml() { - final JsonObject jsonObject = jsonObjectBlueprintValid; - - MicroService expected = new MicroService(SECOND_APPP, MODEL_TYPE1, FIRST_APPP, ""); - Entry entry = jsonObject.entrySet().iterator().next(); - MicroService actual = new BlueprintParser().getNodeRepresentation(entry, jsonObject, null); - - Assert.assertEquals(expected, actual); + @Test(expected = BlueprintParserException.class) + public void getNodeRepresentationFromIncompleteYaml() throws BlueprintParserException { + BlueprintParser.getNodeRepresentation(jsonObjectBlueprintInvalid.entrySet().iterator().next(), + jsonObjectBlueprintInvalid, null); } @Test - public void getMicroServicesFromBlueprintTest() { - MicroService thirdApp = new MicroService(THIRD_APPP, MODEL_TYPE3, "", ""); - MicroService firstApp = new MicroService(FIRST_APPP, MODEL_TYPE1, THIRD_APPP, ""); - MicroService secondApp = new MicroService(SECOND_APPP, MODEL_TYPE2, FIRST_APPP, ""); + public void getNodeRepresentationFromCompleteYamlWithModelVersion() throws BlueprintParserException { + final JsonObject jsonObject = jsonObjectBlueprintValidWithVersion; - Set expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); - Set actual = new BlueprintParser().getMicroServices(microServiceTheWholeBlueprintValid); + BlueprintMicroService expected = new BlueprintMicroService(SECOND_APPP, MODEL_TYPE1, "", "10.0.0"); + Entry entry = jsonObject.entrySet().iterator().next(); + BlueprintMicroService actual = BlueprintParser.getNodeRepresentation(entry, jsonObject, null); Assert.assertEquals(expected, actual); } @Test + public void getMicroServicesFromBlueprintTest() throws BlueprintParserException { + BlueprintMicroService thirdApp = new BlueprintMicroService(THIRD_APPP, MODEL_TYPE_TCA, SECOND_APPP, VERSION); + BlueprintMicroService firstApp = new BlueprintMicroService(FIRST_APPP, MODEL_TYPE_TCA, "", VERSION); + BlueprintMicroService secondApp = new BlueprintMicroService(SECOND_APPP, MODEL_TYPE_TCA, FIRST_APPP, VERSION); - public void fallBackToOneMicroServiceTcaTest() { - MicroService tcaMs = new MicroService(BlueprintParser.TCA, "onap.policies.monitoring.cdap.tca.hi.lo.app", "", - ""); - List expected = Collections.singletonList(tcaMs); - List actual = new BlueprintParser().fallbackToOneMicroService(microServiceBlueprintOldStyleTCA); + Set expected = new HashSet<>(Arrays.asList(firstApp, secondApp, thirdApp)); + Set actual = BlueprintParser.getMicroServices(microServiceTheWholeBlueprintValid); Assert.assertEquals(expected, actual); } @Test - public void fallBackToOneMicroServiceHolmesTest() { - MicroService holmesMs = new MicroService(BlueprintParser.HOLMES, "onap.policies.monitoring.cdap.tca.hi.lo.app", - "", ""); - - List expected = Collections.singletonList(holmesMs); - List actual = new BlueprintParser() - .fallbackToOneMicroService(microServiceBlueprintOldStyleHolmes); + public void fallBackToOneMicroServiceTcaTest() { + BlueprintMicroService tcaMs = new BlueprintMicroService(BlueprintParser.TCA, + "onap.policies.monitoring.cdap.tca.hi.lo.app", "", VERSION); + List expected = Collections.singletonList(tcaMs); + List actual = BlueprintParser.fallbackToOneMicroService(); Assert.assertEquals(expected, actual); } @Test - public void newMicroServiceTest() { - List microServicesChain = new ChainGenerator() - .getChainOfMicroServices(new BlueprintParser().getMicroServices(newMicroServiceBlueprint)); + public void newMicroServiceTest() throws BlueprintParserException { + List microServicesChain = new ChainGenerator() + .getChainOfMicroServices(BlueprintParser.getMicroServices(newMicroServiceBlueprint)); if (microServicesChain.isEmpty()) { - microServicesChain = new BlueprintParser().fallbackToOneMicroService(newMicroServiceBlueprint); + microServicesChain = BlueprintParser.fallbackToOneMicroService(); } assertThat(microServicesChain.size()).isEqualTo(1); assertThat(microServicesChain.get(0).getName()).isEqualTo("pmsh"); diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java index 4b4563cd..83b3dda0 100644 --- a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java +++ b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/ChainGeneratorTest.java @@ -36,42 +36,43 @@ public class ChainGeneratorTest { private static final String SECOND_APPP = "second_app"; private static final String THIRD_APPP = "third_app"; private static final String FOURTH_APPP = "fourth_app"; + private static final String DEFAULT_VERSION = "1.0.0"; @Test public void getChainOfMicroServicesTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", THIRD_APPP, ""); + BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION); + BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", FIRST_APPP, DEFAULT_VERSION); + BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", SECOND_APPP, DEFAULT_VERSION); + BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", THIRD_APPP, DEFAULT_VERSION); - List expectedList = Arrays.asList(ms1, ms2, ms3, ms4); - Set inputSet = new HashSet<>(expectedList); + List expectedList = Arrays.asList(ms1, ms2, ms3, ms4); + Set inputSet = new HashSet<>(expectedList); - List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); + List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); Assert.assertEquals(expectedList, actualList); } @Test public void getChainOfMicroServicesTwiceNoInputTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", "", ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", SECOND_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); + BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION); + BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", "", DEFAULT_VERSION); + BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", SECOND_APPP, DEFAULT_VERSION); + BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", FIRST_APPP, DEFAULT_VERSION); - Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); - List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); + Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); + List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); Assert.assertTrue(actualList.isEmpty()); } @Test public void getChainOfMicroServicesBranchingTest() { - MicroService ms1 = new MicroService(FIRST_APPP, "", "", ""); - MicroService ms2 = new MicroService(SECOND_APPP, "", FIRST_APPP, ""); - MicroService ms3 = new MicroService(THIRD_APPP, "", FIRST_APPP, ""); - MicroService ms4 = new MicroService(FOURTH_APPP, "", FIRST_APPP, ""); + BlueprintMicroService ms1 = new BlueprintMicroService(FIRST_APPP, "", "", DEFAULT_VERSION); + BlueprintMicroService ms2 = new BlueprintMicroService(SECOND_APPP, "", FIRST_APPP, DEFAULT_VERSION); + BlueprintMicroService ms3 = new BlueprintMicroService(THIRD_APPP, "", FIRST_APPP, DEFAULT_VERSION); + BlueprintMicroService ms4 = new BlueprintMicroService(FOURTH_APPP, "", FIRST_APPP, DEFAULT_VERSION); - Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); - List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); + Set inputSet = new HashSet<>(Arrays.asList(ms1, ms2, ms3, ms4)); + List actualList = new ChainGenerator().getChainOfMicroServices(inputSet); Assert.assertTrue(actualList.isEmpty()); } } diff --git a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java index 1453d0ba..f6054d53 100644 --- a/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java +++ b/src/test/java/org/onap/clamp/clds/util/CryptoUtilsTest.java @@ -45,7 +45,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @RunWith(PowerMockRunner.class) -@PowerMockIgnore({ "javax.crypto.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*" }) +@PowerMockIgnore({ "javax.crypto.*", "com.sun.org.apache.xerces.*", "javax.xml.*", "org.xml.*", "javax.management.*" }) public class CryptoUtilsTest { private final String data = "This is a test string"; diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java index 269ad42e..65eb2696 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java @@ -39,7 +39,7 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.onap.clamp.clds.sdc.controller.installer.MicroService; +import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; @RunWith(MockitoJUnitRunner.class) public class ClampGraphBuilderTest { @@ -50,7 +50,7 @@ public class ClampGraphBuilderTest { private ArgumentCaptor collectorCaptor; @Captor - private ArgumentCaptor> microServicesCaptor; + private ArgumentCaptor> microServicesCaptor; @Captor private ArgumentCaptor policyCaptor; @@ -58,17 +58,17 @@ public class ClampGraphBuilderTest { @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); + BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0"); + BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0"); String policy = "OperationalPolicy"; - final List microServices = Arrays.asList(ms1, ms2); + final List microServices = Arrays.asList(ms1, ms2); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).policy(policy).build(); verify(mockPainter, times(1)).doPaint(collectorCaptor.capture(), microServicesCaptor.capture(), - policyCaptor.capture()); + policyCaptor.capture()); Assert.assertEquals(collector, collectorCaptor.getValue()); Assert.assertEquals(microServices, microServicesCaptor.getValue()); @@ -78,8 +78,8 @@ public class ClampGraphBuilderTest { @Test(expected = InvalidStateException.class) public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - MicroService ms1 = new MicroService("ms1", "", "", "ms1_jpa_id"); - MicroService ms2 = new MicroService("ms2", "", "", "ms2_jpa_id"); + BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0"); + BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0"); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index 70adf3ee..636684cd 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -44,6 +44,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mockito; import org.onap.clamp.clds.Application; +import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; import org.onap.clamp.clds.exception.sdc.controller.CsarHandlerException; import org.onap.clamp.clds.exception.sdc.controller.SdcArtifactInstallerException; import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; @@ -73,7 +74,7 @@ import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) -@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller-new") +@ActiveProfiles(profiles = "clamp-default,clamp-default-user,clamp-sdc-controller") public class CsarInstallerItCase { private static final String CSAR_ARTIFACT_NAME = "example/sdc/service_Vloadbalancerms_csar.csar"; @@ -180,7 +181,7 @@ public class CsarInstallerItCase { @Test @Transactional public void testIsCsarAlreadyDeployedTca() throws SdcArtifactInstallerException, SdcToscaParserException, - CsarHandlerException, IOException, InterruptedException { + CsarHandlerException, IOException, InterruptedException, BlueprintParserException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csarHandler = buildFakeCsarHandler(generatedName); assertThat(csarInstaller.isCsarAlreadyDeployed(csarHandler)).isFalse(); @@ -192,7 +193,7 @@ public class CsarInstallerItCase { @Transactional @Commit public void testInstallTheCsarTca() throws SdcArtifactInstallerException, SdcToscaParserException, - CsarHandlerException, IOException, JSONException, InterruptedException { + CsarHandlerException, IOException, JSONException, InterruptedException, BlueprintParserException { String generatedName = RandomStringUtils.randomAlphanumeric(5); CsarHandler csar = buildFakeCsarHandler(generatedName); csarInstaller.installTheCsar(csar); @@ -233,16 +234,9 @@ public class CsarInstallerItCase { assertThat(policyModelsRepository.findAll().size()).isEqualByComparingTo(1); assertThat(policyModelsRepository - .existsById(new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0"))).isTrue(); - } - - @Test(expected = SdcArtifactInstallerException.class) - @Transactional - public void shouldThrowSdcArtifactInstallerException() - throws SdcArtifactInstallerException, SdcToscaParserException, IOException, InterruptedException { - String generatedName = RandomStringUtils.randomAlphanumeric(5); - CsarHandler csarHandler = buildFakeCsarHandler(generatedName); - Mockito.when(csarHandler.getPolicyModelYaml()).thenThrow(IOException.class); - csarInstaller.installTheCsar(csarHandler); + .existsById(new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0"))).isTrue(); + assertThat(policyModelsRepository + .getOne((new PolicyModelId("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0"))) + .getPolicyModelTosca()).isNotBlank(); } } diff --git a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java index f8c1d866..ce1181d3 100644 --- a/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java +++ b/src/test/java/org/onap/clamp/loop/PolicyModelServiceItCase.java @@ -28,6 +28,7 @@ import static org.assertj.core.api.Assertions.assertThat; import java.util.List; import java.util.SortedSet; import java.util.TreeSet; +import java.util.stream.Collectors; import javax.transaction.Transactional; @@ -52,11 +53,13 @@ public class PolicyModelServiceItCase { @Autowired PolicyModelsRepository policyModelsRepository; - private static final String POLICY_MODEL_TYPE_1 = "org.onap.test"; + private static final String POLICY_MODEL_TYPE_1 = "org.onap.testos"; private static final String POLICY_MODEL_TYPE_1_VERSION_1 = "1.0.0"; - private static final String POLICY_MODEL_TYPE_2 = "org.onap.test2"; + private static final String POLICY_MODEL_TYPE_2 = "org.onap.testos2"; + private static final String POLICY_MODEL_TYPE_3 = "org.onap.testos3"; private static final String POLICY_MODEL_TYPE_2_VERSION_1 = "1.0.0"; + private static final String POLICY_MODEL_TYPE_3_VERSION_1 = "1.0.0"; private static final String POLICY_MODEL_TYPE_2_VERSION_2 = "2.0.0"; private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym, @@ -150,9 +153,17 @@ public class PolicyModelServiceItCase { PolicyModel policyModel2 = getPolicyModel(POLICY_MODEL_TYPE_2, "yaml", POLICY_MODEL_TYPE_2_VERSION_2, "TEST", "VARIANT", "user"); policyModelsService.saveOrUpdatePolicyModel(policyModel2); + PolicyModel policyModel3 = getPolicyModel(POLICY_MODEL_TYPE_3, "yaml", POLICY_MODEL_TYPE_3_VERSION_1, "TEST", + "VARIANT", "user"); + policyModelsService.saveOrUpdatePolicyModel(policyModel3); SortedSet sortedSet = new TreeSet<>(); policyModelsService.getAllPolicyModels().forEach(sortedSet::add); - assertThat(sortedSet).contains(policyModel2, policyModel1); + List listToCheck = sortedSet.stream().filter( + policy -> policy.equals(policyModel3) || policy.equals(policyModel2) || policy.equals(policyModel1)) + .collect(Collectors.toList()); + assertThat(listToCheck.get(0)).isEqualByComparingTo(policyModel2); + assertThat(listToCheck.get(1)).isEqualByComparingTo(policyModel1); + assertThat(listToCheck.get(2)).isEqualByComparingTo(policyModel3); } } diff --git a/src/test/resources/application.properties b/src/test/resources/application.properties index bbade742..17c42f56 100644 --- a/src/test/resources/application.properties +++ b/src/test/resources/application.properties @@ -116,7 +116,7 @@ spring.jpa.properties.hibernate.format_sql=true spring.jpa.properties.hibernate.use-new-id-generator-mappings=true # Whether to enable logging of SQL statements. -spring.jpa.show-sql=true +#spring.jpa.show-sql=true #Async Executor default Parameters async.core.pool.size=10 @@ -148,33 +148,6 @@ clamp.config.policy.pap.url=http4://localhost:${docker.http-cache.port.host} clamp.config.policy.pap.userName=healthcheck clamp.config.policy.pap.password=zb!XztG34 -clamp.config.policy.pdpUrl1=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123 -clamp.config.policy.pdpUrl2=http://localhost:${docker.http-cache.port.host}/pdp/ , testpdp, alpha123 -clamp.config.policy.papUrl=http://localhost:${docker.http-cache.port.host}/pap/ , testpap, alpha123 -clamp.config.policy.notificationType=websocket -clamp.config.policy.notificationUebServers=localhost -clamp.config.policy.notificationTopic= -clamp.config.policy.clientId=python -# base64 encoding -clamp.config.policy.clientKey=dGVzdA== -#DEVL for development -#TEST for Test environments -#PROD for prod environments -clamp.config.policy.policyEnvironment=DEVL -# General Policy request properties -# -clamp.config.policy.onap.name=DCAE -clamp.config.policy.pdp.group=default -clamp.config.policy.ms.type=MicroService -clamp.config.policy.ms.policyNamePrefix=Config_MS_ -clamp.config.policy.op.policyNamePrefix=Config_BRMS_Param_ -clamp.config.policy.base.policyNamePrefix=Config_ -clamp.config.policy.op.type=BRMS_Param - -clamp.config.import.tosca.model=false -clamp.config.tosca.policyTypes=tca -clamp.config.tosca.filePath=/tmp/tosca-models - # TCA MicroService Policy request build properties # clamp.config.tca.policyid.prefix=DCAE.Config_ diff --git a/src/test/resources/clds/OperationalPolicyRepresentationBuilderTest.java b/src/test/resources/clds/OperationalPolicyRepresentationBuilderTest.java deleted file mode 100644 index 904525be..00000000 --- a/src/test/resources/clds/OperationalPolicyRepresentationBuilderTest.java +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * 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.clamp.policy.operational; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; - -import java.io.IOException; - -import org.junit.Test; -import org.onap.clamp.clds.util.ResourceFileUtil; -import org.skyscreamer.jsonassert.JSONAssert; - -public class OperationalPolicyRepresentationBuilderTest { - - @Test - public void testOperationalPolicyPayloadConstruction() throws IOException { - JsonObject jsonModel = new GsonBuilder().create() - .fromJson(ResourceFileUtil.getResourceAsString("tosca/model-properties.json"), JsonObject.class); - - JsonObject jsonSchema = OperationalPolicyRepresentationBuilder.generateOperationalPolicySchema(jsonModel); - - assertThat(jsonSchema).isNotNull(); - - JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/operational-policy-json-schema.json"), - new GsonBuilder().create().toJson(jsonSchema), false); - } - -} diff --git a/src/test/resources/clds/blueprint-parser-mapping.json b/src/test/resources/clds/blueprint-parser-mapping.json deleted file mode 100644 index a22e9fcf..00000000 --- a/src/test/resources/clds/blueprint-parser-mapping.json +++ /dev/null @@ -1,18 +0,0 @@ -[ - { - "blueprintKey": "tca_", - "dcaeDeployable":"true", - "files": { - "bpmnXmlFilePath": "classpath:/clds/templates/bpmn/tca-template.xml", - "svgXmlFilePath": "classpath:/clds/templates/bpmn/tca-img.xml" - } - }, - { - "blueprintKey": "holmes_", - "dcaeDeployable":"false", - "files": { - "bpmnXmlFilePath": "classpath:/clds/templates/bpmn/holmes-template.xml", - "svgXmlFilePath": "classpath:/clds/templates/bpmn/holmes-img.xml" - } - } -] diff --git a/src/test/resources/clds/blueprint-with-microservice-chain.yaml b/src/test/resources/clds/blueprint-with-microservice-chain.yaml index fa2d7205..0e9e4bc8 100644 --- a/src/test/resources/clds/blueprint-with-microservice-chain.yaml +++ b/src/test/resources/clds/blueprint-with-microservice-chain.yaml @@ -1,98 +1,202 @@ tosca_definitions_version: cloudify_dsl_1_3 +description: > + This blueprint deploys/manages the TCA module as a Docker container + 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.4/k8splugin_types.yaml + - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.12/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 inputs: - first_app_docker_image: + aaiEnrichmentHost: + type: string + default: "aai.onap.svc.cluster.local" + aaiEnrichmentPort: + type: string + default: "8443" + enableAAIEnrichment: + type: string + default: true + dmaap_host: + type: string + default: message-router.onap.svc.cluster.local + dmaap_port: type: string - default: "image1" - second_app_docker_image: + default: "3904" + enableRedisCaching: type: string - default: "image2" - third_app_docker_image: + default: false + redisHosts: type: string - default: "image3" - dmaap_ip: + default: dcae-redis.onap.svc.cluster.local:6379 + tag_version: type: string - default: "message-router:3904" - dmaap_topic: + default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest" + consul_host: type: string - default: "/events/unauthenticated.DCAE_CL_OUTPUT" + default: consul-server.onap.svc.cluster.local + consul_port: + type: string + default: "8500" + cbs_host: + type: string + default: "config-binding-service.dcae.svc.cluster.local" + cbs_port: + type: string + default: "10000" policy_id: type: string - default: "policy_id" + default: "none" + external_port: + type: string + description: Kubernetes node port on which CDAPgui is exposed + default: "32012" + policy_model_id: + type: string + default: "onap.policies.monitoring.cdap.tca.hi.lo.app" + node_templates: - second_app: - type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + first_app: + type: dcae.nodes.ContainerizedServiceComponent properties: - service_component_type: dcaegen2-analytics-tca - service_component_name_override: second_app - image: { get_input: second_app_docker_image } - policy_id: - policy_model_id: "type2" - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - envs: - grpc_server.host: "first_app.onap" - dmaap_ip: {get_input: dmaap_ip} - dmapp_topic: {get_input: dmaap_topic} - policy_id: {get_input: policy_id} - ports: - - 8080:8080 + service_component_type: 'dcaegen2-analytics-tca' + application_config: {} + docker_config: {} + image: + get_input: tag_version + log_info: + log_directory: "/opt/app/TCAnalytics/logs" relationships: - - type: cloudify.relationships.connected_to - target: first_app + - target: tca_policy_1 + type: cloudify.relationships.depends_on + second_app: + type: dcae.nodes.ContainerizedServiceComponent + relationships: + - target: tca_policy_2 + type: cloudify.relationships.depends_on - type: clamp_node.relationships.gets_input_from target: first_app - first_app: - type: dcae.nodes.ContainerizedPlatformComponent properties: - name: first_app - dns_name: "first_app" - image: { get_input: first_app_docker_image } - container_port: 6565 - policy_id: - policy_model_id: "type1" + service_component_type: 'dcaegen2-analytics-tca' + application_config: {} + docker_config: {} + image: + get_input: tag_version + log_info: + log_directory: "/opt/app/TCAnalytics/logs" + application_config: + app_config: + appDescription: DCAE Analytics Threshold Crossing Alert Application + appName: dcae-tca + tcaAlertsAbatementTableName: TCAAlertsAbatementTable + tcaAlertsAbatementTableTTLSeconds: '1728000' + tcaSubscriberOutputStreamName: TCASubscriberOutputStream + tcaVESAlertsTableName: TCAVESAlertsTable + tcaVESAlertsTableTTLSeconds: '1728000' + tcaVESMessageStatusTableName: TCAVESMessageStatusTable + tcaVESMessageStatusTableTTLSeconds: '86400' + thresholdCalculatorFlowletInstances: '2' + app_preferences: + aaiEnrichmentHost: + get_input: aaiEnrichmentHost + aaiEnrichmentIgnoreSSLCertificateErrors: 'true' + aaiEnrichmentPortNumber: '8443' + aaiEnrichmentProtocol: https + aaiEnrichmentUserName: dcae@dcae.onap.org + aaiEnrichmentUserPassword: demo123456! + aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query + aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf + enableAAIEnrichment: + get_input: enableAAIEnrichment + enableRedisCaching: + get_input: enableRedisCaching + redisHosts: + get_input: redisHosts + enableAlertCEFFormat: 'false' + publisherContentType: application/json + publisherHostName: + get_input: dmaap_host + publisherHostPort: + get_input: dmaap_port + publisherMaxBatchSize: '1' + publisherMaxRecoveryQueueSize: '100000' + publisherPollingInterval: '20000' + publisherProtocol: http + publisherTopicName: unauthenticated.DCAE_CL_OUTPUT + subscriberConsumerGroup: OpenDCAE-c12 + subscriberConsumerId: c12 + subscriberContentType: application/json + subscriberHostName: + get_input: dmaap_host + subscriberHostPort: + get_input: dmaap_port + subscriberMessageLimit: '-1' + subscriberPollingInterval: '30000' + subscriberProtocol: http + subscriberTimeoutMS: '-1' + subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT + tca_policy: '' + service_component_type: dcaegen2-analytics_tca interfaces: cloudify.interfaces.lifecycle: start: inputs: envs: - dmaap_ip: {get_input: dmaap_ip} - dmapp_topic: {get_input: dmaap_topic} - policy_id: {get_input: policy_id} + DMAAPHOST: + { get_input: dmaap_host } + DMAAPPORT: + { get_input: dmaap_port } + DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT" + DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT" + AAIHOST: + { get_input: aaiEnrichmentHost } + AAIPORT: + { get_input: aaiEnrichmentPort } + CONSUL_HOST: + { get_input: consul_host } + CONSUL_PORT: + { get_input: consul_port } + CBS_HOST: + { get_input: cbs_host } + CBS_PORT: + { get_input: cbs_port } + CONFIG_BINDING_SERVICE: "config_binding_service" ports: - - 8081:8081 + - concat: ["11011:", { get_input: external_port }] + third_app: + type: dcae.nodes.ContainerizedServiceComponent + properties: + service_component_type: 'dcaegen2-analytics-tca' + application_config: {} + docker_config: {} + image: + get_input: tag_version + log_info: + log_directory: "/opt/app/TCAnalytics/logs" relationships: - - type: cloudify.relationships.connected_to - target: third_app + - target: tca_policy_3 + type: cloudify.relationships.depends_on - type: clamp_node.relationships.gets_input_from - target: third_app - - third_app: - type: dcae.nodes.ContainerizedPlatformComponent + target: second_app + tca_policy_1: + type: dcae.nodes.policy properties: - name: third_app - dns_name: "third_app" - image: { get_input: third_app_docker_image } - container_port: 443 policy_id: - policy_model_id: "type3" - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - envs: - dmaap_ip: {get_input: dmaap_ip} - dmapp_topic: {get_input: dmaap_topic} - policy_id: {get_input: policy_id} - ports: - - 8082:8082 - tca_policy: + get_input: policy_id + policy_model_id: + get_input: policy_model_id + tca_policy_2: type: dcae.nodes.policy properties: - policy_id: { get_input: policy_id } \ No newline at end of file + policy_id: + get_input: policy_id + policy_model_id: + get_input: policy_model_id + + tca_policy_3: + type: dcae.nodes.policy + properties: + policy_id: + get_input: policy_id + policy_model_id: + get_input: policy_model_id diff --git a/src/test/resources/clds/camel/rest/clamp-api-v2.xml b/src/test/resources/clds/camel/rest/clamp-api-v2.xml index cf99625e..a0a3eb10 100644 --- a/src/test/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/test/resources/clds/camel/rest/clamp-api-v2.xml @@ -237,6 +237,48 @@ + + + + + + + + + + + + + + java.lang.Exception + + false + + + + + + + + - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - false - - - - ${header.CamelHttpResponseCode} != 200 - - false - - - - - ${exchangeProperty[policyComponent].computeState(*)} - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET - Policy status - - - - POLICY - - - - - - - - - - - - - GET - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[policyName]} GET Policy deployment - status - - - - POLICY + + + + false - - - - - - - - - - - ${exchangeProperty[microServicePolicy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[microServicePolicy].getName()} creation - status - + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + false - - POLICY + + + ${header.CamelHttpResponseCode} != 200 + + false + + + + + ${exchangeProperty[policyComponent].computeState(*)} - - - - + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET + Policy status + + + + POLICY + + + + + - - - - - ${exchangeProperty[microServicePolicy].getName()} removal - status - - - - POLICY - - - - - + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[policyName]} GET Policy deployment + status + + + + POLICY + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + GET + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + + + + + + + + + ${exchangeProperty[microServicePolicy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[microServicePolicy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[operationalPolicy].createPolicyPayload()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[operationalPolicy].getName()} creation - status - - - - POLICY - - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[operationalPolicy].getName()} removal - status - - - - POLICY - - - - - + + + + + ${exchangeProperty[microServicePolicy].getName()} removal + status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[guardPolicy].getValue()} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - - - - ${exchangeProperty[guardPolicy].getKey()} creation status - - - - POLICY - - - - - + + + + + + + ${exchangeProperty[operationalPolicy].createPolicyPayload()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[operationalPolicy].getName()} creation + status + + + + POLICY + + + + + - - - - - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[operationalPolicy].getName()} removal + status + + + + POLICY + + + + + - - - - - ${exchangeProperty[guardPolicy].getKey()} removal status - - - - POLICY - - - - - + + + + + + + ${exchangeProperty[guardPolicy].getValue()} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + ${exchangeProperty[guardPolicy].getKey()} creation status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])} - - - - POST - - - application/json - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - + + + + + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + - - - - - PDP Group push ALL status - - - POLICY - - - - - + + + + + ${exchangeProperty[guardPolicy].getKey()} removal status + + + + POLICY + + + + + - - - - - - - ${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])} - - - ${body} - - - null - - - DELETE - - - ${exchangeProperty[X-ONAP-RequestID]} - - - - ${exchangeProperty[X-ONAP-InvocationID]} - - - - ${exchangeProperty[X-ONAP-PartnerName]} - - - - - - ${exchangeProperty[policyName]} PDP Group removal status - - - - POLICY - - - - - java.lang.Exception - - false - - - PDP Group removal, Error reported: ${exception} - - - POLICY - - - - - - - - - + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").createPoliciesPayloadPdpGroup(exchangeProperty[loopObject])} + + + + POST + + + application/json + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + + + + + PDP Group push ALL status + + + POLICY + + + + + + + + + + + + + ${exchangeProperty[loopObject].getComponent("POLICY").listPolicyNamesPdpGroup(exchangeProperty[loopObject])} + + + ${body} + + + null + + + DELETE + + + ${exchangeProperty[X-ONAP-RequestID]} + + + + ${exchangeProperty[X-ONAP-InvocationID]} + + + + ${exchangeProperty[X-ONAP-PartnerName]} + + + + + + ${exchangeProperty[policyName]} PDP Group removal status + + + + POLICY + + + + + java.lang.Exception + + false + + + PDP Group removal, Error reported: ${exception} + + + POLICY + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/clds/holmes-old-style-ms.yaml b/src/test/resources/clds/holmes-old-style-ms.yaml deleted file mode 100644 index 3f0c9a60..00000000 --- a/src/test/resources/clds/holmes-old-style-ms.yaml +++ /dev/null @@ -1,117 +0,0 @@ -tosca_definitions_version: cloudify_dsl_1_3 -imports: - - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml - - https://nexus01.research.att.com:8443/repository/solutioning01-mte2-raw/type_files/docker/2.3.0+t.0.4/node-type.yaml - - https://nexus01.research.att.com:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml - - http://nexus01.research.att.com:8081/repository/solutioning01-mte2-raw/type_files/dmaap/1.2.0/dmaap.yaml -inputs: - dcae_service_location: - type: string - docker_host_override: - type: string - topic0_aaf_password: - type: string - topic0_aaf_username: - type: string - topic0_client_role: - type: string - topic1_aaf_password: - type: string - topic1_aaf_username: - type: string - topic1_client_role: - type: string - location_id: - type: string - service_id: - type: string - policy_id: - type: string - default: "CLAMPPolicyTriggerNoaapp_v1_0_29b0578b_dcee_472c_8cdd0.ClosedLoop_860ee9f2_ba64_11e8_a16b_02bd571477fe_TCA_1d13unw" -node_templates: - policy_0: - type: dcae.nodes.policy - properties: - policy_model: policy.nodes.holmes - policy_filter: "DCAE.Config_Holmes.*" - policy_id: - get_input: policy_id - docker_host_host: - type: dcae.nodes.SelectedDockerHost - properties: - docker_host_override: - get_input: docker_host_override - location_id: - get_input: dcae_service_location - holmes_rule_homes-rule: - type: dcae.nodes.DockerContainerForComponentsUsingDmaap - properties: - application_config: - services_calls: - - msb_config: - concat: - - '{{' - - get_property: - - SELF - - msb_config - - node_name - - '}}' - streams_publishes: [] - streams_subscribes: - - sec_measurement_unsecure: - aaf_password: - get_input: topic0_aaf_password - aaf_username: - get_input: topic0_aaf_username - dmaap_info: <> - type: message_router - - sec_measurement: - aaf_password: - get_input: topic1_aaf_password - aaf_username: - get_input: topic1_aaf_username - dmaap_info: <> - type: message_router - docker_config: - healthcheck: - endpoint: api/holmes-rule-mgmt/v1/healthcheck - interval: 15s - timeout: 1s - type: http - ports: - - 9101:9101 - image: nexus3.onap.org:10001/onap/holmes/rule-manamgement:latest - location_id: - get_input: dcae_service_location - service_component_type: dcae-analytics-holmes-rule-manamgement - streams_publishes: [] - streams_subscribes: - - client_role: - get_input: topic0_client_role - location: - get_input: dcae_service_location - name: topic0 - type: message_router - - client_role: - get_input: topic1_client_role - location: - get_input: dcae_service_location - name: topic1 - type: message_router - relationships: - - target: docker_host_host - type: dcae.relationships.component_contained_in - - target: topic0 - type: dcae.relationships.subscribe_to_events - - target: topic1 - type: dcae.relationships.subscribe_to_events - - target: policy_0 - type: dcae.relationships.depends_on - topic0: - type: dcae.nodes.Topic - properties: - topic_name: '' - topic1: - type: dcae.nodes.Topic - properties: - topic_name: '' diff --git a/src/test/resources/clds/single-microservice-fragment-valid.yaml b/src/test/resources/clds/single-microservice-fragment-invalid.yaml similarity index 100% rename from src/test/resources/clds/single-microservice-fragment-valid.yaml rename to src/test/resources/clds/single-microservice-fragment-invalid.yaml diff --git a/src/test/resources/clds/single-microservice-fragment-valid-with-version.yaml b/src/test/resources/clds/single-microservice-fragment-valid-with-version.yaml new file mode 100644 index 00000000..ae31fb16 --- /dev/null +++ b/src/test/resources/clds/single-microservice-fragment-valid-with-version.yaml @@ -0,0 +1,21 @@ +second_app: + type: dcae.nodes.ContainerizedServiceComponentUsingDmaap + properties: + service_component_type: dcaegen2-analytics-tca + service_component_name_override: second_app + image: { get_input: second_app_docker_image } + name: second_app + policy_id: + policy_model_id: "type1" + policy_model_version: "10.0.0" + interfaces: + cloudify.interfaces.lifecycle: + start: + inputs: + envs: + grpc_server.host: "first_app.onap" + dmaap_ip: {get_input: dmaap_ip} + dmapp_topic: {get_input: dmaap_topic} + policy_id: {get_input: policy_id} + ports: + - 8080:8080 diff --git a/src/test/resources/clds/tca-old-style-ms.yaml b/src/test/resources/clds/tca-old-style-ms.yaml deleted file mode 100644 index b976190a..00000000 --- a/src/test/resources/clds/tca-old-style-ms.yaml +++ /dev/null @@ -1,169 +0,0 @@ -tosca_definitions_version: cloudify_dsl_1_3 -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/R2/dockerplugin/3.2.0/dockerplugin_types.yaml - - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/relationshipplugin/1.0.0/relationshipplugin_types.yaml - - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R2/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml - -inputs: - dh_override: - type: string - default: "component_dockerhost" - dh_location_id: - type: string - default: "zone1" - aaiEnrichmentHost: - type: string - default: "none" - aaiEnrichmentPort: - type: string - default: 8443 - enableAAIEnrichment: - type: string - default: false - dmaap_host: - type: string - default: dmaap.onap-message-router - dmaap_port: - type: string - default: 3904 - enableRedisCaching: - type: string - default: false - redisHosts: - type: string - tag_version: - type: string - default: "nexus3.onap.org:10001/onap//onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.0.0" - consul_host: - type: string - default: consul-server.onap-consul - consul_port: - type: string - default: "8500" - cbs_host: - type: string - default: "config-binding-service.dcae" - cbs_port: - type: string - default: "10000" - policy_id: - type: string - default: "none" - external_port: - type: string - description: "Port for CDAPgui to be exposed" - default: "32010" - -node_templates: - docker_service_host: - properties: - docker_host_override: - get_input: dh_override - location_id: - get_input: dh_location_id - type: dcae.nodes.SelectedDockerHost - tca_docker: - relationships: - - type: dcae.relationships.component_contained_in - target: docker_service_host - - target: tca_policy - type: cloudify.relationships.depends_on - type: dcae.nodes.DockerContainerForComponentsUsingDmaap - properties: - application_config: - app_config: - appDescription: DCAE Analytics Threshold Crossing Alert Application - appName: dcae-tca - tcaAlertsAbatementTableName: TCAAlertsAbatementTable - tcaAlertsAbatementTableTTLSeconds: '1728000' - tcaSubscriberOutputStreamName: TCASubscriberOutputStream - tcaVESAlertsTableName: TCAVESAlertsTable - tcaVESAlertsTableTTLSeconds: '1728000' - tcaVESMessageStatusTableName: TCAVESMessageStatusTable - tcaVESMessageStatusTableTTLSeconds: '86400' - thresholdCalculatorFlowletInstances: '2' - app_preferences: - aaiEnrichmentHost: - get_input: aaiEnrichmentHost - aaiEnrichmentIgnoreSSLCertificateErrors: 'true' - aaiEnrichmentPortNumber: '8443' - aaiEnrichmentProtocol: https - aaiEnrichmentUserName: DCAE - aaiEnrichmentUserPassword: DCAE - aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query - aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf - enableAAIEnrichment: - get_input: enableAAIEnrichment - enableRedisCaching: - get_input: enableRedisCaching - redisHosts: - get_input: redisHosts - enableAlertCEFFormat: 'false' - publisherContentType: application/json - publisherHostName: - get_input: dmaap_host - publisherHostPort: - get_input: dmaap_port - publisherMaxBatchSize: '1' - publisherMaxRecoveryQueueSize: '100000' - publisherPollingInterval: '20000' - publisherProtocol: http - publisherTopicName: unauthenticated.DCAE_CL_OUTPUT - subscriberConsumerGroup: OpenDCAE-c12 - subscriberConsumerId: c12 - subscriberContentType: application/json - subscriberHostName: - get_input: dmaap_host - subscriberHostPort: - get_input: dmaap_port - subscriberMessageLimit: '-1' - subscriberPollingInterval: '30000' - subscriberProtocol: http - subscriberTimeoutMS: '-1' - subscriberTopicName: unauthenticated.SEC_MEASUREMENT_OUTPUT - tca_policy_default: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicUsageArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}' - service_component_type: dcaegen2-analytics_tca - docker_config: - healthcheck: - endpoint: /healthcheck - interval: 15s - timeout: 1s - type: http - image: - get_input: tag_version - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - envs: - DMAAPHOST: - { get_input: dmaap_host } - DMAAPPORT: - { get_input: dmaap_port } - DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT" - DMAAPSUBTOPIC: "unauthenticated.SEC_MEASUREMENT_OUTPUT" - AAIHOST: - { get_input: aaiEnrichmentHost } - AAIPORT: - { get_input: aaiEnrichmentPort } - CONSUL_HOST: - { get_input: consul_host } - CONSUL_PORT: - { get_input: consul_port } - CBS_HOST: - { get_input: cbs_host } - CBS_PORT: - { get_input: cbs_port } - CONFIG_BINDING_SERVICE: "config_binding_service" - ports: - - concat: ["11011:", { get_input: external_port }] - stop: - inputs: - cleanup_image: true - tca_policy: - type: dcae.nodes.policy - properties: - policy_id: - get_input: policy_id - diff --git a/src/test/resources/example/sdc/blueprint-dcae/holmes.yaml b/src/test/resources/example/sdc/blueprint-dcae/holmes.yaml deleted file mode 100644 index f180a7df..00000000 --- a/src/test/resources/example/sdc/blueprint-dcae/holmes.yaml +++ /dev/null @@ -1,174 +0,0 @@ -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://www.getcloudify.org/spec/cloudify/3.4/types.yaml -- https://nexus01.research.att.com:8443/repository/solutioning01-mte2-raw/type_files/docker/2.3.0+t.0.4/node-type.yaml -- https://nexus01.research.att.com:8443/repository/solutioning01-mte2-raw/type_files/relationship/1.0.0/node-type.yaml -- http://nexus01.research.att.com:8081/repository/solutioning01-mte2-raw/type_files/dmaap/1.2.0/dmaap.yaml -inputs: - dcae_service_location: - type: string - docker_host_override: - type: string - topic0_aaf_password: - type: string - topic0_aaf_username: - type: string - topic0_client_role: - type: string - topic1_aaf_password: - type: string - topic1_aaf_username: - type: string - topic1_client_role: - type: string -node_templates: - policy_0: - type: dcae.nodes.policy - properties: - policy_model: policy.nodes.holmes - policy_filter: "DCAE.Config_Holmes.*" - docker_host_host: - type: dcae.nodes.SelectedDockerHost - properties: - docker_host_override: - get_input: docker_host_override - location_id: - get_input: dcae_service_location - holmes-rule_homes-rule: - type: dcae.nodes.DockerContainerForComponentsUsingDmaap - properties: - application_config: - holmes.default.rule.volte.scenario1: 'package dcae.ves.test - - import org.onap.some.related.packages; - - rule"SameVNF_Relation_Rule" - - salience 120 - - no-loop true - - when - - $root : VesAlarm( - - $sourceId: sourceId, sourceId != null && !sourceId.equals(""), - - specificProblem in ( "LSS_cpiPCSCFFailReg(121297)", "LSS_cpiSIPRetransmitInvite(120267)" ), - - $eventId: eventId) - - $child : VesAlarm( eventId != $eventId, - - CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId), - - specificProblem in ("LSS_externalLinkDown(4271)","LSS_failedAttachReqsRateExceeded(4272)"), - - this after [-60s, 60s] $root) - - then - - DmaapService.publishResult(...); - - end' - holmes.default.rule.volte.scenario2: 'package dcae.ves.test - - import org.onap.some.related.packages; - - rule"SameVNF_Relation_Rule_1" - - salience 120 - - no-loop true - - when - - $root : VesAlarm( - - $sourceId: sourceId, sourceId != null && !sourceId.equals(""), - - specificProblem in ( "LSS_cpiPCSCFFailReg(121297)", "LSS_cpiSIPRetransmitInvite(120267)" ), - - $eventId: eventId) - - $child : VesAlarm( eventId != $eventId, - - CorrelationUtil.getInstance().isTopologicallyRelated(sourceId, $sourceId), - - specificProblem in ("LSS_externalLinkDown(4271)","LSS_failedAttachReqsRateExceeded(4272)"), - - this after [-60s, 60s] $root) - - then - - DmaapService.publishResult(...); - - end' - services_calls: - - msb_config: - concat: - - '{{' - - get_property: - - SELF - - msb_config - - node_name - - '}}' - streams_publishes: [] - streams_subscribes: - - sec_measurement_unsecure: - aaf_password: - get_input: topic0_aaf_password - aaf_username: - get_input: topic0_aaf_username - dmaap_info: <> - type: message_router - - sec_measurement: - aaf_password: - get_input: topic1_aaf_password - aaf_username: - get_input: topic1_aaf_username - dmaap_info: <> - type: message_router - docker_config: - healthcheck: - endpoint: api/holmes-rule-mgmt/v1/healthcheck - interval: 15s - timeout: 1s - type: http - ports: - - 9101:9101 - image: nexus3.onap.org:10001/onap/holmes/rule-manamgement:latest - location_id: - get_input: dcae_service_location - service_component_type: dcae-analytics-holmes-rule-manamgement - streams_publishes: [] - streams_subscribes: - - client_role: - get_input: topic0_client_role - location: - get_input: dcae_service_location - name: topic0 - type: message_router - - client_role: - get_input: topic1_client_role - location: - get_input: dcae_service_location - name: topic1 - type: message_router - relationships: - - target: docker_host_host - type: dcae.relationships.component_contained_in - - target: topic0 - type: dcae.relationships.subscribe_to_events - - target: topic1 - type: dcae.relationships.subscribe_to_events - - target: policy_0 - type: dcae.relationships.depends_on - topic0: - type: dcae.nodes.Topic - properties: - topic_name: '' - topic1: - type: dcae.nodes.Topic - properties: - topic_name: '' diff --git a/src/test/resources/example/sdc/blueprint-dcae/not-recognized.yaml b/src/test/resources/example/sdc/blueprint-dcae/not-recognized.yaml deleted file mode 100644 index 6522885f..00000000 --- a/src/test/resources/example/sdc/blueprint-dcae/not-recognized.yaml +++ /dev/null @@ -1,130 +0,0 @@ -tosca_definitions_version: cloudify_dsl_1_3 -imports: -- http://dockercentral.it.att.com:8093/nexus/repository/rawcentral/com.att.dcae.controller/type_files/dockerplugin/2.4.0+t.0.8/node-type.yaml -- http://dockercentral.it.att.com:8093/nexus/repository/rawcentral/com.att.dcae.controller/type_files/dmaap/1.2.0+t.0.9/dmaap.yaml -- http://dockercentral.it.att.com:8093/nexus/repository/rawcentral/com.att.dcae.controller/type_files/relationship/1.0.0+t.0.1/relationship-types.yaml -inputs: - commonEventHeader.domain: - type: string - commonEventHeader.version: - type: string - dcae_service_location: - type: string - docker_host_override: - type: string - default: '' - elementType: - type: string - feed_id: - type: string - mappingType: - type: string - measurementsForVfScalingFields.measurementsForVfScalingVersion: - type: string - phases.docker_map.phaseName: - type: string - topic1_aaf_password: - type: string - topic1_aaf_username: - type: string - topic1_client_role: - type: string -node_templates: - DockerMap_n.1519416493392.3_DockerMap: - type: dcae.nodes.DockerContainerForComponentsUsingDmaap - properties: - application_config: - commonEventHeader.domain: - get_input: commonEventHeader.domain - commonEventHeader.version: - get_input: commonEventHeader.version - csvToVesJson: '{"processing":[{"phase":"pmossFoiPhase","filter":{"class":"Contains","string":"${file}","value":"NOKvMRF"},"processors":[{"class":"LogEvent","title":"PM-FOIEvent-Received","logName":"com.att.gfp.dcae.eventProcessor.input","logLevel":"DEBUG"},{"class":"RunPhase","phase":"vFoiNokRunPhase"}]},{"phase":"vFoiNokRunPhase","comments":"generic parsing","processors":[{"replace":",","field":"data","class":"ReplaceText","find":";"},{"replace":",","field":"file","class":"ReplaceText","find":"_"}]},{"phase":"vFoiNokRunPhase","filter":{"class":"Contains","string":"${data[1]}","value":"Begin date"},"processors":[{"class":"ExtractText","field":"event.commonEventHeader.startEpochMicrosec","value":"${data[1]}","regex":".*Begin date,([^,]*),.*"},{"class":"DateFormatter","value":"${event.commonEventHeader.startEpochMicrosec}","fromFormat":"MM/dd/yy HH:mm:ss a","fromTz":"GMT","toField":"event.commonEventHeader.startEpochMicrosec","toFormat":"#ms","toTz":"#ms"}]},{"phase":"vFoiNokRunPhase","filter":{"class":"Contains","string":"${data[2]}","value":"End date"},"processors":[{"class":"ExtractText","field":"event.commonEventHeader.lastEpochMicrosec","value":"${data[2]}","regex":".*End date,([^,]*),.*"},{"class":"DateFormatter","value":"${event.commonEventHeader.lastEpochMicrosec}","fromFormat":"MM/dd/yy HH:mm:ss a","fromTz":"GMT","toField":"event.commonEventHeader.lastEpochMicrosec","toFormat":"#ms","toTz":"#ms"},{"class":"DateFormatter","value":"${event.commonEventHeader.lastEpochMicrosec}","fromFormat":"#ms","fromTz":"#ms","toField":"event.commonEventHeader.internalHeaderFields.DATETIMEUTC","toFormat":"yyyyMMddHHmmss","toTz":"GMT"}]},{"phase":"vFoiNokRunPhase","processors":[{"class":"ExtractText","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[0].value","value":"${data[7]}","regex":".*CpuSys,+(\\d+,){3}.*"},{"class":"ReplaceText","replace":"","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[0].value","find":","},{"class":"ExtractText","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[1].value","value":"${data[5]}","regex":".*CpuUsage,+(\\d+,){3}.*"},{"class":"ReplaceText","replace":"","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[1].value","find":","},{"class":"ExtractText","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[2].value","value":"${data[7]}","regex":".*CpuSys,+(\\d+,){2}.*"},{"class":"ReplaceText","replace":"","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[2].value","find":","},{"class":"ExtractText","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[3].value","value":"${data[5]}","regex":".*CpuUsage,+(\\d+,){2}.*"},{"class":"ReplaceText","replace":"","field":"event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[3].value","find":","}]},{"phase":"vFoiNokRunPhase","processors":[{"class":"ExtractText","field":"event.commonEventHeader.eventName","value":"${file}","regex":"([^,]*),.*"},{"class":"ExtractText","field":"event.commonEventHeader.reportingEntityName","value":"${file}","regex":".*,([^,]*)\\..*"}]},{"phase":"vFoiNokRunPhase","comments":"generic parsing","processors":[{"class":"Set","updates":{"event.commonEventHeader.lastEpochMicrosec":"${event.commonEventHeader.lastEpochMicrosec}000","event.commonEventHeader.startEpochMicrosec":"${event.commonEventHeader.startEpochMicrosec}000","event.commonEventHeader.domain":"measurementsForVfScaling","event.commonEventHeader.eventName":"Mfvs_${event.commonEventHeader.eventName}","event.commonEventHeader.eventType":"csv2ves","event.commonEventHeader.priority":"Normal","event.commonEventHeader.sequence":0,"event.commonEventHeader.sourceName":"${event.commonEventHeader.reportingEntityName}","event.commonEventHeader.version":3.0,"event.commonEventHeader.eventId":"%{now.ms}","event.commonEventHeader.internalHeaderFields.dbTableSuffix":"","event.measurementsForVfScalingFields.measurementInterval":900,"event.measurementsForVfScalingFields.measurementsForVfScalingVersion":2.0,"event.measurementsForVfScalingFields.additionalMeasurements.name":"csv2ves","event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[0].name":"CpuSysMax","event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[1].name":"CpuUsageMax","event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[2].name":"CpuSysAverage","event.measurementsForVfScalingFields.additionalMeasurements.arrayOfFields[3].name":"CpuUsageAverage"}},{"class":"DateFormatter","value":"${event.commonEventHeader.eventId}","fromFormat":"#ms","fromTz":"#ms","toField":"event.commonEventHeader.eventId","toFormat":"yyyyMMddHHmmssSSS","toTz":"GMT"}]},{"phase":"vFoiNokRunPhase","processors":[{"class":"Clear","fields":["data","file"]},{"class":"LogText","logLevel":"INFO","logText":"Finished-PM-FOIEvent-parsing"},{"class":"LogEvent","title":"PM-FOIEvent-Received-Output"},{"class":"RunPhase","phase":"foiEventToDmaapPhase"}]}]}' - elementType: - get_input: elementType - isSelfServeComponent: 'True' - mappingType: - get_input: mappingType - measurementsForVfScalingFields.measurementsForVfScalingVersion: - get_input: measurementsForVfScalingFields.measurementsForVfScalingVersion - phases.docker_map.phaseName: - get_input: phases.docker_map.phaseName - services_calls: {} - streams_publishes: - DCAE-VES-PM-EVENT: - aaf_password: - get_input: topic1_aaf_password - aaf_username: - get_input: topic1_aaf_username - dmaap_info: <> - type: message_router - streams_subscribes: - DCAE_PM_DATA_C_M: - dmaap_info: <> - type: data_router - useDtiConfig: 'False' - docker_config: - healthcheck: - interval: 300s - script: /opt/app/vec/bin/common/HealthCheck_DockerMap.sh - timeout: 15s - type: docker - volumes: - - container: - bind: /opt/app/dcae-certificate - host: - path: /opt/app/dcae-certificate - - container: - bind: /opt/app/dmd/log/AGENT - host: - path: /opt/logs/DCAE/dockermap/dmd/AGENT - - container: - bind: /opt/app/dmd/log/WATCHER - host: - path: /opt/logs/DCAE/dockermap/dmd/WATCHER - - container: - bind: /opt/app/vec/logs/DCAE - host: - path: /opt/logs/DCAE/dockermap/dockermap-logs - - container: - bind: /opt/app/vec/archive/data - host: - path: /opt/data/DCAE/dockermap/dockermap-archive - image: dockercentral.it.att.com:5100/com.att.dcae.controller/dcae-controller-dockermap:18.02-004 - location_id: - get_input: dcae_service_location - service_component_type: dcae.collectors.docker.map.pm - streams_publishes: - - client_role: - get_input: topic1_client_role - location: - get_input: dcae_service_location - name: topic1_n.1519416493404.5 - type: message_router - streams_subscribes: - - location: - get_input: dcae_service_location - name: feed_n.1519416394214.2 - type: data_router - relationships: - - target: docker_host_host - type: dcae.relationships.component_contained_in - - target: feed_n.1519416394214.2 - type: dcae.relationships.subscribe_to_files - - target: topic1_n.1519416493404.5 - type: dcae.relationships.publish_events - docker_host_host: - type: dcae.nodes.SelectedDockerHost - properties: - docker_host_override: - get_input: docker_host_override - location_id: - get_input: dcae_service_location - feed_n.1519416394214.2: - type: dcae.nodes.ExistingFeed - properties: - feed_id: - get_input: feed_id - topic1_n.1519416493404.5: - type: dcae.nodes.Topic - properties: - topic_name: DCAE-VES-PM-EVENT-v1 diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json deleted file mode 100644 index d7a54162..00000000 --- a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-2.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "global": [ - { - "name": "service", - "value": [ - "4cc5b45a-1f63-4194-8100-cd8e14248c92" - ] - }, - { - "name": "vf", - "value": [ - "023a3f0d-1161-45ff-b4cf-8918a8ccf3ad" - ] - }, - { - "name": "actionSet", - "value": [ - "vnfRecipe" - ] - }, - { - "name": "location", - "value": [ - "DC1" - ] - }, - { - "name": "deployParameters", - "value": { - "aaiEnrichmentHost": "aai.onap.svc.cluster.local", - "aaiEnrichmentPort": "8443", - "enableAAIEnrichment": true, - "dmaap_host": "message-router.onap", - "dmaap_port": "3904", - "enableRedisCaching": false, - "redisHosts": "dcae-redis.onap.svc.cluster.local:6379", - "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.1", - "consul_host": "consul-server.onap", - "consul_port": "8500", - "cbs_host": "config-binding-servicel", - "cbs_port": "10000", - "external_port": "32012", - "policy_model_id": "onap.policies.monitoring.cdap.tca.hi.lo.app", - "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT" - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json deleted file mode 100644 index 012c46e9..00000000 --- a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca-3.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "global": [ - { - "name": "service", - "value": [ - "4cc5b45a-1f63-4194-8100-cd8e14248c92" - ] - }, - { - "name": "vf", - "value": [ - "07e266fc-49ab-4cd7-8378-ca4676f1b9ec" - ] - }, - { - "name": "actionSet", - "value": [ - "vnfRecipe" - ] - }, - { - "name": "location", - "value": [ - "DC1" - ] - }, - { - "name": "deployParameters", - "value": { - "aaiEnrichmentHost": "aai.onap.svc.cluster.local", - "aaiEnrichmentPort": "8443", - "enableAAIEnrichment": true, - "dmaap_host": "message-router.onap.svc.cluster.local", - "dmaap_port": "3904", - "enableRedisCaching": false, - "redisHosts": "dcae-redis.onap.svc.cluster.local:6379", - "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0-STAGING-latest", - "consul_host": "consul-server.onap.svc.cluster.local", - "consul_port": "8500", - "cbs_host": "config-binding-service.dcae.svc.cluster.local", - "cbs_port": "10000", - "external_port": "32012", - "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT", - "policy_model_id": "onap.policies.monitoring.cdap.tca.hi.lo.app" - } - } - ] -} \ No newline at end of file diff --git a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json b/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json deleted file mode 100644 index ce3158d9..00000000 --- a/src/test/resources/example/sdc/blueprint-dcae/prop-text-for-tca.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "global": [ - { - "name": "service", - "value": [ - "4cc5b45a-1f63-4194-8100-cd8e14248c92" - ] - }, - { - "name": "vf", - "value": [ - "07e266fc-49ab-4cd7-8378-ca4676f1b9ec" - ] - }, - { - "name": "actionSet", - "value": [ - "vnfRecipe" - ] - }, - { - "name": "location", - "value": [ - "DC1" - ] - }, - { - "name": "deployParameters", - "value": { - "location_id": "", - "service_id": "", - "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT" - } - } - ] -} diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index 07e58785..c71bcba8 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -1,2 +1,91 @@ - + + + + + + + + + + + + + + + + + + INFO + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{1024} - %msg%n + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/test/resources/tosca/dcea_blueprint.yml b/src/test/resources/tosca/dcea_blueprint.yml deleted file mode 100644 index 0d3ea046..00000000 --- a/src/test/resources/tosca/dcea_blueprint.yml +++ /dev/null @@ -1,170 +0,0 @@ -# -# ============LICENSE_START==================================================== -# ============================================================================= -# Copyright (c) 2018 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====================================================== - -tosca_definitions_version: cloudify_dsl_1_3 - -description: > - This blueprint deploys/manages the TCA module as a Docker container - -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.4/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 -inputs: - aaiEnrichmentHost: - type: string - default: "aai.onap.svc.cluster.local" - aaiEnrichmentPort: - type: string - default: "8443" - enableAAIEnrichment: - type: string - default: true - dmaap_host: - type: string - default: message-router - dmaap_port: - type: string - default: "3904" - enableRedisCaching: - type: string - default: false - redisHosts: - type: string - default: dcae-redis:6379 - tag_version: - type: string - default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0" - consul_host: - type: string - default: consul-server - consul_port: - type: string - default: "8500" - cbs_host: - type: string - default: - test: - test: test - cbs_port: - type: string - default: "10000" - policy_id: - type: string - default: "none" - external_port: - type: string - description: Kubernetes node port on which CDAPgui is exposed - default: "32010" - -node_templates: - tca_k8s: - type: dcae.nodes.ContainerizedServiceComponent - relationships: - - target: tca_policy - type: cloudify.relationships.depends_on - properties: - service_component_type: 'dcaegen2-analytics-tca' - docker_config: {} - image: - get_input: tag_version - log_info: - log_directory: "/opt/app/TCAnalytics/logs" - application_config: - app_config: - appDescription: DCAE Analytics Threshold Crossing Alert Application - appName: dcae-tca-ak-serv - tcaAlertsAbatementTableName: TCAAlertsAbatementTable - tcaAlertsAbatementTableTTLSeconds: '1728000' - tcaSubscriberOutputStreamName: TCASubscriberOutputStream - tcaVESAlertsTableName: TCAVESAlertsTable - tcaVESAlertsTableTTLSeconds: '1728000' - tcaVESMessageStatusTableName: TCAVESMessageStatusTable - tcaVESMessageStatusTableTTLSeconds: '86400' - thresholdCalculatorFlowletInstances: '2' - app_preferences: - aaiEnrichmentHost: - get_input: aaiEnrichmentHost - aaiEnrichmentIgnoreSSLCertificateErrors: 'true' - aaiEnrichmentPortNumber: '8443' - aaiEnrichmentProtocol: https - aaiEnrichmentUserName: DCAE - aaiEnrichmentUserPassword: DCAE - aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query - aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf - enableAAIEnrichment: - get_input: enableAAIEnrichment - enableRedisCaching: - get_input: enableRedisCaching - redisHosts: - get_input: redisHosts - enableAlertCEFFormat: 'false' - publisherContentType: application/json - publisherHostName: - get_input: dmaap_host - publisherHostPort: - get_input: dmaap_port - publisherMaxBatchSize: '1' - publisherMaxRecoveryQueueSize: '100000' - publisherPollingInterval: '20000' - publisherProtocol: http - publisherTopicName: unauthenticated.DCAE_CL_OUTPUT - subscriberConsumerGroup: OpenDCAE-c12 - subscriberConsumerId: c12 - subscriberContentType: application/json - subscriberHostName: - get_input: dmaap_host - subscriberHostPort: - get_input: dmaap_port - subscriberMessageLimit: '-1' - subscriberPollingInterval: '30000' - subscriberProtocol: http - subscriberTimeoutMS: '-1' - subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT - tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}' - interfaces: - cloudify.interfaces.lifecycle: - start: - inputs: - envs: - DMAAPHOST: - { get_input: dmaap_host } - DMAAPPORT: - { get_input: dmaap_port } - DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT" - DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT" - AAIHOST: - { get_input: aaiEnrichmentHost } - AAIPORT: - { get_input: aaiEnrichmentPort } - CONSUL_HOST: - { get_input: consul_host } - CONSUL_PORT: - { get_input: consul_port } - CBS_HOST: - { get_input: cbs_host } - CBS_PORT: - { get_input: cbs_port } - CONFIG_BINDING_SERVICE: "config_binding_service" - ports: - - concat: ["11011:", { get_input: external_port }] - tca_policy: - type: dcae.nodes.policy - properties: - policy_id: - get_input: policy_id -- 2.16.6