Chore: Add gerrit maven verify GHA workflow
[sdnc/oam.git] / platform-logic / generic-resource-api / src / main / xml / SUBNET-API_subnet-allocated-notification.xml
1 <service-logic
2     xmlns='http://www.onap.org/sdnc/svclogic'
3     xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.onap.org/sdnc/svclogic ./svclogic.xsd' module='SUBNET-API' version='${project.version}'>
4     <method rpc='subnet-allocated-notification' mode='sync'>
5         <block>
6             <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
7                 <parameter name="logger" value="message-log"/>
8                 <parameter name="field1" value="__TIMESTAMP__"/>
9                 <parameter name="field2" value="subnet-allocated-notification"/>
10                 <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
11                 <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
12                 <parameter name="field5" value="`$eipam-ip-block.ptnii-name`"/>
13                 <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
14                 <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
15                 <parameter name="field8" value="`$eipam-ip-block.status`"/>
16                 <parameter name="field9" value="`$tmp.key-value`"/>
17             </record>
18             <!--Need to know which ipv version to get the plan name from the network-model.-->
19             <switch test="`$eipam-ip-block.ptnii-name`">
20                 <!--If there's ptnii-name, then it's Gamma service-->
21                 <outcome value='Other'>
22                     <block>
23                         <configure adaptor="com.att.sdnctl.sli.adaptor.ncs.ncsAdaptor" key="SNIIR" activate="true">
24                             <parameter name="input.request-id" value="`$eipam-ip-block.request-id`" />
25                             <parameter name="input.source" value="SDNC" />
26                             <parameter name="input.ptnii-name" value="`$eipam-ip-block.ptnii-name`" />
27                             <parameter name="input.ip-address" value="`$eipam-ip-block.ip-address`" />
28                             <parameter name="input.mask" value="`$eipam-ip-block.prefix-length`" />
29                             <outcome value="success">
30                                 <block>
31                                     <save 
32         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
33         resource='SQL'
34         key="UPDATE EIPAM_IP_SUBNETS
35              SET status = 'PENDING-ACTIVE'
36              WHERE entity_id = $eipam-ip-block.entity-id ; "
37     force='true'
38         pfx='pfx.eipam-subnet-row'></save>
39                                     <set>
40                                         <parameter name="eipam-ip-block.status" value="PENDING-ACTIVE" />
41                                     </set>
42                                     <save plugin="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource" resource="eipam-ip-block">
43                                         <parameter name="eipam-ip-block.status" value="PENDING-ACTIVE" />
44                                     </save>
45                                     <return status="success"></return>
46                                 </block>
47                             </outcome>
48                             <outcome value="Other">
49                                 <!--subnet and subnet_keys are deleted in the EIPAMPlugin-->
50                                 <execute plugin="com.att.sdnctl.sli.plugin.eipam.EIPAMPlugin" method="deletePool">
51                                     <outcome value="success">
52                                         <block>
53                                             <set>
54                                                 <parameter name="eipam-ip-block.status" value="DELETED" />
55                                             </set>
56                                             <return status="failure">
57                                                 <parameter name="error-code" value="1000" />
58                                                 <parameter name="error-message" value="IpBlockInstall failure and deletePool deleted in EIPAM" />
59                                             </return>
60                                         </block>
61                                     </outcome>
62                                     <outcome value="Other">
63                                         <block>
64                                             <save 
65         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
66         resource='SQL'
67         key="UPDATE EIPAM_IP_SUBNETS
68              SET 
69              status = 'ERROR',
70              dealloc_failure = 'deletePool failed in response to NCS_IP_SUBNET_INSTALL_ERROR'
71              WHERE entity_id = $eipam-ip-block.entity-id ; "
72     force='true'
73         pfx='pfx.eipam-subnet-row'></save>
74                                             <set>
75                                                 <parameter name="eipam-ip-block.status" value="NCS_IP_SUBNET_INSTALL_ERROR" />
76                                             </set>
77                                             <update plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" resource="generic-vnf" key="generic-vnf.vnf-id = $tmp.vpe-pool.vpe-id" pfx="vpe-after">
78                                                 <parameter name="operational-status" value="NCS_IP_SUBNET_INSTALL_ERROR" />
79                                                 <parameter name="summary-status" value="`$aai-summary-status-message`" />
80                                                 <parameter name="prov-status" value="PREPROV" />
81                                             </update>
82                                             <return status="failure">
83                                                 <parameter name="error-code" value="1000" />
84                                                 <parameter name="error-message" value="IpBlockInstall failure and deletePool failed in EIPAM, need to manually delete" />
85                                             </return>
86                                         </block>
87                                     </outcome>
88                                 </execute>
89                             </outcome>
90                         </configure>
91                     </block>
92                 </outcome>
93                 <!--If no ptnii-name, check if VIPR or SRIOV-->
94                 <outcome value=''>
95                     <execute plugin="org.onap.ccsdk.sli.core.slipluginutils.SliStringUtils" method="startsWith" emitsOutcome='true' >
96                         <parameter name="source" value="`toUpperCase($eipam-ip-block.plan-name)`" />
97                         <parameter name="target" value="AIC_" />
98                         <outcome value='false'>
99                             <return status="failure">
100                                 <parameter name="error-code" value="500" />
101                                 <parameter name="error-message" value="Unknown Address Plan - not supported!" />
102                             </return>
103                         </outcome>
104                         <outcome value='true'>
105                             <block atomic='true'>
106                                 <get-resource
107         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
108         resource='SQL'
109         key="SELECT * FROM EIPAM_IP_POOLS where plan_name = $eipam-ip-block.plan-name and level = 2 and key_value = $tmp.level2-key-value ;"
110         pfx='tmp.eipam-pool-row'>
111                                     <outcome value='failure'>
112                                         <block atomic='true'>
113                                             <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
114                                                 <parameter name="logger" value="message-log"/>
115                                                 <parameter name="field1" value="__TIMESTAMP__"/>
116                                                 <parameter name="field2" value="subnet-allocated-notification"/>
117                                                 <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
118                                                 <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
119                                                 <parameter name="field5" value="`$eipam-ip-block.ptnii-name`"/>
120                                                 <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
121                                                 <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
122                                                 <parameter name="field8" value="`$eipam-ip-block.status`"/>
123                                                 <parameter name="field9" value="Failed to find this record in DB!"/>
124                                             </record>
125                                             <return status="failure">
126                                                 <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
127                                                 <parameter name="error-code" value="500" />
128                                                 <parameter name="error-message" value="Unknown EIPAM pool - not found in DB!" />
129                                             </return>
130                                         </block>
131                                     </outcome>
132                                     <outcome value="not-found">
133                                         <block atomic='true'>
134                                             <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
135                                                 <parameter name="logger" value="message-log"/>
136                                                 <parameter name="field1" value="__TIMESTAMP__"/>
137                                                 <parameter name="field2" value="subnet-allocated-notification"/>
138                                                 <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
139                                                 <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
140                                                 <parameter name="field5" value="`$eipam-ip-block.ptnii-name`"/>
141                                                 <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
142                                                 <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
143                                                 <parameter name="field8" value="`$eipam-ip-block.status`"/>
144                                                 <parameter name="field9" value="This record is not found in DB!"/>
145                                             </record>
146                                             <return status="failure">
147                                                 <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
148                                                 <parameter name="error-code" value="500" />
149                                                 <parameter name="error-message" value="Unknown EIPAM pool - not found in DB!" />
150                                             </return>
151                                         </block>
152                                     </outcome>
153                                 </get-resource>
154                                 <!--initial subnet should exists-->
155                                 <get-resource
156         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
157         resource='SQL'
158         key="SELECT * from EIPAM_IP_SUBNETS s, EIPAM_IP_SUBNET_KEYS k WHERE s.plan_name = $eipam-ip-block.plan-name and s.entity_id = k.entity_id and k.level = 2 and k.key_value = $tmp.level2-key-value and s.address_family = $tmp.version ; "
159         pfx='pfx.eipam-initial-subnet'>
160                                     <outcome value='failure'>
161                                         <return status="failure">
162                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
163                                             <parameter name="error-code" value="500"/>
164                                             <parameter name="error-message" value="Query to DB table EIPAM_IP_SUBNET_KEYS and EIPAM_IP_SUBNETS failed." />
165                                         </return>
166                                     </outcome>
167                                     <outcome value="not-found">
168                                         <return status="failure">
169                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
170                                             <parameter name="error-code" value="500"/>
171                                             <parameter name="error-message" value="Initial subnet not found, cannot auto extend." />
172                                         </return>
173                                     </outcome>
174                                 </get-resource>
175                                 <!--check if new subnet already exists, possibly from previous attempt.-->
176                                 <get-resource
177         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
178         resource='SQL'
179         key="SELECT * from EIPAM_IP_SUBNETS s WHERE s.plan_name = $eipam-ip-block.plan-name and s.entity_id = $eipam-ip-block.entity-id and s.ip_address = $eipam-ip-block.ip-address ; "
180         pfx='pfx.eipam-subnet-with-same-ip'>
181                                     <outcome value='failure'>
182                                         <return status="failure">
183                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
184                                             <parameter name="error-code" value="500"/>
185                                             <parameter name="error-message" value="Query to DB table EIPAM_IP_SUBNET_KEYS and EIPAM_IP_SUBNETS failed." />
186                                         </return>
187                                     </outcome>
188                                     <outcome value="not-found"></outcome>
189                                 </get-resource>
190                                 <get-resource plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
191         resource="l3-network" 
192                 key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id" 
193                 local-only="false" 
194                 pfx="aai.l3-network">
195                                     <outcome value='not-found'>
196                                         <return status='failure'>
197                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
198                                             <parameter name="error-code" value="404" />
199                                             <parameter name="error-message" value="'l3-network with network-id=' + $pfx.eipam-initial-subnet.network-id + 'Not found in AnAI'" />
200                                         </return>
201                                     </outcome>
202                                     <outcome value='failure'>
203                                         <return status='failure'>
204                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
205                                             <parameter name="error-code" value="500" />
206                                             <parameter name="error-message" value="'Error retrieving l3-network with network-id=' + $pfx.eipam-initial-subnet.network-id + 'from AnAI'" />
207                                         </return>
208                                     </outcome>
209                                 </get-resource>
210                                 <set>
211                                     <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
212                                 </set>
213                                 <save
214         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
215         resource='SQL'
216         key="INSERT EIPAM_IP_SUBNETS
217              SET
218              entity_id = $eipam-ip-block.entity-id ,
219              service_type = $pfx.eipam-initial-subnet.service-type ,
220              ip_address = $eipam-ip-block.ip-prefix ,
221              prefix_length = $eipam-ip-block.mask ,
222              plan_name = $eipam-ip-block.plan-name ,
223              status = 'PENDING_ACTIVE' ,
224              pool_id = $pfx.eipam-initial-subnet.pool-id ,
225              address_family = $pfx.eipam-initial-subnet.address-family ,
226              network_id = $pfx.eipam-initial-subnet.network-id ; "
227     force='true'
228         pfx='pfx.eipam-new-subnet'>
229                                     <outcome value='failure'>
230                                         <return status="failure">
231                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
232                                             <parameter name="error-code" value="500"/>
233                                             <parameter name="error-message" value="Insert to DB table EIPAM_IP_SUBNETS failed." />
234                                         </return>
235                                     </outcome>
236                                     <outcome value='success'></outcome>
237                                 </save>
238                                 <save
239         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
240         resource='SQL'
241         key="INSERT EIPAM_IP_SUBNET_KEYS
242              SET
243              entity_id = $eipam-ip-block.entity-id ,
244              key_name = $tmp.level1-key-name ,
245              key_value = $tmp.level1-key-value ,
246              level = 1 ; "
247     force='true'
248         pfx='pfx.eipam-subnet-level1'>
249                                     <outcome value='success'></outcome>
250                                     <outcome value='failure'>
251                                         <return status="failure">
252                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
253                                             <parameter name="error-code" value="500"/>
254                                             <parameter name="error-message" value="Insert to DB table EIPAM_IP_SUBNET_KEYS failed." />
255                                         </return>
256                                     </outcome>
257                                 </save>
258                                 <save
259         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource'
260         resource='SQL'
261         key="INSERT EIPAM_IP_SUBNET_KEYS
262              SET
263              entity_id = $eipam-ip-block.entity-id ,
264              key_name = $tmp.level2-key-name ,
265              key_value = $tmp.level2-key-value ,
266              level = 2 ; "
267     force='true'
268         pfx='pfx.eipam-subnet-level2'>
269                                     <outcome value='success'></outcome>
270                                     <outcome value='failure'>
271                                         <return status="failure">
272                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
273                                             <parameter name="error-code" value="500"/>
274                                             <parameter name="error-message" value="Insert to DB table EIPAM_IP_SUBNET_KEYS failed." />
275                                         </return>
276                                     </outcome>
277                                 </save>
278                                 <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
279                                     <parameter name="logger" value="message-log"/>
280                                     <parameter name="field1" value="__TIMESTAMP__"/>
281                                     <parameter name="field2" value="Added an entry for subnet-allocated-notification in EIPAM_IP_SUBNETS and EIPAM_IP_SUBNET_KEYS"/>
282                                     <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
283                                     <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
284                                     <parameter name="field5" value="`$pfx.eipam-initial-subnet.network-id`"/>
285                                     <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
286                                     <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
287                                     <parameter name="field8" value="`$eipam-ip-block.status`"/>
288                                     <parameter name="field9" value="`$tmp.key-value`"/>
289                                 </record>
290                                 <get-resource plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
291         resource="subnet" 
292                 key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id
293                         AND subnet.subnet-id = $eipam-ip-block.entity-id"
294                 local-only="false" 
295                 pfx="tmp.aai-initial-subnet">
296                                     <outcome value='not-found'>
297                                         <return status='failure'>
298                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
299                                             <parameter name="error-code" value="404" />
300                                             <parameter name="error-message" value="'l3-network with network-id=' + $pfx.eipam-initial-subnet.network-id + ' And subnet-id=' + $eipam-ip-block.entity-id + ' is Not found in AnAI'" />
301                                         </return>
302                                     </outcome>
303                                     <outcome value='failure'>
304                                         <return status='failure'>
305                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
306                                             <parameter name="error-code" value="500" />
307                                             <parameter name="error-message" value="'Error retrieving l3-network with network-id=' + $pfx.eipam-initial-subnet.network-id + ' And subnet-id=' + $eipam-ip-block.entity-id  + ' from AnAI'" />
308                                         </return>
309                                     </outcome>
310                                 </get-resource>
311                                 <switch test='`$aai.l3-network.subnets.subnet_length`'>
312                                     <outcome value=''>
313                                         <return status='failure'>
314                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
315                                             <parameter name="error-code" value="404" />
316                                             <parameter name="error-message" value="'No subnets found in AAI for network-id=' + $pfx.eipam-initial-subnet.network-id" />
317                                         </return>
318                                     </outcome>
319                                     <outcome value='Other'>
320                                         <set>
321                                             <parameter name='tmp.l3-network.subnet.subnet-name' value="`$aai.l3-network.network-name + '_S' + $aai.l3-network.subnets.subnet_length`" />
322                                         </set>
323                                     </outcome>
324                                 </switch>
325                                 <execute plugin="com.att.sdnctl.sli.plugin.ipAddressTools.IpAddressTool" method="getSubnetAddresses">
326                                     <parameter name="ipAddress" value="`$eipam-ip-block.ip-prefix`" />
327                                     <parameter name="ipVersion" value="`tmp.version`" />
328                                     <parameter name="subnet" value="`$eipam-ip-block.prefix-length`" />
329                                     <parameter name="ctxGateway" value="tmp.return.generate.gateway-address" />
330                                     <parameter name="ctxDhcpStart" value="tmp.return.generate.dhcp-start-address" />
331                                     <parameter name="ctxDhcpEnd" value="tmp.return.generate.dhcp-end-address" />
332                                     <outcome value='failure'>
333                                         <return status='failure'>
334                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
335                                             <parameter name='ack-final' value='Y'/>
336                                             <parameter name="error-code" value="500" />
337                                             <parameter name="error-message" value="Failed to generate gateway addresses using IpAddressTools" />
338                                         </return>
339                                     </outcome>
340                                 </execute>
341                                 <switch test='`$tmp.aai-initial-subnet.dhcp-enabled`'>
342                                     <outcome value='Y'>
343                                         <block atomic="true">
344                                             <set>
345                                                 <parameter name='tmp.l3-network.subnet.dhcp-enabled' value='true' />
346                                                 <parameter name='tmp.l3-network.subnet.dhcp-start' value='`$tmp.return.generate.dhcp-start-address`' />
347                                                 <parameter name='tmp.l3-network.subnet.dhcp-end' value='`$tmp.return.generate.dhcp-end-address`' />
348                                             </set>
349                                         </block>
350                                     </outcome>
351                                     <outcome value='N'>
352                                         <block atomic="true">
353                                             <set>
354                                                 <parameter name='tmp.l3-network.subnet.dhcp-enabled' value='false' />
355                                                 <parameter name='tmp.l3-network.subnet.dhcp-start' value='' />
356                                                 <parameter name='tmp.l3-network.subnet.dhcp-end' value='' />
357                                             </set>
358                                         </block>
359                                     </outcome>
360                                 </switch>
361                                 <save plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
362         resource="subnet" 
363                 key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id 
364                         AND subnet.subnet-id = $eipam-ip-block.entity-id" >
365                                     <!-- Create l3-network object -->
366                                     <parameter name="network-id" value="`$pfx.eipam-initial-subnet.network-id`" />
367                                     <parameter name="subnet-id" value="`$eipam-ip-block.entity-id`" />
368                                     <parameter name="subnet-name" value="`$tmp.l3-network.subnet.subnet-name`" />
369                                     <parameter name="gateway-address" value="`$tmp.return.generate.gateway-address`" />
370                                     <parameter name="network-start-address" value="`$eipam-ip-block.ip-prefix`" />
371                                     <parameter name="cidr-mask" value="`$eipam-ip-block.prefix-length`" />
372                                     <parameter name="ip-version" value="`$tmp.version`" />
373                                     <parameter name="dhcp-start" value="`$tmp.l3-network.subnet.dhcp-start`" />
374                                     <parameter name="dhcp-end" value="`$tmp.l3-network.subnet.dhcp-end`" />
375                                     <parameter name="dhcp-enabled" value="`$tmp.l3-network.subnet.dhcp-enabled`" />
376                                     <parameter name="orchestration-status" value="PendingCreate" />
377                                     <outcome value='failure'>
378                                         <return status='failure'>
379                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
380                                             <parameter name="error-code" value="500" />
381                                             <parameter name="error-message" value="'Cannot save subnet with l3 network-id=' + $pfx.eipam-initial-subnet.network-id + ' And subnet-id=' + $eipam-ip-block.entity-id  + ' in AnAI'" />
382                                         </return>
383                                     </outcome>
384                                     <outcome value='not-found'></outcome>
385                                 </save>
386                                 <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
387                                     <parameter name="logger" value="message-log"/>
388                                     <parameter name="field1" value="__TIMESTAMP__"/>
389                                     <parameter name="field2" value="Added a subnetin AAI"/>
390                                     <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
391                                     <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
392                                     <parameter name="field5" value="`$pfx.eipam-initial-subnet.network-id`"/>
393                                     <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
394                                     <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
395                                     <parameter name="field8" value="`$eipam-ip-block.status`"/>
396                                     <parameter name="field9" value="`$tmp.key-value`"/>
397                                 </record>
398                                 <execute plugin='org.onap.ccsdk.sli.plugins.contrail.ContrailAdaptor' method='sendContrailRequest' emitsOutcome='true' >
399                                     <parameter name='api-name' value='subnet' />
400                                     <parameter name='api-action' value='add' />
401                                     <parameter name='resp-prefix' value='contrailResp' />
402                                     <parameter name='contrail-virtual-network-id' value='`$pfx.eipam-initial-subnet.network-id`' />
403                                     <parameter name='ip-prefix' value='`$eipam-ip-block.ip-prefix`' />
404                                     <parameter name='ip-prefix-len' value='`$eipam-ip-block.prefix-length`' />
405                                     <parameter name='dns-server-address' value='0.0.0.0' />
406                                     <parameter name='enable-dhcp' value='`$tmp.l3-network.subnet.dhcp-enabled`' />
407                                     <parameter name='default-gateway' value='`$tmp.return.generate.gateway-address`' />
408                                     <parameter name='subnet-name' value='`$tmp.l3-network.subnet.subnet-name`' />
409                                     <parameter name='start' value='`$tmp.l3-network.subnet.dhcp-start`' />
410                                     <parameter name='end' value='`$tmp.l3-network.subnet.dhcp-end`' />
411                                     <outcome value='success'>
412                                         <block></block>
413                                     </outcome>
414                                     <outcome value='failure'>
415                                         <block>
416                                             <set>
417                                                 <parameter name="eipam-ip-block.status" value="ERROR" />
418                                             </set>
419                                             <save 
420         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
421         resource='SQL'
422         key="UPDATE EIPAM_IP_SUBNETS
423              SET status = 'ERROR'
424              WHERE entity_id = $eipam-ip-block.entity-id ; "
425     force='true'
426         pfx='pfx.eipam-subnet-row'>
427                                                 <outcome value='failure'>
428                                                     <return status="failure">
429                                                         <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
430                                                         <parameter name="error-code" value="500"/>
431                                                         <parameter name="error-message" value="An error occured while updating subnet to ERROR in mysql." />
432                                                     </return>
433                                                 </outcome>
434                                                 <outcome value="not-found">
435                                                     <return status="failure">
436                                                         <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
437                                                         <parameter name="error-code" value="500"/>
438                                                         <parameter name="error-message" value="An error occured while updating subnet to ERROR in mysql." />
439                                                     </return>
440                                                 </outcome>
441                                             </save>
442                                             <delete plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
443         resource="subnet" 
444         key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id
445                                 AND subnet.subnet-id = $eipam-ip-block.entity-id"></delete>
446                                             <save plugin="org.onap.ccsdk.sli.adaptors.resource.mdsal.ConfigResource" resource="eipam-ip-block">
447                                                 <parameter name="eipam-ip-block.status" value="ERROR" />
448                                             </save>
449                                             <return status='failure'>
450                                                 <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
451                                                 <parameter name="error-code" value="500" />
452                                                 <parameter name="error-message" value="`'Failed to create subnet in Contrail. '+ $contrailResp.resp-code + ':' +$contrailResp.resp-message `" />
453                                             </return>
454                                         </block>
455                                     </outcome>
456                                 </execute>
457                                 <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
458                                     <parameter name="logger" value="message-log"/>
459                                     <parameter name="field1" value="__TIMESTAMP__"/>
460                                     <parameter name="field2" value="Added a subnet in Contrail"/>
461                                     <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
462                                     <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
463                                     <parameter name="field5" value="`$pfx.eipam-initial-subnet.network-id`"/>
464                                     <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
465                                     <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
466                                     <parameter name="field8" value="`$eipam-ip-block.status`"/>
467                                     <parameter name="field9" value="`$tmp.key-value`"/>
468                                 </record>
469                                 <update plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
470         resource="subnet" 
471                 key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id 
472                         AND subnet.subnet-id = $eipam-ip-block.entity-id" >
473                                     <parameter name="orchestration-status" value="Created" />
474                                     <outcome value='not-found'></outcome>
475                                     <outcome value='failure'>
476                                         <block>
477                                             <record plugin="org.onap.ccsdk.sli.core.sli.recording.Slf4jRecorder">
478                                                 <parameter name="logger" value="message-log"/>
479                                                 <parameter name="field1" value="__TIMESTAMP__"/>
480                                                 <parameter name="field2" value="Update status to Created failed in AAI"/>
481                                                 <parameter name="field3" value="`$eipam-ip-block.request-id`"/>
482                                                 <parameter name="field4" value="`$eipam-ip-block.entity-id`"/>
483                                                 <parameter name="field5" value="`$pfx.eipam-initial-subnet.network-id`"/>
484                                                 <parameter name="field6" value="`$eipam-ip-block.ip-address`"/>
485                                                 <parameter name="field7" value="`$eipam-ip-block.prefix-length`"/>
486                                                 <parameter name="field8" value="`$eipam-ip-block.status`"/>
487                                                 <parameter name="field9" value="`$tmp.key-value`"/>
488                                             </record>
489                                             <save 
490         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
491         resource='SQL'
492         key="UPDATE EIPAM_IP_SUBNETS
493              SET status = 'ERROR'
494              WHERE entity_id = $eipam-ip-block.entity-id ; "
495     force='true'
496         pfx='pfx.eipam-subnet-row'>
497                                                 <outcome value='failure'>
498                                                     <return status="failure">
499                                                         <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
500                                                         <parameter name="error-code" value="500"/>
501                                                         <parameter name="error-message" value="An error occured while updating subnet to ERROR in mysql." />
502                                                     </return>
503                                                 </outcome>
504                                                 <outcome value="not-found">
505                                                     <return status="failure">
506                                                         <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
507                                                         <parameter name="error-code" value="500"/>
508                                                         <parameter name="error-message" value="An error occured while updating subnet to ERROR in mysql." />
509                                                     </return>
510                                                 </outcome>
511                                             </save>
512                                             <delete plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
513         resource="subnet" 
514         key="l3-network.network-id = $pfx.eipam-initial-subnet.network-id
515                                 AND subnet.subnet-id = $eipam-ip-block.entity-id"></delete>
516                                             <execute plugin='org.onap.ccsdk.sli.plugins.contrail.ContrailAdaptor' method='sendContrailRequest' emitsOutcome='true' >
517                                                 <parameter name='api-name' value='subnet' />
518                                                 <parameter name='api-action' value='delete' />
519                                                 <parameter name='resp-prefix' value='contrailResp' />
520                                                 <parameter name='contrail-virtual-network-id' value='`$pfx.eipam-initial-subnet.network-id`' />
521                                                 <parameter name='ip-prefix' value='`$eipam-ip-block.ip-prefix`' />
522                                                 <outcome value='failure'>
523                                                     <return status='failure'>
524                                                         <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
525                                                         <parameter name="error-code" value="500" />
526                                                         <parameter name="error-message" value="`'Failed to delete subnet in Contrail. '+ $contrailResp.resp-code + ':' +$contrailResp.resp-message `" />
527                                                     </return>
528                                                 </outcome>
529                                             </execute>
530                                             <set>
531                                                 <parameter name="eipam-ip-block.status" value="ERROR" />
532                                             </set>
533                                             <return status='failure'>
534                                                 <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
535                                                 <parameter name="error-code" value="500" />
536                                                 <parameter name="error-message" value="'Cannot save subnet status to Created with l3 network-id=' + $pfx.eipam-initial-subnet.network-id + ' And subnet-id=' + $eipam-ip-block.entity-id  + ' in AnAI'" />
537                                             </return>
538                                         </block>
539                                     </outcome>
540                                 </update>
541                                 <save 
542         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
543         resource='SQL'
544         key="UPDATE EIPAM_IP_SUBNETS
545              SET status = 'CREATED'
546              WHERE entity_id = $eipam-ip-block.entity-id ; "
547     force='true'
548         pfx='pfx.eipam-subnet-row'>
549                                     <outcome value='failure'>
550                                         <return status="failure">
551                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
552                                             <parameter name="error-code" value="500"/>
553                                             <parameter name="error-message" value="An error occured while updating subnet to CREATED in mysql." />
554                                         </return>
555                                     </outcome>
556                                     <outcome value="not-found">
557                                         <return status="failure">
558                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
559                                             <parameter name="error-code" value="500"/>
560                                             <parameter name="error-message" value="An error occured while updating subnet to CREATED in mysql." />
561                                         </return>
562                                     </outcome>
563                                 </save>
564                                 <!--subnet and subnet_keys are deleted in the EIPAMPlugin-->
565                                 <execute plugin="com.att.sdnctl.sli.plugin.eipam.EIPAMPlugin" method="activateSubnet">
566                                     <outcome value='failure'>
567                                         <return status="failure">
568                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
569                                             <parameter name="error-code" value="500"/>
570                                             <parameter name="error-message" value="An error occured while activating subnet in EIPAM." />
571                                         </return>
572                                     </outcome>
573                                 </execute>
574                                 <save 
575         plugin='org.onap.ccsdk.sli.adaptors.resource.sql.SqlResource' 
576         resource='SQL'
577         key="UPDATE EIPAM_IP_SUBNETS
578              SET status = 'ACTIVE'
579              WHERE entity_id = $eipam-ip-block.entity-id ; "
580     force='true'
581         pfx='pfx.eipam-subnet-row'>
582                                     <outcome value='failure'>
583                                         <return status="failure">
584                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
585                                             <parameter name="error-code" value="500"/>
586                                             <parameter name="error-message" value="An error occured while updating subnet to active in mysql." />
587                                         </return>
588                                     </outcome>
589                                     <outcome value="not-found">
590                                         <return status="failure">
591                                             <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
592                                             <parameter name="error-code" value="500"/>
593                                             <parameter name="error-message" value="An error occured while updating subnet to active in mysql." />
594                                         </return>
595                                     </outcome>
596                                     <outcome value='success'></outcome>
597                                 </save>
598                                 <update plugin="org.onap.ccsdk.sli.adaptors.aai.AAIService" 
599         resource="subnet" 
600                 key="l3-network.network-id = $aai.l3-network.network-id 
601                         AND subnet.subnet-id = $eipam-ip-block.entity-id" >
602                                     <parameter name="orchestration-status" value="Created" />
603                                     <outcome value='failure'>
604                                         <return status="failure">
605                                             <parameter name="error-code" value="500"/>
606                                             <parameter name="error-message" value="Failure updating orchestration-status in AAI for subnet." />
607                                         </return>
608                                     </outcome>
609                                     <outcome value="not-found">
610                                         <return status="failure">
611                                             <parameter name="error-code" value="500"/>
612                                             <parameter name="error-message" value="Failure updating orchestration-status in AAI for subnet.  Subnet not found." />
613                                         </return>
614                                     </outcome>
615                                 </update>
616                                 <return status="success">
617                                     <parameter name='eipam-ip-block.request-id' value="`$eipam-ip-block.entity-id + '-' + $aai.l3-network.contrail-network-fqdn`" />
618                                 </return>
619                             </block>
620                         </outcome>
621                     </execute>
622                 </outcome>
623             </switch>
624         </block>
625     </method>
626 </service-logic>