From 92f2ade3327391adfc7dcafd3e11cf4111d6691d Mon Sep 17 00:00:00 2001 From: Kai Date: Thu, 23 Apr 2020 13:38:24 +0800 Subject: Enable TCAgen2 to policy flow Issue-ID: DCAEGEN2-2198 Signed-off-by: Kai Lu Change-Id: I316f4e3ad8e11320dae7c5bfa29333b6a48c1eeb --- .../dcae/analytics/tca/web/TcaAppProperties.java | 27 +++++- .../src/main/resources/config/application-dev.yaml | 97 +++++++++++----------- 2 files changed, 75 insertions(+), 49 deletions(-) (limited to 'dcae-analytics/dcae-analytics-tca-web/src') diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java index fe905f4..0214a3d 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/TcaAppProperties.java @@ -30,6 +30,11 @@ import org.onap.dcae.analytics.model.configbindingservice.BaseConfigBindingServi import org.onap.dcae.analytics.model.configbindingservice.ConfigBindingServiceConstants; import org.springframework.core.env.Environment; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + import lombok.Data; import lombok.ToString; @@ -78,7 +83,7 @@ public class TcaAppProperties extends BaseConfigBindingServiceProperties { public Tca getTca() { Tca tca = new Tca(); - tca.setPolicy(environment.getProperty(ConfigBindingServiceConstants.POLICY)); + tca.setPolicy(getPolicy()); tca.setProcessingBatchSize(environment.getProperty(ConfigBindingServiceConstants.PROCESSINGBATCHSIZE, Integer.class)); tca.setEnableAbatement(environment.getProperty(ConfigBindingServiceConstants.ENABLEABATEMENT, Boolean.class)); tca.setEnableEcompLogging(environment.getProperty(ConfigBindingServiceConstants.ENABLEECOMPLOGGING, Boolean.class)); @@ -95,6 +100,26 @@ public class TcaAppProperties extends BaseConfigBindingServiceProperties { return tca; } + /** + * Check policies items exist, and return policy. + * @return Policy policy + */ + private String getPolicy() { + + String policies = environment.getProperty(ConfigBindingServiceConstants.POLICIES); + if (policies == null) { + return environment.getProperty(ConfigBindingServiceConstants.POLICY); + } + JsonObject policiesObject = new JsonParser().parse(policies).getAsJsonObject(); + JsonArray items = policiesObject.get(ConfigBindingServiceConstants.ITEMS).getAsJsonArray(); + JsonElement policy = items.get(0) + .getAsJsonObject().get(ConfigBindingServiceConstants.CONFIG) + .getAsJsonObject().get(ConfigBindingServiceConstants.TCAPOLICY); + + return policy.toString(); + + } + @Override public Map getStreamsPublishes() { DmaapInfo dmaapInfo = new DmaapInfo(); diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml index e8f2fe8..93f953c 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml @@ -1,50 +1,51 @@ # DEV PROFILE SETTINGS config-binding-service: - tca: - policy: "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}" - processing_batch_size: 10000 - enable_abatement: true - enable_ecomp_logging: true - aai: - enable_enrichment: true - url: "http://localhost:8443" - username: "DCAE" - password: "DCAE" - generic_vnf_path: "aai/v11/network/generic-vnfs/generic-vnf" - node_query_path: "aai/v11/search/nodes-query" - service_calls: - aai_broker_handle: - - "135.205.226.128:32768" - streams_publishes: - tca_handle_out: - type: "message_router" - aaf_username: "USER" - aaf_password: "PASSWORD" - dmaap_info: - client_role: "publisher" - client_id: "tca-pub-0" - location: "ecomp" - topic_url: "http://localhost:8080/events/PubTopic" - streams_subscribes: - tca_handle_in: - type: "message_router" - aaf_username: "USER" - aaf_password : "PASSWORD" - dmaap_info: - client_role: "subscriber" - client_id: "tca-sub-0" - location: "ecomp" - topic_url: "http://localhost:8080/events/SubTopic" - consumer_group: "cg1" - consumer_ids: - - "c0" - - "c1" - message_limit: 50000 - timeout: -1 - polling: - fixed_rate: 0 - auto_adjusting: - min: 30000 - step_up: 10000 - max: 60000 - step_down: 30000 + config: + tca: + policy: "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}" + processing_batch_size: 10000 + enable_abatement: true + enable_ecomp_logging: true + aai: + enable_enrichment: true + url: "http://localhost:8443" + username: "DCAE" + password: "DCAE" + generic_vnf_path: "aai/v11/network/generic-vnfs/generic-vnf" + node_query_path: "aai/v11/search/nodes-query" + service_calls: + aai_broker_handle: + - "135.205.226.128:32768" + streams_publishes: + tca_handle_out: + type: "message_router" + aaf_username: "USER" + aaf_password: "PASSWORD" + dmaap_info: + client_role: "publisher" + client_id: "tca-pub-0" + location: "ecomp" + topic_url: "http://localhost:8080/events/PubTopic" + streams_subscribes: + tca_handle_in: + type: "message_router" + aaf_username: "USER" + aaf_password : "PASSWORD" + dmaap_info: + client_role: "subscriber" + client_id: "tca-sub-0" + location: "ecomp" + topic_url: "http://localhost:8080/events/SubTopic" + consumer_group: "cg1" + consumer_ids: + - "c0" + - "c1" + message_limit: 50000 + timeout: -1 + polling: + fixed_rate: 0 + auto_adjusting: + min: 30000 + step_up: 10000 + max: 60000 + step_down: 30000 -- cgit 1.2.3-korg