summaryrefslogtreecommitdiffstats
path: root/src/main/resources/clds/camel/routes/dcae-flows.xml
blob: a9d03528d651d4c60769df6a30b981691de78323 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
<routes xmlns="http://camel.apache.org/schema/spring">
	<route id="deploy-loop">
		<from uri="direct:deploy-loop" />
		<choice>
			<when>
				<simple>${exchangeProperty['loopObject'].getLoopTemplate().getBlueprint()} != null
				</simple>
				<to uri="direct:deploy-loop-single-blueprint" />
			</when>
			<when>
				<simple>${exchangeProperty['loopObject'].getLoopTemplate().getBlueprint()} == null
				</simple>
				<to uri="direct:deploy-loop-multi-blueprint" />
			</when>
		</choice>
	</route>
	<route id="deploy-loop-multi-blueprint">
		<from uri="direct:deploy-loop-multi-blueprint" />
		<doTry>
			<log loggingLevel="INFO"
				message="Deploying the blueprints for loop: ${exchangeProperty[loopObject].getName()}" />
			<to
				uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Deploying the loop with multiple blueprints')" />
			<split>
					<simple>${exchangeProperty[loopObject].getMicroServicePolicies()}
					</simple>
					<setProperty propertyName="microServicePolicy">
						<simple>${body}</simple>
					</setProperty>
					<log
						loggingLevel="INFO"
						message="Processing Micro Service Policy: ${exchangeProperty[microServicePolicy].getName()}" />
					<setProperty propertyName="raiseHttpExceptionFlag">
						<simple resultType="java.lang.Boolean">false</simple>
					</setProperty>
					<setBody>
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="getDeployPayload(${exchangeProperty[loopObject]},${exchangeProperty[microServicePolicy].getName()})" />
					</setBody>
					<setProperty propertyName="dcaeDeploymentId">
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="generateDeploymentId()" />
					</setProperty>
					<setHeader headerName="CamelHttpMethod">
						<constant>PUT</constant>
					</setHeader>
					<setHeader headerName="Content-Type">
						<constant>application/json</constant>
					</setHeader>
					<setHeader headerName="X-ONAP-RequestID">
						<simple>${exchangeProperty[X-ONAP-RequestID]}
						</simple>
					</setHeader>
					<setHeader headerName="X-ONAP-InvocationID">
						<simple>${exchangeProperty[X-ONAP-InvocationID]}
						</simple>
					</setHeader>
					<setHeader headerName="X-ONAP-PartnerName">
						<simple>${exchangeProperty[X-ONAP-PartnerName]}
						</simple>
					</setHeader>
					<log loggingLevel="INFO"
						message="Endpoint to deploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}"></log>
					<toD
						uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=300000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
					<convertBodyTo type="java.lang.String" />
					<setProperty propertyName="dcaeResponse">
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="convertDcaeResponse(${body})" />
					</setProperty>
					<setProperty propertyName="dcaeStatusUrl">
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="getStatusUrl(${exchangeProperty[dcaeResponse]})" />
					</setProperty>
					<to
						uri="bean:org.onap.clamp.policy.microservice.MicroServicePolicyService?method=updateDcaeDeploymentFields(${exchangeProperty[microServicePolicy]},${exchangeProperty[dcaeDeploymentId]},${exchangeProperty[dcaeStatusUrl]})" />
			</split>
			<doCatch>
				<exception>java.lang.Exception</exception>
				<handled>
					<constant>false</constant>
				</handled>
				<setProperty propertyName="logMessage">
					<simple>DEPLOY loop status
						(Dep-id:${exchangeProperty[dcaeDeploymentId]},
						StatusUrl:${exchangeProperty[dcaeStatusUrl]})
					</simple>
				</setProperty>
				<setProperty propertyName="logComponent">
					<simple>DCAE</simple>
				</setProperty>
				<to uri="direct:dump-loop-log-http-response" />
			</doCatch>
			<doFinally>
				<to uri="direct:reset-raise-http-exception-flag" />
				<to
					uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
			</doFinally>
		</doTry>
	</route>
	<route id="deploy-loop-single-blueprint">
		<from uri="direct:deploy-loop-single-blueprint" />
		<doTry>
			<log loggingLevel="INFO"
				message="Deploying the loop: ${exchangeProperty[loopObject].getName()}" />
			<to
				uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Deploying the loop')" />
			<setBody>
				<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
					method="getDeployPayload(${exchangeProperty[loopObject]})" />
			</setBody>
			<setProperty propertyName="dcaeDeploymentId">
				<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
					method="generateDeploymentId()" />
			</setProperty>
			<setHeader headerName="CamelHttpMethod">
				<constant>PUT</constant>
			</setHeader>
			<setHeader headerName="Content-Type">
				<constant>application/json</constant>
			</setHeader>
			<setHeader headerName="X-ONAP-RequestID">
				<simple>${exchangeProperty[X-ONAP-RequestID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-InvocationID">
				<simple>${exchangeProperty[X-ONAP-InvocationID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-PartnerName">
				<simple>${exchangeProperty[X-ONAP-PartnerName]}
				</simple>
			</setHeader>
			<log loggingLevel="INFO"
				message="Endpoint to deploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}"></log>
			<toD
				uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[dcaeDeploymentId]}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=300000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
			<convertBodyTo type="java.lang.String" />
			<setProperty propertyName="dcaeResponse">
				<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
					method="convertDcaeResponse(${body})" />
			</setProperty>
			

			<setProperty propertyName="dcaeStatusUrl">
				<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
					method="getStatusUrl(${exchangeProperty[dcaeResponse]})" />
			</setProperty>
			<to
				uri="bean:org.onap.clamp.loop.LoopService?method=updateDcaeDeploymentFields(${exchangeProperty[loopObject]},${exchangeProperty[dcaeDeploymentId]},${exchangeProperty[dcaeStatusUrl]})" />
			<doFinally>
				<to uri="direct:reset-raise-http-exception-flag" />
				<to
					uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
				<setProperty propertyName="logMessage">
					<simple>DEPLOY loop status
						(Dep-id:${exchangeProperty[dcaeDeploymentId]},
						StatusUrl:${exchangeProperty[dcaeStatusUrl]})
					</simple>
				</setProperty>
				<setProperty propertyName="logComponent">
					<simple>DCAE</simple>
				</setProperty>
				<to uri="direct:dump-loop-log-http-response" />
			</doFinally>
		</doTry>
	</route>
	<route id="undeploy-loop">
		<from uri="direct:undeploy-loop" />
		<log loggingLevel="INFO"
			message="Undeploying the loop: ${exchangeProperty[loopObject].getName()} : ${exchangeProperty[loopObject].getDcaeDeploymentId()}" />
		<to
			uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Undeploying the loop')" />
		<choice>
			<when>
				<simple>${exchangeProperty[loopObject].getDcaeDeploymentId()}
					!= null
				</simple>
				<doTry>
					<setBody>
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="getUndeployPayload(${exchangeProperty[loopObject]})" />
					</setBody>
					<setHeader headerName="CamelHttpMethod">
						<constant>DELETE</constant>
					</setHeader>
					<setHeader headerName="Content-Type">
						<constant>application/json</constant>
					</setHeader>

					<setHeader headerName="X-ONAP-RequestID">
						<simple>${exchangeProperty[X-ONAP-RequestID]}
						</simple>
					</setHeader>
					<setHeader headerName="X-ONAP-InvocationID">
						<simple>${exchangeProperty[X-ONAP-InvocationID]}
						</simple>
					</setHeader>
					<setHeader headerName="X-ONAP-PartnerName">
						<simple>${exchangeProperty[X-ONAP-PartnerName]}
						</simple>
					</setHeader>
					<log loggingLevel="INFO"
						message="Endpoint to undeploy loop: {{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}"></log>
					<toD
						uri="{{clamp.config.dcae.deployment.url}}/dcae-deployments/${exchangeProperty[loopObject].getDcaeDeploymentId()}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;mapHttpMessageHeaders=false&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=300000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
					<convertBodyTo type="java.lang.String" />
					<setProperty propertyName="dcaeResponse">
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="convertDcaeResponse(${body})" />
					</setProperty>
					<setProperty propertyName="dcaeStatusUrl">
						<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
							method="getStatusUrl(${exchangeProperty[dcaeResponse]})" />
					</setProperty>
					<to
						uri="bean:org.onap.clamp.loop.LoopService?method=updateDcaeDeploymentFields(${exchangeProperty[loopObject]},${exchangeProperty[loopObject].getDcaeDeploymentId()},${exchangeProperty[dcaeStatusUrl]})" />
					<doFinally>
						<to uri="direct:reset-raise-http-exception-flag" />
						<to
							uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
						<setProperty propertyName="logMessage">
							<simple>UNDEPLOY loop status</simple>
						</setProperty>
						<setProperty propertyName="logComponent">
							<simple>DCAE</simple>
						</setProperty>
						<to uri="direct:dump-loop-log-http-response" />
					</doFinally>
				</doTry>
			</when>
			<otherwise>
				<log loggingLevel="WARNING"
					message="Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !" />
				<to
					uri="bean:org.onap.clamp.loop.log.LoopLogService?method=addLog('Cannot Undeploy for the loop: ${exchangeProperty[loopObject].getName()}, the Deployment ID does not exist !','WARNING',${exchangeProperty[loopObject]})" />

			</otherwise>
		</choice>
	</route>
	<route id="get-dcae-deployment-status">
		<from uri="direct:get-dcae-deployment-status" />
		<log loggingLevel="INFO"
			message="Getting DCAE deployment status for loop: ${exchangeProperty[loopObject].getName()}" />
		<to
			uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting Deployment status')" />
		<doTry>
			<setHeader headerName="CamelHttpMethod">
				<constant>GET</constant>
			</setHeader>
			<setHeader headerName="X-ONAP-RequestID">
				<simple>${exchangeProperty[X-ONAP-RequestID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-InvocationID">
				<simple>${exchangeProperty[X-ONAP-InvocationID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-PartnerName">
				<simple>${exchangeProperty[X-ONAP-PartnerName]}
				</simple>
			</setHeader>
			<log loggingLevel="INFO"
				message="Endpoint to query Closed Loop status: ${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}"></log>
			<toD
				uri="${exchangeProperty[loopObject].getDcaeDeploymentStatusUrl()}?bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=30000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
			<doFinally>
				<to uri="direct:reset-raise-http-exception-flag" />
				<to
					uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
				<setProperty propertyName="logMessage">
					<simple>DCAE deployment status</simple>
				</setProperty>
				<setProperty propertyName="logComponent">
					<simple>DCAE</simple>
				</setProperty>
				<to uri="direct:dump-loop-log-http-response" />
			</doFinally>
		</doTry>
	</route>
	<route id="get-dcae-blueprint-inventory">
		<from uri="direct:get-dcae-blueprint-inventory" />
		<log loggingLevel="INFO"
			message="Getting DCAE blueprint id in inventory" />
		<to
			uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting blueprint id in inventory')" />
		<doTry>
			<setHeader headerName="CamelHttpMethod">
				<constant>GET</constant>
			</setHeader>
			<setHeader headerName="X-ONAP-RequestID">
				<simple>${exchangeProperty[X-ONAP-RequestID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-InvocationID">
				<simple>${exchangeProperty[X-ONAP-InvocationID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-PartnerName">
				<simple>${exchangeProperty[X-ONAP-PartnerName]}
				</simple>
			</setHeader>
			<log loggingLevel="INFO"
				message="Endpoint to query Dcae inventory Loop status: {{clamp.config.dcae.inventory.url}}/dcae-service-types?${header[CamelHttpQuery]}"></log>
			<toD
				uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types?asdcResourceId=${exchangeProperty[blueprintResourceId]}&amp;asdcServiceId=${exchangeProperty[blueprintServiceId]}&amp;typeName=${exchangeProperty[blueprintName]}&amp;bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=30000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
			<convertBodyTo type="java.lang.String" />
			<doFinally>
				<to uri="direct:reset-raise-http-exception-flag" />
				<to
					uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
			</doFinally>
		</doTry>

	</route>
	<route id="get-all-dcae-blueprint-inventory">
		<from uri="direct:get-all-dcae-blueprint-inventory" />
		<log loggingLevel="INFO"
			 message="Getting all DCAE blueprint from inventory" />
		<to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeLog('DCAE', 'Getting all blueprint from inventory')" />
		<doTry>
			<setHeader headerName="CamelHttpMethod">
				<constant>GET</constant>
			</setHeader>
			<setHeader headerName="X-ONAP-RequestID">
				<simple>${exchangeProperty[X-ONAP-RequestID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-InvocationID">
				<simple>${exchangeProperty[X-ONAP-InvocationID]}
				</simple>
			</setHeader>
			<setHeader headerName="X-ONAP-PartnerName">
				<simple>${exchangeProperty[X-ONAP-PartnerName]}
				</simple>
			</setHeader>
			<log loggingLevel="INFO"
				 message="Endpoint to query Blueprints from DCAE inventory: {{clamp.config.dcae.inventory.url}}/dcae-service-types?${header[CamelHttpQuery]}"></log>
			<toD uri="{{clamp.config.dcae.inventory.url}}/dcae-service-types;bridgeEndpoint=true&amp;useSystemProperties=true&amp;throwExceptionOnFailure=${exchangeProperty[raiseHttpExceptionFlag]}&amp;authMethod=Basic&amp;authUsername={{clamp.config.dcae.deployment.userName}}&amp;authPassword={{clamp.config.dcae.deployment.password}}&amp;connectionTimeToLive=5000&amp;httpClient.connectTimeout=10000&amp;httpClient.socketTimeout=30000&amp;authenticationPreemptive=true&amp;connectionClose=true" />
			<convertBodyTo type="java.lang.String" />
			<setProperty propertyName="dcaeResponseList">
				<method ref="org.onap.clamp.loop.components.external.DcaeComponent"
						method="convertToDcaeInventoryResponse(${body})" />
			</setProperty>
			<split>
				<simple>${exchangeProperty[dcaeResponseList]}</simple>
				<convertBodyTo type="org.onap.clamp.clds.model.dcae.DcaeInventoryResponse" />
				<setProperty propertyName="dcaeResponse">
					<simple>${body}</simple>
				</setProperty>
				<to uri="bean:org.onap.clamp.clds.model.dcae.DcaeInventoryCache?method=addDcaeInventoryResponse(${exchangeProperty[dcaeResponse]})" />
			</split>
			<doFinally>
				<to uri="direct:reset-raise-http-exception-flag" />
				<to uri="bean:org.onap.clamp.flow.log.FlowLogOperation?method=invokeReturnLog()" />
			</doFinally>
		</doTry>
	</route>
</routes>