summaryrefslogtreecommitdiffstats
path: root/src/main/resources/clds/camel/routes/loop-flows.xml
blob: 57d32f0fe804527669baf1d36b9e5ae07edd5a79 (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
<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="WARN" 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="policyComponent">
			<simple>${exchangeProperty[loopObject].getComponent('POLICY')}
			</simple>
		</setProperty>
		<setProperty propertyName="policyFound">
			<simple resultType="java.lang.Boolean">true</simple>
		</setProperty>
		<setProperty propertyName="policyDeployed">
			<simple resultType="java.lang.Boolean">true</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>
			<setProperty propertyName="policyVersion">
				<simple>1.0.0</simple>
			</setProperty>
			<setBody>
				<constant>null</constant>
			</setBody>
			<log loggingLevel="INFO"
				message="Processing Micro Service Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
			<to uri="direct:verify-one-policy" />
		</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="policyVersion">
				<simple>1</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]}" />
			<to uri="direct:verify-one-policy" />
			<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>
				<setProperty propertyName="policyVersion">
					<simple>1</simple>
				</setProperty>
				<setBody>
					<constant>null</constant>
				</setBody>
				<log loggingLevel="INFO"
					message="Processing Guard Policy: ${exchangeProperty[policyName]} of type ${exchangeProperty[policyType]}" />
				<to uri="direct:verify-one-policy" />
			</split>
		</split>
		<setProperty propertyName="policyState">
			<simple> ${exchangeProperty[policyComponent].getState()}
			</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>