summaryrefslogtreecommitdiffstats
path: root/src/main/resources/clds/camel/routes/loop-flows.xml
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/clds/camel/routes/loop-flows.xml')
-rw-r--r--src/main/resources/clds/camel/routes/loop-flows.xml250
1 files changed, 250 insertions, 0 deletions
diff --git a/src/main/resources/clds/camel/routes/loop-flows.xml b/src/main/resources/clds/camel/routes/loop-flows.xml
new file mode 100644
index 000000000..ede899e71
--- /dev/null
+++ b/src/main/resources/clds/camel/routes/loop-flows.xml
@@ -0,0 +1,250 @@
+<routes xmlns="http://camel.apache.org/schema/spring">
+ <route id="load-loop">
+ <from uri="direct:load-loop" />
+ <setBody>
+ <simple>${header.loopName}</simple>
+ </setBody>
+ <setProperty propertyName="loopObject">
+ <method
+ ref="org.onap.clamp.loop.LoopService"
+ method="getLoop" />
+ </setProperty>
+
+ <when>
+ <simple>${exchangeProperty[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="update-policy-status-for-loop">
+ <from uri="direct:update-policy-status-for-loop" />
+ <setProperty propertyName="atLeastOnePolicyNotFound">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <setProperty propertyName="atLeastOnePolicyNotDeployed">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <setProperty propertyName="policyComponent">
+ <simple>${exchangeProperty[loopObject].getComponent('POLICY')}
+ </simple>
+ </setProperty>
+ <log
+ loggingLevel="INFO"
+ message="Processing all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" />
+ <split>
+ <simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
+ </simple>
+ <setProperty propertyName="policyName">
+ <simple>${body.getName()}</simple>
+ </setProperty>
+ <setProperty propertyName="policyType">
+ <simple>${body.getModelType()}</simple>
+ </setProperty>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <log
+ loggingLevel="INFO"
+ message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotFound">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+ <to uri="direct:get-deployment-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotDeployed">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+ </split>
+ <log
+ loggingLevel="INFO"
+ message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" />
+ <split>
+ <simple>${exchangeProperty[loopObject].getOperationalPolicies()}
+ </simple>
+ <setProperty propertyName="policyName">
+ <simple>${body.getName()}</simple>
+ </setProperty>
+ <setProperty propertyName="policyType">
+ <simple>onap.policies.controlloop.Operational</simple>
+ </setProperty>
+ <setProperty propertyName="operationalPolicy">
+ <simple>${body}</simple>
+ </setProperty>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <log
+ loggingLevel="INFO"
+ message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotFound">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+ <to uri="direct:get-deployment-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotDeployed">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+
+ <log
+ loggingLevel="INFO"
+ message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" />
+ <split>
+ <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()}
+ </simple>
+ <setProperty propertyName="policyName">
+ <simple>${body.getKey()}</simple>
+ </setProperty>
+ <setProperty propertyName="policyType">
+ <simple>onap.policies.controlloop.Guard</simple>
+ </setProperty>
+ <setBody>
+ <constant>null</constant>
+ </setBody>
+ <log
+ loggingLevel="INFO"
+ message="Processing Guard Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotFound">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+ <to uri="direct:get-deployment-policy" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} != 200 </simple>
+ <setProperty propertyName="atLeastOnePolicyNotDeployed">
+ <simple resultType="java.lang.Boolean">true</simple>
+ </setProperty>
+ </when>
+ </split>
+ </split>
+ <setProperty propertyName="policyState">
+ <simple> ${exchangeProperty[policyComponent].computeState(*)}
+ </simple>
+ </setProperty>
+ <log
+ loggingLevel="INFO"
+ message="Policy state set to: ${exchangeProperty[policyState].getStateName()}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('Policy state set to: ${exchangeProperty[policyState].getStateName()}','INFO','POLICY',${exchangeProperty[loopObject]})" />
+ </route>
+ <route id="update-dcae-status-for-loop">
+ <from uri="direct:update-dcae-status-for-loop" />
+ <log
+ loggingLevel="INFO"
+ message="Updating DCAE status for loop: ${exchangeProperty[loopObject].getName()}" />
+ <setProperty propertyName="dcaeComponent">
+ <simple>${exchangeProperty[loopObject].getComponent('DCAE')}</simple>
+ </setProperty>
+ <when>
+ <simple>${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}
+ != null
+ </simple>
+ <setProperty propertyName="raiseHttpExceptionFlag">
+ <simple resultType="java.lang.Boolean">false</simple>
+ </setProperty>
+ <to uri="direct:get-dcae-deployment-status" />
+ <when>
+ <simple> ${header.CamelHttpResponseCode} == 200 </simple>
+ <convertBodyTo type="java.lang.String" />
+ <setProperty propertyName="dcaeResponse">
+ <method
+ ref="org.onap.clamp.loop.components.external.DcaeComponent"
+ method="convertDcaeResponse(${body})" />
+ </setProperty>
+ </when>
+ </when>
+
+ <setProperty propertyName="dcaeState">
+ <simple> ${exchangeProperty[dcaeComponent].computeState(*)}
+ </simple>
+ </setProperty>
+ <log
+ loggingLevel="INFO"
+ message="DCAE state set to: ${exchangeProperty[dcaeState].getStateName()} - DCAE message: ${exchangeProperty[dcaeResponse].getError()}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('DCAE state set to: ${exchangeProperty[dcaeState].getStateName()} - message: ${exchangeProperty[dcaeResponse].getError()}','INFO','DCAE',${exchangeProperty[loopObject]})" />
+
+ </route>
+ <route id="direct:update-loop-state">
+ <from uri="direct:update-loop-state" />
+ <log
+ loggingLevel="INFO"
+ message="Updating status for loop: ${exchangeProperty[loopObject].getName()}" />
+ <choice>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' and ${exchangeProperty['policyState'].getStateName()} == 'NOT_SENT'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DESIGN')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLATION_FAILED'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLATION_FAILED' or ${exchangeProperty['policyState'].getStateName()} == 'IN_ERROR'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'RUNNING')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'STOPPED')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'SUBMITTED')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_INSTALLATION' or ${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_UNINSTALLATION' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'WAITING')" />
+ </when>
+ <when>
+ <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} != 'NOT_SENT'</simple>
+ <to
+ uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DEPLOYED')" />
+ </when>
+ </choice>
+ <log
+ loggingLevel="INFO"
+ message="New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}" />
+ <to
+ uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}','INFO',${exchangeProperty[loopObject]})" />
+
+ </route>
+</routes> \ No newline at end of file