blob: ede899e71133ddb8ffd494651d59bee7104851c4 [file] [log] [blame]
sebdet09bc8452019-05-23 17:34:07 +02001<routes xmlns="http://camel.apache.org/schema/spring">
2 <route id="load-loop">
3 <from uri="direct:load-loop" />
4 <setBody>
5 <simple>${header.loopName}</simple>
6 </setBody>
7 <setProperty propertyName="loopObject">
8 <method
9 ref="org.onap.clamp.loop.LoopService"
10 method="getLoop" />
11 </setProperty>
12
13 <when>
14 <simple>${exchangeProperty[loopObject]} == null</simple>
15 <setHeader headerName="CamelHttpResponseCode">
16 <constant>404</constant>
17 </setHeader>
18 <log
19 loggingLevel="WARNING"
20 message="Loop not found in database: ${body}" />
21 <stop />
22 </when>
23 </route>
24 <route id="update-policy-status-for-loop">
25 <from uri="direct:update-policy-status-for-loop" />
26 <setProperty propertyName="atLeastOnePolicyNotFound">
27 <simple resultType="java.lang.Boolean">false</simple>
28 </setProperty>
29 <setProperty propertyName="atLeastOnePolicyNotDeployed">
30 <simple resultType="java.lang.Boolean">false</simple>
31 </setProperty>
32 <setProperty propertyName="policyComponent">
33 <simple>${exchangeProperty[loopObject].getComponent('POLICY')}
34 </simple>
35 </setProperty>
36 <log
37 loggingLevel="INFO"
38 message="Processing all MICRO-SERVICES policies defined in loop ${exchangeProperty[loopObject].getName()}" />
39 <split>
40 <simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
41 </simple>
42 <setProperty propertyName="policyName">
43 <simple>${body.getName()}</simple>
44 </setProperty>
45 <setProperty propertyName="policyType">
46 <simple>${body.getModelType()}</simple>
47 </setProperty>
48 <setBody>
49 <constant>null</constant>
50 </setBody>
51 <log
52 loggingLevel="INFO"
53 message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
54 <setProperty propertyName="raiseHttpExceptionFlag">
55 <simple resultType="java.lang.Boolean">false</simple>
56 </setProperty>
57 <to uri="direct:get-policy" />
58 <when>
59 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
60 <setProperty propertyName="atLeastOnePolicyNotFound">
61 <simple resultType="java.lang.Boolean">true</simple>
62 </setProperty>
63 </when>
64 <to uri="direct:get-deployment-policy" />
65 <when>
66 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
67 <setProperty propertyName="atLeastOnePolicyNotDeployed">
68 <simple resultType="java.lang.Boolean">true</simple>
69 </setProperty>
70 </when>
71 </split>
72 <log
73 loggingLevel="INFO"
74 message="Processing all OPERATIONAL policies defined in loop ${exchangeProperty[loopObject].getName()}" />
75 <split>
76 <simple>${exchangeProperty[loopObject].getOperationalPolicies()}
77 </simple>
78 <setProperty propertyName="policyName">
79 <simple>${body.getName()}</simple>
80 </setProperty>
81 <setProperty propertyName="policyType">
82 <simple>onap.policies.controlloop.Operational</simple>
83 </setProperty>
84 <setProperty propertyName="operationalPolicy">
85 <simple>${body}</simple>
86 </setProperty>
87 <setBody>
88 <constant>null</constant>
89 </setBody>
90 <log
91 loggingLevel="INFO"
92 message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
93 <setProperty propertyName="raiseHttpExceptionFlag">
94 <simple resultType="java.lang.Boolean">false</simple>
95 </setProperty>
96 <to uri="direct:get-policy" />
97 <when>
98 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
99 <setProperty propertyName="atLeastOnePolicyNotFound">
100 <simple resultType="java.lang.Boolean">true</simple>
101 </setProperty>
102 </when>
103 <to uri="direct:get-deployment-policy" />
104 <when>
105 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
106 <setProperty propertyName="atLeastOnePolicyNotDeployed">
107 <simple resultType="java.lang.Boolean">true</simple>
108 </setProperty>
109 </when>
110
111 <log
112 loggingLevel="INFO"
113 message="Processing all GUARD policies defined in loop ${exchangeProperty[loopObject].getName()}" />
114 <split>
115 <simple>${exchangeProperty[operationalPolicy].createGuardPolicyPayloads().entrySet()}
116 </simple>
117 <setProperty propertyName="policyName">
118 <simple>${body.getKey()}</simple>
119 </setProperty>
120 <setProperty propertyName="policyType">
121 <simple>onap.policies.controlloop.Guard</simple>
122 </setProperty>
123 <setBody>
124 <constant>null</constant>
125 </setBody>
126 <log
127 loggingLevel="INFO"
128 message="Processing Guard Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
129 <setProperty propertyName="raiseHttpExceptionFlag">
130 <simple resultType="java.lang.Boolean">false</simple>
131 </setProperty>
132 <to uri="direct:get-policy" />
133 <when>
134 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
135 <setProperty propertyName="atLeastOnePolicyNotFound">
136 <simple resultType="java.lang.Boolean">true</simple>
137 </setProperty>
138 </when>
139 <to uri="direct:get-deployment-policy" />
140 <when>
141 <simple> ${header.CamelHttpResponseCode} != 200 </simple>
142 <setProperty propertyName="atLeastOnePolicyNotDeployed">
143 <simple resultType="java.lang.Boolean">true</simple>
144 </setProperty>
145 </when>
146 </split>
147 </split>
148 <setProperty propertyName="policyState">
149 <simple> ${exchangeProperty[policyComponent].computeState(*)}
150 </simple>
151 </setProperty>
152 <log
153 loggingLevel="INFO"
154 message="Policy state set to: ${exchangeProperty[policyState].getStateName()}" />
155 <to
156 uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLogForComponent('Policy state set to: ${exchangeProperty[policyState].getStateName()}','INFO','POLICY',${exchangeProperty[loopObject]})" />
157 </route>
158 <route id="update-dcae-status-for-loop">
159 <from uri="direct:update-dcae-status-for-loop" />
160 <log
161 loggingLevel="INFO"
162 message="Updating DCAE status for loop: ${exchangeProperty[loopObject].getName()}" />
163 <setProperty propertyName="dcaeComponent">
164 <simple>${exchangeProperty[loopObject].getComponent('DCAE')}</simple>
165 </setProperty>
166 <when>
167 <simple>${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}
168 != null
169 </simple>
170 <setProperty propertyName="raiseHttpExceptionFlag">
171 <simple resultType="java.lang.Boolean">false</simple>
172 </setProperty>
173 <to uri="direct:get-dcae-deployment-status" />
174 <when>
175 <simple> ${header.CamelHttpResponseCode} == 200 </simple>
176 <convertBodyTo type="java.lang.String" />
177 <setProperty propertyName="dcaeResponse">
178 <method
179 ref="org.onap.clamp.loop.components.external.DcaeComponent"
180 method="convertDcaeResponse(${body})" />
181 </setProperty>
182 </when>
183 </when>
184
185 <setProperty propertyName="dcaeState">
186 <simple> ${exchangeProperty[dcaeComponent].computeState(*)}
187 </simple>
188 </setProperty>
189 <log
190 loggingLevel="INFO"
191 message="DCAE state set to: ${exchangeProperty[dcaeState].getStateName()} - DCAE message: ${exchangeProperty[dcaeResponse].getError()}" />
192 <to
193 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]})" />
194
195 </route>
196 <route id="direct:update-loop-state">
197 <from uri="direct:update-loop-state" />
198 <log
199 loggingLevel="INFO"
200 message="Updating status for loop: ${exchangeProperty[loopObject].getName()}" />
201 <choice>
202 <when>
203 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' and ${exchangeProperty['policyState'].getStateName()} == 'NOT_SENT'</simple>
204 <to
205 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DESIGN')" />
206 </when>
207 <when>
208 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'IN_ERROR' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLATION_FAILED'</simple>
209 <to
210 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
211 </when>
212 <when>
213 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLATION_FAILED' or ${exchangeProperty['policyState'].getStateName()} == 'IN_ERROR'</simple>
214 <to
215 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'IN_ERROR')" />
216 </when>
217 <when>
218 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
219 <to
220 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'RUNNING')" />
221 </when>
222 <when>
223 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT'</simple>
224 <to
225 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'STOPPED')" />
226 </when>
227 <when>
228 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'BLUEPRINT_DEPLOYED' or ${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_UNINSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
229 <to
230 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'SUBMITTED')" />
231 </when>
232 <when>
233 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_INSTALLATION' or ${exchangeProperty['dcaeState'].getStateName()} == 'PROCESSING_MICROSERVICE_UNINSTALLATION' and ${exchangeProperty['policyState'].getStateName()} == 'SENT_AND_DEPLOYED'</simple>
234 <to
235 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'WAITING')" />
236 </when>
237 <when>
238 <simple>${exchangeProperty['dcaeState'].getStateName()} == 'MICROSERVICE_INSTALLED_SUCCESSFULLY' and ${exchangeProperty['policyState'].getStateName()} != 'NOT_SENT'</simple>
239 <to
240 uri="bean:org.onap.clamp.loop.LoopService?method=updateLoopState(${exchangeProperty[loopObject]},'DEPLOYED')" />
241 </when>
242 </choice>
243 <log
244 loggingLevel="INFO"
245 message="New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}" />
246 <to
247 uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('New loop state is: ${exchangeProperty[loopObject].getLastComputedState().toString()}','INFO',${exchangeProperty[loopObject]})" />
248
249 </route>
250</routes>