Replaced all tabs with spaces in java and pom.xml
[so.git] / bpmn / so-bpmn-tasks / src / main / java / org / onap / so / bpmn / infrastructure / aai / tasks / AAIUpdateTasks.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Modifications Copyright (c) 2019 Samsung
8  * ================================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * ============LICENSE_END=========================================================
21  */
22
23 package org.onap.so.bpmn.infrastructure.aai.tasks;
24
25 import java.util.List;
26 import java.util.Map;
27 import org.onap.so.adapters.nwrest.CreateNetworkResponse;
28 import org.onap.so.adapters.nwrest.UpdateNetworkResponse;
29 import org.onap.so.bpmn.common.BuildingBlockExecution;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection;
32 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
33 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
34 import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network;
35 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
36 import org.onap.so.bpmn.servicedecomposition.bbobjects.Subnet;
37 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
38 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
39 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
40 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
41 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
42 import org.onap.so.client.exception.BBObjectNotFoundException;
43 import org.onap.so.client.exception.ExceptionBuilder;
44 import org.onap.so.client.orchestration.AAICollectionResources;
45 import org.onap.so.client.orchestration.AAIConfigurationResources;
46 import org.onap.so.client.orchestration.AAINetworkResources;
47 import org.onap.so.client.orchestration.AAIServiceInstanceResources;
48 import org.onap.so.client.orchestration.AAIVfModuleResources;
49 import org.onap.so.client.orchestration.AAIVnfResources;
50 import org.onap.so.client.orchestration.AAIVolumeGroupResources;
51 import org.onap.so.db.catalog.beans.OrchestrationStatus;
52 import org.slf4j.Logger;
53 import org.slf4j.LoggerFactory;
54 import org.springframework.beans.factory.annotation.Autowired;
55 import org.springframework.stereotype.Component;
56
57 @Component
58 public class AAIUpdateTasks {
59     private static final Logger logger = LoggerFactory.getLogger(AAIUpdateTasks.class);
60     private static final String ALACARTE = "aLaCarte";
61     private static final String MULTI_STAGE_DESIGN_OFF = "false";
62     private static final String MULTI_STAGE_DESIGN_ON = "true";
63     @Autowired
64     private AAIServiceInstanceResources aaiServiceInstanceResources;
65     @Autowired
66     private AAIVnfResources aaiVnfResources;
67     @Autowired
68     private AAIVfModuleResources aaiVfModuleResources;
69     @Autowired
70     private ExceptionBuilder exceptionUtil;
71     @Autowired
72     private ExtractPojosForBB extractPojosForBB;
73     @Autowired
74     private AAIVolumeGroupResources aaiVolumeGroupResources;
75     @Autowired
76     private AAINetworkResources aaiNetworkResources;
77     @Autowired
78     private AAICollectionResources aaiCollectionResources;
79     @Autowired
80     private AAIConfigurationResources aaiConfigurationResources;
81
82     public void updateOrchestrationStatusAssignedService(BuildingBlockExecution execution) {
83         try {
84             ServiceInstance serviceInstance =
85                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
86             aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
87                     OrchestrationStatus.ASSIGNED);
88             execution.setVariable("aaiServiceInstanceRollback", true);
89         } catch (Exception ex) {
90             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
91         }
92     }
93
94     public void updateOrchestrationStatusActiveService(BuildingBlockExecution execution) {
95         try {
96             ServiceInstance serviceInstance =
97                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
98             aaiServiceInstanceResources.updateOrchestrationStatusServiceInstance(serviceInstance,
99                     OrchestrationStatus.ACTIVE);
100         } catch (Exception ex) {
101             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
102         }
103     }
104
105     public void updateOrchestrationStatusAssignedVnf(BuildingBlockExecution execution) {
106         try {
107             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
108             aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ASSIGNED);
109         } catch (Exception ex) {
110             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
111         }
112     }
113
114     public void updateOrchestrationStatusActiveVnf(BuildingBlockExecution execution) {
115         try {
116             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
117             aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.ACTIVE);
118         } catch (Exception ex) {
119             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
120         }
121     }
122
123     public void updateOrchestrationStatusAssignedVolumeGroup(BuildingBlockExecution execution) {
124         try {
125             GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
126
127             VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
128             CloudRegion cloudRegion = gBBInput.getCloudRegion();
129             volumeGroup.setHeatStackId("");
130             aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
131                     OrchestrationStatus.ASSIGNED);
132         } catch (Exception ex) {
133             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
134         }
135     }
136
137     public void updateOrchestrationStatusActiveVolumeGroup(BuildingBlockExecution execution) {
138         try {
139             GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
140
141             VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
142             CloudRegion cloudRegion = gBBInput.getCloudRegion();
143
144             aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
145                     OrchestrationStatus.ACTIVE);
146         } catch (Exception ex) {
147             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
148         }
149     }
150
151     public void updateOrchestrationStatusCreatedVolumeGroup(BuildingBlockExecution execution) {
152         try {
153             GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
154
155             VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
156             CloudRegion cloudRegion = gBBInput.getCloudRegion();
157
158             aaiVolumeGroupResources.updateOrchestrationStatusVolumeGroup(volumeGroup, cloudRegion,
159                     OrchestrationStatus.CREATED);
160         } catch (Exception ex) {
161             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
162         }
163     }
164
165     public void updateHeatStackIdVolumeGroup(BuildingBlockExecution execution) {
166         try {
167             GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
168             String heatStackId = execution.getVariable("heatStackId");
169             if (heatStackId == null) {
170                 heatStackId = "";
171             }
172             VolumeGroup volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
173             CloudRegion cloudRegion = gBBInput.getCloudRegion();
174             volumeGroup.setHeatStackId(heatStackId);
175
176             aaiVolumeGroupResources.updateHeatStackIdVolumeGroup(volumeGroup, cloudRegion);
177         } catch (Exception ex) {
178             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
179         }
180     }
181
182     public void updateOrchestrationStatusAssignedVfModule(BuildingBlockExecution execution) {
183         try {
184             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
185             vfModule.setHeatStackId("");
186             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
187             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
188         } catch (Exception ex) {
189             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
190         }
191     }
192
193     public void updateOrchestrationStatusPendingActivationVfModule(BuildingBlockExecution execution) {
194         try {
195             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
196             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
197             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf,
198                     OrchestrationStatus.PENDING_ACTIVATION);
199         } catch (Exception ex) {
200             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
201         }
202     }
203
204     public void updateOrchestrationStatusAssignedOrPendingActivationVfModule(BuildingBlockExecution execution) {
205         try {
206             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
207             vfModule.setHeatStackId("");
208             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
209             String multiStageDesign = MULTI_STAGE_DESIGN_OFF;
210             if (vnf.getModelInfoGenericVnf() != null) {
211                 multiStageDesign = vnf.getModelInfoGenericVnf().getMultiStageDesign();
212             }
213             boolean aLaCarte = (boolean) execution.getVariable(ALACARTE);
214             if (aLaCarte && multiStageDesign != null && multiStageDesign.equalsIgnoreCase(MULTI_STAGE_DESIGN_ON)) {
215                 aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf,
216                         OrchestrationStatus.PENDING_ACTIVATION);
217             } else {
218                 aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
219             }
220         } catch (Exception ex) {
221             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
222         }
223     }
224
225     public void updateOrchestrationStatusCreatedVfModule(BuildingBlockExecution execution) {
226         try {
227             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
228             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
229             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED);
230         } catch (Exception ex) {
231             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
232         }
233     }
234
235     public void updateOrchestrationStatusDeactivateVfModule(BuildingBlockExecution execution) {
236         execution.setVariable("aaiDeactivateVfModuleRollback", false);
237         try {
238             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
239             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
240             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.CREATED);
241             execution.setVariable("aaiDeactivateVfModuleRollback", true);
242         } catch (Exception ex) {
243             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
244         }
245     }
246
247     /**
248      * BPMN access method to update status of L3Network to Assigned in AAI
249      * 
250      * @param execution
251      * @throws BBObjectNotFoundException
252      */
253     public void updateOrchestrationStatusAssignedNetwork(BuildingBlockExecution execution) {
254         updateNetwork(execution, OrchestrationStatus.ASSIGNED);
255     }
256
257     /**
258      * BPMN access method to update status of L3Network to Active in AAI
259      * 
260      * @param execution
261      * @throws BBObjectNotFoundException
262      */
263     public void updateOrchestrationStatusActiveNetwork(BuildingBlockExecution execution) {
264         updateNetwork(execution, OrchestrationStatus.ACTIVE);
265     }
266
267     /**
268      * BPMN access method to update status of L3Network to Created in AAI
269      * 
270      * @param execution
271      * @throws BBObjectNotFoundException
272      */
273     public void updateOrchestrationStatusCreatedNetwork(BuildingBlockExecution execution) {
274         updateNetwork(execution, OrchestrationStatus.CREATED);
275     }
276
277     protected void updateNetwork(BuildingBlockExecution execution, OrchestrationStatus status) {
278         try {
279             L3Network l3Network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
280             updateNetworkAAI(l3Network, status);
281         } catch (Exception ex) {
282             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
283         }
284     }
285
286     protected void updateNetworkAAI(L3Network l3Network, OrchestrationStatus status) {
287         L3Network copiedl3Network = l3Network.shallowCopyId();
288
289         copiedl3Network.setOrchestrationStatus(status);
290         l3Network.setOrchestrationStatus(status);
291         aaiNetworkResources.updateNetwork(copiedl3Network);
292
293         List<Subnet> subnets = l3Network.getSubnets();
294         if (subnets != null) {
295             for (Subnet subnet : subnets) {
296                 Subnet copiedSubnet = subnet.shallowCopyId();
297                 copiedSubnet.setOrchestrationStatus(status);
298                 aaiNetworkResources.updateSubnet(copiedl3Network, copiedSubnet);
299             }
300         }
301     }
302
303     /**
304      * BPMN access method to update status of L3Network Collection to Active in AAI
305      * 
306      * @param execution
307      * @throws BBObjectNotFoundException
308      */
309     public void updateOrchestrationStatusActiveNetworkCollection(BuildingBlockExecution execution) {
310         execution.setVariable("aaiNetworkCollectionActivateRollback", false);
311         try {
312             ServiceInstance serviceInstance =
313                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
314             Collection networkCollection = serviceInstance.getCollection();
315             Collection copiedNetworkCollection = networkCollection.shallowCopyId();
316
317             networkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
318             copiedNetworkCollection.setOrchestrationStatus(OrchestrationStatus.ACTIVE);
319             aaiCollectionResources.updateCollection(copiedNetworkCollection);
320             execution.setVariable("aaiNetworkCollectionActivateRollback", true);
321         } catch (Exception ex) {
322             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
323         }
324     }
325
326     public void updateOrchestrationStatusActivateVfModule(BuildingBlockExecution execution) {
327         execution.setVariable("aaiActivateVfModuleRollback", false);
328         try {
329             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
330             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
331             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ACTIVE);
332             execution.setVariable("aaiActivateVfModuleRollback", true);
333         } catch (Exception ex) {
334             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
335         }
336     }
337
338     public void updateHeatStackIdVfModule(BuildingBlockExecution execution) {
339         try {
340             String heatStackId = execution.getVariable("heatStackId");
341             if (heatStackId == null) {
342                 heatStackId = "";
343             }
344             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
345             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
346             vfModule.setHeatStackId(heatStackId);
347             aaiVfModuleResources.updateHeatStackIdVfModule(vfModule, vnf);
348         } catch (Exception ex) {
349             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
350         }
351     }
352
353     /**
354      * BPMN access method to update L3Network after it was created in cloud
355      * 
356      * @param execution
357      * @throws Exception
358      */
359     public void updateNetworkCreated(BuildingBlockExecution execution) throws Exception {
360         execution.setVariable("aaiNetworkActivateRollback", false);
361         L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
362         L3Network copiedl3network = l3network.shallowCopyId();
363         CreateNetworkResponse response = execution.getVariable("createNetworkResponse");
364         try {
365             if (response.getNetworkFqdn() != null) {
366                 l3network.setContrailNetworkFqdn(response.getNetworkFqdn());
367             }
368             l3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
369             l3network.setHeatStackId(response.getNetworkStackId());
370             l3network.setNeutronNetworkId(response.getNeutronNetworkId());
371
372             copiedl3network.setContrailNetworkFqdn(response.getNetworkFqdn());
373             copiedl3network.setOrchestrationStatus(OrchestrationStatus.CREATED);
374             copiedl3network.setHeatStackId(response.getNetworkStackId());
375             copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
376
377             aaiNetworkResources.updateNetwork(copiedl3network);
378
379             Map<String, String> subnetMap = response.getSubnetMap();
380             List<Subnet> subnets = l3network.getSubnets();
381             if (subnets != null && subnetMap != null) {
382                 for (Subnet subnet : subnets) {
383                     Subnet copiedSubnet = subnet.shallowCopyId();
384                     copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
385                     copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
386                     aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
387                 }
388             }
389
390             execution.setVariable("aaiNetworkActivateRollback", true);
391         } catch (Exception ex) {
392             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
393         }
394     }
395
396     /**
397      * BPMN access method to update L3Network after it was updated in cloud
398      * 
399      * @param execution
400      * @throws Exception
401      */
402     public void updateNetworkUpdated(BuildingBlockExecution execution) throws Exception {
403         L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
404         L3Network copiedl3network = l3network.shallowCopyId();
405         UpdateNetworkResponse response = execution.getVariable("updateNetworkResponse");
406         try {
407             copiedl3network.setNeutronNetworkId(response.getNeutronNetworkId());
408             aaiNetworkResources.updateNetwork(copiedl3network);
409
410             Map<String, String> subnetMap = response.getSubnetMap();
411             List<Subnet> subnets = l3network.getSubnets();
412             if (subnets != null && subnetMap != null) {
413                 for (Subnet subnet : subnets) {
414                     Subnet copiedSubnet = subnet.shallowCopyId();
415                     copiedSubnet.setNeutronSubnetId(subnetMap.get(copiedSubnet.getSubnetId()));
416                     copiedSubnet.setOrchestrationStatus(OrchestrationStatus.CREATED);
417                     aaiNetworkResources.updateSubnet(copiedl3network, copiedSubnet);
418                 }
419             }
420         } catch (Exception ex) {
421             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
422         }
423     }
424
425     public void updateObjectNetwork(BuildingBlockExecution execution) {
426         try {
427             L3Network l3network = extractPojosForBB.extractByKey(execution, ResourceKey.NETWORK_ID);
428             aaiNetworkResources.updateNetwork(l3network);
429         } catch (Exception ex) {
430             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
431         }
432     }
433
434     /**
435      * BPMN access method to update ServiceInstance
436      * 
437      * @param execution
438      */
439     public void updateServiceInstance(BuildingBlockExecution execution) {
440         try {
441             ServiceInstance serviceInstance =
442                     extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
443             aaiServiceInstanceResources.updateServiceInstance(serviceInstance);
444         } catch (Exception ex) {
445             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
446         }
447     }
448
449     public void updateObjectVnf(BuildingBlockExecution execution) {
450         try {
451             GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
452             aaiVnfResources.updateObjectVnf(genericVnf);
453         } catch (Exception ex) {
454             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
455         }
456     }
457
458     public void updateOrchestrationStatusDeleteVfModule(BuildingBlockExecution execution) {
459         execution.setVariable("aaiDeleteVfModuleRollback", false);
460         try {
461             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
462             vfModule.setHeatStackId("");
463             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
464
465             VfModule copiedVfModule = vfModule.shallowCopyId();
466             copiedVfModule.setHeatStackId("");
467             aaiVfModuleResources.updateOrchestrationStatusVfModule(vfModule, vnf, OrchestrationStatus.ASSIGNED);
468             execution.setVariable("aaiDeleteVfModuleRollback", true);
469         } catch (Exception ex) {
470             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
471         }
472     }
473
474     public void updateModelVfModule(BuildingBlockExecution execution) {
475         try {
476             VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
477             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
478             aaiVfModuleResources.changeAssignVfModule(vfModule, vnf);
479         } catch (Exception ex) {
480             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
481         }
482     }
483
484     public void updateOrchestrationStatusActivateFabricConfiguration(BuildingBlockExecution execution) {
485         try {
486             Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
487             aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration, OrchestrationStatus.ACTIVE);
488         } catch (Exception ex) {
489             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
490         }
491     }
492
493     public void updateOrchestrationStatusDeactivateFabricConfiguration(BuildingBlockExecution execution) {
494         try {
495             Configuration configuration = extractPojosForBB.extractByKey(execution, ResourceKey.CONFIGURATION_ID);
496             aaiConfigurationResources.updateOrchestrationStatusConfiguration(configuration,
497                     OrchestrationStatus.ASSIGNED);
498         } catch (Exception ex) {
499             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
500         }
501     }
502
503     public void updateIpv4OamAddressVnf(BuildingBlockExecution execution) {
504         try {
505             String ipv4OamAddress = execution.getVariable("oamManagementV4Address");
506             if (ipv4OamAddress != null) {
507                 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
508                 GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
509
510                 genericVnf.setIpv4OamAddress(ipv4OamAddress);
511                 copiedGenericVnf.setIpv4OamAddress(ipv4OamAddress);
512
513                 aaiVnfResources.updateObjectVnf(copiedGenericVnf);
514             }
515         } catch (Exception ex) {
516             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
517         }
518     }
519
520     public void updateManagementV6AddressVnf(BuildingBlockExecution execution) {
521         try {
522             String managementV6Address = execution.getVariable("oamManagementV6Address");
523             if (managementV6Address != null) {
524                 GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
525                 GenericVnf copiedGenericVnf = genericVnf.shallowCopyId();
526
527                 genericVnf.setManagementV6Address(managementV6Address);
528                 copiedGenericVnf.setManagementV6Address(managementV6Address);
529
530                 aaiVnfResources.updateObjectVnf(copiedGenericVnf);
531             }
532         } catch (Exception ex) {
533             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
534         }
535     }
536
537     public void updateContrailServiceInstanceFqdnVfModule(BuildingBlockExecution execution) {
538         try {
539             String contrailServiceInstanceFqdn = execution.getVariable("contrailServiceInstanceFqdn");
540             if (contrailServiceInstanceFqdn != null) {
541                 VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
542                 GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
543                 vfModule.setContrailServiceInstanceFqdn(contrailServiceInstanceFqdn);
544                 aaiVfModuleResources.updateContrailServiceInstanceFqdnVfModule(vfModule, vnf);
545             }
546         } catch (Exception ex) {
547             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
548         }
549     }
550
551     public void updateOrchestrationStatusConfigAssignedVnf(BuildingBlockExecution execution) {
552         try {
553             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
554             aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGASSIGNED);
555         } catch (Exception ex) {
556             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
557         }
558     }
559
560     public void updateOrchestrationStausConfigDeployConfigureVnf(BuildingBlockExecution execution) {
561         try {
562             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
563             aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURE);
564
565         } catch (Exception ex) {
566             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
567         }
568
569     }
570
571     public void updateOrchestrationStausConfigDeployConfiguredVnf(BuildingBlockExecution execution) {
572         try {
573             GenericVnf vnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
574             aaiVnfResources.updateOrchestrationStatusVnf(vnf, OrchestrationStatus.CONFIGURED);
575
576         } catch (Exception ex) {
577             exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
578         }
579
580     }
581 }