diff options
30 files changed, 604 insertions, 394 deletions
diff --git a/extra/sql/bulkload/create-tables.sql b/extra/sql/bulkload/create-tables.sql index 50c8d42c..522086c9 100644 --- a/extra/sql/bulkload/create-tables.sql +++ b/extra/sql/bulkload/create-tables.sql @@ -124,10 +124,10 @@ dcae_deployment_id varchar(255), dcae_deployment_status_url varchar(255), device_type_scope varchar(255), - policy_model_type varchar(255) not null, - policy_tosca MEDIUMTEXT not null, shared bit not null, loop_element_model_id varchar(255), + policy_model_type varchar(255), + policy_model_version varchar(255), primary key (name) ) engine=InnoDB; @@ -233,6 +233,11 @@ foreign key (loop_element_model_id) references loop_element_models (name); + alter table micro_service_policies + add constraint FKn17j9ufmyhqicb6cvr1dbjvkt + foreign key (policy_model_type, policy_model_version) + references policy_models (policy_model_type, version); + alter table operational_policies add constraint FKi9kh7my40737xeuaye9xwbnko foreign key (loop_element_model_id) diff --git a/extra/sql/dump/test-data.sql b/extra/sql/dump/test-data.sql index 711b4091..0cd2e035 100644 --- a/extra/sql/dump/test-data.sql +++ b/extra/sql/dump/test-data.sql @@ -53,7 +53,7 @@ UNLOCK TABLES; LOCK TABLES `hibernate_sequence` WRITE; /*!40000 ALTER TABLE `hibernate_sequence` DISABLE KEYS */; -INSERT INTO `hibernate_sequence` VALUES (11); +INSERT INTO `hibernate_sequence` VALUES (4); /*!40000 ALTER TABLE `hibernate_sequence` ENABLE KEYS */; UNLOCK TABLES; @@ -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-02-17 01:28:17.591501','','2020-02-17 01:28:18.213276',NULL,NULL,'CONFIG_POLICY',NULL); +INSERT INTO `loop_element_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app',NULL,'2020-02-19 15:16:21.107439','','2020-02-19 15:16:22.017835',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_mrun2_v1_0_ResourceInstanceName1_tca','','2020-02-17 01:28:18.089349','','2020-02-17 01:28:18.089349','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-1158b029-696f-445f-ab39-240c366a7082',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-4c432782-f871-473d-9547-470fe5dbaa89\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-16c5dae3-8360-4767-a2b9-ae940cc6546a\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"383.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">tca_tca</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-9f8c55b9-0fb4-4d2a-a19d-88726bba03f6\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"465\" x2=\"553\" y1=\"41\"/><polygon fill=\"none\" points=\" 551 39 551 43 555 41\"/><polygon points=\" 551 39 551 43 555 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"OperationalPolicy\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"557\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"557\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"569.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">OperationalPolicy</text><line y2=\"1\" fill=\"none\" x1=\"557\" x2=\"618\" y1=\"42\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-dcd24657-e760-4378-9f40-a82540ee725a\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"680\" x2=\"768\" y1=\"41\"/><polygon fill=\"none\" points=\" 766 39 766 43 770 41\"/><polygon points=\" 766 39 766 43 770 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"789\" cy=\"41\"/></g></g></g></svg>',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_mrun2_v1_0_ResourceInstanceName1_tca_3','','2020-02-17 01:28:17.881069','','2020-02-17 01:28:17.881069','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-ad0016dc-8fa1-44d3-be1f-38e646d7fc6e',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-307b7e33-2a07-4567-8acf-08bfd899360a\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-d23f574c-8f5f-4156-a9ad-e0fe872ac361\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"382.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">tca_k8s</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-0df0f798-1cce-455d-9a02-cf074208e13e\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"465\" x2=\"553\" y1=\"41\"/><polygon fill=\"none\" points=\" 551 39 551 43 555 41\"/><polygon points=\" 551 39 551 43 555 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"OperationalPolicy\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"557\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"557\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"569.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">OperationalPolicy</text><line y2=\"1\" fill=\"none\" x1=\"557\" x2=\"618\" y1=\"42\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-53bcf3ee-d242-4b9d-9eec-da84f5afe416\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"680\" x2=\"768\" y1=\"41\"/><polygon fill=\"none\" points=\" 766 39 766 43 770 41\"/><polygon points=\" 766 39 766 43 770 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"789\" cy=\"41\"/></g></g></g></svg>',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); -INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_mrun2_v1_0_ResourceInstanceName2_tca_2','','2020-02-17 01:28:17.503778','','2020-02-17 01:28:17.503778','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-b68b1479-deab-49ce-b782-6bcd92e7f339',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-0307a925-c3ed-4f07-8029-fbb958e0b953\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-64e12ff6-d108-408f-827e-d18c6abe3f0d\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"382.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">tca_k8s</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-2271388b-e1f4-4593-8b02-de09b8752cce\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"465\" x2=\"553\" y1=\"41\"/><polygon fill=\"none\" points=\" 551 39 551 43 555 41\"/><polygon points=\" 551 39 551 43 555 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"OperationalPolicy\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"557\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"557\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"569.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">OperationalPolicy</text><line y2=\"1\" fill=\"none\" x1=\"557\" x2=\"618\" y1=\"42\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-8381b10b-acdf-4e10-9ff8-043f124b8f6d\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"680\" x2=\"768\" y1=\"41\"/><polygon fill=\"none\" points=\" 766 39 766 43 770 41\"/><polygon points=\" 766 39 766 43 770 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"789\" cy=\"41\"/></g></g></g></svg>',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName1_tca','','2020-02-19 15:16:21.571592','','2020-02-19 15:16:21.571592','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-7aec6c68-df86-4f02-a48f-5d383d813fd4',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-b548b729-9646-40d4-825b-348fe357c742\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-a1ac8a3f-8879-4ac7-8ab5-a6a5b9edacf2\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"393\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">app</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"482\" cy=\"41\"/></g></g></g></svg>',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName1_tca_3','','2020-02-19 15:16:21.363011','','2020-02-19 15:16:21.363011','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-01671aaa-75e6-42bc-a83e-b9ff897aec5d',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-619cce6e-3b20-4050-bf96-b234977b8bcd\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-b04c2639-5eb7-48ac-95b5-49de51180d4e\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"393\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">app</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"482\" cy=\"41\"/></g></g></g></svg>',1,'63cac700-ab9a-4115-a74f-7eac85e3fce0'); +INSERT INTO `loop_templates` VALUES ('LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName2_tca_2','','2020-02-19 15:16:21.057572','','2020-02-19 15:16:21.057572','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-b1b12323-0d48-48b9-bb5f-f9b336d268fe',0,'<svg xmlns=\"http://www.w3.org/2000/svg\"><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"start-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><circle fill=\"none\" r=\"17\" cx=\"18\" cy=\"41\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-e7d67214-4b9a-4c7c-8713-389a6c19b07b\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"35\" x2=\"123\" y1=\"41\"/><polygon fill=\"none\" points=\" 121 39 121 43 125 41\"/><polygon points=\" 121 39 121 43 125 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"VES\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"127\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"127\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"177.5\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">VES</text><line y2=\"83\" fill=\"none\" x1=\"147\" x2=\"147\" y1=\"1\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"Arrow-4ce85a88-0f48-461f-92d9-188fb2e0057a\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><line y2=\"41\" fill=\"none\" x1=\"250\" x2=\"338\" y1=\"41\"/><polygon fill=\"none\" points=\" 336 39 336 43 340 41\"/><polygon points=\" 336 39 336 43 340 41\" stroke=\"none\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"onap.policies.monitoring.cdap.tca.hi.lo.app\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"2\"><rect fill=\"none\" x=\"342\" width=\"123\" y=\"1\" height=\"82\"/></g><g fill-opacity=\"0\" fill=\"rgb(0,0,0)\" text-rendering=\"optimizeQuality\" shape-rendering=\"geometricPrecision\" stroke=\"rgb(0,0,0)\" stroke-opacity=\"0\" stroke-width=\"2\"><rect x=\"342\" width=\"123\" y=\"1\" height=\"82\" stroke=\"none\"/></g><g text-rendering=\"optimizeQuality\" stroke-width=\"2\" shape-rendering=\"geometricPrecision\" font-family=\"sans-serif\"><text x=\"393\" xml:space=\"preserve\" y=\"46.5\" stroke=\"none\">app</text><line y2=\"61\" fill=\"none\" x1=\"342\" x2=\"465\" y1=\"61\"/></g></g></g><g fill-opacity=\"1\" color-rendering=\"auto\" color-interpolation=\"auto\" text-rendering=\"auto\" stroke=\"black\" stroke-linecap=\"square\" stroke-miterlimit=\"10\" shape-rendering=\"auto\" stroke-opacity=\"1\" fill=\"black\" stroke-dasharray=\"none\" font-weight=\"normal\" stroke-width=\"1\" font-family=\"\'Dialog\'\" font-style=\"normal\" data-element-id=\"stop-circle\" stroke-linejoin=\"miter\" font-size=\"12px\" image-rendering=\"auto\" stroke-dashoffset=\"0\"><!--Generated by the Batik Graphics2D SVG Generator--><defs id=\"genericDefs\"/><g><g shape-rendering=\"geometricPrecision\" text-rendering=\"optimizeQuality\" stroke-width=\"4\"><circle fill=\"none\" r=\"17\" cx=\"482\" cy=\"41\"/></g></g></g></svg>',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_mrun2_v1_0_ResourceInstanceName1_tca',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_mrun2_v1_0_ResourceInstanceName1_tca_3',0); -INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_mrun2_v1_0_ResourceInstanceName2_tca_2',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName1_tca',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName1_tca_3',0); +INSERT INTO `looptemplates_to_loopelementmodels` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','LOOP_TEMPLATE_QIfdq_v1_0_ResourceInstanceName2_tca_2',0); /*!40000 ALTER TABLE `looptemplates_to_loopelementmodels` ENABLE KEYS */; UNLOCK TABLES; @@ -152,15 +152,15 @@ UNLOCK TABLES; LOCK TABLES `policy_models` WRITE; /*!40000 ALTER TABLE `policy_models` DISABLE KEYS */; -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.Guard','1.0.0','','2020-02-17 01:28:32.023344','','2020-02-17 01:28:32.023344','Guard','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.Blacklist','1.0.0','','2020-02-17 01:28:31.924684','','2020-02-17 01:28:31.924684','Blacklist','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.FrequencyLimiter','1.0.0','','2020-02-17 01:28:31.916091','','2020-02-17 01:28:31.916091','FrequencyLimiter','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.MinMax','1.0.0','','2020-02-17 01:28:31.930419','','2020-02-17 01:28:31.930419','MinMax','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.Operational','1.0.0','','2020-02-17 01:28:32.007254','','2020-02-17 01:28:32.007254','Operational','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controloop.operational.Apex','1.0.0','','2020-02-17 01:28:32.020428','','2020-02-17 01:28:32.020428','Apex','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.controloop.operational.Drools','1.0.0','','2020-02-17 01:28:31.916299','','2020-02-17 01:28:31.916299','Drools','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.Monitoring','1.0.0','','2020-02-17 01:28:32.090217','','2020-02-17 01:28:32.090217','Monitoring','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); -INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0','','2020-02-17 01:28:17.629390','','2020-02-17 01:28:17.629390','app','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.Guard','1.0.0','','2020-02-19 15:16:32.550573','','2020-02-19 15:16:32.550573','Guard','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.Blacklist','1.0.0','','2020-02-19 15:16:32.674581','','2020-02-19 15:16:32.674581','Blacklist','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.FrequencyLimiter','1.0.0','','2020-02-19 15:16:32.580634','','2020-02-19 15:16:32.580634','FrequencyLimiter','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.guard.MinMax','1.0.0','','2020-02-19 15:16:32.550894','','2020-02-19 15:16:32.550894','MinMax','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controlloop.Operational','1.0.0','','2020-02-19 15:16:32.689085','','2020-02-19 15:16:32.689085','Operational','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controloop.operational.Apex','1.0.0','','2020-02-19 15:16:32.661448','','2020-02-19 15:16:32.661448','Apex','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.controloop.operational.Drools','1.0.0','','2020-02-19 15:16:32.553673','','2020-02-19 15:16:32.553673','Drools','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.Monitoring','1.0.0','','2020-02-19 15:16:32.738454','','2020-02-19 15:16:32.738454','Monitoring','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); +INSERT INTO `policy_models` VALUES ('onap.policies.monitoring.cdap.tca.hi.lo.app','1.0.0','','2020-02-19 15:16:21.136405','','2020-02-19 15:16:21.136405','app','{\"policyTypeId\": \"onap.policies.controlloop.operational\",\"policyTypeVersion\": \"1.0.0\",\"policyId\": \"OPERATIONAL_z711F_v1_0_ResourceInstanceName1_tca\"}'); /*!40000 ALTER TABLE `policy_models` ENABLE KEYS */; UNLOCK TABLES; @@ -182,4 +182,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2020-02-17 9:29:33 +-- Dump completed on 2020-02-19 23:17:54 diff --git a/src/main/java/org/onap/clamp/clds/service/CldsService.java b/src/main/java/org/onap/clamp/clds/service/CldsService.java index 783ee703..3b84e360 100644 --- a/src/main/java/org/onap/clamp/clds/service/CldsService.java +++ b/src/main/java/org/onap/clamp/clds/service/CldsService.java @@ -102,11 +102,16 @@ public class CldsService extends SecureServiceBase { @Autowired public CldsService( @Value("${clamp.config.security.permission.type.cl:permission-type-cl}") String cldsPersmissionTypeCl, - @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}") String cldsPermissionTypeClManage, - @Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}") String cldsPermissionTypeClEvent, - @Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}") String cldsPermissionTypeFilterVf, - @Value("${clamp.config.security.permission.type.template:permission-type-template}") String cldsPermissionTypeTemplate, - @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}") String cldsPermissionTypeTosca, + @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}") + String cldsPermissionTypeClManage, + @Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}") + String cldsPermissionTypeClEvent, + @Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}") + String cldsPermissionTypeFilterVf, + @Value("${clamp.config.security.permission.type.template:permission-type-template}") + String cldsPermissionTypeTemplate, + @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}") + String cldsPermissionTypeTosca, @Value("${clamp.config.security.permission.instance:dev}") String cldsPermissionInstance) { this.cldsPermissionTypeFilterVf = cldsPermissionTypeFilterVf; this.cldsPermissionInstance = cldsPermissionInstance; @@ -125,7 +130,7 @@ public class CldsService extends SecureServiceBase { * Gets clds info. CLDS IFO service will return 3 things 1. User Name 2. CLDS * code version that is currently installed from pom.xml file 3. User * permissions - * + * * @return the clds info */ public CldsInfo getCldsInfo() { diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java index 6ce89873..7edf6c1a 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilder.java @@ -24,16 +24,17 @@ package org.onap.clamp.clds.util.drawing; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; +import java.util.HashSet; +import java.util.Set; +import org.onap.clamp.loop.template.LoopElementModel; +import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.operational.OperationalPolicy; public class ClampGraphBuilder { - private String policy; + private Set<OperationalPolicy> policies = new HashSet<>(); private String collector; - private List<BlueprintMicroService> microServices = new ArrayList<>(); + private Set<MicroServicePolicy> microServices = new HashSet<>(); + private Set<LoopElementModel> loopElementModels = new HashSet<>(); private final Painter painter; public ClampGraphBuilder(Painter painter) { @@ -45,33 +46,64 @@ public class ClampGraphBuilder { return this; } - public ClampGraphBuilder policy(String policy) { - this.policy = policy; + public ClampGraphBuilder addPolicy(OperationalPolicy policy) { + this.policies.add(policy); return this; } - public ClampGraphBuilder addMicroService(BlueprintMicroService ms) { + public ClampGraphBuilder addAllPolicies(Set<OperationalPolicy> policies) { + this.policies.addAll(policies); + return this; + } + + public ClampGraphBuilder addMicroService(MicroServicePolicy ms) { microServices.add(ms); return this; } - public ClampGraphBuilder addAllMicroServices(List<BlueprintMicroService> msList) { + public ClampGraphBuilder addAllMicroServices(Set<MicroServicePolicy> msList) { microServices.addAll(msList); return this; } /** + * This method adds all loop element specified in input to the current structure. + * + * @param loopElementModels A set of LoopElementModels + * @return Return the current ClampGraphBuilder + */ + public ClampGraphBuilder addAllLoopElementModels(Set<LoopElementModel> loopElementModels) { + for (LoopElementModel elem : loopElementModels) { + this.addLoopElementModel(elem); + } + return this; + } + + /** + * This method adds one loop element specified in input to the current structure. + * + * @param loopElementModel A LoopElementModels + * @return Return the current ClampGraphBuilder + */ + public ClampGraphBuilder addLoopElementModel(LoopElementModel loopElementModel) { + if (LoopElementModel.MICRO_SERVICE_TYPE.equals(loopElementModel.getLoopElementType())) { + microServices.add(new MicroServicePolicy(loopElementModel.getName(), + loopElementModel.getPolicyModels().first(), + false, + null)); + } else if (LoopElementModel.OPERATIONAL_POLICY_TYPE.equals(loopElementModel.getLoopElementType())) { + policies.add(new OperationalPolicy(loopElementModel.getName(), null, null, + loopElementModel.getPolicyModels().first())); + } + return this; + } + + /** * Build the SVG. - * + * * @return Clamp graph (SVG) */ public ClampGraph build() { - if (microServices.isEmpty()) { - throw new InvalidStateException("At least one microservice is required"); - } - if (Objects.isNull(policy) || policy.trim().isEmpty()) { - throw new InvalidStateException("Policy element must be present"); - } - return new ClampGraph(painter.doPaint(collector, microServices, policy)); + return new ClampGraph(painter.doPaint(collector, microServices, policies)); } } diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java index d96c9e53..af62d84a 100755 --- a/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/Painter.java @@ -28,17 +28,17 @@ import java.awt.BasicStroke; import java.awt.Color; import java.awt.Point; import java.awt.RenderingHints; -import java.util.List; - +import java.util.Set; import org.apache.batik.svggen.SVGGraphics2D; -import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; +import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.operational.OperationalPolicy; public class Painter { private final int canvasSize; private final SVGGraphics2D g2d; private final DocumentBuilder documentBuilder; - private static final int DEFALUT_CANVAS_SIZE = 900; + private static final int DEFAULT_CANVAS_SIZE = 900; private static final int SLIM_LINE = 2; private static final int THICK_LINE = 4; private static final double RECT_RATIO = 3.0 / 2.0; @@ -54,10 +54,10 @@ public class Painter { public Painter(SVGGraphics2D svgGraphics2D, DocumentBuilder documentBuilder) { this.g2d = svgGraphics2D; this.documentBuilder = documentBuilder; - this.canvasSize = DEFALUT_CANVAS_SIZE; + this.canvasSize = DEFAULT_CANVAS_SIZE; } - DocumentBuilder doPaint(String collector, List<BlueprintMicroService> microServices, String policy) { + DocumentBuilder doPaint(String collector, Set<MicroServicePolicy> microServices, Set<OperationalPolicy> policies) { int numOfRectangles = 2 + microServices.size(); int numOfArrows = numOfRectangles + 1; int baseLength = (canvasSize - 2 * CIRCLE_RADIUS) / (numOfArrows + numOfRectangles); @@ -71,20 +71,25 @@ public class Painter { Point origin = new Point(1, rectHeight / 2); ImageBuilder ib = new ImageBuilder(g2d, documentBuilder, origin, baseLength, rectHeight); - doTheActualDrawing(collector, microServices, policy, ib); + doTheActualDrawing(collector, microServices, policies, ib); return ib.getDocumentBuilder(); } - private void doTheActualDrawing(String collector, List<BlueprintMicroService> microServices, String policy, - ImageBuilder ib) { + private void doTheActualDrawing(String collector, Set<MicroServicePolicy> microServices, + Set<OperationalPolicy> policies, + ImageBuilder ib) { ib.circle("start-circle", SLIM_LINE).arrow().rectangle(collector, RectTypes.COLECTOR, collector); - for (BlueprintMicroService ms : microServices) { - ib.arrow().rectangle(ms.getModelType(), RectTypes.MICROSERVICE, ms.getName()); + for (MicroServicePolicy ms : microServices) { + ib.arrow().rectangle(ms.getName(), + RectTypes.MICROSERVICE, ms.getPolicyModel().getPolicyAcronym()); } - - ib.arrow().rectangle(policy, RectTypes.POLICY, policy).arrow().circle("stop-circle", THICK_LINE); + for (OperationalPolicy policy : policies) { + ib.arrow().rectangle(policy.getName(), RectTypes.POLICY, policy.getPolicyModel().getPolicyAcronym()) + .arrow(); + } + ib.circle("stop-circle", THICK_LINE); } private void adjustGraphics2DProperties() { diff --git a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java b/src/main/java/org/onap/clamp/clds/util/drawing/SvgLoopGenerator.java index 251f4886..f289d979 100644 --- a/src/main/java/org/onap/clamp/clds/util/drawing/SvgFacade.java +++ b/src/main/java/org/onap/clamp/clds/util/drawing/SvgLoopGenerator.java @@ -24,30 +24,51 @@ package org.onap.clamp.clds.util.drawing; -import java.util.List; - +import java.util.HashSet; +import java.util.Set; import org.apache.batik.svggen.SVGGraphics2D; -import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; import org.onap.clamp.clds.util.XmlTools; -import org.springframework.stereotype.Component; +import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.LoopElementModel; +import org.onap.clamp.loop.template.LoopTemplate; +import org.onap.clamp.loop.template.LoopTemplateLoopElementModel; import org.w3c.dom.Document; -@Component -public class SvgFacade { +public class SvgLoopGenerator { + /** + * Generate the SVG images from the loop. + * + * @param loop The loop object, so it won't use the loop template + * @return A String containing the SVG + */ + public static String getSvgImage(Loop loop) { + SVGGraphics2D svgGraphics2D = new SVGGraphics2D(XmlTools.createEmptySvgDocument()); + Document document = XmlTools.createEmptySvgDocument(); + DocumentBuilder dp = new DocumentBuilder(document, svgGraphics2D.getDOMFactory()); + Painter painter = new Painter(svgGraphics2D, dp); + ClampGraphBuilder cgp = new ClampGraphBuilder(painter).collector("VES"); + cgp.addAllMicroServices(loop.getMicroServicePolicies()); + ClampGraph cg = cgp.addAllPolicies(loop.getOperationalPolicies()).build(); + return cg.getAsSvg(); + } + /** - * Generate the SVG images from the microservice Chain. - * - * @param microServicesChain THe chain of microservices + * Generate the SVG images from the loop template. + * + * @param loopTemplate The loop template * @return A String containing the SVG */ - public String getSvgImage(List<BlueprintMicroService> microServicesChain) { + public static String getSvgImage(LoopTemplate loopTemplate) { SVGGraphics2D svgGraphics2D = new SVGGraphics2D(XmlTools.createEmptySvgDocument()); Document document = XmlTools.createEmptySvgDocument(); DocumentBuilder dp = new DocumentBuilder(document, svgGraphics2D.getDOMFactory()); Painter painter = new Painter(svgGraphics2D, dp); ClampGraphBuilder cgp = new ClampGraphBuilder(painter).collector("VES"); - cgp.addAllMicroServices(microServicesChain); - ClampGraph cg = cgp.policy("OperationalPolicy").build(); + Set<LoopElementModel> elementModelsSet = new HashSet<>(); + for (LoopTemplateLoopElementModel elementModelLink:loopTemplate.getLoopElementModelsUsed()) { + elementModelsSet.add(elementModelLink.getLoopElementModel()); + } + ClampGraph cg = cgp.addAllLoopElementModels(elementModelsSet).build(); return cg.getAsSvg(); } diff --git a/src/main/java/org/onap/clamp/loop/CsarInstaller.java b/src/main/java/org/onap/clamp/loop/CsarInstaller.java index c0cfac96..b5ebdb94 100644 --- a/src/main/java/org/onap/clamp/loop/CsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/CsarInstaller.java @@ -25,12 +25,10 @@ package org.onap.clamp.loop; import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; - import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Map.Entry; - import org.json.simple.parser.ParseException; import org.onap.clamp.clds.client.DcaeInventoryServices; import org.onap.clamp.clds.client.PolicyEngineServices; @@ -42,7 +40,6 @@ import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; import org.onap.clamp.clds.sdc.controller.installer.BlueprintParser; import org.onap.clamp.clds.sdc.controller.installer.ChainGenerator; import org.onap.clamp.clds.sdc.controller.installer.CsarHandler; -import org.onap.clamp.clds.util.drawing.SvgFacade; import org.onap.clamp.loop.service.CsarServiceInstaller; import org.onap.clamp.loop.service.Service; import org.onap.clamp.loop.template.LoopElementModel; @@ -79,9 +76,6 @@ public class CsarInstaller { private DcaeInventoryServices dcaeInventoryService; @Autowired - private SvgFacade svgFacade; - - @Autowired private CsarServiceInstaller csarServiceInstaller; @Autowired @@ -89,7 +83,7 @@ public class CsarInstaller { /** * Verify whether Csar is deployed. - * + * * @param csar The Csar Handler * @return The flag indicating whether Csar is deployed * @throws SdcArtifactInstallerException The SdcArtifactInstallerException @@ -100,16 +94,16 @@ public class CsarInstaller { for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) { alreadyInstalled = alreadyInstalled && loopTemplatesRepository.existsById(LoopTemplate.generateLoopTemplateName( - csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(), - blueprint.getValue().getResourceAttached().getResourceInstanceName(), - blueprint.getValue().getBlueprintArtifactName())); + csar.getSdcNotification().getServiceName(), csar.getSdcNotification().getServiceVersion(), + blueprint.getValue().getResourceAttached().getResourceInstanceName(), + blueprint.getValue().getBlueprintArtifactName())); } return alreadyInstalled; } /** * Install the service and loop templates from the csar. - * + * * @param csar The Csar Handler * @throws SdcArtifactInstallerException The SdcArtifactInstallerException * @throws InterruptedException The InterruptedException @@ -125,7 +119,7 @@ public class CsarInstaller { /** * Install the loop templates from the csar. - * + * * @param csar The Csar Handler * @param service The service object that is related to the loop * @throws SdcArtifactInstallerException The SdcArtifactInstallerException @@ -150,7 +144,8 @@ public class CsarInstaller { } private LoopTemplate createLoopTemplateFromBlueprint(CsarHandler csar, BlueprintArtifact blueprintArtifact, - Service service) throws IOException, ParseException, InterruptedException, BlueprintParserException { + Service service) + throws IOException, ParseException, InterruptedException, BlueprintParserException { LoopTemplate newLoopTemplate = new LoopTemplate(); newLoopTemplate.setBlueprint(blueprintArtifact.getDcaeBlueprint()); newLoopTemplate.setName(LoopTemplate.generateLoopTemplateName(csar.getSdcNotification().getServiceName(), @@ -165,7 +160,6 @@ public class CsarInstaller { newLoopTemplate.setModelService(service); newLoopTemplate.addLoopElementModels(createMicroServiceModels(microServicesChain)); newLoopTemplate.setMaximumInstancesAllowed(0); - newLoopTemplate.setSvgRepresentation(svgFacade.getSvgImage(microServicesChain)); DcaeInventoryResponse dcaeResponse = queryDcaeToGetServiceTypeId(blueprintArtifact); newLoopTemplate.setDcaeBlueprintId(dcaeResponse.getTypeId()); return newLoopTemplate; @@ -175,8 +169,9 @@ public class CsarInstaller { throws InterruptedException { HashSet<LoopElementModel> newSet = new HashSet<>(); for (BlueprintMicroService microService : microServicesChain) { - LoopElementModel loopElementModel = new LoopElementModel(microService.getModelType(), "CONFIG_POLICY", - null); + LoopElementModel loopElementModel = + new LoopElementModel(microService.getModelType(), LoopElementModel.MICRO_SERVICE_TYPE, + null); newSet.add(loopElementModel); loopElementModel.addPolicyModel(getPolicyModel(microService)); } diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 0ac8030d..676626a1 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -27,7 +27,6 @@ import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFManager; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; - import java.io.Serializable; import java.util.HashMap; import java.util.HashSet; @@ -35,7 +34,6 @@ import java.util.Map; import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; - import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; @@ -50,11 +48,11 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; import javax.persistence.Transient; - import org.hibernate.annotations.SortNatural; import org.hibernate.annotations.Type; import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; +import org.onap.clamp.clds.util.drawing.SvgLoopGenerator; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.common.AuditEntity; import org.onap.clamp.loop.components.external.DcaeComponent; @@ -68,7 +66,7 @@ import org.onap.clamp.policy.operational.OperationalPolicy; @Entity @Table(name = "loops") -@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)}) public class Loop extends AuditEntity implements Serializable { /** @@ -101,7 +99,7 @@ public class Loop extends AuditEntity implements Serializable { private JsonObject globalPropertiesJson; @Expose - @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) + @ManyToOne(fetch = FetchType.EAGER, cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) @JoinColumn(name = "service_uuid") private Service modelService; @@ -119,7 +117,7 @@ public class Loop extends AuditEntity implements Serializable { private Set<OperationalPolicy> operationalPolicies = new HashSet<>(); @Expose - @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER) + @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.EAGER) @JoinTable(name = "loops_to_microservicepolicies", joinColumns = @JoinColumn(name = "loop_name"), inverseJoinColumns = @JoinColumn(name = "microservicepolicy_name")) private Set<MicroServicePolicy> microServicePolicies = new HashSet<>(); @@ -130,8 +128,8 @@ public class Loop extends AuditEntity implements Serializable { private SortedSet<LoopLog> loopLogs = new TreeSet<>(); @Expose - @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER) - @JoinColumn(name = "loop_template_name", nullable=false) + @ManyToOne(cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}, fetch = FetchType.EAGER) + @JoinColumn(name = "loop_template_name", nullable = false) private LoopTemplate loopTemplate; private void initializeExternalComponents() { @@ -229,14 +227,28 @@ public class Loop extends AuditEntity implements Serializable { this.loopLogs = loopLogs; } - void addOperationalPolicy(OperationalPolicy opPolicy) { + /** + * This method adds an operational policy to the loop. + * It re-computes the Svg as well. + * + * @param opPolicy the operationalPolicy to add + */ + public void addOperationalPolicy(OperationalPolicy opPolicy) { operationalPolicies.add(opPolicy); opPolicy.setLoop(this); + this.setSvgRepresentation(SvgLoopGenerator.getSvgImage(this)); } - void addMicroServicePolicy(MicroServicePolicy microServicePolicy) { + /** + * This method adds an micro service policy to the loop. + * It re-computes the Svg as well. + * + * @param microServicePolicy the micro service to add + */ + public void addMicroServicePolicy(MicroServicePolicy microServicePolicy) { microServicePolicies.add(microServicePolicy); microServicePolicy.getUsedByLoops().add(this); + this.setSvgRepresentation(SvgLoopGenerator.getSvgImage(this)); } public void addLog(LoopLog log) { @@ -295,7 +307,7 @@ public class Loop extends AuditEntity implements Serializable { * @return The generated loop name */ public static String generateLoopName(String serviceName, String serviceVersion, String resourceName, - String blueprintFileName) { + String blueprintFileName) { StringBuilder buffer = new StringBuilder("LOOP_").append(serviceName).append("_v").append(serviceVersion) .append("_").append(resourceName).append("_").append(blueprintFileName.replaceAll(".yaml", "")); return buffer.toString().replace('.', '_').replaceAll(" ", ""); diff --git a/src/main/java/org/onap/clamp/loop/LoopService.java b/src/main/java/org/onap/clamp/loop/LoopService.java index fb857fbf..6ea412c0 100644 --- a/src/main/java/org/onap/clamp/loop/LoopService.java +++ b/src/main/java/org/onap/clamp/loop/LoopService.java @@ -24,12 +24,13 @@ package org.onap.clamp.loop; import com.google.gson.JsonObject; - import java.util.List; import java.util.Set; - import javax.persistence.EntityNotFoundException; - +import org.apache.commons.lang3.RandomStringUtils; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelsService; +import org.onap.clamp.policy.Policy; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.microservice.MicroServicePolicyService; import org.onap.clamp.policy.operational.OperationalPolicy; @@ -49,6 +50,9 @@ public class LoopService { @Autowired private OperationalPolicyService operationalPolicyService; + @Autowired + private PolicyModelsService policyModelsService; + Loop saveOrUpdateLoop(Loop loop) { return loopsRepository.save(loop); } @@ -67,7 +71,7 @@ public class LoopService { /** * This method is used to refresh the DCAE deployment status fields. - * + * * @param loop The loop instance to be modified * @param deploymentId The deployment ID as returned by DCAE * @param deploymentUrl The Deployment URL as returned by DCAE @@ -83,6 +87,19 @@ public class LoopService { loopsRepository.save(loop); } + Loop addOperationalPolicy(String loopName, String policyType, String policyVersion) { + Loop loop = findClosedLoopByName(loopName); + PolicyModel policyModel = policyModelsService.getPolicyModel(policyType, policyVersion); + if (policyModel == null) { + return null; + } + loop.addOperationalPolicy( + new OperationalPolicy(Policy.generatePolicyName("OPERATIONAL", loop.getModelService().getName(), + loop.getModelService().getVersion(), RandomStringUtils.randomAlphanumeric(3), + RandomStringUtils.randomAlphanumeric(4)), loop, null, policyModel)); + return loopsRepository.save(loop); + } + Loop updateAndSaveOperationalPolicies(String loopName, List<OperationalPolicy> newOperationalPolicies) { Loop loop = findClosedLoopByName(loopName); Set<OperationalPolicy> newPolicies = operationalPolicyService.updatePolicies(loop, newOperationalPolicies); @@ -114,11 +131,11 @@ public class LoopService { } /** - * Api to refresh the Operational Policy UI window. - * - * @param loopName The loop Name - * @return The refreshed loop object - */ + * Api to refresh the Operational Policy UI window. + * + * @param loopName The loop Name + * @return The refreshed loop object + */ public Loop refreshOpPolicyJsonRepresentation(String loopName) { Loop loop = findClosedLoopByName(loopName); Set<OperationalPolicy> policyList = loop.getOperationalPolicies(); diff --git a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java index ca26b136..89332bbd 100644 --- a/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java +++ b/src/main/java/org/onap/clamp/loop/components/external/DcaeComponent.java @@ -54,7 +54,7 @@ public class DcaeComponent extends ExternalComponent { "The DCAE blueprint has been found in the DCAE inventory but not yet instancianted for this loop"); public static final ExternalComponentState PROCESSING_MICROSERVICE_INSTALLATION = new ExternalComponentState( "PROCESSING_MICROSERVICE_INSTALLATION", "Clamp has requested DCAE to install the microservices " - + "defined in the DCAE blueprint and it's currently processing the request"); + + "defined in the DCAE blueprint and it's currently processing the request"); public static final ExternalComponentState MICROSERVICE_INSTALLATION_FAILED = new ExternalComponentState( "MICROSERVICE_INSTALLATION_FAILED", "Clamp has requested DCAE to install the microservices defined in the DCAE blueprint and it failed"); @@ -63,7 +63,7 @@ public class DcaeComponent extends ExternalComponent { "Clamp has requested DCAE to install the DCAE blueprint and it has been installed successfully"); public static final ExternalComponentState PROCESSING_MICROSERVICE_UNINSTALLATION = new ExternalComponentState( "PROCESSING_MICROSERVICE_UNINSTALLATION", "Clamp has requested DCAE to uninstall the microservices " - + "defined in the DCAE blueprint and it's currently processing the request"); + + "defined in the DCAE blueprint and it's currently processing the request"); public static final ExternalComponentState MICROSERVICE_UNINSTALLATION_FAILED = new ExternalComponentState( "MICROSERVICE_UNINSTALLATION_FAILED", "Clamp has requested DCAE to uninstall the microservices defined in the DCAE blueprint and it failed"); @@ -91,7 +91,7 @@ public class DcaeComponent extends ExternalComponent { /** * Convert the json response to a DcaeOperationStatusResponse. - * + * * @param responseBody The DCAE response Json paylaod * @return The dcae object provisioned */ @@ -146,13 +146,14 @@ public class DcaeComponent extends ExternalComponent { /** * Return the deploy payload for DCAE. * - * @param loop The loop object + * @param loop The loop object * @param microServicePolicy The micro service policy * @return The payload used to send deploy closed loop request */ public static String getDeployPayload(Loop loop, MicroServicePolicy microServicePolicy) { JsonObject globalProp = loop.getGlobalPropertiesJson(); - JsonObject deploymentProp = globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName()); + JsonObject deploymentProp = + globalProp.getAsJsonObject(DEPLOYMENT_PARAMETER).getAsJsonObject(microServicePolicy.getName()); String serviceTypeId = microServicePolicy.getDcaeBlueprintId(); diff --git a/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java index e6ba9815..47960598 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java @@ -43,13 +43,13 @@ import org.hibernate.annotations.SortNatural; import org.onap.clamp.loop.common.AuditEntity; /** - * This class represents a micro service model for a loop template. + * This class represents a micro service/operational/... model for a loop template. + * So it's an element in the flow (a box shown in the loop). */ @Entity @Table(name = "loop_element_models") public class LoopElementModel extends AuditEntity implements Serializable { - public static final String DEFAULT_GROUP_NAME = "DEFAULT"; /** * The serial version id. */ @@ -65,11 +65,13 @@ public class LoopElementModel extends AuditEntity implements Serializable { private String dcaeBlueprintId; /** - * Here we store the blueprint coming from DCAE. + * Here we store the blueprint coming from DCAE, it can be null if this is not a micro service model. */ @Column(columnDefinition = "MEDIUMTEXT", name = "blueprint_yaml") private String blueprint; + public static String MICRO_SERVICE_TYPE = "MICRO_SERVICE_TYPE"; + public static String OPERATIONAL_POLICY_TYPE = "OPERATIONAL_POLICY_TYPE"; /** * The type of element. */ @@ -89,14 +91,14 @@ public class LoopElementModel extends AuditEntity implements Serializable { */ @Expose @ManyToMany( - fetch = FetchType.EAGER, - cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) + fetch = FetchType.EAGER, + cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) @JoinTable( - name = "loopelementmodels_to_policymodels", - joinColumns = @JoinColumn(name = "loop_element_name", referencedColumnName = "name"), - inverseJoinColumns = { - @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), - @JoinColumn(name = "policy_model_version", referencedColumnName = "version")}) + name = "loopelementmodels_to_policymodels", + joinColumns = @JoinColumn(name = "loop_element_name", referencedColumnName = "name"), + inverseJoinColumns = { + @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), + @JoinColumn(name = "policy_model_version", referencedColumnName = "version")}) @SortNatural private SortedSet<PolicyModel> policyModels = new TreeSet<>(); @@ -228,10 +230,10 @@ public class LoopElementModel extends AuditEntity implements Serializable { /** * Constructor. * - * @param name The name id + * @param name The name id * @param loopElementType The type of loop element - * @param blueprint The blueprint defined for dcae that contains the - * policy type to use + * @param blueprint The blueprint defined for dcae that contains the + * policy type to use */ public LoopElementModel(String name, String loopElementType, String blueprint) { this.name = name; diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java index 54096cb8..a7bbd9dd 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java @@ -39,6 +39,7 @@ import javax.persistence.ManyToOne; import javax.persistence.OneToMany; import javax.persistence.Table; import org.hibernate.annotations.SortNatural; +import org.onap.clamp.clds.util.drawing.SvgLoopGenerator; import org.onap.clamp.loop.common.AuditEntity; import org.onap.clamp.loop.service.Service; @@ -73,17 +74,17 @@ public class LoopTemplate extends AuditEntity implements Serializable { @Expose @OneToMany( - cascade = CascadeType.ALL, - fetch = FetchType.EAGER, - mappedBy = "loopTemplate", - orphanRemoval = true) + cascade = CascadeType.ALL, + fetch = FetchType.EAGER, + mappedBy = "loopTemplate", + orphanRemoval = true) @SortNatural private SortedSet<LoopTemplateLoopElementModel> loopElementModelsUsed = new TreeSet<>(); @Expose @ManyToOne( - fetch = FetchType.EAGER, - cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) + fetch = FetchType.EAGER, + cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH}) @JoinColumn(name = "service_uuid") private Service modelService; @@ -244,10 +245,7 @@ public class LoopTemplate extends AuditEntity implements Serializable { * @param loopElementModel The loopElementModel to add */ public void addLoopElementModel(LoopElementModel loopElementModel) { - LoopTemplateLoopElementModel jointEntry = new LoopTemplateLoopElementModel(this, - loopElementModel, this.loopElementModelsUsed.size()); - this.loopElementModelsUsed.add(jointEntry); - loopElementModel.getUsedByLoopTemplates().add(jointEntry); + this.addLoopElementModel(loopElementModel,this.loopElementModelsUsed.size()); } /** @@ -255,13 +253,14 @@ public class LoopTemplate extends AuditEntity implements Serializable { * specified manually. * * @param loopElementModel The loopElementModel to add - * @param listPosition The position in the flow + * @param listPosition The position in the flow */ public void addLoopElementModel(LoopElementModel loopElementModel, Integer listPosition) { LoopTemplateLoopElementModel jointEntry = - new LoopTemplateLoopElementModel(this, loopElementModel, listPosition); + new LoopTemplateLoopElementModel(this, loopElementModel, listPosition); this.loopElementModelsUsed.add(jointEntry); loopElementModel.getUsedByLoopTemplates().add(jointEntry); + this.setSvgRepresentation(SvgLoopGenerator.getSvgImage(this)); } /** @@ -301,16 +300,16 @@ public class LoopTemplate extends AuditEntity implements Serializable { /** * Constructor. * - * @param name The loop template name id - * @param blueprint The blueprint containing all microservices (legacy - * case) - * @param svgRepresentation The svg representation of that loop template + * @param name The loop template name id + * @param blueprint The blueprint containing all microservices (legacy + * case) + * @param svgRepresentation The svg representation of that loop template * @param maxInstancesAllowed The maximum number of instances that can be - * created from that template - * @param service The service associated to that loop template + * created from that template + * @param service The service associated to that loop template */ public LoopTemplate(String name, String blueprint, String svgRepresentation, - Integer maxInstancesAllowed, Service service) { + Integer maxInstancesAllowed, Service service) { this.name = name; this.setBlueprint(blueprint); this.svgRepresentation = svgRepresentation; @@ -352,17 +351,17 @@ public class LoopTemplate extends AuditEntity implements Serializable { /** * Generate the loop template name. * - * @param serviceName The service name - * @param serviceVersion The service version - * @param resourceName The resource name + * @param serviceName The service name + * @param serviceVersion The service version + * @param resourceName The resource name * @param blueprintFileName The blueprint file name * @return The generated loop template name */ public static String generateLoopTemplateName(String serviceName, String serviceVersion, - String resourceName, String blueprintFileName) { + String resourceName, String blueprintFileName) { StringBuilder buffer = new StringBuilder("LOOP_TEMPLATE_").append(serviceName).append("_v") - .append(serviceVersion).append("_").append(resourceName).append("_") - .append(blueprintFileName.replaceAll(".yaml", "")); + .append(serviceVersion).append("_").append(resourceName).append("_") + .append(blueprintFileName.replaceAll(".yaml", "")); return buffer.toString().replace('.', '_').replaceAll(" ", ""); } } diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java index 279d602c..29382137 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplatesService.java @@ -24,11 +24,7 @@ package org.onap.clamp.loop.template; import java.util.List; -import org.onap.clamp.clds.exception.sdc.controller.BlueprintParserException; -import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; -import org.onap.clamp.clds.sdc.controller.installer.BlueprintParser; import org.onap.clamp.clds.sdc.controller.installer.ChainGenerator; -import org.onap.clamp.clds.util.drawing.SvgFacade; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -40,9 +36,6 @@ public class LoopTemplatesService { @Autowired ChainGenerator chainGenerator; - @Autowired - private SvgFacade svgFacade; - /** * Constructor. */ @@ -56,24 +49,6 @@ public class LoopTemplatesService { return loopTemplatesRepository.save(loopTemplate); } - /** - * Saves or updates loop template Object. - * - * @param templateName the loop template name - * @param loopTemplate the loop template object - * @return the loop template - * @throws BlueprintParserException In case of issues with the blueprint - * parsing - */ - public LoopTemplate saveOrUpdateLoopTemplateByName(String templateName, - LoopTemplate loopTemplate) throws BlueprintParserException { - - if (getLoopTemplate(templateName) != null) { - loopTemplate.setName(getLoopTemplate(templateName).getName()); - } - return saveOrUpdateLoopTemplate(createTemplateFromBlueprint(templateName, loopTemplate)); - } - public List<String> getLoopTemplateNames() { return loopTemplatesRepository.getAllLoopTemplateNames(); } @@ -89,23 +64,4 @@ public class LoopTemplatesService { public void deleteLoopTemplate(String name) { loopTemplatesRepository.deleteById(name); } - - private LoopTemplate createTemplateFromBlueprint(String templateName, LoopTemplate loopTemplate) - throws BlueprintParserException { - - String blueprintYaml = loopTemplate.getBlueprint(); - List<BlueprintMicroService> microServicesChain = - chainGenerator.getChainOfMicroServices(BlueprintParser.getMicroServices(blueprintYaml)); - if (microServicesChain.isEmpty()) { - microServicesChain = BlueprintParser.fallbackToOneMicroService(); - } - loopTemplate.setSvgRepresentation(svgFacade.getSvgImage(microServicesChain)); - loopTemplate.setName(templateName); - - LoopTemplate existingTemplate = getLoopTemplate(templateName); - if (existingTemplate != null) { - loopTemplate.setName(existingTemplate.getName()); - } - return loopTemplate; - } } diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index c6568205..e1c08eea 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -42,7 +42,7 @@ import org.onap.clamp.loop.common.AuditEntity; import org.onap.clamp.loop.template.LoopElementModel; @MappedSuperclass -@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)}) public abstract class Policy extends AuditEntity { @Expose @@ -55,6 +55,10 @@ public abstract class Policy extends AuditEntity { @Column(columnDefinition = "json", name = "configurations_json") private JsonObject configurationsJson; + /** + * This attribute can be null when the user add a policy on the loop instance, not the template. + * When null, It therefore indicates that this policy is not by default in the loop template. + */ @Expose @ManyToOne(fetch = FetchType.EAGER) @JoinColumn(name = "loop_element_model_id") @@ -68,20 +72,19 @@ public abstract class Policy extends AuditEntity { /** * Name getter. - * + * * @return the name */ public abstract String getName(); /** * Name setter. - * */ public abstract void setName(String name); /** * jsonRepresentation getter. - * + * * @return the jsonRepresentation */ public JsonObject getJsonRepresentation() { @@ -90,7 +93,7 @@ public abstract class Policy extends AuditEntity { /** * jsonRepresentation setter. - * + * * @param jsonRepresentation The jsonRepresentation to set */ public void setJsonRepresentation(JsonObject jsonRepresentation) { @@ -99,7 +102,7 @@ public abstract class Policy extends AuditEntity { /** * configurationsJson getter. - * + * * @return The configurationsJson */ public JsonObject getConfigurationsJson() { @@ -108,7 +111,7 @@ public abstract class Policy extends AuditEntity { /** * configurationsJson setter. - * + * * @param configurationsJson the configurationsJson to set */ public void setConfigurationsJson(JsonObject configurationsJson) { @@ -117,7 +120,7 @@ public abstract class Policy extends AuditEntity { /** * loopElementModel getter. - * + * * @return the loopElementModel */ public LoopElementModel getLoopElementModel() { @@ -126,7 +129,7 @@ public abstract class Policy extends AuditEntity { /** * loopElementModel setter. - * + * * @param loopElementModel the loopElementModel to set */ public void setLoopElementModel(LoopElementModel loopElementModel) { @@ -135,7 +138,7 @@ public abstract class Policy extends AuditEntity { /** * pdpGroup getter. - * + * * @return the pdpGroup */ public String getPdpGroup() { @@ -144,7 +147,7 @@ public abstract class Policy extends AuditEntity { /** * pdpGroup setter. - * + * * @param pdpGroup the pdpGroup to set */ public void setPdpGroup(String pdpGroup) { @@ -162,7 +165,7 @@ public abstract class Policy extends AuditEntity { * @return The generated policy name */ public static String generatePolicyName(String policyType, String serviceName, String serviceVersion, - String resourceName, String blueprintFilename) { + String resourceName, String blueprintFilename) { StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v") .append(serviceVersion).append("_").append(resourceName).append("_") .append(blueprintFilename.replaceAll(".yaml", "")); diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java index 43c8d6e0..8d9017ea 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -30,20 +30,20 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; - import java.io.Serializable; import java.util.HashSet; import java.util.Map; import java.util.Set; - import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.FetchType; import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinColumns; import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; import javax.persistence.Table; import javax.persistence.Transient; - import org.hibernate.annotations.TypeDef; import org.hibernate.annotations.TypeDefs; import org.json.JSONObject; @@ -51,12 +51,13 @@ import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.dao.model.jsontype.StringJsonUserType; import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.policy.Policy; import org.yaml.snakeyaml.Yaml; @Entity @Table(name = "micro_service_policies") -@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)}) public class MicroServicePolicy extends Policy implements Serializable { /** * The serial version ID. @@ -72,10 +73,6 @@ public class MicroServicePolicy extends Policy implements Serializable { private String name; @Expose - @Column(nullable = false, name = "policy_model_type") - private String modelType; - - @Expose @Column(name = "context") private String context; @@ -87,9 +84,6 @@ public class MicroServicePolicy extends Policy implements Serializable { @Column(name = "shared", nullable = false) private Boolean shared; - @Column(columnDefinition = "MEDIUMTEXT", name = "policy_tosca", nullable = false) - private String policyTosca; - @ManyToMany(mappedBy = "microServicePolicies", fetch = FetchType.EAGER) private Set<Loop> usedByLoops = new HashSet<>(); @@ -105,6 +99,12 @@ public class MicroServicePolicy extends Policy implements Serializable { @Column(name = "dcae_blueprint_id") private String dcaeBlueprintId; + @Expose + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumns({@JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), + @JoinColumn(name = "policy_model_version", referencedColumnName = "version")}) + private PolicyModel policyModel; + public MicroServicePolicy() { // serialization } @@ -114,24 +114,23 @@ public class MicroServicePolicy extends Policy implements Serializable { * using the ToscaYamlToJsonConvertor. * * @param name The name of the MicroService - * @param modelType The model type of the MicroService - * @param policyTosca The policy Tosca of the MicroService + * @param policyModel The policy model of the MicroService * @param shared The flag indicate whether the MicroService is shared * @param usedByLoops The list of loops that uses this MicroService */ - public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared, - Set<Loop> usedByLoops) { + public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, + Set<Loop> usedByLoops) { this.name = name; - this.modelType = modelType; - this.policyTosca = policyTosca; + this.policyModel = policyModel; this.shared = shared; this.setJsonRepresentation(JsonUtils.GSON_JPA_MODEL - .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca, modelType), JsonObject.class)); + .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(), + policyModel.getPolicyModelType()), JsonObject.class)); this.usedByLoops = usedByLoops; } private JsonObject createJsonFromPolicyTosca() { - Map<String, Object> map = new Yaml().load(this.getPolicyTosca()); + Map<String, Object> map = new Yaml().load(this.getPolicyModel().getPolicyModelTosca()); JSONObject jsonObject = new JSONObject(map); return new Gson().fromJson(jsonObject.toString(), JsonObject.class); } @@ -141,18 +140,16 @@ public class MicroServicePolicy extends Policy implements Serializable { * the jsonRepresentation instead. * * @param name The name of the MicroService - * @param modelType The model type of the MicroService - * @param policyTosca The policy Tosca of the MicroService + * @param policyModel The policy model type of the MicroService * @param shared The flag indicate whether the MicroService is * shared * @param jsonRepresentation The UI representation in json format * @param usedByLoops The list of loops that uses this MicroService */ - public MicroServicePolicy(String name, String modelType, String policyTosca, Boolean shared, - JsonObject jsonRepresentation, Set<Loop> usedByLoops) { + public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, + JsonObject jsonRepresentation, Set<Loop> usedByLoops) { this.name = name; - this.modelType = modelType; - this.policyTosca = policyTosca; + this.policyModel = policyModel; this.shared = shared; this.usedByLoops = usedByLoops; this.setJsonRepresentation(jsonRepresentation); @@ -165,7 +162,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * name setter. - * + * * @param name the name to set */ @Override @@ -173,14 +170,6 @@ public class MicroServicePolicy extends Policy implements Serializable { this.name = name; } - public String getModelType() { - return modelType; - } - - void setModelType(String modelType) { - this.modelType = modelType; - } - public Boolean getShared() { return shared; } @@ -189,14 +178,6 @@ public class MicroServicePolicy extends Policy implements Serializable { this.shared = shared; } - public String getPolicyTosca() { - return policyTosca; - } - - void setPolicyTosca(String policyTosca) { - this.policyTosca = policyTosca; - } - public Set<Loop> getUsedByLoops() { return usedByLoops; } @@ -221,9 +202,17 @@ public class MicroServicePolicy extends Policy implements Serializable { this.deviceTypeScope = deviceTypeScope; } + public PolicyModel getPolicyModel() { + return policyModel; + } + + public void setPolicyModel(PolicyModel policyModel) { + this.policyModel = policyModel; + } + /** * dcaeDeploymentId getter. - * + * * @return the dcaeDeploymentId */ public String getDcaeDeploymentId() { @@ -232,7 +221,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * dcaeDeploymentId setter. - * + * * @param dcaeDeploymentId the dcaeDeploymentId to set */ public void setDcaeDeploymentId(String dcaeDeploymentId) { @@ -241,7 +230,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * dcaeDeploymentStatusUrl getter. - * + * * @return the dcaeDeploymentStatusUrl */ public String getDcaeDeploymentStatusUrl() { @@ -250,7 +239,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * dcaeDeploymentStatusUrl setter. - * + * * @param dcaeDeploymentStatusUrl the dcaeDeploymentStatusUrl to set */ public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) { @@ -259,7 +248,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * dcaeBlueprintId getter. - * + * * @return the dcaeBlueprintId */ public String getDcaeBlueprintId() { @@ -268,7 +257,7 @@ public class MicroServicePolicy extends Policy implements Serializable { /** * dcaeBlueprintId setter. - * + * * @param dcaeBlueprintId the dcaeBlueprintId to set */ void setDcaeBlueprintId(String dcaeBlueprintId) { @@ -306,7 +295,9 @@ public class MicroServicePolicy extends Policy implements Serializable { } private String getMicroServicePropertyNameFromTosca(JsonObject object) { - return object.getAsJsonObject("policy_types").getAsJsonObject(this.modelType).getAsJsonObject("properties") + return object.getAsJsonObject("policy_types").getAsJsonObject(this.getPolicyModel().getPolicyModelType()) + .getAsJsonObject( + "properties") .keySet().toArray(new String[1])[0]; } @@ -329,8 +320,8 @@ public class MicroServicePolicy extends Policy implements Serializable { JsonObject policyDetails = new JsonObject(); thisPolicy.add(this.getName(), policyDetails); - policyDetails.addProperty("type", this.getModelType()); - policyDetails.addProperty("version", "1.0.0"); + policyDetails.addProperty("type", this.getPolicyModel().getPolicyModelType()); + policyDetails.addProperty("version", this.getPolicyModel().getVersion()); JsonObject policyMetadata = new JsonObject(); policyDetails.add("metadata", policyMetadata); diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java index 29a4e56d..b17bf1ac 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java @@ -65,7 +65,7 @@ public class MicroServicePolicyService implements PolicyService<MicroServicePoli public MicroServicePolicy getAndUpdateMicroServicePolicy(Loop loop, MicroServicePolicy policy) { return repository.save( repository.findById(policy.getName()).map(p -> updateMicroservicePolicyProperties(p, policy, loop)) - .orElse(new MicroServicePolicy(policy.getName(), policy.getModelType(), policy.getPolicyTosca(), + .orElse(new MicroServicePolicy(policy.getName(), policy.getPolicyModel(), policy.getShared(), policy.getJsonRepresentation(), Sets.newHashSet(loop)))); } diff --git a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java index a1c8cdbd..0825ea9e 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java @@ -62,7 +62,7 @@ import org.yaml.snakeyaml.Yaml; @Entity @Table(name = "operational_policies") -@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +@TypeDefs({@TypeDef(name = "json", typeClass = StringJsonUserType.class)}) public class OperationalPolicy extends Policy implements Serializable { /** * The serial version ID. @@ -83,8 +83,8 @@ public class OperationalPolicy extends Policy implements Serializable { @Expose @ManyToOne(fetch = FetchType.EAGER) - @JoinColumns({ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), - @JoinColumn(name = "policy_model_version", referencedColumnName = "version") }) + @JoinColumns({@JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), + @JoinColumn(name = "policy_model_version", referencedColumnName = "version")}) private PolicyModel policyModel; public OperationalPolicy() { @@ -98,10 +98,12 @@ public class OperationalPolicy extends Policy implements Serializable { * @param loop The loop that uses this operational policy * @param configurationsJson The operational policy property in the format of * json + * @param policyModel The policy model associated if any, can be null */ - public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson) { + public OperationalPolicy(String name, Loop loop, JsonObject configurationsJson, PolicyModel policyModel) { this.name = name; this.loop = loop; + this.setPolicyModel(policyModel); this.setConfigurationsJson(configurationsJson); LegacyOperationalPolicy.preloadConfiguration(configurationsJson, loop); try { @@ -128,7 +130,7 @@ public class OperationalPolicy extends Policy implements Serializable { /** * name setter. - * + * * @param name the name to set */ @Override @@ -138,7 +140,7 @@ public class OperationalPolicy extends Policy implements Serializable { /** * policyModel getter. - * + * * @return the policyModel */ public PolicyModel getPolicyModel() { @@ -147,7 +149,7 @@ public class OperationalPolicy extends Policy implements Serializable { /** * policyModel setter. - * + * * @param policyModel the policyModel to set */ public void setPolicyModel(PolicyModel policyModel) { @@ -186,7 +188,7 @@ public class OperationalPolicy extends Policy implements Serializable { /** * Create policy Yaml from json defined here. - * + * * @return A string containing Yaml */ public String createPolicyPayloadYaml() { @@ -260,7 +262,6 @@ public class OperationalPolicy extends Policy implements Serializable { /** * Regenerate the Operational Policy Json Representation. - * */ public void updateJsonRepresentation() { try { 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 95f4f7be..174912b2 100644 --- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java +++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicyService.java @@ -35,28 +35,30 @@ import org.springframework.stereotype.Service; @Service public class OperationalPolicyService implements PolicyService<OperationalPolicy> { - private final OperationalPolicyRepository repository; + private final OperationalPolicyRepository operationalPolicyRepository; @Autowired public OperationalPolicyService(OperationalPolicyRepository repository) { - this.repository = repository; + this.operationalPolicyRepository = repository; } @Override public Set<OperationalPolicy> updatePolicies(Loop loop, List<OperationalPolicy> operationalPolicies) { return operationalPolicies - .stream() - .map(policy -> - repository - .findById(policy.getName()) - .map(p -> setConfigurationJson(p, policy.getConfigurationsJson())) - .orElse(new OperationalPolicy(policy.getName(), loop, policy.getConfigurationsJson()))) - .collect(Collectors.toSet()); + .parallelStream() + .map(policy -> + operationalPolicyRepository + .findById(policy.getName()) + .map(p -> setConfigurationJson(p, policy.getConfigurationsJson())) + .orElse(new OperationalPolicy(policy.getName(), loop, + policy.getConfigurationsJson(), + policy.getPolicyModel()))) + .collect(Collectors.toSet()); } @Override public boolean isExisting(String policyName) { - return repository.existsById(policyName); + return operationalPolicyRepository.existsById(policyName); } private OperationalPolicy setConfigurationJson(OperationalPolicy policy, JsonObject configurationsJson) { diff --git a/src/main/java/org/onap/clamp/util/SemanticVersioning.java b/src/main/java/org/onap/clamp/util/SemanticVersioning.java index 10228449..8852e2a4 100644 --- a/src/main/java/org/onap/clamp/util/SemanticVersioning.java +++ b/src/main/java/org/onap/clamp/util/SemanticVersioning.java @@ -26,8 +26,6 @@ package org.onap.clamp.util; /** * This class is the base class for object that requires semantic versioning. * ... This class supports also a.b.c.d... etc ... as a version. - * - * */ public class SemanticVersioning { public static final int BEFORE = -1; @@ -41,7 +39,7 @@ public class SemanticVersioning { * @param arg0 A version in string for semantic versioning (a.b.c.d...) * @param arg1 A version in string for semantic versioning (a.b.c.d...) * @return objects (arg0, arg1) given as parameters. It returns the value: 0: if - * (arg0==arg1) -1: if (arg0 < arg1) 1: if (arg0 > arg1) + * (arg0==arg1) -1: if (arg0 < arg1) 1: if (arg0 > arg1) */ public static int compare(String arg0, String arg1) { @@ -60,12 +58,12 @@ public class SemanticVersioning { int smalestStringLength = Math.min(arg0Array.length, arg1Array.length); for (int currentVersionIndex = - 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) { + 0; currentVersionIndex < smalestStringLength; ++currentVersionIndex) { if (Integer.parseInt(arg0Array[currentVersionIndex]) < Integer - .parseInt(arg1Array[currentVersionIndex])) { + .parseInt(arg1Array[currentVersionIndex])) { return BEFORE; } else if (Integer.parseInt(arg0Array[currentVersionIndex]) > Integer - .parseInt(arg1Array[currentVersionIndex])) { + .parseInt(arg1Array[currentVersionIndex])) { return AFTER; } // equals, so do not return anything, continue @@ -88,6 +86,6 @@ public class SemanticVersioning { return DEFAULT_VERSION; } String[] versionArray = currentVersion.split("\\."); - return String.valueOf(Integer.parseInt(versionArray[0]) + 1)+".0.0"; + return String.valueOf(Integer.parseInt(versionArray[0]) + 1) + ".0.0"; } } diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java index 65eb2696..63209e9f 100644 --- a/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java +++ b/src/test/java/org/onap/clamp/clds/util/drawing/ClampGraphBuilderTest.java @@ -26,12 +26,12 @@ package org.onap.clamp.clds.util.drawing; +import static org.assertj.core.api.Assertions.assertThat; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; -import java.util.Arrays; -import java.util.List; - +import com.google.gson.JsonObject; +import java.util.Set; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -39,7 +39,10 @@ import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; -import org.onap.clamp.clds.sdc.controller.installer.BlueprintMicroService; +import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.operational.OperationalPolicy; @RunWith(MockitoJUnitRunner.class) public class ClampGraphBuilderTest { @@ -50,47 +53,52 @@ public class ClampGraphBuilderTest { private ArgumentCaptor<String> collectorCaptor; @Captor - private ArgumentCaptor<List<BlueprintMicroService>> microServicesCaptor; + private ArgumentCaptor<Set<MicroServicePolicy>> microServicesCaptor; @Captor - private ArgumentCaptor<String> policyCaptor; + private ArgumentCaptor<Set<OperationalPolicy>> policyCaptor; + /** + * Do a quick test of the graphBuilder chain. + */ @Test public void clampGraphBuilderCompleteChainTest() { String collector = "VES"; - BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0"); - BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0"); + MicroServicePolicy ms1 = new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0"), false, + null); + MicroServicePolicy ms2 = new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0"), false, + null); - String policy = "OperationalPolicy"; - final List<BlueprintMicroService> microServices = Arrays.asList(ms1, ms2); + OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new Loop(), new JsonObject(), + new PolicyModel("org.onap.opolicy", null, "1.0.0", "opolicy1")); + final Set<OperationalPolicy> opPolicies = Set.of(opPolicy); + final Set<MicroServicePolicy> microServices = Set.of(ms1, ms2); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); - clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).policy(policy).build(); + clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).addPolicy(opPolicy).build(); verify(mockPainter, times(1)).doPaint(collectorCaptor.capture(), microServicesCaptor.capture(), policyCaptor.capture()); Assert.assertEquals(collector, collectorCaptor.getValue()); Assert.assertEquals(microServices, microServicesCaptor.getValue()); - Assert.assertEquals(policy, policyCaptor.getValue()); + Assert.assertEquals(opPolicies, policyCaptor.getValue()); } - @Test(expected = InvalidStateException.class) + /** + * Do a quick test of the graphBuilder chain when no policy is given. + */ + @Test public void clampGraphBuilderNoPolicyGivenTest() { String collector = "VES"; - BlueprintMicroService ms1 = new BlueprintMicroService("ms1", "", "", "1.0.0"); - BlueprintMicroService ms2 = new BlueprintMicroService("ms2", "", "", "1.0.0"); + MicroServicePolicy ms1 = + new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0"), false, null); + MicroServicePolicy ms2 = + new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0"), false, null); ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); - clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build(); - } + assertThat(clampGraphBuilder.collector(collector).addMicroService(ms1).addMicroService(ms2).build()) + .isNotNull(); - @Test(expected = InvalidStateException.class) - public void clampGraphBuilderNoMicroServiceGivenTest() { - String collector = "VES"; - String policy = "OperationalPolicy"; - - ClampGraphBuilder clampGraphBuilder = new ClampGraphBuilder(mockPainter); - clampGraphBuilder.collector(collector).policy(policy).build(); } } diff --git a/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java b/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java new file mode 100644 index 00000000..aad11adb --- /dev/null +++ b/src/test/java/org/onap/clamp/clds/util/drawing/SvgLoopGeneratorTest.java @@ -0,0 +1,77 @@ +/*- + * ============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.clds.util.drawing; + +import static org.assertj.core.api.Assertions.assertThat; + +import com.google.gson.JsonObject; +import java.io.IOException; +import java.util.HashSet; +import javax.xml.parsers.ParserConfigurationException; +import org.junit.Test; +import org.onap.clamp.loop.Loop; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.policy.microservice.MicroServicePolicy; +import org.onap.clamp.policy.operational.OperationalPolicy; +import org.xml.sax.SAXException; + +public class SvgLoopGeneratorTest { + private Loop getLoop() { + MicroServicePolicy ms1 = + new MicroServicePolicy("ms1", new PolicyModel("org.onap.ms1", "", "1.0.0", "short.ms1"), + false, + new HashSet<Loop>()); + MicroServicePolicy ms2 = + new MicroServicePolicy("ms2", new PolicyModel("org.onap.ms2", "", "1.0.0", "short.ms2"), + false, new HashSet<Loop>()); + OperationalPolicy opPolicy = new OperationalPolicy("OperationalPolicy", new Loop(), new JsonObject(), + new PolicyModel("org.onap.opolicy", null, "1.0.0", "short.OperationalPolicy")); + Loop loop = new Loop(); + loop.addMicroServicePolicy(ms1); + loop.addMicroServicePolicy(ms2); + loop.addOperationalPolicy(opPolicy); + return loop; + } + + /** + * Test a Svg rendering with all objects. + * + * @throws IOException In case of isssues + * @throws ParserConfigurationException In case of isssues + * @throws SAXException In case of isssues + */ + @Test + public void getAsSvgTest() throws IOException, ParserConfigurationException, SAXException { + String xml = SvgLoopGenerator.getSvgImage(getLoop()); + assertThat(xml).contains("data-element-id=\"VES\""); + assertThat(xml).contains(">VES<"); + assertThat(xml).contains("data-element-id=\"ms1\""); + assertThat(xml).contains("data-element-id=\"ms2\""); + assertThat(xml).contains(">short.ms1<"); + assertThat(xml).contains(">short.ms2<"); + assertThat(xml).contains("data-element-id=\"OperationalPolicy\""); + assertThat(xml).contains(">short.OperationalPolicy<"); + + } +} diff --git a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java index fa9cc063..57e99a3d 100644 --- a/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java +++ b/src/test/java/org/onap/clamp/loop/DcaeComponentTest.java @@ -27,11 +27,9 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.Gson; import com.google.gson.JsonObject; - import java.io.IOException; import java.util.HashSet; import java.util.List; - import org.apache.camel.Exchange; import org.apache.camel.Message; import org.json.simple.parser.ParseException; @@ -42,6 +40,7 @@ import org.onap.clamp.clds.model.dcae.DcaeOperationStatusResponse; import org.onap.clamp.loop.components.external.DcaeComponent; import org.onap.clamp.loop.components.external.ExternalComponentState; import org.onap.clamp.loop.template.LoopTemplate; +import org.onap.clamp.loop.template.PolicyModel; import org.onap.clamp.policy.microservice.MicroServicePolicy; public class DcaeComponentTest { @@ -54,8 +53,8 @@ public class DcaeComponentTest { loopTest.setDcaeDeploymentId("123456789"); loopTest.setDcaeDeploymentStatusUrl("http4://localhost:8085"); - MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, + MicroServicePolicy microServicePolicy = new MicroServicePolicy("configPolicyTest", new PolicyModel("policy1", + "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"), true, new Gson().fromJson("{\"configtype\":\"json\"}", JsonObject.class), new HashSet<>()); microServicePolicy.setConfigurationsJson(new Gson().fromJson("{\"param1\":\"value1\"}", JsonObject.class)); @@ -67,6 +66,10 @@ public class DcaeComponentTest { return loopTest; } + /** + * Test the DcaeReponse roughly. + * @throws IOException In case of issues + */ @Test public void convertDcaeResponseTest() throws IOException { String dcaeFakeResponse = "{'requestId':'testId','operationType':'install','status':'state'," @@ -99,6 +102,11 @@ public class DcaeComponentTest { assertThat(unDeploymentPayload).isEqualTo(expectedPayload); } + /** + * Test the computeState method of the DcaeComponent roughly. + * + * @throws IOException In case of issues + */ @Test public void computeStateTest() throws IOException { Exchange exchange = Mockito.mock(Exchange.class); @@ -157,6 +165,11 @@ public class DcaeComponentTest { assertThat(state9.getStateName()).isEqualTo("IN_ERROR"); } + /** + * Test the Converter to DcaeInventoryResponse method. + * @throws IOException In case of failure + * @throws ParseException In case of failure + */ @Test public void convertToDcaeInventoryResponseTest() throws IOException, ParseException { String dcaeFakeResponse = "{\n" + " \"links\": {\n" + " \"previousLink\": {\n" diff --git a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java index c85d5a57..4fd78d18 100644 --- a/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/DeployFlowTestItCase.java @@ -28,13 +28,10 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; - import java.io.IOException; import java.util.HashSet; import java.util.Set; - import javax.transaction.Transactional; - import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.builder.ExchangeBuilder; @@ -42,6 +39,8 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; import org.onap.clamp.loop.template.LoopTemplate; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @@ -56,11 +55,20 @@ public class DeployFlowTestItCase { CamelContext camelContext; @Autowired + PolicyModelsService policyModelsService; + + @Autowired LoopService loopService; @Autowired LoopsRepository loopsRepository; + /** + * This method tests a deployment a single blueprint. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void deployWithSingleBlueprintTest() throws JsonSyntaxException, IOException { @@ -85,6 +93,12 @@ public class DeployFlowTestItCase { assertThat(loopAfterTest.getDcaeDeploymentId()).isNotNull(); } + /** + * This method tests the deployment of multiple separated blueprints. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void deployWithMultipleBlueprintTest() throws JsonSyntaxException, IOException { @@ -117,6 +131,12 @@ public class DeployFlowTestItCase { assertThat(loopAfterTest.getDcaeDeploymentId()).isNull(); } + /** + * This method tests the undeployment of a single blueprint. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void undeployWithSingleBlueprintTest() throws JsonSyntaxException, IOException { @@ -142,6 +162,12 @@ public class DeployFlowTestItCase { assertThat(loopAfterTest.getDcaeDeploymentStatusUrl().contains("/uninstall")).isTrue(); } + /** + * This method tests the undeployment of multiple separated blueprints. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void undeployWithMultipleBlueprintTest() throws JsonSyntaxException, IOException { @@ -175,7 +201,12 @@ public class DeployFlowTestItCase { assertThat(loopAfterTest.getDcaeDeploymentId()).isNull(); } - + /** + * This method tests the DCAE get status for a single blueprint. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void getStatusWithSingleBlueprintTest() throws JsonSyntaxException, IOException { @@ -206,6 +237,12 @@ public class DeployFlowTestItCase { assertThat(loopAfterTest.getComponent("POLICY")).isNotNull(); } + /** + * This method tests the dcae get status for multiple blueprints. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + */ @Test @Transactional public void getStatusWithMultipleBlueprintTest() throws JsonSyntaxException, IOException { @@ -256,8 +293,13 @@ public class DeployFlowTestItCase { private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation, String policyTosca, String jsonProperties, boolean shared) { - MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared, + + PolicyModel policyModel = new PolicyModel(modelType, policyTosca,"1.0.0"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); + MicroServicePolicy microService = new MicroServicePolicy(name, policyModel, + shared, gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>()); + microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class)); return microService; } diff --git a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java index f1e5c092..714cbd59 100644 --- a/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopControllerTestItCase.java @@ -30,16 +30,15 @@ import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import com.google.gson.JsonParser; - import java.util.Set; - import javax.transaction.Transactional; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.loop.template.LoopTemplate; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.microservice.MicroServicePolicyService; import org.onap.clamp.policy.operational.OperationalPolicy; @@ -64,6 +63,9 @@ public class LoopControllerTestItCase { MicroServicePolicyService microServicePolicyService; @Autowired + PolicyModelsService policyModelsService; + + @Autowired LoopController loopController; private void saveTestLoopToDb() { @@ -129,8 +131,10 @@ public class LoopControllerTestItCase { @Transactional public void testUpdateMicroservicePolicy() { saveTestLoopToDb(); - MicroServicePolicy policy = new MicroServicePolicy("policyName", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, + PolicyModel policyModel = new PolicyModel("", + "tosca_definitions_version: tosca_simple_yaml_1_0_0","1.0.0"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); + MicroServicePolicy policy = new MicroServicePolicy("policyName", policyModel, false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopController.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, policy); assertThat(microServicePolicyService.isExisting("policyName")).isTrue(); diff --git a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java index 62b25605..e6c477b4 100644 --- a/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopRepositoriesItCase.java @@ -30,10 +30,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; - import java.time.Instant; import java.util.HashSet; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; @@ -92,32 +90,33 @@ public class LoopRepositoriesItCase { return new Service(serviceDetails, resourceDetails); } - private OperationalPolicy getOperationalPolicy(String configJson, String name) { - return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class)); + private OperationalPolicy getOperationalPolicy(String configJson, String name, PolicyModel policyModel) { + return new OperationalPolicy(name, null, new Gson().fromJson(configJson, JsonObject.class), policyModel); } private LoopElementModel getLoopElementModel(String yaml, String name, String policyType, String createdBy, - PolicyModel policyModel) { + PolicyModel policyModel) { LoopElementModel model = new LoopElementModel(name, policyType, yaml); model.addPolicyModel(policyModel); return model; } - private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym, - String policyVariant, String createdBy) { + private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, + String policyAcronym) { return new PolicyModel(policyType, policyModelTosca, version, policyAcronym); } private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation, String createdBy, - Integer maxInstancesAllowed) { + Integer maxInstancesAllowed) { LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null); template.addLoopElementModel(getLoopElementModel("yaml", "microService1", "org.onap.policy.drools", createdBy, - getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1", createdBy))); + getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools"))); + loopTemplateRepository.save(template); return template; } private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson, - String dcaeId, String dcaeUrl, String dcaeBlueprintId) { + String dcaeId, String dcaeUrl, String dcaeBlueprintId) { Loop loop = new Loop(); loop.setName(name); loop.setSvgRepresentation(svgRepresentation); @@ -129,9 +128,9 @@ public class LoopRepositoriesItCase { return loop; } - private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation, - String policyTosca, String jsonProperties, boolean shared) { - MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared, + private MicroServicePolicy getMicroServicePolicy(String name, String jsonRepresentation, String jsonProperties, + boolean shared, PolicyModel policyModel) { + MicroServicePolicy microService = new MicroServicePolicy(name, policyModel, shared, gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>()); microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class)); return microService; @@ -141,17 +140,20 @@ public class LoopRepositoriesItCase { return new LoopLog(message, type, "CLAMP", loop); } + /** + * This method does a crud test and save a loop template and a loop object in db. + */ @Test @Transactional public void crudTest() { // Setup Loop loopTest = getLoop("ControlLoopTest", "<xml></xml>", "yamlcontent", "{\"testname\":\"testvalue\"}", "123456789", "https://dcaetest.org", "UUID-blueprint"); - OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest"); + OperationalPolicy opPolicy = this.getOperationalPolicy("{\"type\":\"GUARD\"}", "GuardOpPolicyTest", + getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools")); loopTest.addOperationalPolicy(opPolicy); - MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "", - "{\"configtype\":\"json\"}", "tosca_definitions_version: tosca_simple_yaml_1_0_0", - "{\"param1\":\"value1\"}", true); + MicroServicePolicy microServicePolicy = getMicroServicePolicy("configPolicyTest", "{\"configtype\":\"json\"}", + "{\"param1\":\"value1\"}", true, getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools")); loopTest.addMicroServicePolicy(microServicePolicy); LoopLog loopLog = getLoopLog(LogType.INFO, "test message", loopTest); loopTest.addLog(loopLog); @@ -182,7 +184,7 @@ public class LoopRepositoriesItCase { assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true); assertThat(microServiceModelsRepository.existsById( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getName())) - .isEqualTo(true); + .isEqualTo(true); assertThat(policyModelsRepository.existsById(new PolicyModelId( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() .first().getPolicyModelType(), @@ -238,7 +240,7 @@ public class LoopRepositoriesItCase { assertThat(servicesRepository.existsById(loopInDb.getModelService().getServiceUuid())).isEqualTo(true); assertThat(microServiceModelsRepository.existsById( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getName())) - .isEqualTo(true); + .isEqualTo(true); assertThat(policyModelsRepository.existsById(new PolicyModelId( loopInDb.getLoopTemplate().getLoopElementModelsUsed().first().getLoopElementModel().getPolicyModels() diff --git a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java index 8089bf1a..15264871 100644 --- a/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java +++ b/src/test/java/org/onap/clamp/loop/LoopServiceTestItCase.java @@ -26,12 +26,9 @@ package org.onap.clamp.loop; import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.JsonObject; - import java.util.Set; import java.util.stream.Collectors; - import javax.transaction.Transactional; - import org.assertj.core.util.Lists; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,6 +38,8 @@ import org.onap.clamp.loop.log.LogType; import org.onap.clamp.loop.log.LoopLog; import org.onap.clamp.loop.log.LoopLogService; import org.onap.clamp.loop.template.LoopTemplate; +import org.onap.clamp.loop.template.PolicyModel; +import org.onap.clamp.loop.template.PolicyModelsService; import org.onap.clamp.policy.microservice.MicroServicePolicy; import org.onap.clamp.policy.microservice.MicroServicePolicyService; import org.onap.clamp.policy.operational.OperationalPolicy; @@ -71,6 +70,9 @@ public class LoopServiceTestItCase { @Autowired LoopLogService loopLogService; + @Autowired + PolicyModelsService policyModelsService; + @Test @Transactional public void shouldCreateEmptyLoop() { @@ -99,7 +101,7 @@ public class LoopServiceTestItCase { // given saveTestLoopToDb(); OperationalPolicy operationalPolicy = new OperationalPolicy("policyName", null, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class)); + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); // when Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, @@ -123,9 +125,11 @@ public class LoopServiceTestItCase { public void shouldAddMicroservicePolicyToLoop() { // given saveTestLoopToDb(); - MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + PolicyModel policyModel = new PolicyModel("org.policies.policyModel1", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyModel1"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); + MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel, + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); // when Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, @@ -147,13 +151,18 @@ public class LoopServiceTestItCase { public void shouldCreateNewMicroservicePolicyAndUpdateJsonRepresentationOfOldOne() { // given saveTestLoopToDb(); - - MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", "", "", false, + PolicyModel policyModel1 = new PolicyModel("org.policies.firstPolicyName", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "firstPolicyName"); + policyModelsService.saveOrUpdatePolicyModel(policyModel1); + PolicyModel policyModel2 = new PolicyModel("org.policies.secondPolicyName", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName"); + policyModelsService.saveOrUpdatePolicyModel(policyModel2); + MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1, false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy)); - MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", true, - JsonUtils.GSON.fromJson("{}", JsonObject.class), null); + MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2, false, + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); // when firstMicroServicePolicy @@ -170,13 +179,12 @@ public class LoopServiceTestItCase { assertThat(savedPolicies).contains(secondMicroServicePolicy); assertThat(savedPolicies).usingElementComparatorIgnoringFields("usedByLoops", "createdDate", "updatedDate", "createdBy", "updatedBy").containsExactlyInAnyOrder(firstMicroServicePolicy, secondMicroServicePolicy); - } private void saveTestLoopToDb() { Loop testLoop = createTestLoop(EXAMPLE_LOOP_NAME, "blueprint", "representation"); testLoop.setGlobalPropertiesJson(JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class)); - LoopTemplate template = new LoopTemplate(); + LoopTemplate template = new LoopTemplate(); template.setName("testTemplate"); testLoop.setLoopTemplate(template); loopService.saveOrUpdateLoop(testLoop); @@ -187,14 +195,18 @@ public class LoopServiceTestItCase { public void shouldRemoveOldMicroservicePolicyIfNotInUpdatedList() { // given saveTestLoopToDb(); - - MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", "", - "\"tosca_definitions_version: tosca_simple_yaml_1_0_0\"", false, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + PolicyModel policyModel1 = new PolicyModel("org.policies.firstPolicyName", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "firstPolicyName"); + policyModelsService.saveOrUpdatePolicyModel(policyModel1); + PolicyModel policyModel2 = new PolicyModel("org.policies.secondPolicyName", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "secondPolicyName"); + policyModelsService.saveOrUpdatePolicyModel(policyModel2); + MicroServicePolicy firstMicroServicePolicy = new MicroServicePolicy("firstPolicyName", policyModel1, + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstMicroServicePolicy)); - MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("policyName", "", "secondPolicyTosca", - true, JsonUtils.GSON.fromJson("{}", JsonObject.class), null); + MicroServicePolicy secondMicroServicePolicy = new MicroServicePolicy("secondPolicyName", policyModel2, + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); // when Loop actualLoop = loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, @@ -219,11 +231,11 @@ public class LoopServiceTestItCase { JsonObject newJsonConfiguration = JsonUtils.GSON.fromJson("{}", JsonObject.class); OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class)); + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy)); OperationalPolicy secondOperationalPolicy = new OperationalPolicy("secondPolicyName", null, - newJsonConfiguration); + newJsonConfiguration, null); // when firstOperationalPolicy.setConfigurationsJson(newJsonConfiguration); @@ -250,11 +262,11 @@ public class LoopServiceTestItCase { saveTestLoopToDb(); OperationalPolicy firstOperationalPolicy = new OperationalPolicy("firstPolicyName", null, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class)); + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(firstOperationalPolicy)); OperationalPolicy secondOperationalPolicy = new OperationalPolicy("policyName", null, - JsonUtils.GSON.fromJson("{}", JsonObject.class)); + JsonUtils.GSON.fromJson("{}", JsonObject.class), null); // when Loop actualLoop = loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, @@ -300,19 +312,21 @@ public class LoopServiceTestItCase { // Add log Loop loop = loopsRepository.findById(EXAMPLE_LOOP_NAME).orElse(null); loop.addLog(new LoopLog("test", LogType.INFO, "CLAMP", loop)); - LoopTemplate template = new LoopTemplate(); + LoopTemplate template = new LoopTemplate(); template.setName("testTemplate"); loop.setLoopTemplate(template); loop = loopService.saveOrUpdateLoop(loop); // Add op policy OperationalPolicy operationalPolicy = new OperationalPolicy("opPolicy", null, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class)); + JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateAndSaveOperationalPolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(operationalPolicy)); + PolicyModel policyModel = new PolicyModel("org.policies.microPolicy", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "microPolicy"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); // Add Micro service policy - MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + MicroServicePolicy microServicePolicy = new MicroServicePolicy("microPolicy", policyModel, + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateAndSaveMicroservicePolicies(EXAMPLE_LOOP_NAME, Lists.newArrayList(microServicePolicy)); // Verify it's there @@ -352,9 +366,11 @@ public class LoopServiceTestItCase { public void testUpdateMicroservicePolicy() { saveTestLoopToDb(); assertThat(microServicePolicyService.isExisting("policyName")).isFalse(); - MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", "", - "tosca_definitions_version: tosca_simple_yaml_1_0_0", false, - JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); + PolicyModel policyModel = new PolicyModel("org.policies.policyName", + "tosca_definitions_version: tosca_simple_yaml_1_0_0", "1.0.0", "policyName"); + policyModelsService.saveOrUpdatePolicyModel(policyModel); + MicroServicePolicy microServicePolicy = new MicroServicePolicy("policyName", policyModel, + false, JsonUtils.GSON.fromJson(EXAMPLE_JSON, JsonObject.class), null); loopService.updateMicroservicePolicy(EXAMPLE_LOOP_NAME, microServicePolicy); assertThat(microServicePolicyService.isExisting("policyName")).isTrue(); } diff --git a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java index ae4b2564..a2a4536f 100644 --- a/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java +++ b/src/test/java/org/onap/clamp/loop/LoopToJsonTest.java @@ -32,11 +32,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import com.google.gson.JsonSyntaxException; - import java.io.IOException; import java.util.HashSet; import java.util.Random; - import org.junit.Test; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; @@ -56,11 +54,13 @@ public class LoopToJsonTest { private Gson gson = new Gson(); private OperationalPolicy getOperationalPolicy(String configJson, String name) { - return new OperationalPolicy(name, null, gson.fromJson(configJson, JsonObject.class)); + return new OperationalPolicy(name, null, gson.fromJson(configJson, JsonObject.class), + getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1")); } private Loop getLoop(String name, String svgRepresentation, String blueprint, String globalPropertiesJson, - String dcaeId, String dcaeUrl, String dcaeBlueprintId) throws JsonSyntaxException, IOException { + String dcaeId, String dcaeUrl, String dcaeBlueprintId) + throws JsonSyntaxException, IOException { Loop loop = new Loop(name, svgRepresentation); loop.setGlobalPropertiesJson(new Gson().fromJson(globalPropertiesJson, JsonObject.class)); loop.setLastComputedState(LoopState.DESIGN); @@ -70,8 +70,9 @@ public class LoopToJsonTest { } private MicroServicePolicy getMicroServicePolicy(String name, String modelType, String jsonRepresentation, - String policyTosca, String jsonProperties, boolean shared) { - MicroServicePolicy microService = new MicroServicePolicy(name, modelType, policyTosca, shared, + String policyTosca, String jsonProperties, boolean shared) { + MicroServicePolicy microService = new MicroServicePolicy(name, new PolicyModel(modelType, policyTosca, "1.0.0"), + shared, gson.fromJson(jsonRepresentation, JsonObject.class), new HashSet<>()); microService.setConfigurationsJson(new Gson().fromJson(jsonProperties, JsonObject.class)); return microService; @@ -87,12 +88,12 @@ public class LoopToJsonTest { } private PolicyModel getPolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym, - String policyVariant) { + String policyVariant) { return new PolicyModel(policyType, policyModelTosca, version, policyAcronym); } private LoopTemplate getLoopTemplate(String name, String blueprint, String svgRepresentation, - Integer maxInstancesAllowed) { + Integer maxInstancesAllowed) { LoopTemplate template = new LoopTemplate(name, blueprint, svgRepresentation, maxInstancesAllowed, null); template.addLoopElementModel(getLoopElementModel("yaml", "microService1", getPolicyModel("org.onap.policy.drools", "yaml", "1.0.0", "Drools", "type1"))); diff --git a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java index 7762111b..b42e1536 100644 --- a/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java +++ b/src/test/java/org/onap/clamp/policy/downloader/PolicyEngineControllerTestItCase.java @@ -25,13 +25,10 @@ package org.onap.clamp.policy.downloader; import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.JsonSyntaxException; - import java.io.IOException; import java.time.Instant; import java.util.List; - import javax.transaction.Transactional; - import org.junit.Test; import org.junit.runner.RunWith; import org.onap.clamp.clds.Application; @@ -53,12 +50,19 @@ public class PolicyEngineControllerTestItCase { @Autowired PolicyModelsRepository policyModelsRepository; + /** + * This method tests a fake synchronization with the emulator. + * + * @throws JsonSyntaxException In case of issues + * @throws IOException In case of issues + * @throws InterruptedException In case of issues + */ @Test @Transactional public void synchronizeAllPoliciesTest() throws JsonSyntaxException, IOException, InterruptedException { policyController.synchronizeAllPolicies(); Instant firstExecution = policyController.getLastInstantExecuted(); - assertThat (firstExecution).isNotNull(); + assertThat(firstExecution).isNotNull(); List<PolicyModel> policyModelsList = policyModelsRepository.findAll(); assertThat(policyModelsList.size()).isGreaterThanOrEqualTo(8); assertThat(policyModelsList).contains(new PolicyModel("onap.policies.Monitoring", null, "1.0.0")); @@ -67,7 +71,7 @@ public class PolicyEngineControllerTestItCase { // Re-do it to check that there is no issue with duplicate key policyController.synchronizeAllPolicies(); Instant secondExecution = policyController.getLastInstantExecuted(); - assertThat (secondExecution).isNotNull(); + assertThat(secondExecution).isNotNull(); assertThat(firstExecution).isBefore(secondExecution); } diff --git a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java index 1556ac6d..3911494f 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/MicroServicePayloadTest.java @@ -24,21 +24,21 @@ package org.onap.clamp.policy.microservice; import com.google.gson.JsonObject; - import java.io.IOException; import java.util.HashSet; - import org.junit.Test; import org.onap.clamp.clds.util.JsonUtils; import org.onap.clamp.clds.util.ResourceFileUtil; +import org.onap.clamp.loop.template.PolicyModel; import org.skyscreamer.jsonassert.JSONAssert; public class MicroServicePayloadTest { @Test public void testPayloadConstruction() throws IOException { - MicroServicePolicy policy = new MicroServicePolicy("testPolicy", "onap.policies.monitoring.cdap.tca.hi.lo.app", - ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"), false, new HashSet<>()); + MicroServicePolicy policy = new MicroServicePolicy("testPolicy", new PolicyModel( + "onap.policies.monitoring.cdap.tca.hi.lo.app", + ResourceFileUtil.getResourceAsString("tosca/tosca_example.yaml"),"1.0.0"), false, new HashSet<>()); policy.setConfigurationsJson(JsonUtils.GSON.fromJson( ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-properties.json"), JsonObject.class)); JSONAssert.assertEquals(ResourceFileUtil.getResourceAsString("tosca/micro-service-policy-payload.json"), diff --git a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java index 728b61cc..f42bbc1c 100644 --- a/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java +++ b/src/test/java/org/onap/clamp/policy/microservice/OperationalPolicyPayloadTest.java @@ -27,10 +27,8 @@ import static org.assertj.core.api.Assertions.assertThat; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; - import java.io.IOException; import java.util.Map; - import org.junit.Test; import org.onap.clamp.clds.util.ResourceFileUtil; import org.onap.clamp.policy.operational.LegacyOperationalPolicy; @@ -43,7 +41,7 @@ public class OperationalPolicyPayloadTest { public void testOperationalPolicyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); - OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig); + OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null); assertThat(policy.createPolicyPayloadYaml()) .isEqualTo(ResourceFileUtil.getResourceAsString("tosca/operational-policy-payload.yaml")); @@ -65,7 +63,7 @@ public class OperationalPolicyPayloadTest { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-no-guard-properties.json"), JsonObject.class); - OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig); + OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null); Map<String, String> guardsMap = policy.createGuardPolicyPayloads(); assertThat(guardsMap).isEmpty(); assertThat(guardsMap.entrySet()).isEmpty(); @@ -75,7 +73,7 @@ public class OperationalPolicyPayloadTest { public void testGuardPolicyPayloadConstruction() throws IOException { JsonObject jsonConfig = new GsonBuilder().create().fromJson( ResourceFileUtil.getResourceAsString("tosca/operational-policy-properties.json"), JsonObject.class); - OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig); + OperationalPolicy policy = new OperationalPolicy("testPolicy", null, jsonConfig, null); Map<String, String> guardsMap = policy.createGuardPolicyPayloads(); |