From eb71d70552c827e1d8405862f73e8cbd827c6e48 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 9 Apr 2019 18:10:32 +0200 Subject: PDP Group support Add support to push all policies to pdp group + log Issue-ID: CLAMP-303 Change-Id: Ie53b1dfd11ef8db9c2b5ccca0511e6f6343fb70a Signed-off-by: sebdet --- src/main/java/org/onap/clamp/loop/Loop.java | 26 +++++++++++++ src/main/resources/application-noaaf.properties | 2 +- src/main/resources/application.properties | 2 +- .../resources/clds/camel/rest/clamp-api-v2.xml | 11 +++++- .../resources/clds/camel/routes/flexible-flow.xml | 43 ++++++++++++++++++---- 5 files changed, 73 insertions(+), 11 deletions(-) (limited to 'src/main') diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index a24d3449f..83f938dde 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -23,6 +23,8 @@ package org.onap.clamp.loop; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.annotations.Expose; @@ -257,6 +259,30 @@ public class Loop implements Serializable { return buffer.toString().replace('.', '_').replaceAll(" ", ""); } + public String createPoliciesPayloadPdpGroup() { + JsonObject jsonObject = new JsonObject(); + JsonArray jsonArray = new JsonArray(); + jsonObject.add("policies", jsonArray); + + for (OperationalPolicy opPolicy : this.getOperationalPolicies()) { + JsonObject policyNode = new JsonObject(); + jsonArray.add(policyNode); + policyNode.addProperty("policy-id", opPolicy.getName()); + + for (String guardName : opPolicy.createGuardPolicyPayloads().keySet()) { + JsonObject guardPolicyNode = new JsonObject(); + jsonArray.add(guardPolicyNode); + guardPolicyNode.addProperty("policy-id", guardName); + } + } + for (MicroServicePolicy microServicePolicy : this.getMicroServicePolicies()) { + JsonObject policyNode = new JsonObject(); + jsonArray.add(policyNode); + policyNode.addProperty("policy-id", microServicePolicy.getName()); + } + return new GsonBuilder().setPrettyPrinting().create().toJson(jsonObject); + } + @Override public int hashCode() { final int prime = 31; diff --git a/src/main/resources/application-noaaf.properties b/src/main/resources/application-noaaf.properties index 84e97ea30..5316f8197 100644 --- a/src/main/resources/application-noaaf.properties +++ b/src/main/resources/application-noaaf.properties @@ -135,7 +135,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment- # # # Configuration Settings for Policy Engine Components -clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081/policy/api/v1 +clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081 clamp.config.policy.userName=test clamp.config.policy.password=test clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4792d057d..54cd4676a 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -150,7 +150,7 @@ clamp.config.dcae.deployment.template=classpath:/clds/templates/dcae-deployment- # # # Configuration Settings for Policy Engine Components -clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081/policy/api/v1 +clamp.config.policy.url=http://policy.api.simpledemo.onap.org:8081 clamp.config.policy.userName=test clamp.config.policy.password=test clamp.config.policy.pdpUrl1=http://policy.api.simpledemo.onap.org:8081/pdp/ , testpdp, alpha123 diff --git a/src/main/resources/clds/camel/rest/clamp-api-v2.xml b/src/main/resources/clds/camel/rest/clamp-api-v2.xml index 810c9d205..8a39f1358 100644 --- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml +++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml @@ -175,8 +175,17 @@ - + + true + + + + + diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml index 33419c219..64af7b264 100644 --- a/src/main/resources/clds/camel/routes/flexible-flow.xml +++ b/src/main/resources/clds/camel/routes/flexible-flow.xml @@ -113,7 +113,7 @@ application/json - {{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies DELETE - {{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()} + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()} POST - application/json + application/yaml; legacy-version - {{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies DELETE - {{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()} + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()} application/json - {{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies DELETE - {{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()} + {{clamp.config.policy.url}}/policy/api/v1/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()} - + + + + + + ${header.LoopObject.createPoliciesPayloadPdpGroup()} + + + + POST + + + application/json + + + {{clamp.config.policy.url}}/policy/pap/v1/pdps + + + + + + \ No newline at end of file -- cgit 1.2.3-korg