From 8604d37f2f6bdd011de62ec474b6883413d30348 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 10 Mar 2020 02:44:53 -0700 Subject: Fix the tosca converter Fix the new tosca converter to support metadata section Issue-ID: CLAMP-580 Signed-off-by: sebdet Change-Id: I9068bd9dc89851c630660a7f78fae1cb70bdc178 --- docs/swagger/swagger.json | 122 ++++---- docs/swagger/swagger.pdf | 6 +- extra/sql/dump/test-data.sql | 32 +- .../onap/clamp/clds/tosca/update/Component.java | 121 -------- .../onap/clamp/clds/tosca/update/Extractor.java | 116 -------- .../org/onap/clamp/clds/tosca/update/Field.java | 147 --------- .../clamp/clds/tosca/update/MetadataParser.java | 46 +++ .../onap/clamp/clds/tosca/update/ParserToJson.java | 321 -------------------- .../org/onap/clamp/clds/tosca/update/Template.java | 66 ++-- .../clamp/clds/tosca/update/TemplateField.java | 148 +++++++++ .../clds/tosca/update/TemplateManagement.java | 191 ------------ .../clds/tosca/update/ToscaConverterManager.java | 192 ++++++++++++ .../clds/tosca/update/ToscaConverterToJson.java | 331 +++++++++++++++++++++ .../onap/clamp/clds/tosca/update/ToscaElement.java | 121 ++++++++ .../clamp/clds/tosca/update/ToscaItemsParser.java | 109 +++++++ .../clamp/loop/service/CsarServiceInstaller.java | 2 +- .../onap/clamp/loop/service/ServiceRepository.java | 32 -- src/main/java/org/onap/clamp/policy/Policy.java | 8 +- .../operational/OperationalPolicyService.java | 21 +- src/main/resources/META-INF/resources/swagger.html | 2 +- src/main/resources/application-noaaf.properties | 7 +- .../clds/tosca_update/default-tosca-types.yaml | 87 ++++++ .../clds/tosca_update/defaultToscaTypes.yaml | 87 ------ .../clds/tosca_update/templates.properties | 15 - .../clamp/clds/tosca/update/ArrayFieldTest.java | 8 +- .../clamp/clds/tosca/update/ComponentTest.java | 50 ---- .../clamp/clds/tosca/update/ConstraintTest.java | 22 +- .../onap/clamp/clds/tosca/update/PropertyTest.java | 18 +- .../clds/tosca/update/TemplateManagementTest.java | 205 ------------- .../onap/clamp/clds/tosca/update/TemplateTest.java | 6 +- .../tosca/update/ToscaConverterManagerTest.java | 205 +++++++++++++ .../clamp/clds/tosca/update/ToscaElementTest.java | 50 ++++ .../org/onap/clamp/loop/CsarInstallerItCase.java | 5 +- .../src/components/dialogs/Policy/PolicyModal.js | 2 +- ui-react/src/components/menu/MenuBar.js | 12 +- .../menu/__snapshots__/MenuBar.test.js.snap | 21 +- 36 files changed, 1473 insertions(+), 1461 deletions(-) delete mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/Component.java delete mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java delete mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/Field.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/MetadataParser.java delete mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/TemplateField.java delete mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterManager.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterToJson.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/ToscaElement.java create mode 100644 src/main/java/org/onap/clamp/clds/tosca/update/ToscaItemsParser.java delete mode 100644 src/main/java/org/onap/clamp/loop/service/ServiceRepository.java create mode 100644 src/main/resources/clds/tosca_update/default-tosca-types.yaml delete mode 100644 src/main/resources/clds/tosca_update/defaultToscaTypes.yaml delete mode 100644 src/main/resources/clds/tosca_update/templates.properties delete mode 100644 src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java delete mode 100644 src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java create mode 100644 src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java create mode 100644 src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java diff --git a/docs/swagger/swagger.json b/docs/swagger/swagger.json index 3b34182c..1ed4a4ba 100644 --- a/docs/swagger/swagger.json +++ b/docs/swagger/swagger.json @@ -4,7 +4,7 @@ "version" : "5.0.0-SNAPSHOT", "title" : "Clamp Rest API" }, - "host" : "localhost:39237", + "host" : "localhost:46347", "basePath" : "/restservices/clds/", "schemes" : [ "http" ], "paths" : { @@ -827,13 +827,6 @@ "asString" : { "type" : "string" }, - "asNumber" : { - "$ref" : "#/definitions/Number" - }, - "asFloat" : { - "type" : "number", - "format" : "float" - }, "asByte" : { "type" : "string", "format" : "byte" @@ -841,6 +834,10 @@ "asCharacter" : { "type" : "string" }, + "asFloat" : { + "type" : "number", + "format" : "float" + }, "asBigDecimal" : { "type" : "number" }, @@ -851,30 +848,33 @@ "type" : "integer", "format" : "int32" }, + "asNumber" : { + "$ref" : "#/definitions/Number" + }, "string" : { "type" : "boolean" }, "asJsonObject" : { "$ref" : "#/definitions/JsonObject" }, - "asJsonArray" : { - "$ref" : "#/definitions/JsonArray" - }, "jsonObject" : { "type" : "boolean" }, - "jsonArray" : { - "type" : "boolean" + "asJsonArray" : { + "$ref" : "#/definitions/JsonArray" }, - "jsonPrimitive" : { + "jsonNull" : { "type" : "boolean" }, - "jsonNull" : { + "jsonPrimitive" : { "type" : "boolean" }, "asJsonPrimitive" : { "$ref" : "#/definitions/JsonPrimitive" }, + "jsonArray" : { + "type" : "boolean" + }, "asJsonNull" : { "$ref" : "#/definitions/JsonNull" } @@ -973,33 +973,23 @@ "asString" : { "type" : "string" }, - "asJsonArray" : { - "$ref" : "#/definitions/JsonArray" - }, "jsonObject" : { "type" : "boolean" }, - "jsonArray" : { - "type" : "boolean" + "asJsonArray" : { + "$ref" : "#/definitions/JsonArray" }, - "jsonPrimitive" : { + "jsonNull" : { "type" : "boolean" }, - "jsonNull" : { + "jsonPrimitive" : { "type" : "boolean" }, "asJsonPrimitive" : { "$ref" : "#/definitions/JsonPrimitive" }, - "asJsonNull" : { - "$ref" : "#/definitions/JsonNull" - }, - "asNumber" : { - "$ref" : "#/definitions/Number" - }, - "asFloat" : { - "type" : "number", - "format" : "float" + "jsonArray" : { + "type" : "boolean" }, "asByte" : { "type" : "string", @@ -1008,6 +998,13 @@ "asCharacter" : { "type" : "string" }, + "asJsonNull" : { + "$ref" : "#/definitions/JsonNull" + }, + "asFloat" : { + "type" : "number", + "format" : "float" + }, "asBigDecimal" : { "type" : "number" }, @@ -1017,6 +1014,9 @@ "asShort" : { "type" : "integer", "format" : "int32" + }, + "asNumber" : { + "$ref" : "#/definitions/Number" } }, "x-className" : { @@ -1174,33 +1174,23 @@ "asString" : { "type" : "string" }, - "asJsonArray" : { - "$ref" : "#/definitions/JsonArray" - }, "jsonObject" : { "type" : "boolean" }, - "jsonArray" : { - "type" : "boolean" + "asJsonArray" : { + "$ref" : "#/definitions/JsonArray" }, - "jsonPrimitive" : { + "jsonNull" : { "type" : "boolean" }, - "jsonNull" : { + "jsonPrimitive" : { "type" : "boolean" }, "asJsonPrimitive" : { "$ref" : "#/definitions/JsonPrimitive" }, - "asJsonNull" : { - "$ref" : "#/definitions/JsonNull" - }, - "asNumber" : { - "$ref" : "#/definitions/Number" - }, - "asFloat" : { - "type" : "number", - "format" : "float" + "jsonArray" : { + "type" : "boolean" }, "asByte" : { "type" : "string", @@ -1209,6 +1199,13 @@ "asCharacter" : { "type" : "string" }, + "asJsonNull" : { + "$ref" : "#/definitions/JsonNull" + }, + "asFloat" : { + "type" : "number", + "format" : "float" + }, "asBigDecimal" : { "type" : "number" }, @@ -1218,6 +1215,9 @@ "asShort" : { "type" : "integer", "format" : "int32" + }, + "asNumber" : { + "$ref" : "#/definitions/Number" } } }, @@ -1242,13 +1242,6 @@ "asString" : { "type" : "string" }, - "asNumber" : { - "$ref" : "#/definitions/Number" - }, - "asFloat" : { - "type" : "number", - "format" : "float" - }, "asByte" : { "type" : "string", "format" : "byte" @@ -1256,6 +1249,10 @@ "asCharacter" : { "type" : "string" }, + "asFloat" : { + "type" : "number", + "format" : "float" + }, "asBigDecimal" : { "type" : "number" }, @@ -1266,27 +1263,30 @@ "type" : "integer", "format" : "int32" }, + "asNumber" : { + "$ref" : "#/definitions/Number" + }, "asJsonObject" : { "$ref" : "#/definitions/JsonObject" }, - "asJsonArray" : { - "$ref" : "#/definitions/JsonArray" - }, "jsonObject" : { "type" : "boolean" }, - "jsonArray" : { - "type" : "boolean" + "asJsonArray" : { + "$ref" : "#/definitions/JsonArray" }, - "jsonPrimitive" : { + "jsonNull" : { "type" : "boolean" }, - "jsonNull" : { + "jsonPrimitive" : { "type" : "boolean" }, "asJsonPrimitive" : { "$ref" : "#/definitions/JsonPrimitive" }, + "jsonArray" : { + "type" : "boolean" + }, "asJsonNull" : { "$ref" : "#/definitions/JsonNull" } diff --git a/docs/swagger/swagger.pdf b/docs/swagger/swagger.pdf index a1d7b18d..1095ce71 100644 --- a/docs/swagger/swagger.pdf +++ b/docs/swagger/swagger.pdf @@ -4,8 +4,8 @@ << /Title (Clamp Rest API) /Creator (Asciidoctor PDF 1.5.0.alpha.10, based on Prawn 1.3.0) /Producer (Asciidoctor PDF 1.5.0.alpha.10, based on Prawn 1.3.0) -/CreationDate (D:20200309160816-07'00') -/ModDate (D:20200309160816-07'00') +/CreationDate (D:20200310073214-07'00') +/ModDate (D:20200310073214-07'00') >> endobj 2 0 obj @@ -5910,7 +5910,7 @@ ET BT 71.30850000000001 592.176 Td /F1.0 10.5 Tf -<203a206c6f63616c686f73743a3339323337> Tj +<203a206c6f63616c686f73743a3436333437> Tj ET 0.000 0.000 0.000 SCN diff --git a/extra/sql/dump/test-data.sql b/extra/sql/dump/test-data.sql index c4e1e0b7..6c8f9c19 100644 --- a/extra/sql/dump/test-data.sql +++ b/extra/sql/dump/test-data.sql @@ -63,7 +63,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-03-09 15:32:37.733946','Not found','2020-03-09 15:32:38.968545',NULL,NULL,'MICRO_SERVICE_TYPE',NULL); +INSERT INTO `loop_element_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app',NULL,'2020-03-10 15:34:31.130357','Not found','2020-03-10 15:34:31.845293',NULL,NULL,'MICRO_SERVICE_TYPE',NULL); /*!40000 ALTER TABLE `loop_element_models` ENABLE KEYS */; UNLOCK TABLES; @@ -82,9 +82,9 @@ UNLOCK TABLES; LOCK TABLES `loop_templates` WRITE; /*!40000 ALTER TABLE `loop_templates` DISABLE KEYS */; -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_knKBA_v1_0_ResourceInstanceName1_tca','Not found','2020-03-09 15:32:38.823195','Not found','2020-03-09 15:32:38.823195','CLOSED','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-63a27491-910c-4d4d-a730-557bb7214af1',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_knKBA_v1_0_ResourceInstanceName1_tca_3','Not found','2020-03-09 15:32:38.243680','Not found','2020-03-09 15:32:38.243680','CLOSED','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-d7f45a12-2175-467d-b6bc-430370ece032',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_knKBA_v1_0_ResourceInstanceName2_tca_2','Not found','2020-03-09 15:32:37.679097','Not found','2020-03-09 15:32:37.679097','CLOSED','#\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-8d3bfe7e-65e4-4990-9b55-c214c244cdfa',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName1_tca','Not found','2020-03-10 15:34:31.780435','Not found','2020-03-10 15:34:31.780435','CLOSED','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-28fa0ed8-0e43-44ae-82cc-68e7507dd9f1',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName1_tca_3','Not found','2020-03-10 15:34:31.399393','Not found','2020-03-10 15:34:31.399393','CLOSED','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-bd15286f-cfff-4703-b4f2-accbe3e79ce9',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName2_tca_2','Not found','2020-03-10 15:34:31.109027','Not found','2020-03-10 15:34:31.109027','CLOSED','#\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-7c473cb9-c825-43ec-97ce-6017c7ff15a2',0,'VESapp',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); /*!40000 ALTER TABLE `loop_templates` ENABLE KEYS */; UNLOCK TABLES; @@ -122,9 +122,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_knKBA_v1_0_ResourceInstanceName1_tca',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_knKBA_v1_0_ResourceInstanceName1_tca_3',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_knKBA_v1_0_ResourceInstanceName2_tca_2',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName1_tca',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName1_tca_3',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_MZ8ks_v1_0_ResourceInstanceName2_tca_2',0); /*!40000 ALTER TABLE `looptemplates_to_loopelementmodels` ENABLE KEYS */; UNLOCK TABLES; @@ -152,13 +152,13 @@ UNLOCK TABLES; LOCK TABLES `policy_models` WRITE; /*!40000 ALTER TABLE `policy_models` DISABLE KEYS */; -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.Blacklist','1.0.0','Not found','2020-03-09 15:32:42.528466','Not found','2020-03-09 15:32:43.229545','Blacklist','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.Blacklist:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports blacklist of entity id\'s from performing control loop actions on.\n properties:\n blacklist:\n type: list\n description: List of entity id\'s\n required: true\n entry_schema:\n type: string','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"xacml\"\n ]\n }\n ]\n}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.FrequencyLimiter','1.0.0','Not found','2020-03-09 15:32:42.464419','Not found','2020-03-09 15:32:43.255365','FrequencyLimiter','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.FrequencyLimiter:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports limiting the frequency of actions being taken by a Actor.\n properties:\n timeWindow:\n type: integer\n description: The time window to count the actions against.\n required: true\n timeUnits:\n type: string\n description: The units of time the window is counting.\n constraints:\n - valid_values: [\"second\", \"minute\", \"hour\", \"day\", \"week\", \"month\", \"year\"]\n limit:\n type: integer\n description: The limit\n required: true\n constraints:\n - greater_than: 0','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"xacml\"\n ]\n }\n ]\n}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.MinMax','2.0.0','Not found','2020-03-09 15:32:42.424488','Not found','2020-03-09 15:32:42.424488','MinMax','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.MinMax:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports Min/Max number of entity for scaling operations\n properties:\n min:\n type: integer\n required: true\n description: The minimum instances of this entity\n max:\n type: integer\n required: false\n description: The maximum instances of this entity',NULL); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.operational.common.Apex','1.0.0','Not found','2020-03-09 15:32:42.460317','Not found','2020-03-09 15:32:43.280860','Apex','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.common.Apex:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Apex PDP\n properties:\n engineServiceParameters:\n type: string\n description: The engine parameters like name, instanceCount, policy implementation, parameters etc.\n required: true\n eventInputParameters:\n type: string\n description: The event input parameters.\n required: true\n eventOutputParameters:\n type: string\n description: The event output parameters.\n required: true\n javaProperties:\n type: string\n description: Name/value pairs of properties to be set for APEX if needed.\n required: false\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n operation:\n type: string\n description: The operation the actor is performing.\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n metadata:\n clamp_possible_values: \n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n metadata:\n clamp_possible_values: \n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"drools\"\n ]\n }\n ]\n}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.operational.common.Drools','1.0.0','Not found','2020-03-09 15:32:42.385667','Not found','2020-03-09 15:32:43.309310','Drools','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.common.Drools:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Drools PDP\n properties:\n controllerName:\n type: string\n description: Drools controller properties\n required: false\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n operation:\n type: string\n description: The operation the actor is performing.\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n metadata:\n clamp_possible_values: \n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n metadata:\n clamp_possible_values: \n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"drools\"\n ]\n }\n ]\n}'); -INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0','Not found','2020-03-09 15:32:37.762082','Not found','2020-03-09 15:32:43.330702','app','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: a base policy type for all policies that govern 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: onap.datatypes.monitoring.tca_policy\n description: TCA Policy JSON\n required: true\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 \"supportedPdpGroups\": [\n {\n \"monitoring\": [\n \"xacml\"\n ]\n }\n ]\n}'); -INSERT INTO `policy_models` VALUES ('onap.policies.operational.legacy','1.0.0','Not found','2020-03-09 15:31:28.413120','Not found','2020-03-09 15:31:28.413120','OperationalPolicyLegacy','',NULL); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.Blacklist','1.0.0','Not found','2020-03-10 15:34:16.151282','Not found','2020-03-10 15:34:16.653893','Blacklist','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.Blacklist:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports blacklist of entity id\'s from performing control loop actions on.\n properties:\n blacklist:\n type: list\n description: List of entity id\'s\n required: true\n entry_schema:\n type: string','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"xacml\"\n ]\n }\n ]\n}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.FrequencyLimiter','1.0.0','Not found','2020-03-10 15:34:16.022020','Not found','2020-03-10 15:34:16.698932','FrequencyLimiter','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.FrequencyLimiter:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports limiting the frequency of actions being taken by a Actor.\n properties:\n timeWindow:\n type: integer\n description: The time window to count the actions against.\n required: true\n timeUnits:\n type: string\n description: The units of time the window is counting.\n constraints:\n - valid_values: [\"second\", \"minute\", \"hour\", \"day\", \"week\", \"month\", \"year\"]\n limit:\n type: integer\n description: The limit\n required: true\n constraints:\n - greater_than: 0','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"xacml\"\n ]\n }\n ]\n}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.common.MinMax','2.0.0','Not found','2020-03-10 15:34:16.006652','Not found','2020-03-10 15:34:16.006652','MinMax','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.guard.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n This is the base Policy Type for Guard policies that guard the execution of Operational\n Policies.\n properties:\n actor:\n type: string\n description: Specifies the Actor the guard applies to.\n required: true\n operation:\n type: string\n description: Specified the operation that the actor is performing the guard applies to.\n required: true\n timeRange:\n type: tosca.datatypes.TimeInterval\n description: |\n An optional range of time during the day the guard policy is valid for.\n required: false\n id:\n type: string\n description: The Control Loop id this applies to.\n required: false\n onap.policies.controlloop.guard.common.MinMax:\n derived_from: onap.policies.controlloop.guard.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Supports Min/Max number of entity for scaling operations\n properties:\n min:\n type: integer\n required: true\n description: The minimum instances of this entity\n max:\n type: integer\n required: false\n description: The maximum instances of this entity',NULL); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.operational.common.Apex','1.0.0','Not found','2020-03-10 15:34:16.007394','Not found','2020-03-10 15:34:16.743212','Apex','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.common.Apex:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Apex PDP\n properties:\n engineServiceParameters:\n type: string\n description: The engine parameters like name, instanceCount, policy implementation, parameters etc.\n required: true\n eventInputParameters:\n type: string\n description: The event input parameters.\n required: true\n eventOutputParameters:\n type: string\n description: The event output parameters.\n required: true\n javaProperties:\n type: string\n description: Name/value pairs of properties to be set for APEX if needed.\n required: false\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n operation:\n type: string\n description: The operation the actor is performing.\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n metadata:\n clamp_possible_values: \n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n metadata:\n clamp_possible_values: \n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"drools\"\n ]\n }\n ]\n}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.operational.common.Drools','1.0.0','Not found','2020-03-10 15:34:16.007394','Not found','2020-03-10 15:34:16.776393','Drools','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.controlloop.operational.common.Drools:\n derived_from: onap.policies.controlloop.operational.Common\n type_version: 1.0.0\n version: 1.0.0\n description: Operational policies for Drools PDP\n properties:\n controllerName:\n type: string\n description: Drools controller properties\n required: false\n onap.policies.controlloop.operational.Common:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: |\n Operational Policy for Control Loop execution. Originated in Frankfurt to support TOSCA Compliant\n Policy Types. This does NOT support the legacy Policy YAML policy type.\n properties:\n id:\n type: string\n description: The unique control loop id.\n required: true\n timeout:\n type: integer\n description: |\n Overall timeout for executing all the operations. This timeout should equal or exceed the total\n timeout for each operation listed.\n required: true\n abatement:\n type: boolean\n description: Whether an abatement event message will be expected for the control loop from DCAE.\n required: true\n default: false\n trigger:\n type: string\n description: Initial operation to execute upon receiving an Onset event message for the Control Loop.\n required: true\n operations:\n type: list\n description: List of operations to be performed when Control Loop is triggered.\n required: true\n entry_schema:\n type: onap.datatype.controlloop.Operation\ndata_types:\n onap.datatype.controlloop.Target:\n derived_from: tosca.datatypes.Root\n description: Definition for a entity in A&AI to perform a control loop operation on\n properties:\n targetType:\n type: string\n description: Category for the target type\n required: true\n constraints:\n - valid_values: [VNF, VM, VFMODULE, PNF]\n entityIds:\n type: map\n description: |\n Map of values that identify the resource. If none are provided, it is assumed that the\n entity that generated the ONSET event will be the target.\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Actor:\n derived_from: tosca.datatypes.Root\n description: An actor/operation/target definition\n properties:\n actor:\n type: string\n description: The actor performing the operation.\n required: true\n operation:\n type: string\n description: The operation the actor is performing.\n required: true\n target:\n type: onap.datatype.controlloop.Target\n description: The resource the operation should be performed on.\n required: true\n metadata:\n clamp_possible_values: \n payload:\n type: map\n description: Name/value pairs of payload information passed by Policy to the actor\n required: false\n entry_schema:\n type: string\n\n onap.datatype.controlloop.Operation:\n derived_from: tosca.datatypes.Root\n description: An operation supported by an actor\n properties:\n id:\n type: string\n description: Unique identifier for the operation\n required: true\n description:\n type: string\n description: A user-friendly description of the intent for the operation\n required: false\n operation:\n type: onap.datatype.controlloop.Actor\n description: The definition of the operation to be performed.\n required: true\n metadata:\n clamp_possible_values: \n timeout:\n type: integer\n description: The amount of time for the actor to perform the operation.\n required: true\n retries:\n type: integer\n description: The number of retries the actor should attempt to perform the operation.\n required: true\n default: 0\n success:\n type: string\n description: Points to the operation to invoke on success. A value of \"final_success\" indicates and end to the operation.\n required: false\n default: final_success\n failure:\n type: string\n description: Points to the operation to invoke on Actor operation failure.\n required: false\n default: final_failure\n failure_timeout:\n type: string\n description: Points to the operation to invoke when the time out for the operation occurs.\n required: false\n default: final_failure_timeout\n failure_retries:\n type: string\n description: Points to the operation to invoke when the current operation has exceeded its max retries.\n required: false\n default: final_failure_retries\n failure_exception:\n type: string\n description: Points to the operation to invoke when the current operation causes an exception.\n required: false\n default: final_failure_exception\n failure_guard:\n type: string\n description: Points to the operation to invoke when the current operation is blocked due to guard policy enforcement.\n required: false\n default: final_failure_guard','{\n \"supportedPdpGroups\": [\n {\n \"controlloop\": [\n \"drools\"\n ]\n }\n ]\n}'); +INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0','Not found','2020-03-10 15:34:31.141969','Not found','2020-03-10 15:34:31.141969','app','tosca_definitions_version: tosca_simple_yaml_1_1_0\npolicy_types:\n onap.policies.Monitoring:\n derived_from: tosca.policies.Root\n version: 1.0.0\n description: a base policy type for all policies that govern 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: onap.datatypes.monitoring.tca_policy\n description: TCA Policy JSON\n required: true\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',NULL); +INSERT INTO `policy_models` VALUES ('onap.policies.operational.legacy','1.0.0','Not found','2020-03-10 15:34:09.817128','Not found','2020-03-10 15:34:09.817128','OperationalPolicyLegacy','',NULL); /*!40000 ALTER TABLE `policy_models` ENABLE KEYS */; UNLOCK TABLES; @@ -168,7 +168,7 @@ UNLOCK TABLES; LOCK TABLES `services` WRITE; /*!40000 ALTER TABLE `services` DISABLE KEYS */; -INSERT INTO `services` VALUES ('63cac700-ab9a-4115-a74f-7eac85e3fce0','vLoadBalancerMS','{\n \"CP\": {},\n \"VL\": {},\n \"VF\": {\n \"vLoadBalancerMS 0\": {\n \"resourceVendor\": \"Test\",\n \"name\": \"vLoadBalancerMS\",\n \"resourceVendorModelNumber\": \"\",\n \"description\": \"vLBMS\",\n \"invariantUUID\": \"1a31b9f2-e50d-43b7-89b3-a040250cf506\",\n \"UUID\": \"b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6\",\n \"type\": \"VF\",\n \"category\": \"Application L4+\",\n \"subcategory\": \"Load Balancer\",\n \"version\": \"1.0\",\n \"customizationUUID\": \"465246dc-7748-45f4-a013-308d92922552\",\n \"resourceVendorRelease\": \"1.0\"\n }\n },\n \"CR\": {},\n \"VFC\": {},\n \"PNF\": {},\n \"Service\": {},\n \"CVFC\": {},\n \"Service Proxy\": {},\n \"Configuration\": {},\n \"AllottedResource\": {},\n \"VFModule\": {\n \"Vloadbalancerms..vpkg..module-1\": {\n \"vfModuleModelInvariantUUID\": \"ca052563-eb92-4b5b-ad41-9111768ce043\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vpkg..module-1\",\n \"vfModuleModelUUID\": \"1e725ccc-b823-4f67-82b9-4f4367070dbc\",\n \"vfModuleModelCustomizationUUID\": \"1bffdc31-a37d-4dee-b65c-dde623a76e52\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vpkg\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n },\n \"Vloadbalancerms..vdns..module-3\": {\n \"vfModuleModelInvariantUUID\": \"4c10ba9b-f88f-415e-9de3-5d33336047fa\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vdns..module-3\",\n \"vfModuleModelUUID\": \"4fa73b49-8a6c-493e-816b-eb401567b720\",\n \"vfModuleModelCustomizationUUID\": \"bafcdab0-801d-4d81-9ead-f464640a38b1\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vdns\",\n \"max_vf_module_instances\": 50,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n },\n \"Vloadbalancerms..base_template..module-0\": {\n \"vfModuleModelInvariantUUID\": \"921f7c96-ebdd-42e6-81b9-1cfc0c9796f3\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..base_template..module-0\",\n \"vfModuleModelUUID\": \"63734409-f745-4e4d-a38b-131638a0edce\",\n \"vfModuleModelCustomizationUUID\": \"86baddea-c730-4fb8-9410-cd2e17fd7f27\",\n \"min_vf_module_instances\": 1,\n \"vf_module_label\": \"base_template\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Base\",\n \"isBase\": true,\n \"initial_count\": 1,\n \"volume_group\": false\n },\n \"Vloadbalancerms..vlb..module-2\": {\n \"vfModuleModelInvariantUUID\": \"a772a1f4-0064-412c-833d-4749b15828dd\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vlb..module-2\",\n \"vfModuleModelUUID\": \"0f5c3f6a-650a-4303-abb6-fff3e573a07a\",\n \"vfModuleModelCustomizationUUID\": \"96a78aad-4ffb-4ef0-9c4f-deb03bf1d806\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vlb\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n }\n }\n}','{\n \"serviceType\": \"\",\n \"serviceRole\": \"\",\n \"description\": \"vLBMS\",\n \"type\": \"Service\",\n \"instantiationType\": \"A-la-carte\",\n \"namingPolicy\": \"\",\n \"serviceEcompNaming\": \"true\",\n \"environmentContext\": \"General_Revenue-Bearing\",\n \"name\": \"vLoadBalancerMS\",\n \"invariantUUID\": \"30ec5b59-4799-48d8-ac5f-1058a6b0e48f\",\n \"ecompGeneratedNaming\": \"true\",\n \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\",\n \"category\": \"Network L4+\"\n}','1.0'); +INSERT INTO `services` VALUES ('63cac700-ab9a-4115-a74f-7eac85e3fce0','vLoadBalancerMS','{\n \"CP\": {},\n \"VL\": {},\n \"VF\": {\n \"vLoadBalancerMS 0\": {\n \"resourceVendor\": \"Test\",\n \"name\": \"vLoadBalancerMS\",\n \"resourceVendorModelNumber\": \"\",\n \"description\": \"vLBMS\",\n \"invariantUUID\": \"1a31b9f2-e50d-43b7-89b3-a040250cf506\",\n \"UUID\": \"b4c4f3d7-929e-4b6d-a1cd-57e952ddc3e6\",\n \"type\": \"VF\",\n \"category\": \"Application L4+\",\n \"subcategory\": \"Load Balancer\",\n \"version\": \"1.0\",\n \"customizationUUID\": \"465246dc-7748-45f4-a013-308d92922552\",\n \"resourceVendorRelease\": \"1.0\",\n \"controllerProperties\": {\n \"sdnc_model_name\": \"baseconfiguration\",\n \"sdnc_model_version\": \"1.0.0\",\n \"workflows\": {\n \"resource-assignment\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n },\n \"activate\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n },\n \"activate-restconf\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n },\n \"activate-cli\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n },\n \"assign-activate\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n },\n \"imperative-test-wf\": {\n \"inputs\": {\n \"resource-assignment-properties\": {\n \"request-id\": \"\",\n \"service-instance-id\": \"\",\n \"vnf-id\": \"\",\n \"action-name\": \"\",\n \"scope-type\": \"\",\n \"hostname\": \"\",\n \"vnf_name\": \"\"\n }\n }\n }\n }\n }\n }\n },\n \"CR\": {},\n \"VFC\": {},\n \"PNF\": {},\n \"Service\": {},\n \"CVFC\": {},\n \"Service Proxy\": {},\n \"Configuration\": {},\n \"AllottedResource\": {},\n \"VFModule\": {\n \"Vloadbalancerms..vpkg..module-1\": {\n \"vfModuleModelInvariantUUID\": \"ca052563-eb92-4b5b-ad41-9111768ce043\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vpkg..module-1\",\n \"vfModuleModelUUID\": \"1e725ccc-b823-4f67-82b9-4f4367070dbc\",\n \"vfModuleModelCustomizationUUID\": \"1bffdc31-a37d-4dee-b65c-dde623a76e52\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vpkg\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n },\n \"Vloadbalancerms..vdns..module-3\": {\n \"vfModuleModelInvariantUUID\": \"4c10ba9b-f88f-415e-9de3-5d33336047fa\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vdns..module-3\",\n \"vfModuleModelUUID\": \"4fa73b49-8a6c-493e-816b-eb401567b720\",\n \"vfModuleModelCustomizationUUID\": \"bafcdab0-801d-4d81-9ead-f464640a38b1\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vdns\",\n \"max_vf_module_instances\": 50,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n },\n \"Vloadbalancerms..base_template..module-0\": {\n \"vfModuleModelInvariantUUID\": \"921f7c96-ebdd-42e6-81b9-1cfc0c9796f3\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..base_template..module-0\",\n \"vfModuleModelUUID\": \"63734409-f745-4e4d-a38b-131638a0edce\",\n \"vfModuleModelCustomizationUUID\": \"86baddea-c730-4fb8-9410-cd2e17fd7f27\",\n \"min_vf_module_instances\": 1,\n \"vf_module_label\": \"base_template\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Base\",\n \"isBase\": true,\n \"initial_count\": 1,\n \"volume_group\": false\n },\n \"Vloadbalancerms..vlb..module-2\": {\n \"vfModuleModelInvariantUUID\": \"a772a1f4-0064-412c-833d-4749b15828dd\",\n \"vfModuleModelVersion\": \"1\",\n \"vfModuleModelName\": \"Vloadbalancerms..vlb..module-2\",\n \"vfModuleModelUUID\": \"0f5c3f6a-650a-4303-abb6-fff3e573a07a\",\n \"vfModuleModelCustomizationUUID\": \"96a78aad-4ffb-4ef0-9c4f-deb03bf1d806\",\n \"min_vf_module_instances\": 0,\n \"vf_module_label\": \"vlb\",\n \"max_vf_module_instances\": 1,\n \"vf_module_type\": \"Expansion\",\n \"isBase\": false,\n \"initial_count\": 0,\n \"volume_group\": false\n }\n }\n}','{\n \"serviceType\": \"\",\n \"serviceRole\": \"\",\n \"description\": \"vLBMS\",\n \"type\": \"Service\",\n \"instantiationType\": \"A-la-carte\",\n \"namingPolicy\": \"\",\n \"serviceEcompNaming\": \"true\",\n \"environmentContext\": \"General_Revenue-Bearing\",\n \"name\": \"vLoadBalancerMS\",\n \"invariantUUID\": \"30ec5b59-4799-48d8-ac5f-1058a6b0e48f\",\n \"ecompGeneratedNaming\": \"true\",\n \"UUID\": \"63cac700-ab9a-4115-a74f-7eac85e3fce0\",\n \"category\": \"Network L4+\"\n}','1.0'); /*!40000 ALTER TABLE `services` ENABLE KEYS */; UNLOCK TABLES; /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; @@ -180,4 +180,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-03-09 22:34:15 +-- Dump completed on 2020-03-10 22:35:47 diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Component.java b/src/main/java/org/onap/clamp/clds/tosca/update/Component.java deleted file mode 100644 index 6db129d1..00000000 --- a/src/main/java/org/onap/clamp/clds/tosca/update/Component.java +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ============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.tosca.update; - -import java.util.ArrayList; -import java.util.LinkedHashMap; - -public class Component { - - /** - * name parameter is used as "key", in the LinkedHashMap of Components. - */ - private String name; - private String derivedFrom; - private String version; - private String typeVersion; - private String description; - private LinkedHashMap properties; - - public Component() { - } - - /** - * Constructor. - * - * @param name name - * @param derivedFrom derivedFrom - * @param description description - */ - @SuppressWarnings({"unchecked", "rawtypes"}) - public Component(String name, String derivedFrom, String description) { - super(); - this.name = name; - this.derivedFrom = derivedFrom; - this.description = description; - this.properties = new LinkedHashMap(); - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDerivedFrom() { - return derivedFrom; - } - - public void setDerivedFrom(String derivedFrom) { - this.derivedFrom = derivedFrom; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getTypeVersion() { - return typeVersion; - } - - public void setTypeVersion(String typeVersion) { - this.typeVersion = typeVersion; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public LinkedHashMap getProperties() { - return properties; - } - - public void setProperties(LinkedHashMap properties) { - this.properties = properties; - } - - public void addProperties(Property property) { - this.properties.put(property.getName(), property); - } - - public ArrayList propertiesNames() { - return new ArrayList<>(properties.keySet()); - } - - @Override - public String toString() { - return name + ": " + description + ", version: " + version + ", nb de properties: " + properties.size() - + System.getProperty("line.separator") + propertiesNames(); - } -} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java b/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java deleted file mode 100644 index c6eabcd3..00000000 --- a/src/main/java/org/onap/clamp/clds/tosca/update/Extractor.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============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.tosca.update; - -import java.util.LinkedHashMap; -import java.util.Map.Entry; -import org.yaml.snakeyaml.Yaml; - -public class Extractor { - private LinkedHashMap allItems; - private String source; - private String nativeComponent; - - /** - * Constructor. - * - * @param toParse Tosca to parse - * @param nativeComponent The policy type to scan - */ - public Extractor(String toParse, String nativeComponent) { - - this.source = toParse; - this.nativeComponent = nativeComponent; - allItems = new LinkedHashMap(); - getAllAsMaps(); - } - - public LinkedHashMap getAllItems() { - return allItems; - } - - public String getSource() { - return source; - } - - /** - * Yaml Parse gets raw policies and datatypes, in different sections : necessary to extract - * all entities and put them at the same level. - * - * @return an object - */ - @SuppressWarnings("unchecked") - public LinkedHashMap getAllAsMaps() { - Yaml yaml = new Yaml(); - Object contentFile = yaml.load(source); - LinkedHashMap> file = - (LinkedHashMap>) contentFile; - // Get DataTypes - LinkedHashMap dataTypes = file.get("data_types"); - dataTypes = (dataTypes == null) ? (new LinkedHashMap<>()) : dataTypes; - // Get Policies : first, get topology and after extract policies from it - LinkedHashMap policyTypes = file.get("policy_types"); - // Put the policies and datatypes in the same collection - dataTypes.putAll(policyTypes); - - Object contentNativeFile = yaml.load(nativeComponent); - LinkedHashMap dataTypesEmbedded = - ((LinkedHashMap>) contentNativeFile).get("data_types"); - dataTypes.putAll(dataTypesEmbedded); - - parseInComponent(dataTypes); - return dataTypes; - } - - /** - * With all the component, get as Map, Components and Components properties are created. - * - * @param allMaps maps - */ - @SuppressWarnings("unchecked") - public void parseInComponent(LinkedHashMap allMaps) { - //Component creations, from the file maps - for (Entry itemToParse : allMaps.entrySet()) { - LinkedHashMap componentBody = (LinkedHashMap) itemToParse.getValue(); - Component component = new Component(itemToParse.getKey(), (String) componentBody.get("derived_from"), - (String) componentBody.get("description")); - //If policy, version and type_version : - if (componentBody.get("type_version") != null) { - component.setVersion((String) componentBody.get("type_version")); - component.setTypeVersion((String) componentBody.get("type_version")); - } - //Properties creation, from the map - if (componentBody.get("properties") != null) { - LinkedHashMap properties = - (LinkedHashMap) componentBody.get("properties"); - for (Entry itemToProperty : properties.entrySet()) { - Property property = new Property(itemToProperty.getKey(), - (LinkedHashMap) itemToProperty.getValue()); - component.addProperties(property); - } - } - this.allItems.put(component.getName(), component); - } - } -} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Field.java b/src/main/java/org/onap/clamp/clds/tosca/update/Field.java deleted file mode 100644 index e01f14c4..00000000 --- a/src/main/java/org/onap/clamp/clds/tosca/update/Field.java +++ /dev/null @@ -1,147 +0,0 @@ -/*- - * ============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.tosca.update; - -public class Field { - private String title; - private Object value; - private Boolean visible; - private Boolean staticValue; - - public Field(String title) { - this.title = title; - } - - /** - * Constructor. - * - * @param title The title - * @param value The value - * @param visible visible or not - * @param staticValue The static value - */ - public Field(String title, Object value, Boolean visible, Boolean staticValue) { - this.title = title; - this.value = value; - this.visible = visible; - this.staticValue = staticValue; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Object getValue() { - return value; - } - - public void setValue(Object value) { - this.value = value; - } - - public Boolean getVisible() { - return visible; - } - - public void setVisible(Boolean visible) { - this.visible = visible; - } - - public Boolean getStaticValue() { - return staticValue; - } - - public void setStaticValue(Boolean staticValue) { - this.staticValue = staticValue; - } - - public String toString() { - return title + " " + value + " " + visible + " " + staticValue; - } - - /** - * This method compares two fields. - * - * @param otherField Compare the current object with the one specified - * @return true if they are totally equals, false otherwise - */ - public boolean compareWithField(Object otherField) { - if (this == otherField) { - return true; - } - if (otherField == null || getClass() != otherField.getClass()) { - return false; - } - - Field field = (Field) otherField; - - if (title != null ? !title.equals(field.title) : field.title != null) { - return false; - } - if (value != null ? !value.equals(field.value) : field.value != null) { - return false; - } - if (visible != null ? !visible.equals(field.visible) : field.visible != null) { - return false; - } - return staticValue != null ? staticValue.equals(field.staticValue) : field.staticValue == null; - } - - @Override - public boolean equals(Object object) { - if (this == object) { - return true; - } - if (object == null || getClass() != object.getClass()) { - return false; - } - - Field field = (Field) object; - - return title != null ? title.equals(field.title) : field.title == null; - } - - @Override - public int hashCode() { - return title != null ? title.hashCode() : 0; - } - - /** - * This method test the entire equality. - * - * @param field1 object one - * @param field2 object two - * @return true if they are totally equals (all attributes, false otherwise - */ - public static boolean fieldsEquals(Field field1, Field field2) { - return (field2.getTitle().equals(field1.getTitle()) && field2.getValue().equals(field1.getValue()) - && field2.getVisible().equals(field1.getVisible()) - && field2.getStaticValue().equals(field1.getStaticValue())); - } - -} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/MetadataParser.java b/src/main/java/org/onap/clamp/clds/tosca/update/MetadataParser.java new file mode 100644 index 00000000..fb70231f --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/MetadataParser.java @@ -0,0 +1,46 @@ + +/*- + * ============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.tosca.update; + +import com.google.gson.JsonObject; +import org.onap.clamp.tosca.DictionaryService; + +public class MetadataParser { + + /** + * This method is used to start the processing of the metadata field. + * + * @param property The property metadata as Json Object + * @param dictionaryService the Dictionary service, if null nothing will be done + * @return The jsonObject structure that must be added to the json schema + */ + public static JsonObject processAllMetadataElement(Property property, DictionaryService dictionaryService) { + if (dictionaryService != null) { + return null; + } else { + return null; + } + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java b/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java deleted file mode 100644 index 3c5cf975..00000000 --- a/src/main/java/org/onap/clamp/clds/tosca/update/ParserToJson.java +++ /dev/null @@ -1,321 +0,0 @@ -/*- - * ============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.tosca.update; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.ArrayList; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map.Entry; - -public class ParserToJson { - private LinkedHashMap components; - private LinkedHashMap templates; - - public ParserToJson(LinkedHashMap components, LinkedHashMap templates) { - this.components = components; - this.templates = templates; - } - - /** - * For a given component, launch process to parse it in Json. - * - * @param nameComponent name components - * @return return - */ - public JsonObject getJsonProcess(String nameComponent, String typeComponent) { - JsonObject glob = new JsonObject(); - - if (typeComponent.equals("object")) { - glob = this.getFieldAsObject(matchComponent(nameComponent)); - } - else { - /*glob = this.getFieldAsArray(matchComponent(nameComponent));*/ - } - - return glob; - } - - /** - * Return the classical/general fields of the component, & launch the properties deployment. - * - * @param component the compo - * @return a json object - */ - public JsonObject getFieldAsObject(Component component) { - - JsonObject globalFields = new JsonObject(); - if (templates.get("object").hasFields("title")) { - globalFields.addProperty("title", component.getName()); - } - if (templates.get("object").hasFields("type")) { - globalFields.addProperty("type", "object"); - } - if (templates.get("object").hasFields("description")) { - if (component.getDescription() != null) { - globalFields.addProperty("description", component.getDescription()); - } - } - if (templates.get("object").hasFields("required")) { - globalFields.add("required", this.getRequirements(component.getName())); - } - if (templates.get("object").hasFields("properties")) { - globalFields.add("properties", this.deploy(component.getName())); - } - return globalFields; - } - - /** - * Get the required properties of the Component, including the parents properties requirements. - * - * @param nameComponent name component - * @return a json array - */ - public JsonArray getRequirements(String nameComponent) { - JsonArray requirements = new JsonArray(); - Component toParse = components.get(nameComponent); - //Check for a father component, and launch the same process - if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root") - && !toParse.getDerivedFrom().equals("tosca.policies.Root")) { - requirements.addAll(getRequirements(toParse.getDerivedFrom())); - } - //Each property is checked, and add to the requirement array if it's required - Collection properties = toParse.getProperties().values(); - for (Property property : properties) { - if (property.getItems().containsKey("required") - && property.getItems().get("required").equals(true)) { - requirements.add(property.getName()); - } - } - return requirements; - } - - /** - * The beginning of the recursive process. Get the parents (or not) to launch the same process, and otherwise - * deploy and parse the properties. - * - * @param nameComponent name component - * @return a json object - */ - public JsonObject deploy(String nameComponent) { - JsonObject jsonSchema = new JsonObject(); - Component toParse = components.get(nameComponent); - //Check for a father component, and launch the same process - if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root") - && !toParse.getDerivedFrom().equals("tosca.policies.Root")) { - jsonSchema = this.getParent(toParse.getDerivedFrom()); - } - //For each component property, check if its a complex properties (a component) or not. In that case, - //launch the analyse of the property. - for (Entry property : toParse.getProperties().entrySet()) { - if (matchComponent((String) property.getValue().getItems().get("type")) != null) { - jsonSchema.add(property.getValue().getName(), - this.getJsonProcess((String) property.getValue().getItems().get("type"), "object")); - } - else { - jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue())); - } - } - return jsonSchema; - } - - /** - * If a component has a parent, it is deploy in the same way. - * - * @param nameComponent name component - * @return a json object - */ - public JsonObject getParent(String nameComponent) { - return deploy(nameComponent); - } - - /** - * to be done. - * - * @param property property - * @return a json object - */ - @SuppressWarnings("unchecked") - public JsonObject complexParse(Property property) { - JsonObject propertiesInJson = new JsonObject(); - Template currentPropertyTemplate; - String typeProperty = (String) property.getItems().get("type"); - if (typeProperty.toLowerCase().equals("list") || typeProperty.toLowerCase().equals("map")) { - currentPropertyTemplate = templates.get("object"); - } - else { - String propertyType = (String) property.getItems().get("type"); - currentPropertyTemplate = templates.get(propertyType.toLowerCase()); - } - //Each "special" field is analysed, and has a specific treatment - for (String propertyField : property.getItems().keySet()) { - switch (propertyField) { - case "type": - if (currentPropertyTemplate.hasFields(propertyField)) { - String fieldtype = (String) property.getItems().get(propertyField); - switch (fieldtype.toLowerCase()) { - case "list": - propertiesInJson.addProperty("type", "array"); - break; - case "map": - propertiesInJson.addProperty("type", "object"); - break; - case "scalar-unit.time": - case "scalar-unit.frequency": - case "scalar-unit.size": - propertiesInJson.addProperty("type", "string"); - break; - case "timestamp": - propertiesInJson.addProperty("type", "string"); - propertiesInJson.addProperty("format", "date-time"); - break; - case "float": - propertiesInJson.addProperty("type", "number"); - break; - case "range": - propertiesInJson.addProperty("type", "integer"); - if (!checkConstraintPresence(property, "greater_than") - && currentPropertyTemplate.hasFields("exclusiveMinimum")) { - propertiesInJson.addProperty("exclusiveMinimum", false); - } - if (!checkConstraintPresence(property, "less_than") - && currentPropertyTemplate.hasFields("exclusiveMaximum")) { - propertiesInJson.addProperty("exclusiveMaximum", false); - } - break; - default: - propertiesInJson.addProperty("type", currentPropertyTemplate.getName()); - break; - } - } - break; - case "metadata": - break; - case "constraints": - property.addConstraintsAsJson(propertiesInJson, - (ArrayList) property.getItems().get("constraints"), - currentPropertyTemplate); - break; - case "entry_schema": - //Here, a way to check if entry is a component (datatype) or a simple string - if (matchComponent(this.extractSpecificFieldFromMap(property, "entry_schema")) != null) { - String nameComponent = this.extractSpecificFieldFromMap(property, "entry_schema"); - ParserToJson child = new ParserToJson(components, templates); - JsonObject propertiesContainer = new JsonObject(); - - switch ((String) property.getItems().get("type")) { - case "map": // Get it as an object - JsonObject componentAsProperty = child.getJsonProcess(nameComponent, "object"); - propertiesContainer.add(nameComponent, componentAsProperty); - if (currentPropertyTemplate.hasFields("properties")) { - propertiesInJson.add("properties", propertiesContainer); - } - break; - default://list : get it as an Array - JsonObject componentAsItem = child.getJsonProcess(nameComponent, "object"); - if (currentPropertyTemplate.hasFields("properties")) { - propertiesInJson.add("items", componentAsItem); - } - break; - } - - } - // Native cases - else if (property.getItems().get("type").equals("list")) { - JsonObject itemContainer = new JsonObject(); - String valueInEntrySchema = this.extractSpecificFieldFromMap(property, "entry_schema"); - itemContainer.addProperty("type", valueInEntrySchema); - propertiesInJson.add("items", itemContainer); - } - // MAP Case, for now nothing - - break; - default: - //Each classical field : type, description, default.. - if (currentPropertyTemplate.hasFields(propertyField) && !propertyField.equals("required")) { - property.addFieldToJson(propertiesInJson, propertyField, - property.getItems().get(propertyField)); - } - break; - } - } - return propertiesInJson; - } - - /** - * Look for a matching Component for the name paramater, in the components list. - * - * @param name the name - * @return a component - */ - public Component matchComponent(String name) { - Component correspondingComponent = null; - if (components == null) { - return null; - } - for (Component component : components.values()) { - if (component.getName().equals(name)) { - correspondingComponent = component; - } - } - return correspondingComponent; - } - - /** - * Simple method to extract quickly a type field from particular property item. - * - * @param property the property - * @param fieldName the fieldname - * @return a string - */ - @SuppressWarnings("unchecked") - public String extractSpecificFieldFromMap(Property property, String fieldName) { - LinkedHashMap entrySchemaFields = - (LinkedHashMap) property.getItems().get(fieldName); - return entrySchemaFields.get("type"); - } - - /** - * Check if a constraint, for a specific property, is there. - * - * @param property property - * @param nameConstraint name constraint - * @return a flag boolean - */ - public boolean checkConstraintPresence(Property property, String nameConstraint) { - boolean presentConstraint = false; - if (property.getItems().containsKey("constraints")) { - ArrayList constraints = (ArrayList) property.getItems().get("constraints"); - for (Object constraint : constraints) { - if (constraint instanceof LinkedHashMap) { - if (((LinkedHashMap) constraint).containsKey(nameConstraint)) { - presentConstraint = true; - } - } - } - } - return presentConstraint; - } -} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/Template.java b/src/main/java/org/onap/clamp/clds/tosca/update/Template.java index 4507e3d7..6a531aee 100644 --- a/src/main/java/org/onap/clamp/clds/tosca/update/Template.java +++ b/src/main/java/org/onap/clamp/clds/tosca/update/Template.java @@ -33,16 +33,16 @@ public class Template { * name parameter is used as "key", in the LinkedHashMap of Templates. */ private String name; - private List fields; + private List templateFields; public Template(String name) { this.name = name; - this.fields = new ArrayList<>(); + this.templateFields = new ArrayList<>(); } - public Template(String name, List fields) { + public Template(String name, List templateFields) { this.name = name; - this.fields = fields; + this.templateFields = templateFields; } public String getName() { @@ -53,12 +53,12 @@ public class Template { this.name = name; } - public List getFields() { - return fields; + public List getTemplateFields() { + return templateFields; } - public void setFields(List fields) { - this.fields = fields; + public void setTemplateFields(List templateFields) { + this.templateFields = templateFields; } /** @@ -68,8 +68,8 @@ public class Template { * @return Ture if it exists, false otherwise */ public boolean hasFields(String fieldName) { - for (Field field : this.getFields()) { - if (field.getTitle().equals(fieldName)) { + for (TemplateField templateField : this.getTemplateFields()) { + if (templateField.getTitle().equals(fieldName)) { return true; } } @@ -82,21 +82,21 @@ public class Template { * @param fieldName The field name * @return THe Field found */ - public Field getSpecificField(String fieldName) { - for (Field field : this.getFields()) { - if (field.getTitle().equals(fieldName)) { - return field; + public TemplateField getSpecificField(String fieldName) { + for (TemplateField templateField : this.getTemplateFields()) { + if (templateField.getTitle().equals(fieldName)) { + return templateField; } } return null; } - public void addField(Field field) { - fields.add(field); + public void addField(TemplateField templateField) { + templateFields.add(templateField); } - public void removeField(Field field) { - fields.remove(field); + public void removeField(TemplateField templateField) { + templateFields.remove(templateField); } /** @@ -106,9 +106,9 @@ public class Template { * @param state True or false */ public void setVisibility(String nameField, boolean state) { - for (Field field : this.fields) { - if (field.getTitle().equals(nameField)) { - field.setVisible(state); + for (TemplateField templateField : this.templateFields) { + if (templateField.getTitle().equals(nameField)) { + templateField.setVisible(state); } } } @@ -120,9 +120,9 @@ public class Template { * @param state true or false */ public void setStatic(String nameField, boolean state) { - for (Field field : this.fields) { - if (field.getTitle().equals(nameField)) { - field.setStaticValue(state); + for (TemplateField templateField : this.templateFields) { + if (templateField.getTitle().equals(nameField)) { + templateField.setStaticValue(state); } } } @@ -134,9 +134,9 @@ public class Template { * @param newValue The new value as Object */ public void updateValueField(String nameField, Object newValue) { - for (Field field : this.fields) { - if (field.getTitle().equals(nameField)) { - field.setValue(newValue); + for (TemplateField templateField : this.templateFields) { + if (templateField.getTitle().equals(nameField)) { + templateField.setValue(newValue); } } } @@ -149,18 +149,18 @@ public class Template { */ public boolean checkFields(Template template) { boolean duplicateFields = false; - if (template.getFields().size() == this.getFields().size()) { + if (template.getTemplateFields().size() == this.getTemplateFields().size()) { int countMatchingFields = 0; //loop each component of first - for (Field templateFieldToCheck : template.getFields()) { - for (Field templateField : this.getFields()) { + for (TemplateField templateFieldToCheck : template.getTemplateFields()) { + for (TemplateField templateField : this.getTemplateFields()) { if (templateFieldToCheck.compareWithField(templateField)) { countMatchingFields++; } } } - if (template.getFields().size() == countMatchingFields) { + if (template.getTemplateFields().size() == countMatchingFields) { duplicateFields = true; } } @@ -212,13 +212,13 @@ public class Template { */ public void injectStaticValue(JsonObject jsonSchema, String fieldName) { if (isVisible(fieldName)) { - Field toInject = this.getSpecificField(fieldName); + TemplateField toInject = this.getSpecificField(fieldName); jsonSchema.addProperty(fieldName, (String) toInject.getValue()); } } @Override public String toString() { - return " fields : " + fields; + return " templateFields : " + templateFields; } } diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/TemplateField.java b/src/main/java/org/onap/clamp/clds/tosca/update/TemplateField.java new file mode 100644 index 00000000..34446436 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/TemplateField.java @@ -0,0 +1,148 @@ +/*- + * ============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.tosca.update; + +public class TemplateField { + private String title; + private Object value; + private Boolean visible; + private Boolean staticValue; + + public TemplateField(String title) { + this.title = title; + } + + /** + * Constructor. + * + * @param title The title + * @param value The value + * @param visible visible or not + * @param staticValue The static value + */ + public TemplateField(String title, Object value, Boolean visible, Boolean staticValue) { + this.title = title; + this.value = value; + this.visible = visible; + this.staticValue = staticValue; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public Object getValue() { + return value; + } + + public void setValue(Object value) { + this.value = value; + } + + public Boolean getVisible() { + return visible; + } + + public void setVisible(Boolean visible) { + this.visible = visible; + } + + public Boolean getStaticValue() { + return staticValue; + } + + public void setStaticValue(Boolean staticValue) { + this.staticValue = staticValue; + } + + public String toString() { + return title + " " + value + " " + visible + " " + staticValue; + } + + /** + * This method compares two fields. + * + * @param otherField Compare the current object with the one specified + * @return true if they are totally equals, false otherwise + */ + public boolean compareWithField(Object otherField) { + if (this == otherField) { + return true; + } + if (otherField == null || getClass() != otherField.getClass()) { + return false; + } + + TemplateField templateField = (TemplateField) otherField; + + if (title != null ? !title.equals(templateField.title) : templateField.title != null) { + return false; + } + if (value != null ? !value.equals(templateField.value) : templateField.value != null) { + return false; + } + if (visible != null ? !visible.equals(templateField.visible) : templateField.visible != null) { + return false; + } + return staticValue != null ? staticValue.equals(templateField.staticValue) : templateField.staticValue == null; + } + + @Override + public boolean equals(Object object) { + if (this == object) { + return true; + } + if (object == null || getClass() != object.getClass()) { + return false; + } + + TemplateField templateField = (TemplateField) object; + + return title != null ? title.equals(templateField.title) : templateField.title == null; + } + + @Override + public int hashCode() { + return title != null ? title.hashCode() : 0; + } + + /** + * This method test the entire equality. + * + * @param templateField1 object one + * @param templateField2 object two + * @return true if they are totally equals (all attributes, false otherwise + */ + public static boolean fieldsEquals(TemplateField templateField1, TemplateField templateField2) { + return (templateField2.getTitle().equals(templateField1.getTitle()) + && templateField2.getValue().equals(templateField1.getValue()) + && templateField2.getVisible().equals(templateField1.getVisible()) + && templateField2.getStaticValue().equals(templateField1.getStaticValue())); + } + +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java b/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java deleted file mode 100644 index 74307715..00000000 --- a/src/main/java/org/onap/clamp/clds/tosca/update/TemplateManagement.java +++ /dev/null @@ -1,191 +0,0 @@ -/*- - * ============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.tosca.update; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import java.io.IOException; -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import org.onap.clamp.clds.util.JsonUtils; - -public class TemplateManagement { - - private LinkedHashMap templates; - private LinkedHashMap components; - private ParserToJson parserToJson; - private Extractor extractor; - - /** - * Constructor. - * - * @param yamlContent Yaml content as string - * @param templateProperties template properties as string - * @throws IOException in case of failure - */ - public TemplateManagement(String yamlContent, String nativeComponent, String templateProperties) - throws IOException { - if (yamlContent != null && !yamlContent.isEmpty()) { - this.extractor = new Extractor(yamlContent, nativeComponent); - this.components = extractor.getAllItems(); - this.templates = initializeTemplates(templateProperties); - } - else { - components = null; - } - } - - //GETTERS & SETTERS - public LinkedHashMap getComponents() { - return components; - } - - public void setComponents(LinkedHashMap components) { - this.components = components; - } - - public ParserToJson getParseToJson() { - return parserToJson; - } - - public void setParseToJson(ParserToJson parserToJson) { - this.parserToJson = parserToJson; - } - - public LinkedHashMap getTemplates() { - return templates; - } - - public void setTemplates(LinkedHashMap templates) { - this.templates = templates; - } - - public Extractor getExtractor() { - return extractor; - } - - /** - * Add a template. - * - * @param name name - * @param fields fields - */ - public void addTemplate(String name, List fields) { - Template template = new Template(name, fields); - //If it is true, the operation does not have any interest : - // replace OR put two different object with the same body - if (!templates.containsKey(template.getName()) || !this.hasTemplate(template)) { - this.templates.put(template.getName(), template); - } - } - - /** - * By name, find and remove a given template. - * - * @param nameTemplate name template - */ - public void removeTemplate(String nameTemplate) { - this.templates.remove(nameTemplate); - } - - /** - * Update Template : adding with true flag, removing with false. - * - * @param nameTemplate name template - * @param field field name - * @param operation operation - */ - public void updateTemplate(String nameTemplate, Field field, Boolean operation) { - // Operation = true && field is not present => add Field - if (operation && !this.templates.get(nameTemplate).getFields().contains(field)) { - this.templates.get(nameTemplate).addField(field); - } - // Operation = false && field is present => remove Field - else if (!operation && this.templates.get(nameTemplate).getFields().contains(field)) { - this.templates.get(nameTemplate).removeField(field); - } - } - - /** - * Check if the JSONTemplates have the same bodies. - * - * @param template template - * @return a boolean - */ - public boolean hasTemplate(Template template) { - boolean duplicateTemplate = false; - Collection templatesName = templates.keySet(); - if (templatesName.contains(template.getName())) { - Template existingTemplate = templates.get(template.getName()); - duplicateTemplate = existingTemplate.checkFields(template); - } - return duplicateTemplate; - } - - /** - * For a given Component, get a corresponding JsonObject, through parseToJSON. - * - * @param componentName name - * @return an json object - */ - public JsonObject launchTranslation(String componentName) throws UnknownComponentException { - this.parserToJson = new ParserToJson(components, templates); - if (parserToJson.matchComponent(componentName) == null) { - throw new UnknownComponentException(componentName); - } - return parserToJson.getJsonProcess(componentName, "object"); - } - - /** - * Create and complete several Templates from file.properties. - * - * @param jsonTemplates The template properties as String - * @return a map - */ - @SuppressWarnings("unused") - private LinkedHashMap initializeTemplates(String jsonTemplates) { - - LinkedHashMap generatedTemplates = new LinkedHashMap<>(); - JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class); - - for (Map.Entry templateAsJson : templates.entrySet()) { - Template template = new Template(templateAsJson.getKey()); - JsonObject templateBody = (JsonObject) templateAsJson.getValue(); - for (Map.Entry field : templateBody.entrySet()) { - String fieldName = field.getKey(); - JsonObject bodyFieldAsJson = (JsonObject) field.getValue(); - Object fieldValue = bodyFieldAsJson.get("defaultValue").getAsString(); - Boolean fieldVisible = bodyFieldAsJson.get("visible").getAsBoolean(); - Boolean fieldStatic = bodyFieldAsJson.get("static").getAsBoolean(); - Field bodyField = new Field(fieldName, fieldValue, fieldVisible, fieldStatic); - template.getFields().add(bodyField); - } - generatedTemplates.put(template.getName(), template); - } - return generatedTemplates; - } - -} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterManager.java b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterManager.java new file mode 100644 index 00000000..b3224b04 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterManager.java @@ -0,0 +1,192 @@ +/*- + * ============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.tosca.update; + +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import java.io.IOException; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import org.onap.clamp.clds.util.JsonUtils; + +public class ToscaConverterManager { + + private LinkedHashMap templates; + private LinkedHashMap components; + private ToscaConverterToJson toscaConverterToJson; + private ToscaItemsParser toscaItemsParser; + + /** + * Constructor. + * + * @param toscaYamlContent Policy Tosca Yaml content as string + * @param nativeToscaDatatypes The tosca yaml with tosca native datatypes + * @param templateProperties template properties as string + * @throws IOException in case of failure + */ + public ToscaConverterManager(String toscaYamlContent, String nativeToscaDatatypes, String templateProperties) + throws IOException { + if (toscaYamlContent != null && !toscaYamlContent.isEmpty()) { + this.toscaItemsParser = new ToscaItemsParser(toscaYamlContent, nativeToscaDatatypes); + this.components = toscaItemsParser.getAllItemsFound(); + this.templates = initializeTemplates(templateProperties); + } + else { + components = null; + } + } + + //GETTERS & SETTERS + public LinkedHashMap getComponents() { + return components; + } + + public void setComponents(LinkedHashMap components) { + this.components = components; + } + + public ToscaConverterToJson getParseToJson() { + return toscaConverterToJson; + } + + public void setParseToJson(ToscaConverterToJson toscaConverterToJson) { + this.toscaConverterToJson = toscaConverterToJson; + } + + public LinkedHashMap getTemplates() { + return templates; + } + + public void setTemplates(LinkedHashMap templates) { + this.templates = templates; + } + + public ToscaItemsParser getToscaItemsParser() { + return toscaItemsParser; + } + + /** + * Add a template. + * + * @param name name + * @param templateFields fields + */ + public void addTemplate(String name, List templateFields) { + Template template = new Template(name, templateFields); + //If it is true, the operation does not have any interest : + // replace OR put two different object with the same body + if (!templates.containsKey(template.getName()) || !this.hasTemplate(template)) { + this.templates.put(template.getName(), template); + } + } + + /** + * By name, find and remove a given template. + * + * @param nameTemplate name template + */ + public void removeTemplate(String nameTemplate) { + this.templates.remove(nameTemplate); + } + + /** + * Update Template : adding with true flag, removing with false. + * + * @param nameTemplate name template + * @param templateField field name + * @param operation operation + */ + public void updateTemplate(String nameTemplate, TemplateField templateField, Boolean operation) { + // Operation = true && field is not present => add Field + if (operation && !this.templates.get(nameTemplate).getTemplateFields().contains(templateField)) { + this.templates.get(nameTemplate).addField(templateField); + } + // Operation = false && field is present => remove Field + else if (!operation && this.templates.get(nameTemplate).getTemplateFields().contains(templateField)) { + this.templates.get(nameTemplate).removeField(templateField); + } + } + + /** + * Check if the JSONTemplates have the same bodies. + * + * @param template template + * @return a boolean + */ + public boolean hasTemplate(Template template) { + boolean duplicateTemplate = false; + Collection templatesName = templates.keySet(); + if (templatesName.contains(template.getName())) { + Template existingTemplate = templates.get(template.getName()); + duplicateTemplate = existingTemplate.checkFields(template); + } + return duplicateTemplate; + } + + /** + * For a given Component, get a corresponding JsonObject, through parseToJSON. + * + * @param componentName name + * @return an json object + */ + public JsonObject startConversionToJson(String componentName) throws UnknownComponentException { + this.toscaConverterToJson = new ToscaConverterToJson(components, templates); + if (toscaConverterToJson.matchComponent(componentName) == null) { + throw new UnknownComponentException(componentName); + } + return toscaConverterToJson.getJsonProcess(componentName, "object"); + } + + /** + * Create and complete several Templates from file.properties. + * + * @param jsonTemplates The template properties as String + * @return a map + */ + @SuppressWarnings("unused") + private LinkedHashMap initializeTemplates(String jsonTemplates) { + + LinkedHashMap generatedTemplates = new LinkedHashMap<>(); + JsonObject templates = JsonUtils.GSON.fromJson(jsonTemplates, JsonObject.class); + + for (Map.Entry templateAsJson : templates.entrySet()) { + Template template = new Template(templateAsJson.getKey()); + JsonObject templateBody = (JsonObject) templateAsJson.getValue(); + for (Map.Entry field : templateBody.entrySet()) { + String fieldName = field.getKey(); + JsonObject bodyFieldAsJson = (JsonObject) field.getValue(); + Object fieldValue = bodyFieldAsJson.get("defaultValue").getAsString(); + Boolean fieldVisible = bodyFieldAsJson.get("visible").getAsBoolean(); + Boolean fieldStatic = bodyFieldAsJson.get("static").getAsBoolean(); + TemplateField bodyTemplateField = new TemplateField(fieldName, fieldValue, fieldVisible, fieldStatic); + template.getTemplateFields().add(bodyTemplateField); + } + generatedTemplates.put(template.getName(), template); + } + return generatedTemplates; + } + +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterToJson.java b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterToJson.java new file mode 100644 index 00000000..297d568b --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaConverterToJson.java @@ -0,0 +1,331 @@ +/*- + * ============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.tosca.update; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.Map.Entry; +import org.onap.clamp.tosca.DictionaryService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class ToscaConverterToJson { + private LinkedHashMap components; + private LinkedHashMap templates; + + // if this one is set, the dictionary mechanism is enabled + @Autowired + private DictionaryService dictionaryService; + + public ToscaConverterToJson(LinkedHashMap components, LinkedHashMap templates) { + this.components = components; + this.templates = templates; + } + + /** + * For a given component, launch process to parse it in Json. + * + * @param nameComponent name components + * @return return + */ + public JsonObject getJsonProcess(String nameComponent, String typeComponent) { + JsonObject glob = new JsonObject(); + + if (typeComponent.equals("object")) { + glob = this.getFieldAsObject(matchComponent(nameComponent)); + } + else { + /*glob = this.getFieldAsArray(matchComponent(nameComponent));*/ + } + + return glob; + } + + /** + * Return the classical/general fields of the component, & launch the properties deployment. + * + * @param toscaElement the compo + * @return a json object + */ + public JsonObject getFieldAsObject(ToscaElement toscaElement) { + + JsonObject globalFields = new JsonObject(); + if (templates.get("object").hasFields("title")) { + globalFields.addProperty("title", toscaElement.getName()); + } + if (templates.get("object").hasFields("type")) { + globalFields.addProperty("type", "object"); + } + if (templates.get("object").hasFields("description")) { + if (toscaElement.getDescription() != null) { + globalFields.addProperty("description", toscaElement.getDescription()); + } + } + if (templates.get("object").hasFields("required")) { + globalFields.add("required", this.getRequirements(toscaElement.getName())); + } + if (templates.get("object").hasFields("properties")) { + globalFields.add("properties", this.deploy(toscaElement.getName())); + } + return globalFields; + } + + /** + * Get the required properties of the Component, including the parents properties requirements. + * + * @param nameComponent name component + * @return a json array + */ + public JsonArray getRequirements(String nameComponent) { + JsonArray requirements = new JsonArray(); + ToscaElement toParse = components.get(nameComponent); + //Check for a father component, and launch the same process + if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root") + && !toParse.getDerivedFrom().equals("tosca.policies.Root")) { + requirements.addAll(getRequirements(toParse.getDerivedFrom())); + } + //Each property is checked, and add to the requirement array if it's required + Collection properties = toParse.getProperties().values(); + for (Property property : properties) { + if (property.getItems().containsKey("required") + && property.getItems().get("required").equals(true)) { + requirements.add(property.getName()); + } + } + return requirements; + } + + /** + * The beginning of the recursive process. Get the parents (or not) to launch the same process, and otherwise + * deploy and parse the properties. + * + * @param nameComponent name component + * @return a json object + */ + public JsonObject deploy(String nameComponent) { + JsonObject jsonSchema = new JsonObject(); + ToscaElement toParse = components.get(nameComponent); + //Check for a father component, and launch the same process + if (!toParse.getDerivedFrom().equals("tosca.datatypes.Root") + && !toParse.getDerivedFrom().equals("tosca.policies.Root")) { + jsonSchema = this.getParent(toParse.getDerivedFrom()); + } + //For each component property, check if its a complex properties (a component) or not. In that case, + //launch the analyse of the property. + for (Entry property : toParse.getProperties().entrySet()) { + if (matchComponent((String) property.getValue().getItems().get("type")) != null) { + jsonSchema.add(property.getValue().getName(), + this.getJsonProcess((String) property.getValue().getItems().get("type"), "object")); + } + else { + jsonSchema.add(property.getValue().getName(), this.complexParse(property.getValue())); + } + } + return jsonSchema; + } + + /** + * If a component has a parent, it is deploy in the same way. + * + * @param nameComponent name component + * @return a json object + */ + public JsonObject getParent(String nameComponent) { + return deploy(nameComponent); + } + + /** + * to be done. + * + * @param property property + * @return a json object + */ + @SuppressWarnings("unchecked") + public JsonObject complexParse(Property property) { + JsonObject propertiesInJson = new JsonObject(); + Template currentPropertyTemplate; + String typeProperty = (String) property.getItems().get("type"); + if (typeProperty.toLowerCase().equals("list") || typeProperty.toLowerCase().equals("map")) { + currentPropertyTemplate = templates.get("object"); + } + else { + String propertyType = (String) property.getItems().get("type"); + currentPropertyTemplate = templates.get(propertyType.toLowerCase()); + } + //Each "special" field is analysed, and has a specific treatment + for (String propertyField : property.getItems().keySet()) { + switch (propertyField) { + case "type": + if (currentPropertyTemplate.hasFields(propertyField)) { + String fieldtype = (String) property.getItems().get(propertyField); + switch (fieldtype.toLowerCase()) { + case "list": + propertiesInJson.addProperty("type", "array"); + break; + case "map": + propertiesInJson.addProperty("type", "object"); + break; + case "scalar-unit.time": + case "scalar-unit.frequency": + case "scalar-unit.size": + propertiesInJson.addProperty("type", "string"); + break; + case "timestamp": + propertiesInJson.addProperty("type", "string"); + propertiesInJson.addProperty("format", "date-time"); + break; + case "float": + propertiesInJson.addProperty("type", "number"); + break; + case "range": + propertiesInJson.addProperty("type", "integer"); + if (!checkConstraintPresence(property, "greater_than") + && currentPropertyTemplate.hasFields("exclusiveMinimum")) { + propertiesInJson.addProperty("exclusiveMinimum", false); + } + if (!checkConstraintPresence(property, "less_than") + && currentPropertyTemplate.hasFields("exclusiveMaximum")) { + propertiesInJson.addProperty("exclusiveMaximum", false); + } + break; + default: + propertiesInJson.addProperty("type", currentPropertyTemplate.getName()); + break; + } + } + break; + case "metadata": + propertiesInJson.add("enum", MetadataParser.processAllMetadataElement(property, + dictionaryService)); + break; + case "constraints": + property.addConstraintsAsJson(propertiesInJson, + (ArrayList) property.getItems().get("constraints"), + currentPropertyTemplate); + break; + case "entry_schema": + //Here, a way to check if entry is a component (datatype) or a simple string + if (matchComponent(this.extractSpecificFieldFromMap(property, "entry_schema")) != null) { + String nameComponent = this.extractSpecificFieldFromMap(property, "entry_schema"); + ToscaConverterToJson child = new ToscaConverterToJson(components, templates); + JsonObject propertiesContainer = new JsonObject(); + + switch ((String) property.getItems().get("type")) { + case "map": // Get it as an object + JsonObject componentAsProperty = child.getJsonProcess(nameComponent, "object"); + propertiesContainer.add(nameComponent, componentAsProperty); + if (currentPropertyTemplate.hasFields("properties")) { + propertiesInJson.add("properties", propertiesContainer); + } + break; + default://list : get it as an Array + JsonObject componentAsItem = child.getJsonProcess(nameComponent, "object"); + if (currentPropertyTemplate.hasFields("properties")) { + propertiesInJson.add("items", componentAsItem); + } + break; + } + + } + // Native cases + else if (property.getItems().get("type").equals("list")) { + JsonObject itemContainer = new JsonObject(); + String valueInEntrySchema = this.extractSpecificFieldFromMap(property, "entry_schema"); + itemContainer.addProperty("type", valueInEntrySchema); + propertiesInJson.add("items", itemContainer); + } + // MAP Case, for now nothing + + break; + default: + //Each classical field : type, description, default.. + if (currentPropertyTemplate.hasFields(propertyField) && !propertyField.equals("required")) { + property.addFieldToJson(propertiesInJson, propertyField, + property.getItems().get(propertyField)); + } + break; + } + } + return propertiesInJson; + } + + /** + * Look for a matching Component for the name paramater, in the components list. + * + * @param name the name + * @return a component + */ + public ToscaElement matchComponent(String name) { + ToscaElement correspondingToscaElement = null; + if (components == null) { + return null; + } + for (ToscaElement toscaElement : components.values()) { + if (toscaElement.getName().equals(name)) { + correspondingToscaElement = toscaElement; + } + } + return correspondingToscaElement; + } + + /** + * Simple method to extract quickly a type field from particular property item. + * + * @param property the property + * @param fieldName the fieldname + * @return a string + */ + @SuppressWarnings("unchecked") + public String extractSpecificFieldFromMap(Property property, String fieldName) { + LinkedHashMap entrySchemaFields = + (LinkedHashMap) property.getItems().get(fieldName); + return entrySchemaFields.get("type"); + } + + /** + * Check if a constraint, for a specific property, is there. + * + * @param property property + * @param nameConstraint name constraint + * @return a flag boolean + */ + public boolean checkConstraintPresence(Property property, String nameConstraint) { + boolean presentConstraint = false; + if (property.getItems().containsKey("constraints")) { + ArrayList constraints = (ArrayList) property.getItems().get("constraints"); + for (Object constraint : constraints) { + if (constraint instanceof LinkedHashMap) { + if (((LinkedHashMap) constraint).containsKey(nameConstraint)) { + presentConstraint = true; + } + } + } + } + return presentConstraint; + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaElement.java b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaElement.java new file mode 100644 index 00000000..d702cda5 --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaElement.java @@ -0,0 +1,121 @@ +/*- + * ============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.tosca.update; + +import java.util.ArrayList; +import java.util.LinkedHashMap; + +public class ToscaElement { + + /** + * name parameter is used as "key", in the LinkedHashMap of Components. + */ + private String name; + private String derivedFrom; + private String version; + private String typeVersion; + private String description; + private LinkedHashMap properties; + + public ToscaElement() { + } + + /** + * Constructor. + * + * @param name name + * @param derivedFrom derivedFrom + * @param description description + */ + @SuppressWarnings({"unchecked", "rawtypes"}) + public ToscaElement(String name, String derivedFrom, String description) { + super(); + this.name = name; + this.derivedFrom = derivedFrom; + this.description = description; + this.properties = new LinkedHashMap(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDerivedFrom() { + return derivedFrom; + } + + public void setDerivedFrom(String derivedFrom) { + this.derivedFrom = derivedFrom; + } + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getTypeVersion() { + return typeVersion; + } + + public void setTypeVersion(String typeVersion) { + this.typeVersion = typeVersion; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public LinkedHashMap getProperties() { + return properties; + } + + public void setProperties(LinkedHashMap properties) { + this.properties = properties; + } + + public void addProperties(Property property) { + this.properties.put(property.getName(), property); + } + + public ArrayList propertiesNames() { + return new ArrayList<>(properties.keySet()); + } + + @Override + public String toString() { + return name + ": " + description + ", version: " + version + ", nb de properties: " + properties.size() + + System.getProperty("line.separator") + propertiesNames(); + } +} diff --git a/src/main/java/org/onap/clamp/clds/tosca/update/ToscaItemsParser.java b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaItemsParser.java new file mode 100644 index 00000000..443a4b0c --- /dev/null +++ b/src/main/java/org/onap/clamp/clds/tosca/update/ToscaItemsParser.java @@ -0,0 +1,109 @@ +/*- + * ============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.tosca.update; + +import java.io.IOException; +import java.util.LinkedHashMap; +import java.util.Map.Entry; +import org.yaml.snakeyaml.Yaml; + +public class ToscaItemsParser { + private LinkedHashMap allItemsFound; + + /** + * Constructor. + * + * @param toscaYaml The tosca to parse + * @param toscaNativeDataTypeYaml THe name of the policy type to search + */ + public ToscaItemsParser(String toscaYaml, String toscaNativeDataTypeYaml) { + this.allItemsFound = searchAllToscaElements(toscaYaml, toscaNativeDataTypeYaml); + } + + public LinkedHashMap getAllItemsFound() { + return allItemsFound; + } + + private static LinkedHashMap searchAllDataTypesAndPolicyTypes(String toscaYaml) { + LinkedHashMap> file = + (LinkedHashMap>) new Yaml().load(toscaYaml); + // Get DataTypes + LinkedHashMap allItemsFound = file.get("data_types"); + allItemsFound = (allItemsFound == null) ? (new LinkedHashMap<>()) : allItemsFound; + // Put the policies and datatypes in the same collection + allItemsFound.putAll(file.get("policy_types")); + return allItemsFound; + } + + private static LinkedHashMap searchAllNativeToscaDataTypes(String toscaNativeYaml) { + return ((LinkedHashMap>) new Yaml().load(toscaNativeYaml)) + .get("data_types"); + } + + /** + * Yaml Parse gets raw policies and datatypes, in different sections : necessary to extract + * all entities and put them at the same level. + * + * @return a map + */ + private static LinkedHashMap searchAllToscaElements(String toscaYaml, + String nativeToscaYaml) { + LinkedHashMap allItemsFound = searchAllDataTypesAndPolicyTypes(toscaYaml); + allItemsFound.putAll(searchAllNativeToscaDataTypes(nativeToscaYaml)); + return parseAllItemsFound(allItemsFound); + } + + /** + * With all the component, get as Map, Components and Components properties are created. + * + * @param allMaps maps + */ + private static LinkedHashMap parseAllItemsFound(LinkedHashMap allMaps) { + LinkedHashMap allItemsFound = new LinkedHashMap(); + //Component creations, from the file maps + for (Entry itemToParse : allMaps.entrySet()) { + LinkedHashMap componentBody = (LinkedHashMap) itemToParse.getValue(); + ToscaElement toscaElement = + new ToscaElement(itemToParse.getKey(), (String) componentBody.get("derived_from"), + (String) componentBody.get("description")); + //If policy, version and type_version : + if (componentBody.get("type_version") != null) { + toscaElement.setVersion((String) componentBody.get("type_version")); + toscaElement.setTypeVersion((String) componentBody.get("type_version")); + } + //Properties creation, from the map + if (componentBody.get("properties") != null) { + LinkedHashMap properties = + (LinkedHashMap) componentBody.get("properties"); + for (Entry itemToProperty : properties.entrySet()) { + Property property = new Property(itemToProperty.getKey(), + (LinkedHashMap) itemToProperty.getValue()); + toscaElement.addProperties(property); + } + } + allItemsFound.put(toscaElement.getName(), toscaElement); + } + return allItemsFound; + } +} diff --git a/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java index 889125fe..b7ed1de9 100644 --- a/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java +++ b/src/main/java/org/onap/clamp/loop/service/CsarServiceInstaller.java @@ -54,7 +54,7 @@ public class CsarServiceInstaller { private static final EELFLogger logger = EELFManager.getInstance().getLogger(CsarServiceInstaller.class); @Autowired - ServiceRepository serviceRepository; + ServicesRepository serviceRepository; @Autowired CdsServices cdsServices; diff --git a/src/main/java/org/onap/clamp/loop/service/ServiceRepository.java b/src/main/java/org/onap/clamp/loop/service/ServiceRepository.java deleted file mode 100644 index a6c5ff18..00000000 --- a/src/main/java/org/onap/clamp/loop/service/ServiceRepository.java +++ /dev/null @@ -1,32 +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.loop.service; - -import org.springframework.data.repository.CrudRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface ServiceRepository extends CrudRepository { - -} diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index d52e418e..c9055bf9 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -44,7 +44,7 @@ import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; import org.json.JSONObject; -import org.onap.clamp.clds.tosca.update.TemplateManagement; +import org.onap.clamp.clds.tosca.update.ToscaConverterManager; import org.onap.clamp.clds.tosca.update.UnknownComponentException; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; @@ -300,9 +300,9 @@ public abstract class Policy extends AuditEntity { public static JsonObject generateJsonRepresentationFromToscaModel(String policyToscaModel, String policyModelType) throws IOException, UnknownComponentException { - return new TemplateManagement(policyToscaModel,ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + return new ToscaConverterManager(policyToscaModel,ResourceFileUtil.getResourceAsString( + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")) - .launchTranslation(policyModelType); + .startConversionToJson(policyModelType); } } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java index 357a96d2..ad6cbd94 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java @@ -23,11 +23,11 @@ package org.onap.clamp.policy.operational; -import com.google.gson.JsonObject; import java.util.List; import java.util.Set; import java.util.stream.Collectors; import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.PolicyModelsRepository; import org.onap.clamp.policy.PolicyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -37,9 +37,13 @@ public class OperationalPolicyService implements PolicyService operationalPolicyRepository .findById(policy.getName()) - .map(p -> setConfigurationJson(p, policy)) - .orElse(new OperationalPolicy(policy.getName(), loop, - policy.getConfigurationsJson(), - policy.getPolicyModel(), null, policy.getPdpGroup(), policy.getPdpSubgroup()))) + .map(p -> setConfiguration(p, policy)) + .orElse(initializeMissingFields(loop,policy))) .collect(Collectors.toSet()); } @@ -61,7 +63,12 @@ public class OperationalPolicyService implements PolicyServiceh2{page-b

1.2. URI scheme

-

Host : localhost:39237
+

Host : localhost:46347
BasePath : /restservices/clds/
Schemes : HTTP

diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index 288511b3..3ce033f6 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -176,4 +176,9 @@ clamp.config.security.permission.instance=dev clamp.config.security.authentication.class=org.onap.aaf.cadi.principal.X509Principal ## Tosca converter -clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.json \ No newline at end of file +clamp.config.tosca.converter.templates=classpath:/clds/tosca_updates/templates.json + +# Configuration settings for CDS +clamp.config.cds.url=http4://blueprints-processor-http:8080 +clamp.config.cds.userName=ccsdkapps +clamp.config.cds.password=ccsdkapps \ No newline at end of file diff --git a/src/main/resources/clds/tosca_update/default-tosca-types.yaml b/src/main/resources/clds/tosca_update/default-tosca-types.yaml new file mode 100644 index 00000000..a11a7369 --- /dev/null +++ b/src/main/resources/clds/tosca_update/default-tosca-types.yaml @@ -0,0 +1,87 @@ +tosca_definitions_version: tosca_simple_yaml_1_1_0 +data_types: + tosca.datatypes.Root: + description: The TOSCA root Data Type all other TOSCA base Data Types derive from + tosca.datatypes.Credential: + derived_from: tosca.datatypes.Root + properties: + protocol: + type: string + required: false + token_type: + type: string + default: password + token: + type: string + keys: + type: map + required: false + entry_schema: + type: string + user: + type: string + required: false + tosca.datatypes.TimeInterval: + derived_from: tosca.datatypes.Root + properties: + start_time: + type: timestamp + required: true + end_time: + type: timestamp + required: true + tosca.datatypes.network.NetworkInfo: + derived_from: tosca.datatypes.Root + properties: + network_name: + type: string + network_id: + type: string + addresses: + type: list + entry_schema: + type: string + tosca.datatypes.network.PortInfo: + derived_from: tosca.datatypes.Root + properties: + port_name: + type: string + port_id: + type: string + network_id: + type: string + mac_address: + type: string + addresses: + type: list + entry_schema: + type: string + # tosca.datatypes.network.PortDef: + # derived_from: integer + # constraints: + # - in_range: [ 1, 65535 ] + # tosca.datatypes.network.PortSpec: + # derived_from: tosca.datatypes.Root + # properties: + # protocol: + # type: string + # required: true + # default: tcp + # constraints: + # - valid_values: [ udp, tcp, igmp ] + # target: + # type: PortDef + # required: false + # target_range: + # type: range + # required: false + # constraints: + # - in_range: [ 1, 65535 ] + # source: + # type: PortDef + # required: false + # source_range: + # type: range + # required: false + # constraints: + # - in_range: [ 1, 65535 ] \ No newline at end of file diff --git a/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml b/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml deleted file mode 100644 index a11a7369..00000000 --- a/src/main/resources/clds/tosca_update/defaultToscaTypes.yaml +++ /dev/null @@ -1,87 +0,0 @@ -tosca_definitions_version: tosca_simple_yaml_1_1_0 -data_types: - tosca.datatypes.Root: - description: The TOSCA root Data Type all other TOSCA base Data Types derive from - tosca.datatypes.Credential: - derived_from: tosca.datatypes.Root - properties: - protocol: - type: string - required: false - token_type: - type: string - default: password - token: - type: string - keys: - type: map - required: false - entry_schema: - type: string - user: - type: string - required: false - tosca.datatypes.TimeInterval: - derived_from: tosca.datatypes.Root - properties: - start_time: - type: timestamp - required: true - end_time: - type: timestamp - required: true - tosca.datatypes.network.NetworkInfo: - derived_from: tosca.datatypes.Root - properties: - network_name: - type: string - network_id: - type: string - addresses: - type: list - entry_schema: - type: string - tosca.datatypes.network.PortInfo: - derived_from: tosca.datatypes.Root - properties: - port_name: - type: string - port_id: - type: string - network_id: - type: string - mac_address: - type: string - addresses: - type: list - entry_schema: - type: string - # tosca.datatypes.network.PortDef: - # derived_from: integer - # constraints: - # - in_range: [ 1, 65535 ] - # tosca.datatypes.network.PortSpec: - # derived_from: tosca.datatypes.Root - # properties: - # protocol: - # type: string - # required: true - # default: tcp - # constraints: - # - valid_values: [ udp, tcp, igmp ] - # target: - # type: PortDef - # required: false - # target_range: - # type: range - # required: false - # constraints: - # - in_range: [ 1, 65535 ] - # source: - # type: PortDef - # required: false - # source_range: - # type: range - # required: false - # constraints: - # - in_range: [ 1, 65535 ] \ No newline at end of file diff --git a/src/main/resources/clds/tosca_update/templates.properties b/src/main/resources/clds/tosca_update/templates.properties deleted file mode 100644 index 5da239b1..00000000 --- a/src/main/resources/clds/tosca_update/templates.properties +++ /dev/null @@ -1,15 +0,0 @@ -#Numeric types -integer=type,description,title,deprecated,default,enum,const,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum -number=type,description,title,deprecated,default,enum,const,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum -range=type,description,title,deprecated,default,enum,const,multipleOf,maximum,exclusiveMaximum,minimum,exclusiveMinimum -# -boolean=type,description,title,deprecated,default,enum,const,readOnly,writeOnly -#String types -string=type,description,title,deprecated,default,enum,const,minLength,maxLength,pattern,format -timestamp=type,description,title,deprecated,default,enum,const,minLength,maxLength,pattern,format -scalar-unit.time=type,description,title,deprecated,default,enum,const,minLength,maxLength,pattern,format -scalar-unit.frequency=type,description,title,deprecated,default,enum,const,minLength,maxLength,pattern,format -scalar-unit.size=type,description,title,deprecated,default,enum,const,minLength,maxLength,pattern,format -#Complex types -array=type,description,title,deprecated,default,enum,const,minItems,maxItems,uniqueItems,minContains,maxContains -object=type,description,title,deprecated,default,enum,const,properties,minProperties,maxProperties,required,dependentRequired,dependencies,readOnly,writeOnly diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java index a99d4ab5..83c374e9 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ArrayFieldTest.java @@ -37,12 +37,12 @@ public class ArrayFieldTest extends TestCase { * @throws IOException in case of failure */ public void testDeploy() throws IOException { - TemplateManagement templateManagement = new TemplateManagement(ResourceFileUtil.getResourceAsString( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager(ResourceFileUtil.getResourceAsString( "tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"),ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), + "clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor"); - Property property = component.getProperties().get("actor"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor"); + Property property = toscaElement.getProperties().get("actor"); ArrayField arrayParser = new ArrayField((ArrayList) property.getItems().get("default")); JsonArray toTest = arrayParser.deploy(); String reference = "[1,\"String\",5.5,true]"; diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java deleted file mode 100644 index 565547e4..00000000 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ComponentTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ============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.tosca.update; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import junit.framework.TestCase; -import org.onap.clamp.clds.util.ResourceFileUtil; - -public class ComponentTest extends TestCase { - - /** - * Test propertiesName. - * - * @throws IOException In case of failure - */ - public void testPropertiesNames() throws IOException { - ArrayList reference = new ArrayList<>(Arrays.asList("actor", "operation", "target", "payload")); - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor"); - assertEquals(reference, component.propertiesNames()); - } - -} diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java index a4d329e2..a73fd673 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ConstraintTest.java @@ -31,12 +31,12 @@ import org.onap.clamp.clds.util.ResourceFileUtil; public class ConstraintTest extends TestCase { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/constraints.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Operation"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Operation"); public ConstraintTest() throws IOException { } @@ -45,15 +45,15 @@ public class ConstraintTest extends TestCase { * Test get value array. */ public void testGetValuesArray() { - Property property = component.getProperties().get("timeout"); - Template template = templateManagement.getTemplates().get("integer"); + Property property = toscaElement.getProperties().get("timeout"); + Template template = toscaConverterManager.getTemplates().get("integer"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList) property.getItems().get("constraints"), template); String reference = "{\"enum\":[3,4,5.5,6,10]}"; assertEquals(reference, String.valueOf(resultProcess)); - property = component.getProperties().get("success"); - template = templateManagement.getTemplates().get("string"); + property = toscaElement.getProperties().get("success"); + template = toscaConverterManager.getTemplates().get("string"); resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList) property.getItems().get("constraints"), template); @@ -66,8 +66,8 @@ public class ConstraintTest extends TestCase { */ public void testGetSpecificLength() { //Test for string type, same process for array - Property property = component.getProperties().get("id"); - Template template = templateManagement.getTemplates().get("string"); + Property property = toscaElement.getProperties().get("id"); + Template template = toscaConverterManager.getTemplates().get("string"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList) property.getItems().get("constraints"), template); @@ -83,8 +83,8 @@ public class ConstraintTest extends TestCase { */ public void testGetLimitValue() { //Test for array type, same process for string - Property property = component.getProperties().get("description"); - Template template = templateManagement.getTemplates().get("array"); + Property property = toscaElement.getProperties().get("description"); + Template template = toscaConverterManager.getTemplates().get("array"); JsonObject resultProcess = new JsonObject(); property.addConstraintsAsJson(resultProcess, (ArrayList) property.getItems().get("constraints"), template); diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java index 62def32b..bb1929f9 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/PropertyTest.java @@ -40,12 +40,12 @@ public class PropertyTest extends TestCase { * @throws IOException In case of failure */ public void testParseArray() throws IOException { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPoliciesEXTENTED.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.Actor"); - Property property = component.getProperties().get("actor"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor"); + Property property = toscaElement.getProperties().get("actor"); JsonArray toTest = property.parseArray((ArrayList) property.getItems().get("default")); assertNotNull(toTest); } @@ -56,13 +56,13 @@ public class PropertyTest extends TestCase { * @throws IOException In case of failure */ public void testAddConstraintsAsJson() throws IOException { - TemplateManagement templateManagement = new TemplateManagement( + ToscaConverterManager toscaConverterManager = new ToscaConverterManager( ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - Component component = templateManagement.getComponents().get("onap.datatype.controlloop.operation.Failure"); - Property property = component.getProperties().get("category"); - Template template = templateManagement.getTemplates().get("string"); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.operation.Failure"); + Property property = toscaElement.getProperties().get("category"); + Template template = toscaConverterManager.getTemplates().get("string"); JsonObject toTest = new JsonObject(); property.addConstraintsAsJson(toTest, (ArrayList) property.getItems().get("constraints"), template); String test = "{\"enum\":[\"error\",\"timeout\",\"retries\",\"guard\",\"exception\"]}"; diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java deleted file mode 100644 index aaa54938..00000000 --- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateManagementTest.java +++ /dev/null @@ -1,205 +0,0 @@ -/*- - * ============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.tosca.update; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import junit.framework.TestCase; -import org.onap.clamp.clds.util.ResourceFileUtil; - -public class TemplateManagementTest extends TestCase { - - /** - * Test the launch translation wit operational policies. - * - * @throws IOException In case of failure - * @throws UnknownComponentException In case of failure - */ - public void testLaunchTranslationTca() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" - + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); - String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); - } - - /** - * Test the launch translation wit operational policies. - * - * @throws IOException In case of failure - * @throws UnknownComponentException In case of failure - */ - public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" - + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); - String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); - } - - /** - * Test the launch translation wit operational policies. - * - * @throws IOException In case of failure - * @throws UnknownComponentException In case of failure - */ - public void testLaunchTranslationApex() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" - + ".policies.controlloop.operational.common.Apex/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); - String componentName = "onap.policies.controlloop.operational.common.Apex"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); - } - - /** - * Test the launch translation wit operational policies. - * - * @throws IOException In case of failure - * @throws UnknownComponentException In case of failure - */ - public void testLaunchTranslationDrools() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" - + ".policies.controlloop.operational.common.Drools/versions/1.0.0?" - + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( - "clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); - String componentName = "onap.policies.controlloop.operational.common.Drools"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); - } - - /** - * Test the launch translation. - * - * @throws IOException In case of failure - * @throws UnknownComponentException In case of failure - */ - public void testLaunchTranslation() throws IOException, UnknownComponentException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - assertNull(templateManagement.getParseToJson()); - String componentName = "onap.policies.controlloop.operational.common.Drools"; - templateManagement.launchTranslation(componentName); - assertNotNull(templateManagement.getParseToJson()); - } - - /** - * Test addTemplate. - * - * @throws IOException In case of failure - */ - public void testAddTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().size(); - List templateFields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"), - new Field( - "required"), - new Field("metadata"), new Field("constraints"))); - templateManagement.addTemplate("test", templateFields); - assertNotSame(count, templateManagement.getTemplates().size()); - } - - /** - * test Remove template. - * - * @throws IOException In case of failure - */ - public void testRemoveTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().size(); - templateManagement.removeTemplate("string"); - assertNotSame(count, templateManagement.getTemplates().size()); - } - - /** - * Test update template. - * - * @throws IOException In case of failure - */ - public void testUpdateTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - int count = templateManagement.getTemplates().get("integer").getFields().size(); - templateManagement.updateTemplate("integer", new Field("type"), false); - assertNotSame(count, templateManagement.getTemplates().get("integer").getFields().size()); - } - - /** - * Test has template. - * - * @throws IOException In case of failure - */ - public void testHasTemplate() throws IOException { - TemplateManagement templateManagement = - new TemplateManagement( - ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/defaultToscaTypes.yaml"), - ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); - boolean has = true; - List templateFieldsString = - new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"), new Field("required"), - new Field("metadata"), new Field("constraints"))); - Template templateTest = new Template("String", templateFieldsString); - has = templateManagement.hasTemplate(templateTest); - assertEquals(false, has); - } - -} diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java index 4ffb4e28..02c5747b 100644 --- a/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java +++ b/src/test/java/org/onap/clamp/clds/tosca/update/TemplateTest.java @@ -35,11 +35,11 @@ public class TemplateTest extends TestCase { */ public void testCheckFields() { Template toTest = new Template("toTest"); - List fields = new ArrayList<>(Arrays.asList(new Field("type"), new Field("description"),new Field( + List templateFields = new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"),new TemplateField( "enum"))); - toTest.setFields(fields); + toTest.setTemplateFields(templateFields); Template reference = new Template("toTest"); - reference.setFields(fields); + reference.setTemplateFields(templateFields); assertTrue(toTest.checkFields(reference)); } diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java new file mode 100644 index 00000000..49384121 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaConverterManagerTest.java @@ -0,0 +1,205 @@ +/*- + * ============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.tosca.update; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import junit.framework.TestCase; +import org.onap.clamp.clds.util.ResourceFileUtil; + +public class ToscaConverterManagerTest extends TestCase { + + /** + * Test the launch translation wit operational policies. + * + * @throws IOException In case of failure + * @throws UnknownComponentException In case of failure + */ + public void testLaunchTranslationTca() throws IOException, UnknownComponentException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.monitoring.cdap.tca.hi.lo.app/versions/1.0.0?" + + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + "clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + assertNull(toscaConverterManager.getParseToJson()); + String componentName = "onap.policies.monitoring.cdap.tca.hi.lo.app"; + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); + } + + /** + * Test the launch translation wit operational policies. + * + * @throws IOException In case of failure + * @throws UnknownComponentException In case of failure + */ + public void testLaunchTranslationFrequencyLimiter() throws IOException, UnknownComponentException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.controlloop.guard.common.FrequencyLimiter/versions/1.0.0?" + + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + "clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + assertNull(toscaConverterManager.getParseToJson()); + String componentName = "onap.policies.controlloop.guard.common.FrequencyLimiter"; + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); + } + + /** + * Test the launch translation wit operational policies. + * + * @throws IOException In case of failure + * @throws UnknownComponentException In case of failure + */ + public void testLaunchTranslationApex() throws IOException, UnknownComponentException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.controlloop.operational.common.Apex/versions/1.0.0?" + + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + "clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + assertNull(toscaConverterManager.getParseToJson()); + String componentName = "onap.policies.controlloop.operational.common.Apex"; + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); + } + + /** + * Test the launch translation wit operational policies. + * + * @throws IOException In case of failure + * @throws UnknownComponentException In case of failure + */ + public void testLaunchTranslationDrools() throws IOException, UnknownComponentException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("http-cache/example/policy/api/v1/policytypes/onap" + + ".policies.controlloop.operational.common.Drools/versions/1.0.0?" + + "connectionTimeToLive=5000/.file"), ResourceFileUtil.getResourceAsString( + "clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + assertNull(toscaConverterManager.getParseToJson()); + String componentName = "onap.policies.controlloop.operational.common.Drools"; + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); + } + + /** + * Test the launch translation. + * + * @throws IOException In case of failure + * @throws UnknownComponentException In case of failure + */ + public void testLaunchTranslation() throws IOException, UnknownComponentException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + assertNull(toscaConverterManager.getParseToJson()); + String componentName = "onap.policies.controlloop.operational.common.Drools"; + toscaConverterManager.startConversionToJson(componentName); + assertNotNull(toscaConverterManager.getParseToJson()); + } + + /** + * Test addTemplate. + * + * @throws IOException In case of failure + */ + public void testAddTemplate() throws IOException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + int count = toscaConverterManager.getTemplates().size(); + List templateFields = new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"), + new TemplateField( + "required"), + new TemplateField("metadata"), new TemplateField("constraints"))); + toscaConverterManager.addTemplate("test", templateFields); + assertNotSame(count, toscaConverterManager.getTemplates().size()); + } + + /** + * test Remove template. + * + * @throws IOException In case of failure + */ + public void testRemoveTemplate() throws IOException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + int count = toscaConverterManager.getTemplates().size(); + toscaConverterManager.removeTemplate("string"); + assertNotSame(count, toscaConverterManager.getTemplates().size()); + } + + /** + * Test update template. + * + * @throws IOException In case of failure + */ + public void testUpdateTemplate() throws IOException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + int count = toscaConverterManager.getTemplates().get("integer").getTemplateFields().size(); + toscaConverterManager.updateTemplate("integer", new TemplateField("type"), false); + assertNotSame(count, toscaConverterManager.getTemplates().get("integer").getTemplateFields().size()); + } + + /** + * Test has template. + * + * @throws IOException In case of failure + */ + public void testHasTemplate() throws IOException { + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + boolean has = true; + List templateFieldsString = + new ArrayList<>(Arrays.asList(new TemplateField("type"), new TemplateField("description"), new TemplateField("required"), + new TemplateField("metadata"), new TemplateField("constraints"))); + Template templateTest = new Template("String", templateFieldsString); + has = toscaConverterManager.hasTemplate(templateTest); + assertEquals(false, has); + } + +} diff --git a/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java new file mode 100644 index 00000000..7ffba4e0 --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/tosca/update/ToscaElementTest.java @@ -0,0 +1,50 @@ +/*- + * ============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.tosca.update; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import junit.framework.TestCase; +import org.onap.clamp.clds.util.ResourceFileUtil; + +public class ToscaElementTest extends TestCase { + + /** + * Test propertiesName. + * + * @throws IOException In case of failure + */ + public void testPropertiesNames() throws IOException { + ArrayList reference = new ArrayList<>(Arrays.asList("actor", "operation", "target", "payload")); + ToscaConverterManager toscaConverterManager = + new ToscaConverterManager( + ResourceFileUtil.getResourceAsString("tosca/new-converter/sampleOperationalPolicies.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/default-tosca-types.yaml"), + ResourceFileUtil.getResourceAsString("clds/tosca_update/templates.json")); + ToscaElement toscaElement = toscaConverterManager.getComponents().get("onap.datatype.controlloop.Actor"); + assertEquals(reference, toscaElement.propertiesNames()); + } + +} diff --git a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java index fd215dd3..a57a35ea 100644 --- a/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java +++ b/src/test/java/org/onap/clamp/loop/CsarInstallerItCase.java @@ -27,7 +27,6 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; - import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -50,7 +49,7 @@ import org.onap.clamp.clds.sdc.controller.installer.BlueprintArtifact; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; -import org.onap.clamp.loop.service.ServiceRepository; +import org.onap.clamp.loop.service.ServicesRepository; import org.onap.clamp.loop.template.LoopTemplate; import org.onap.clamp.loop.template.LoopTemplateLoopElementModel; import org.onap.clamp.loop.template.LoopTemplatesRepository; @@ -87,7 +86,7 @@ public class CsarInstallerItCase { private LoopTemplatesRepository loopTemplatesRepo; @Autowired - ServiceRepository serviceRepository; + ServicesRepository serviceRepository; @Autowired PolicyModelsRepository policyModelsRepository; diff --git a/ui-react/src/components/dialogs/Policy/PolicyModal.js b/ui-react/src/components/dialogs/Policy/PolicyModal.js index 634c5ac5..08bc8e0d 100644 --- a/ui-react/src/components/dialogs/Policy/PolicyModal.js +++ b/ui-react/src/components/dialogs/Policy/PolicyModal.js @@ -117,7 +117,7 @@ export default class PolicyModal extends React.Component { display_required_only: false, show_opt_in: true, prompt_before_delete: true, - required_by_default: true + required_by_default: false }) } diff --git a/ui-react/src/components/menu/MenuBar.js b/ui-react/src/components/menu/MenuBar.js index 4eafaa44..7cf56570 100644 --- a/ui-react/src/components/menu/MenuBar.js +++ b/ui-react/src/components/menu/MenuBar.js @@ -85,7 +85,6 @@ export default class MenuBar extends React.Component { render () { return ( - View All Templates @@ -93,16 +92,15 @@ export default class MenuBar extends React.Component { Upload Tosca Model View Tosca Models - - - Manage Dictionaries + Manage Metadata Dictionaries Create - Open + Open + Close + Modify + Properties - Close - Modify Refresh Status diff --git a/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap b/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap index 9070e87e..92444ea3 100644 --- a/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap +++ b/ui-react/src/components/menu/__snapshots__/MenuBar.test.js.snap @@ -162,10 +162,6 @@ exports[`Verify MenuBar Test the render method 1`] = ` > View Tosca Models - - - Manage Dictionaries + Manage Metadata Dictionaries - Properties + Close - Close + Modify + - Modify + Properties