aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java6
-rw-r--r--src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java2
-rw-r--r--src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java14
-rw-r--r--src/main/resources/clds/camel/rest/clamp-api-v2.xml81
-rw-r--r--src/main/resources/clds/camel/routes/flexible-flow.xml149
5 files changed, 217 insertions, 35 deletions
diff --git a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
index f1056504..c3b24bc8 100644
--- a/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
+++ b/src/main/java/org/onap/clamp/clds/config/CamelConfiguration.java
@@ -21,14 +21,19 @@
*/
package org.onap.clamp.clds.config;
+import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.model.rest.RestBindingMode;
import org.onap.clamp.clds.util.ClampVersioning;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CamelConfiguration extends RouteBuilder {
+ @Autowired
+ CamelContext camelContext;
+
@Override
public void configure() {
restConfiguration().component("servlet").bindingMode(RestBindingMode.json).jsonDataFormat("json-gson")
@@ -38,5 +43,6 @@ public class CamelConfiguration extends RouteBuilder {
.apiProperty("api.version", ClampVersioning.getCldsVersionFromProps())
.apiProperty("base.path", "/restservices/clds/");
// .apiProperty("cors", "true");
+ camelContext.setTracing(true);
}
}
diff --git a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
index 93374fe1..5a8ccca9 100644
--- a/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
+++ b/src/main/java/org/onap/clamp/clds/sdc/controller/installer/BlueprintParser.java
@@ -88,7 +88,7 @@ public class BlueprintParser {
}
String msName = theBiggestMicroServiceKey.toLowerCase().contains(HOLMES_PREFIX) ? HOLMES : TCA;
return Collections
- .singletonList(new MicroService(msName, "onap.policy.monitoring.cdap.tca.hi.lo.ap", "", "", ""));
+ .singletonList(new MicroService(msName, "onap.policy.monitoring.cdap.tca.hi.lo.app", "", "", ""));
}
String getName(Entry<String, JsonElement> entry) {
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 b6b591db..1859a4d6 100644
--- a/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
+++ b/src/main/java/org/onap/clamp/policy/operational/OperationalPolicy.java
@@ -31,8 +31,7 @@ import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -182,15 +181,20 @@ public class OperationalPolicy implements Serializable, Policy {
return (new Yaml()).dump(jsonMap);
}
- public List<String> createGuardPolicyPayloads() {
- List<String> result = new ArrayList<>();
+ /**
+ * Return a map containing all Guard policies indexed by Guard policy Name.
+ *
+ * @return The Guards map
+ */
+ public Map<String, String> createGuardPolicyPayloads() {
+ Map<String, String> result = new HashMap<>();
JsonObject guard = new JsonObject();
JsonElement guardsList = this.getConfigurationsJson().get("guard_policies");
for (Entry<String, JsonElement> guardElem : guardsList.getAsJsonObject().entrySet()) {
guard.addProperty("policy-id", guardElem.getKey());
guard.add("contents", guardElem.getValue());
- result.add(new GsonBuilder().create().toJson(guard));
+ result.put(guardElem.getKey(), new GsonBuilder().create().toJson(guard));
}
return result;
}
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 c17595e1..76f45881 100644
--- a/src/main/resources/clds/camel/rest/clamp-api-v2.xml
+++ b/src/main/resources/clds/camel/rest/clamp-api-v2.xml
@@ -102,35 +102,82 @@
</setBody>
<log
loggingLevel="INFO"
- message="Loop name received: ${body}"></log>
+ message="Receive SUBMIT request for loop: ${body}" />
<to
uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
- <setHeader headerName="LoopObject">
- <method
- ref="org.onap.clamp.loop.LoopService"
- method="getLoop" />
- </setHeader>
- <split streaming="true">
+ <to uri="direct:load-loop" />
+ <log
+ loggingLevel="INFO"
+ message="Processing all MICRO-SERVICES policies defined in loop ${header.LoopObject.getName()}" />
+ <split>
<simple>${header.LoopObject.getMicroServicePolicies()}
</simple>
- <setHeader headerName="HttpQueryException">
+ <setHeader headerName="microServicePolicy">
+ <simple>${body}</simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Processing Micro Service Policy: ${header.microServicePolicy.getName()}" />
+ <setHeader headerName="HttpQueryExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setHeader>
+ <to uri="direct:delete-micro-service-policy" />
+
+ <setHeader headerName="HttpQueryExceptionFlag">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setHeader>
+ <to uri="direct:create-micro-service-policy" />
+ </split>
+
+ <log
+ loggingLevel="INFO"
+ message="Processing all OPERATIONAL policies defined in loop ${header.LoopObject.getName()}" />
+ <split>
+ <simple>${header.LoopObject.getOperationalPolicies()}
+ </simple>
+ <setHeader headerName="operationalPolicy">
+ <simple>${body}</simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Processing Operational Policy: ${header.operationalPolicy.getName()}" />
+ <setHeader headerName="HttpQueryExceptionFlag">
<simple resultType="java.lang.Boolean">false</simple>
</setHeader>
- <to uri="direct:delete-micro-service"/>
-
- <setHeader headerName="HttpQueryException">
+ <to uri="direct:delete-operational-policy" />
+
+ <setHeader headerName="HttpQueryExceptionFlag">
<simple resultType="java.lang.Boolean">true</simple>
</setHeader>
- <setBody>
- <simple>${body.createPolicyPayload()}</simple>
- </setBody>
- <to uri="direct:create-micro-service"/>
+ <to uri="direct:create-operational-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Processing all GUARD policies defined in loop ${header.LoopObject.getName()}" />
+ <split>
+ <simple>${header.operationalPolicy.createGuardPolicyPayloads().entrySet()}
+ </simple>
+ <setHeader headerName="guardPolicy">
+ <simple>${body}</simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Processing Guard Policy: ${header.guardPolicy.getKey()}" />
+
+ <setHeader headerName="HttpQueryExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setHeader>
+ <to uri="direct:delete-guard-policy" />
+
+ <setHeader headerName="HttpQueryExceptionFlag">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setHeader>
+ <to uri="direct:create-guard-policy" />
+ </split>
</split>
</route>
</put>
- <put
- uri="/v2/loop/delete/{loopName}">
+ <put uri="/v2/loop/delete/{loopName}">
<route>
<to
uri="bean:org.onap.clamp.authorization.AuthorizationController?method=authorize(*,'cl','','update')" />
diff --git a/src/main/resources/clds/camel/routes/flexible-flow.xml b/src/main/resources/clds/camel/routes/flexible-flow.xml
index b8244990..15a247b5 100644
--- a/src/main/resources/clds/camel/routes/flexible-flow.xml
+++ b/src/main/resources/clds/camel/routes/flexible-flow.xml
@@ -75,43 +75,168 @@
</when>
</choice>
</route>
- <route id="delete-micro-service">
- <from uri="direct:delete-micro-service" />
+ <route id="load-loop">
+ <from uri="direct:load-loop" />
+ <setHeader headerName="LoopObject">
+ <method
+ ref="org.onap.clamp.loop.LoopService"
+ method="getLoop" />
+ </setHeader>
+
+ <when>
+ <simple>${header.LoopObject} == null</simple>
+ <setHeader headerName="CamelHttpResponseCode">
+ <constant>404</constant>
+ </setHeader>
+ <log
+ loggingLevel="WARNING"
+ message="Loop not found in database: ${body}" />
+ <stop />
+ </when>
+
+ </route>
+
+ <route id="create-micro-service-policy">
+ <from uri="direct:create-micro-service-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Creating Micro Service Policy: ${header.microServicePolicy.getName()}" />
+ <setBody>
+ <simple>${header.microServicePolicy.createPolicyPayload()}
+ </simple>
+ </setBody>
<setHeader headerName="CamelHttpMethod">
- <constant>DELETE</constant>
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
</setHeader>
<setHeader headerName="CamelHttpUri">
- <simple>{{clamp.config.policy.url}}/policyTypes/${body.getModelType()}/versions/1.0.0/policies/${body.getName()}
+ <simple>{{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies
</simple>
</setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Policy Endpoint for microservice: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+ <toD
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+ </route>
+ <route id="delete-micro-service-policy">
+ <from uri="direct:delete-micro-service-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Deleting Micro Service Policy: ${header.microServicePolicy.getName()}" />
<setBody>
<constant>null</constant>
</setBody>
- <!--<convertBodyTo type="org.onap.clamp.policy.microservice.MicroServicePolicy"/> -->
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="CamelHttpUri">
+ <simple>{{clamp.config.policy.url}}/policyTypes/${header.microServicePolicy.getModelType()}/versions/1.0.0/policies/${header.microServicePolicy.getName()}
+ </simple>
+ </setHeader>
<log
loggingLevel="INFO"
message="Policy Endpoint for microservice: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
<toD
- uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryException}" />
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
+ </route>
+
+ <route id="create-operational-policy">
+ <from uri="direct:create-operational-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Creating Operational Policy: ${header.operationalPolicy.getName()}" />
+ <setBody>
+ <simple>${header.operationalPolicy.createPolicyPayload()}
+ </simple>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>POST</constant>
+ </setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
+ <setHeader headerName="CamelHttpUri">
+ <simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies
+ </simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Policy Endpoint for operational ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+ <toD
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+ </route>
+ <route id="delete-operational-policy">
+ <from uri="direct:delete-operational-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Deleting Operational Policy: ${header.operationalPolicy.getName()}" />
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="CamelHttpUri">
+ <simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controloop.operational/versions/1.0.0/policies/${header.operationalPolicy.getName()}
+ </simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Policy Endpoint for operational: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+ <toD
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
</route>
- <route id="create-micro-service">
- <from uri="direct:create-micro-service" />
+ <route id="create-guard-policy">
+ <from uri="direct:create-guard-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Creating Guard Policy: ${header.guardPolicy.getKey()}" />
+ <setBody>
+ <simple>${header.guardPolicy.getValue()}
+ </simple>
+ </setBody>
<setHeader headerName="CamelHttpMethod">
<constant>POST</constant>
</setHeader>
+ <setHeader headerName="Content-Type">
+ <constant>application/json</constant>
+ </setHeader>
<setHeader headerName="CamelHttpUri">
- <simple>{{clamp.config.policy.url}}/policyTypes/${body.getModelType()}/versions/1.0.0/policies
+ <simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies
</simple>
</setHeader>
- <!--<convertBodyTo type="org.onap.clamp.policy.microservice.MicroServicePolicy"/> -->
<log
loggingLevel="INFO"
- message="Policy Endpoint for microservice: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+ message="Policy Endpoint for operational ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
+ <toD
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}" />
+ </route>
+ <route id="delete-guard-policy">
+ <from uri="direct:delete-guard-policy" />
+ <log
+ loggingLevel="INFO"
+ message="Deleting Guard Policy: ${header.guardPolicy.getKey()}" />
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <setHeader headerName="CamelHttpMethod">
+ <constant>DELETE</constant>
+ </setHeader>
+ <setHeader headerName="CamelHttpUri">
+ <simple>{{clamp.config.policy.url}}/policyTypes/onap.policies.controlloop.Guard/versions/1.0.0/policies/${header.guardPolicy.getKey()}
+ </simple>
+ </setHeader>
+ <log
+ loggingLevel="INFO"
+ message="Policy Endpoint for operational: ${header.CamelHttpMethod} ${header.CamelHttpUri}"></log>
<toD
- uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryException}" />
+ uri="http4://policyhost:8085?throwExceptionOnFailure=${header.HttpQueryExceptionFlag}&amp;deleteWithBody=false&amp;mapHttpMessageBody=false&amp;mapHttpMessageFormUrlEncodedBody=false" />
</route>
</routes> \ No newline at end of file