a1fcbff0dbcd6f8bd8800c6a9718034f5372a208
[so.git] /
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.client.adapter.vnf.mapper;
24
25 import static java.util.Arrays.asList;
26 import java.io.IOException;
27 import java.io.UnsupportedEncodingException;
28 import java.util.ArrayList;
29 import java.util.Arrays;
30 import java.util.Collection;
31 import java.util.Collections;
32 import java.util.HashMap;
33 import java.util.HashSet;
34 import java.util.List;
35 import java.util.Map;
36 import java.util.Optional;
37 import javax.annotation.PostConstruct;
38 import org.apache.commons.lang3.StringUtils;
39 import org.onap.sdnc.northbound.client.model.GenericResourceApiParam;
40 import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam;
41 import org.onap.sdnc.northbound.client.model.GenericResourceApiSubInterfaceNetworkData;
42 import org.onap.sdnc.northbound.client.model.GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData;
43 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleTopology;
44 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleassignmentsVfModuleAssignments;
45 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms;
46 import org.onap.sdnc.northbound.client.model.GenericResourceApiVfmoduletopologyVfModuleTopology;
47 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmNetworkData;
48 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmTopologyData;
49 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataFloatingIps;
50 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataInterfaceRoutePrefixes;
51 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkInformationItems;
52 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem;
53 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps;
54 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataSriovParameters;
55 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters;
56 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmNames;
57 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmNetworks;
58 import org.onap.sdnc.northbound.client.model.GenericResourceApiVmtopologydataVmnamesVnfcNames;
59 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfNetworkData;
60 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfTopology;
61 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcNetworkData;
62 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcNetworkData;
63 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts;
64 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort;
65 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfResourceAssignments;
66 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones;
67 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks;
68 import org.onap.sdnc.northbound.client.model.GenericResourceApiVnftopologyVnfTopology;
69 import org.onap.so.adapters.vnfrest.CreateVfModuleRequest;
70 import org.onap.so.adapters.vnfrest.DeleteVfModuleRequest;
71 import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
72 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
73 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
74 import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
75 import org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup;
76 import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext;
77 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
78 import org.onap.so.entity.MsoRequest;
79 import org.onap.so.jsonpath.JsonPathUtil;
80 import org.onap.so.openstack.utils.MsoMulticloudUtils;
81 import org.springframework.beans.factory.annotation.Autowired;
82 import org.springframework.stereotype.Component;
83 import com.fasterxml.jackson.core.JsonParseException;
84 import com.fasterxml.jackson.core.JsonProcessingException;
85 import com.fasterxml.jackson.databind.DeserializationFeature;
86 import com.fasterxml.jackson.databind.JsonMappingException;
87 import com.fasterxml.jackson.databind.ObjectMapper;
88 import com.google.common.base.Joiner;
89
90
91 @Component
92 public class VnfAdapterVfModuleObjectMapper {
93     @Autowired
94     protected VnfAdapterObjectMapperUtils vnfAdapterObjectMapperUtils;
95     private static List<String> sdncResponseParamsToSkip =
96             asList("vnf_id", "vf_module_id", "vnf_name", "vf_module_name");
97
98     private ObjectMapper mapper = new ObjectMapper();
99     private static final JsonPathUtil jsonPath = JsonPathUtil.getInstance();
100     private static final String SUB_INT = "subint";
101     private static final String SUBNET_ID = "_subnet_id";
102     private static final String V6_SUBNET_ID = "_v6_subnet_id";
103     private static final String PORT = "port";
104     private static final String SUB_INT_COUNT = "_subintcount";
105     private static final String VLAN_IDS = "_vlan_ids";
106     private static final String NET_NAMES = "_net_names";
107     private static final String NET_IDS = "_net_ids";
108     private static final String IP = "_ip";
109     private static final String V6_IP = "_v6_ip";
110     private static final String FLOATING_IP = "_floating_ip";
111     private static final String FLOATING_V6_IP = "_floating_v6_ip";
112     private static final String UNDERSCORE = "_";
113
114     @PostConstruct
115     public void init() {
116         mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);
117     }
118
119     public CreateVfModuleRequest createVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
120             OrchestrationContext orchestrationContext, ServiceInstance serviceInstance, GenericVnf genericVnf,
121             VfModule vfModule, VolumeGroup volumeGroup, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse)
122             throws IOException {
123         CreateVfModuleRequest createVfModuleRequest = new CreateVfModuleRequest();
124
125         createVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
126         createVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
127         createVfModuleRequest.setTenantId(cloudRegion.getTenantId());
128         createVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
129         createVfModuleRequest.setVfModuleName(vfModule.getVfModuleName());
130         createVfModuleRequest.setVnfId(genericVnf.getVnfId());
131         createVfModuleRequest.setVnfType(genericVnf.getVnfType());
132         createVfModuleRequest.setVnfVersion(serviceInstance.getModelInfoServiceInstance().getModelVersion());
133         createVfModuleRequest.setVfModuleType(vfModule.getModelInfoVfModule().getModelName());
134         createVfModuleRequest.setModelCustomizationUuid(vfModule.getModelInfoVfModule().getModelCustomizationUUID());
135         if (volumeGroup != null) {
136             createVfModuleRequest.setVolumeGroupId(volumeGroup.getVolumeGroupId());
137             createVfModuleRequest.setVolumeGroupStackId(volumeGroup.getHeatStackId());
138         }
139         VfModule baseVfModule = getBaseVfModule(genericVnf);
140         if (baseVfModule != null) {
141             createVfModuleRequest.setBaseVfModuleId(baseVfModule.getVfModuleId());
142             createVfModuleRequest.setBaseVfModuleStackId(baseVfModule.getHeatStackId());
143         }
144         createVfModuleRequest.setVfModuleParams(buildVfModuleParamsMap(requestContext, serviceInstance, genericVnf,
145                 vfModule, sdncVnfQueryResponse, sdncVfModuleQueryResponse));
146
147         createVfModuleRequest.setSkipAAI(true);
148         createVfModuleRequest.setBackout(Boolean.TRUE.equals(orchestrationContext.getIsRollbackEnabled()));
149         createVfModuleRequest.setFailIfExists(true);
150
151         MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
152         createVfModuleRequest.setMsoRequest(msoRequest);
153
154         String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
155         createVfModuleRequest.setMessageId(messageId);
156         createVfModuleRequest
157                 .setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
158
159         return createVfModuleRequest;
160     }
161
162     private MsoRequest buildMsoRequest(RequestContext requestContext, ServiceInstance serviceInstance) {
163         MsoRequest msoRequest = new MsoRequest();
164         msoRequest.setRequestId(requestContext.getMsoRequestId());
165         msoRequest.setServiceInstanceId(serviceInstance.getServiceInstanceId());
166         return msoRequest;
167     }
168
169     private Map<String, Object> buildVfModuleParamsMap(RequestContext requestContext, ServiceInstance serviceInstance,
170             GenericVnf genericVnf, VfModule vfModule, String sdncVnfQueryResponse, String sdncVfModuleQueryResponse)
171             throws IOException {
172
173
174         GenericResourceApiVnfTopology vnfTop =
175                 mapper.readValue(sdncVnfQueryResponse, GenericResourceApiVnfTopology.class);
176         GenericResourceApiVfModuleTopology vfModuleTop =
177                 mapper.readValue(sdncVfModuleQueryResponse, GenericResourceApiVfModuleTopology.class);
178         GenericResourceApiVnftopologyVnfTopology vnfTopology = vnfTop.getVnfTopology();
179         GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = vfModuleTop.getVfModuleTopology();
180         Map<String, Object> paramsMap = new HashMap<>();
181
182         if (vfModuleTopology.getSdncGeneratedCloudResources()) {
183             buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, true);
184             buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, null, true);
185         } else {
186             Map<String, String> networkRoleMap = buildNetworkRoleMap(vfModuleTopology);
187             buildParamsMapFromVfModuleSdncResponse(paramsMap, vfModuleTopology, false);
188             buildParamsMapFromVnfSdncResponse(paramsMap, vnfTopology, networkRoleMap, false);
189         }
190
191         // build the sdnc_directives from paramsMap
192         buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.SDNC_DIRECTIVES, paramsMap);
193         buildDirectivesParamFromMap(paramsMap, MsoMulticloudUtils.USER_DIRECTIVES, requestContext.getUserParams());
194
195         buildMandatoryParamsMap(paramsMap, serviceInstance, genericVnf, vfModule);
196
197         // Parameters received from the request should overwrite any parameters received from SDNC
198         paramsMap.putAll(requestContext.getUserParams());
199
200         if (vfModule.getCloudParams() != null) {
201             paramsMap.putAll(vfModule.getCloudParams());
202         }
203         return paramsMap;
204     }
205
206     private void buildDirectivesParamFromMap(Map<String, Object> paramsMap, String directive,
207             Map<String, Object> srcMap) {
208         StringBuilder directives = new StringBuilder();
209         int no_directives_size = 0;
210         if (directive.equals(MsoMulticloudUtils.USER_DIRECTIVES)
211                 && srcMap.containsKey(MsoMulticloudUtils.OOF_DIRECTIVES)) {
212             no_directives_size = 1;
213         }
214         if (srcMap.size() > no_directives_size) {
215             directives.append("{ \"attributes\": [ ");
216             int i = 0;
217             for (String attributeName : srcMap.keySet()) {
218                 if (!(MsoMulticloudUtils.USER_DIRECTIVES.equals(directive)
219                         && attributeName.equals(MsoMulticloudUtils.OOF_DIRECTIVES))) {
220                     directives.append(new AttributeNameValue(attributeName, srcMap.get(attributeName).toString()));
221                     if (i < (srcMap.size() - 1 + no_directives_size))
222                         directives.append(", ");
223                     i++;
224                 }
225             }
226             directives.append("] }");
227         } else {
228             directives.append("{}");
229         }
230         paramsMap.put(directive, directives.toString());
231     }
232
233     private void buildMandatoryParamsMap(Map<String, Object> paramsMap, ServiceInstance serviceInstance,
234             GenericVnf genericVnf, VfModule vfModule) {
235         paramsMap.put("vnf_id", genericVnf.getVnfId());
236         paramsMap.put("vnf_name", genericVnf.getVnfName());
237         paramsMap.put("vf_module_id", vfModule.getVfModuleId());
238         paramsMap.put("vf_module_name", vfModule.getVfModuleName());
239         paramsMap.put("environment_context", serviceInstance.getModelInfoServiceInstance().getEnvironmentContext());
240         paramsMap.putIfAbsent("environment_context", "");
241         paramsMap.put("workload_context", serviceInstance.getModelInfoServiceInstance().getWorkloadContext());
242         paramsMap.putIfAbsent("workload_context", "");
243         Integer vfModuleIndex = vfModule.getModuleIndex();
244         if (vfModuleIndex != null) {
245             paramsMap.put("vf_module_index", vfModuleIndex.toString());
246         }
247     }
248
249     private void buildParamsMapFromVnfSdncResponse(Map<String, Object> paramsMap,
250             GenericResourceApiVnftopologyVnfTopology vnfTopology, Map<String, String> networkRoleMap,
251             boolean skipVnfResourceAssignments) throws IOException {
252         // Get VNF parameters from SDNC response
253         GenericResourceApiParam vnfParametersData = vnfTopology.getVnfParametersData();
254         buildParamsMapFromSdncParams(paramsMap, vnfParametersData);
255
256         if (!skipVnfResourceAssignments) {
257             GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments =
258                     vnfTopology.getVnfResourceAssignments();
259             if (vnfResourceAssignments != null) {
260                 // Availability Zones
261                 buildAvailabilityZones(paramsMap, vnfResourceAssignments);
262                 // VNF Networks
263                 buildVnfNetworks(paramsMap, vnfResourceAssignments, networkRoleMap);
264             }
265         }
266     }
267
268     private void buildAvailabilityZones(Map<String, Object> paramsMap,
269             GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments) {
270         GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsAvailabilityZones availabilityZones =
271                 vnfResourceAssignments.getAvailabilityZones();
272         if (availabilityZones != null) {
273             List<String> availabilityZonesList = availabilityZones.getAvailabilityZone();
274             if (availabilityZonesList != null) {
275                 for (int i = 0; i < availabilityZonesList.size(); i++) {
276                     paramsMap.put("availability_zone_" + i, availabilityZonesList.get(i));
277                 }
278             }
279         }
280     }
281
282     private void buildVnfNetworks(Map<String, Object> paramsMap,
283             GenericResourceApiVnfresourceassignmentsVnfResourceAssignments vnfResourceAssignments,
284             Map<String, String> networkRoleMap) {
285         GenericResourceApiVnfresourceassignmentsVnfresourceassignmentsVnfNetworks vnfNetworks =
286                 vnfResourceAssignments.getVnfNetworks();
287         if (vnfNetworks != null) {
288             List<GenericResourceApiVnfNetworkData> vnfNetworksList = vnfNetworks.getVnfNetwork();
289             if (vnfNetworksList != null) {
290                 for (int i = 0; i < vnfNetworksList.size(); i++) {
291                     GenericResourceApiVnfNetworkData vnfNetwork = vnfNetworksList.get(i);
292                     String networkRole = vnfNetwork.getNetworkRole();
293                     String vnfNetworkKey = networkRoleMap.get(networkRole);
294                     if (vnfNetworkKey == null || vnfNetworkKey.isEmpty()) {
295                         vnfNetworkKey = networkRole;
296                     }
297
298                     String vnfNetworkNeutronIdValue = vnfNetwork.getNeutronId();
299                     paramsMap.put(vnfNetworkKey + "_net_id", vnfNetworkNeutronIdValue);
300                     String vnfNetworkNetNameValue = vnfNetwork.getNetworkName();
301                     paramsMap.put(vnfNetworkKey + "_net_name", vnfNetworkNetNameValue);
302                     String vnfNetworkNetFqdnValue = vnfNetwork.getContrailNetworkFqdn();
303                     paramsMap.put(vnfNetworkKey + "_net_fqdn", vnfNetworkNetFqdnValue);
304
305                     buildVnfNetworkSubnets(paramsMap, vnfNetwork, vnfNetworkKey);
306
307                 }
308             }
309         }
310     }
311
312     private void buildVnfNetworkSubnets(Map<String, Object> paramsMap, GenericResourceApiVnfNetworkData vnfNetwork,
313             String vnfNetworkKey) {
314         String vnfNetworkString = convertToString(vnfNetwork);
315         Optional<String> ipv4Ips = jsonPath.locateResult(vnfNetworkString,
316                 "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv4' && @.dhcp-enabled == 'Y')].subnet-id");
317         if (ipv4Ips.isPresent())
318             addPairToMap(paramsMap, vnfNetworkKey, SUBNET_ID, ipv4Ips.get());
319
320         Optional<String> ipv6Ips = jsonPath.locateResult(vnfNetworkString,
321                 "$.subnets-data.subnet-data[*].[?(@.ip-version == 'ipv6' && @.dhcp-enabled == 'Y')].subnet-id");
322         if (ipv6Ips.isPresent())
323             addPairToMap(paramsMap, vnfNetworkKey, V6_SUBNET_ID, ipv6Ips.get());
324     }
325
326     private void buildParamsMapFromVfModuleSdncResponse(Map<String, Object> paramsMap,
327             GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology, boolean skipVfModuleAssignments)
328             throws IOException {
329         // Get VF Module parameters from SDNC response
330         GenericResourceApiParam vfModuleParametersData = vfModuleTopology.getVfModuleParameters();
331         buildParamsMapFromSdncParams(paramsMap, vfModuleParametersData);
332
333         if (!skipVfModuleAssignments) {
334             GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments =
335                     vfModuleTopology.getVfModuleAssignments();
336             if (vfModuleAssignments != null) {
337                 // VNF-VMS
338                 GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
339                 if (vms != null) {
340                     List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
341                     if (vmsList != null) {
342                         for (GenericResourceApiVmTopologyData vm : vmsList) {
343                             String key = vm.getVmType();
344                             buildVfModuleVmNames(paramsMap, vm, key);
345                             GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
346                             if (vmNetworks != null) {
347                                 List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
348                                 if (vmNetworksList != null) {
349                                     for (int n = 0; n < vmNetworksList.size(); n++) {
350                                         GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
351                                         network.getNetworkRoleTag();
352                                         String networkKey = network.getNetworkRole();
353                                         // Floating IPs
354                                         buildVfModuleFloatingIps(paramsMap, network, key, networkKey);
355                                         // Interface Route Prefixes
356                                         buildVfModuleInterfaceRoutePrefixes(paramsMap, network, key, networkKey);
357                                         // SRIOV Parameters
358                                         buildVfModuleSriovParameters(paramsMap, network, networkKey);
359                                         // IPV4 and IPV6 Addresses
360                                         buildVfModuleNetworkInformation(paramsMap, network, key, networkKey);
361
362                                         buildVlanInformation(paramsMap, network, key, networkKey);
363
364                                     }
365                                 }
366                             }
367
368                             buildParamsMapFromVfModuleForHeatTemplate(paramsMap, vm);
369                         }
370                     }
371                 }
372             }
373         }
374     }
375
376     protected void buildVlanInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
377             String key, String networkKey) {
378
379         String networkString = convertToString(network);
380         String vlanFilterKey = key + UNDERSCORE + networkKey + UNDERSCORE + "vlan_filter";
381         String privateVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "private_vlans";
382         String publicVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "public_vlans";
383         String guestVlansKey = key + UNDERSCORE + networkKey + UNDERSCORE + "guest_vlans";
384
385         if (network.getSegmentationId() != null) {
386             paramsMap.put(vlanFilterKey, network.getSegmentationId());
387         }
388
389         List<String> privateVlans = jsonPath.locateResultList(networkString,
390                 "$.related-networks.related-network[?(@.vlan-tags.is-private == true)].vlan-tags.upper-tag-id");
391         List<String> publicVlans = jsonPath.locateResultList(networkString,
392                 "$.related-networks.related-network[?(@.vlan-tags.is-private == false)].vlan-tags.upper-tag-id");
393         List<String> concat = new ArrayList<>(privateVlans);
394         concat.addAll(publicVlans);
395         Collection<String> guestVlans = new HashSet<>(concat);
396
397         if (!privateVlans.isEmpty()) {
398             paramsMap.put(privateVlansKey, Joiner.on(",").join(privateVlans));
399         }
400         if (!publicVlans.isEmpty()) {
401             paramsMap.put(publicVlansKey, Joiner.on(",").join(publicVlans));
402         }
403         if (!guestVlans.isEmpty()) {
404             paramsMap.put(guestVlansKey, Joiner.on(",").join(guestVlans));
405         }
406     }
407
408     private void buildVfModuleVmNames(Map<String, Object> paramsMap, GenericResourceApiVmTopologyData vm, String key) {
409         String values = "";
410         GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
411         if (vmNames != null) {
412             List<String> valueList = vmNames.getVmName();
413             if (valueList != null) {
414                 for (int i = 0; i < valueList.size(); i++) {
415                     String value = valueList.get(i);
416                     if (i != valueList.size() - 1) {
417                         values += value + ",";
418                     } else {
419                         values += value;
420                     }
421                     paramsMap.put(key + "_name_" + i, value);
422                 }
423                 paramsMap.put(key + "_names", values);
424             }
425         }
426     }
427
428     private void buildVfModuleFloatingIps(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
429             String key, String networkKey) {
430         GenericResourceApiVmnetworkdataFloatingIps floatingIps = network.getFloatingIps();
431         if (floatingIps != null) {
432             List<String> floatingIpV4List = floatingIps.getFloatingIpV4();
433             if (floatingIpV4List != null) {
434                 // add only one ipv4 floating ip for now
435                 String floatingIPKey = key + UNDERSCORE + networkKey + FLOATING_IP;
436                 String floatingIPKeyValue = floatingIpV4List.get(0);
437                 if (floatingIPKeyValue != null && !floatingIPKeyValue.isEmpty()) {
438                     paramsMap.put(floatingIPKey, floatingIPKeyValue);
439                 }
440             }
441             // add only one ipv6 floating ip for now
442             List<String> floatingIpV6List = floatingIps.getFloatingIpV6();
443             if (floatingIpV6List != null) {
444                 String floatingIPV6Key = key + UNDERSCORE + networkKey + FLOATING_V6_IP;
445                 String floatingIPV6KeyValue = floatingIpV6List.get(0);
446                 if (floatingIPV6KeyValue != null && !floatingIPV6KeyValue.isEmpty()) {
447                     paramsMap.put(floatingIPV6Key, floatingIPV6KeyValue);
448                 }
449             }
450         }
451     }
452
453     private void buildVfModuleInterfaceRoutePrefixes(Map<String, Object> paramsMap,
454             GenericResourceApiVmNetworkData network, String key, String networkKey) {
455         GenericResourceApiVmnetworkdataInterfaceRoutePrefixes interfaceRoutePrefixes =
456                 network.getInterfaceRoutePrefixes();
457         if (interfaceRoutePrefixes != null) {
458             List<String> interfaceRoutePrefixesList = interfaceRoutePrefixes.getInterfaceRoutePrefix();
459             StringBuilder sbInterfaceRoutePrefixes = new StringBuilder();
460             sbInterfaceRoutePrefixes.append("[");
461             if (interfaceRoutePrefixesList != null) {
462                 for (int a = 0; a < interfaceRoutePrefixesList.size(); a++) {
463                     String interfaceRoutePrefixValue = interfaceRoutePrefixesList.get(a);
464                     if (a != interfaceRoutePrefixesList.size() - 1) {
465                         sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \""
466                                 + interfaceRoutePrefixValue + "\"}" + ",");
467                     } else {
468                         sbInterfaceRoutePrefixes.append("{\"interface_route_table_routes_route_prefix\": \""
469                                 + interfaceRoutePrefixValue + "\"}");
470                     }
471                 }
472                 sbInterfaceRoutePrefixes.append("]");
473                 if (interfaceRoutePrefixesList.size() > 0) {
474                     paramsMap.put(key + UNDERSCORE + networkKey + "_route_prefixes",
475                             sbInterfaceRoutePrefixes.toString());
476                 }
477             }
478         }
479     }
480
481     private void buildVfModuleSriovParameters(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
482             String networkKey) {
483         // SRIOV Parameters
484         GenericResourceApiVmnetworkdataSriovParameters sriovParameters = network.getSriovParameters();
485         if (sriovParameters != null) {
486             GenericResourceApiVmnetworkdataSriovparametersHeatVlanFilters heatVlanFilters =
487                     sriovParameters.getHeatVlanFilters();
488             if (heatVlanFilters != null) {
489                 List<String> heatVlanFiltersList = heatVlanFilters.getHeatVlanFilter();
490                 StringBuilder sriovFilterBuf = new StringBuilder();
491                 if (heatVlanFiltersList != null) {
492                     for (int a = 0; a < heatVlanFiltersList.size(); a++) {
493                         String heatVlanFilterValue = heatVlanFiltersList.get(a);
494                         if (a != heatVlanFiltersList.size() - 1) {
495                             sriovFilterBuf.append(heatVlanFilterValue).append(",");
496                         } else {
497                             sriovFilterBuf.append(heatVlanFilterValue);
498                         }
499                     }
500                     if (heatVlanFiltersList.size() > 0) {
501                         paramsMap.put(networkKey + "_ATT_VF_VLAN_FILTER", sriovFilterBuf.toString());
502                     }
503                 }
504             }
505         }
506     }
507
508     private void buildVfModuleNetworkInformation(Map<String, Object> paramsMap, GenericResourceApiVmNetworkData network,
509             String key, String networkKey) {
510
511         GenericResourceApiVmnetworkdataNetworkInformationItems networkInformationItems =
512                 network.getNetworkInformationItems();
513         StringBuilder sbIpv4Ips = new StringBuilder();
514         StringBuilder sbIpv6Ips = new StringBuilder();
515
516         if (networkInformationItems != null) {
517             List<GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem> networkInformationItemList =
518                     networkInformationItems.getNetworkInformationItem();
519             if (networkInformationItemList != null) {
520                 for (int a = 0; a < networkInformationItemList.size(); a++) {
521                     GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkInformationItem ipAddress =
522                             networkInformationItemList.get(a);
523                     if (ipAddress != null) {
524                         GenericResourceApiVmnetworkdataNetworkinformationitemsNetworkinformationitemNetworkIps ips =
525                                 ipAddress.getNetworkIps();
526                         if (ips != null) {
527                             List<String> ipsList = ips.getNetworkIp();
528                             if (ipsList != null) {
529                                 String ipVersion = ipAddress.getIpVersion();
530                                 for (int b = 0; b < ipsList.size(); b++) {
531                                     String ipAddressValue = ipsList.get(b);
532                                     if (ipVersion.equals("ipv4")) {
533                                         if (b != ipsList.size() - 1) {
534                                             sbIpv4Ips.append(ipAddressValue + ",");
535                                         } else {
536                                             sbIpv4Ips.append(ipAddressValue);
537                                         }
538                                         paramsMap.put(key + UNDERSCORE + networkKey + IP + UNDERSCORE + b,
539                                                 ipAddressValue);
540                                     } else if (ipVersion.equals("ipv6")) {
541                                         if (b != ipsList.size() - 1) {
542                                             sbIpv6Ips.append(ipAddressValue + ",");
543                                         } else {
544                                             sbIpv6Ips.append(ipAddressValue);
545                                         }
546                                         paramsMap.put(key + UNDERSCORE + networkKey + V6_IP + UNDERSCORE + b,
547                                                 ipAddressValue);
548                                     }
549                                 }
550                                 paramsMap.put(key + UNDERSCORE + networkKey + "_ips", sbIpv4Ips.toString());
551                                 paramsMap.put(key + UNDERSCORE + networkKey + "_v6_ips", sbIpv6Ips.toString());
552                             }
553                         }
554                     }
555                 }
556             }
557         }
558     }
559
560     /*
561      * Build Mapping from GenericResourceApi SDNC for Heat Template so that AIC - PO gets accurate requests for vf
562      * module assignments. Build Count of SubInterfaces, VLAN Tag, network_name, network_id, ip_address (V4 and V6) and
563      * Floating IPs Addresses (V4 and V6) for Heat Template
564      */
565     private void buildParamsMapFromVfModuleForHeatTemplate(Map<String, Object> paramsMap,
566             GenericResourceApiVmTopologyData vm) {
567         GenericResourceApiVmtopologydataVmNames vmNames = vm.getVmNames();
568
569         if (vmNames != null) {
570
571             List<GenericResourceApiVmtopologydataVmnamesVnfcNames> vnfcNamesList = vmNames.getVnfcNames();
572             if (vnfcNamesList != null) {
573
574                 for (int i = 0; i < vnfcNamesList.size(); i++) {
575
576                     GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames = vnfcNamesList.get(i);
577                     parseVnfcNamesData(paramsMap, vnfcNames);
578                 }
579             }
580         }
581     }
582
583     /*
584      * Parse vnfcNames data to build Mapping from GenericResourceApi SDNC for Heat Template.
585      */
586     private void parseVnfcNamesData(Map<String, Object> paramsMap,
587             GenericResourceApiVmtopologydataVmnamesVnfcNames vnfcNames) {
588
589         if (vnfcNames != null) {
590             GenericResourceApiVnfcNetworkData vnfcNetworks = vnfcNames.getVnfcNetworks();
591             if (vnfcNetworks != null) {
592                 List<GenericResourceApiVnfcnetworkdataVnfcNetworkData> vnfcNetworkdataList =
593                         vnfcNetworks.getVnfcNetworkData();
594
595                 if (vnfcNetworkdataList != null) {
596
597                     for (int networkDataIdx = 0; networkDataIdx < vnfcNetworkdataList.size(); networkDataIdx++) {
598
599                         GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata =
600                                 vnfcNetworkdataList.get(networkDataIdx);
601                         parseVnfcNetworkData(paramsMap, vnfcNetworkdata, networkDataIdx);
602                     }
603                 }
604             }
605         }
606     }
607
608     /*
609      * Parse VnfcNetworkData to build Mapping from GenericResourceApi SDNC for Heat Template. Build Count of
610      * SubInterfaces, VLAN Tag, network_name, network_id, ip_address (V4 and V6) and Floating IPs Addresses (V4 and V6)
611      * for Heat Template
612      */
613     private void parseVnfcNetworkData(Map<String, Object> paramsMap,
614             GenericResourceApiVnfcnetworkdataVnfcNetworkData vnfcNetworkdata, int networkDataIdx) {
615
616         String vmTypeKey = vnfcNetworkdata.getVnfcType();
617         GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcPorts vnfcPorts = vnfcNetworkdata.getVnfcPorts();
618         if (vnfcPorts != null) {
619             List<GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort> vnfcPortList =
620                     vnfcPorts.getVnfcPort();
621             if (vnfcPortList != null) {
622                 for (int portIdx = 0; portIdx < vnfcPortList.size(); portIdx++) {
623
624                     GenericResourceApiVnfcnetworkdataVnfcnetworkdataVnfcportsVnfcPort vnfcPort =
625                             vnfcPortList.get(portIdx);
626                     GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces = vnfcPort.getVnicSubInterfaces();
627
628                     String vnicSubInterfacesString = convertToString(vnicSubInterfaces);
629                     String networkRoleKey = vnfcPort.getCommonSubInterfaceRole();
630                     String subInterfaceKey =
631                             createVnfcSubInterfaceKey(vmTypeKey, networkDataIdx, networkRoleKey, portIdx);
632                     String globalSubInterfaceKey = createGlobalVnfcSubInterfaceKey(vmTypeKey, networkRoleKey, portIdx);
633
634                     buildVfModuleSubInterfacesCount(paramsMap, globalSubInterfaceKey, vnicSubInterfaces);
635
636                     buildVfModuleVlanTag(paramsMap, subInterfaceKey, vnicSubInterfacesString);
637
638                     buildVfModuleNetworkName(paramsMap, subInterfaceKey, vnicSubInterfacesString);
639
640                     buildVfModuleNetworkId(paramsMap, subInterfaceKey, vnicSubInterfacesString);
641
642                     buildVfModuleIpV4AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
643
644                     buildVfModuleIpV6AddressHeatTemplate(paramsMap, subInterfaceKey, vnicSubInterfacesString);
645
646                     buildVfModuleFloatingIpV4HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
647
648                     buildVfModuleFloatingIpV6HeatTemplate(paramsMap, globalSubInterfaceKey, vnicSubInterfacesString);
649                 }
650             }
651         }
652     }
653
654     /*
655      * Build "count" (calculating the total number of sub-interfaces) for Heat Template Building Criteria :
656      * {vm-type}_subint_{network-role}_port_{index}_subintcount vmTypeKey = vm-type, networkRoleKey =
657      * common-sub-interface-role Example: fw_subint_ctrl_port_0_subintcount
658      *
659      */
660     private void buildVfModuleSubInterfacesCount(Map<String, Object> paramsMap, String keyPrefix,
661             GenericResourceApiSubInterfaceNetworkData vnicSubInterfaces) {
662
663         List<GenericResourceApiSubinterfacenetworkdataSubInterfaceNetworkData> subInterfaceNetworkDataList =
664                 vnicSubInterfaces.getSubInterfaceNetworkData();
665
666         if ((subInterfaceNetworkDataList != null) && !subInterfaceNetworkDataList.isEmpty()) {
667             addPairToMap(paramsMap, keyPrefix, SUB_INT_COUNT, String.valueOf(subInterfaceNetworkDataList.size()));
668         }
669     }
670
671     protected String createVnfcSubInterfaceKey(String vmTypeKey, int networkDataIdx, String networkRoleKey,
672             int portIdx) {
673
674         return Joiner.on(UNDERSCORE)
675                 .join(Arrays.asList(vmTypeKey, networkDataIdx, SUB_INT, networkRoleKey, PORT, portIdx));
676     }
677
678     protected String createGlobalVnfcSubInterfaceKey(String vmTypeKey, String networkRoleKey, int portIdx) {
679
680         return Joiner.on(UNDERSCORE).join(Arrays.asList(vmTypeKey, SUB_INT, networkRoleKey, PORT, portIdx));
681     }
682
683     /*
684      * Build VLAN Tag for Heat Template Building Criteria :
685      * {vm-type}_{index}_subint_{network-role}_port_{index}_vlan_ids vmTypeKey = vm-type, networkRoleKey =
686      * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_vlan_ids
687      *
688      */
689     protected void buildVfModuleVlanTag(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
690
691         List<String> vlanTagIds =
692                 jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].vlan-tag-id");
693
694         addPairToMap(paramsMap, keyPrefix, VLAN_IDS, vlanTagIds);
695     }
696
697     /*
698      * Build "network_name" for Heat Template Building Criteria :
699      * {vm-type}_{index}_subint_{network-role}_port_{index}_net_names vmTypeKey = vm-type, networkRoleKey =
700      * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_net_names
701      *
702      */
703     protected void buildVfModuleNetworkName(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
704
705         List<String> neworkNames =
706                 jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-name");
707
708         addPairToMap(paramsMap, keyPrefix, NET_NAMES, neworkNames);
709     }
710
711     /*
712      * Build "network_id" for Heat Template Building Criteria :
713      * {vm-type}_{index}_subint_{network-role}_port_{index}_net_ids vmTypeKey = vm-type, networkRoleKey =
714      * common-sub-interface-role Example: fw_0_subint_ctrl_port_0_net_ids
715      *
716      */
717     protected void buildVfModuleNetworkId(Map<String, Object> paramsMap, String keyPrefix, String vnicSubInterfaces) {
718
719         List<String> neworkIds =
720                 jsonPath.locateResultList(vnicSubInterfaces, "$.sub-interface-network-data[*].network-id");
721
722         addPairToMap(paramsMap, keyPrefix, NET_IDS, neworkIds);
723     }
724
725     /*
726      * Build ip_address for V4 for Heat Template Building Criteria :
727      * {vm-type}_{index}_subint_{network-role}_port_{index}_ip_{index} -- for ipV4 key = vm-type, networkRoleKey =
728      * NetWork-Role
729      */
730     protected void buildVfModuleIpV4AddressHeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
731             String vnicSubInterfaces) {
732
733         List<String> ipv4Ips = jsonPath.locateResultList(vnicSubInterfaces,
734                 "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv4')].network-ips.network-ip[*]");
735
736         addPairToMap(paramsMap, keyPrefix, IP, ipv4Ips);
737
738         for (int i = 0; i < ipv4Ips.size(); i++) {
739             addPairToMap(paramsMap, keyPrefix, IP + UNDERSCORE + i, ipv4Ips.get(i));
740         }
741
742     }
743
744     /*
745      * Build ip_address for Heat Template Building Criteria :
746      * {vm-type}_{index}_subint_{network-role}_port_{index}_v6_ip_{index} -- for ipV6 key = vm-type, networkRoleKey =
747      * NetWork-Role
748      */
749     protected void buildVfModuleIpV6AddressHeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
750             String vnicSubInterfaces) {
751
752         List<String> ipv6Ips = jsonPath.locateResultList(vnicSubInterfaces,
753                 "$.sub-interface-network-data[*].network-information-items.network-information-item[?(@.ip-version == 'ipv6')].network-ips.network-ip[*]");
754
755         addPairToMap(paramsMap, keyPrefix, V6_IP, ipv6Ips);
756
757         for (int i = 0; i < ipv6Ips.size(); i++) {
758             addPairToMap(paramsMap, keyPrefix, V6_IP + UNDERSCORE + i, ipv6Ips.get(i));
759         }
760     }
761
762     /*
763      * Build floatingip_address for Heat Template Building Criteria :
764      * {vm-type}_subint_{network-role}_port_{index}_floating_ip -- for ipV4
765      */
766     protected void buildVfModuleFloatingIpV4HeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
767             String vnicSubInterfaces) {
768
769         List<String> floatingV4 = jsonPath.locateResultList(vnicSubInterfaces,
770                 "$.sub-interface-network-data[*].floating-ips.floating-ip-v4[*]");
771
772         if (!floatingV4.isEmpty()) {
773             floatingV4 = Collections.singletonList(floatingV4.get(0));
774         }
775         addPairToMap(paramsMap, keyPrefix, FLOATING_IP, floatingV4);
776
777     }
778
779     /*
780      * Build floatingip_address for Heat Template Building Criteria :
781      * {vm-type}_subint_{network-role}_port_{index}_floating_v6_ip -- for ipV6
782      */
783     protected void buildVfModuleFloatingIpV6HeatTemplate(Map<String, Object> paramsMap, String keyPrefix,
784             String vnicSubInterfaces) {
785
786         List<String> floatingV6 = jsonPath.locateResultList(vnicSubInterfaces,
787                 "$.sub-interface-network-data[*].floating-ips.floating-ip-v6[*]");
788
789         if (!floatingV6.isEmpty()) {
790             floatingV6 = Collections.singletonList(floatingV6.get(0));
791         }
792         addPairToMap(paramsMap, keyPrefix, FLOATING_V6_IP, floatingV6);
793     }
794
795     protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, String value) {
796
797         addPairToMap(paramsMap, keyPrefix, key, Collections.singletonList(value));
798     }
799
800     protected void addPairToMap(Map<String, Object> paramsMap, String keyPrefix, String key, List<String> value) {
801
802         if (!value.isEmpty()) {
803             paramsMap.put(keyPrefix + key, Joiner.on(",").join(value));
804         }
805     }
806
807     private void buildParamsMapFromSdncParams(Map<String, Object> paramsMap, GenericResourceApiParam parametersData) {
808         if (parametersData != null) {
809             List<GenericResourceApiParamParam> paramsList = parametersData.getParam();
810             if (paramsList != null) {
811                 for (int i = 0; i < paramsList.size(); i++) {
812                     GenericResourceApiParamParam param = paramsList.get(i);
813                     String parameterName = param.getName();
814                     if (!sdncResponseParamsToSkip.contains(parameterName)) {
815                         String parameterValue = param.getValue();
816                         paramsMap.put(parameterName, parameterValue);
817                     }
818                 }
819             }
820         }
821     }
822
823     private Map<String, String> buildNetworkRoleMap(GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology)
824             throws JsonParseException, JsonMappingException, IOException {
825         Map<String, String> networkRoleMap = new HashMap<>();
826         GenericResourceApiVfmoduleassignmentsVfModuleAssignments vfModuleAssignments =
827                 vfModuleTopology.getVfModuleAssignments();
828         if (vfModuleAssignments != null) {
829             GenericResourceApiVfmoduleassignmentsVfmoduleassignmentsVms vms = vfModuleAssignments.getVms();
830             if (vms != null) {
831                 List<GenericResourceApiVmTopologyData> vmsList = vms.getVm();
832                 if (vmsList != null) {
833                     for (GenericResourceApiVmTopologyData vm : vmsList) {
834                         GenericResourceApiVmtopologydataVmNetworks vmNetworks = vm.getVmNetworks();
835                         if (vmNetworks != null) {
836                             List<GenericResourceApiVmNetworkData> vmNetworksList = vmNetworks.getVmNetwork();
837                             if (vmNetworksList != null) {
838                                 for (int n = 0; n < vmNetworksList.size(); n++) {
839                                     GenericResourceApiVmNetworkData network = vmNetworksList.get(n);
840                                     String networkRole = network.getNetworkRole();
841                                     String networkRoleValue = network.getNetworkRoleTag();
842                                     if (networkRoleValue == null || networkRoleValue.isEmpty()) {
843                                         networkRoleValue = networkRole;
844                                     }
845                                     networkRoleMap.put(networkRole, networkRoleValue);
846                                 }
847                             }
848                         }
849                     }
850                 }
851             }
852         }
853         return networkRoleMap;
854     }
855
856     public DeleteVfModuleRequest deleteVfModuleRequestMapper(RequestContext requestContext, CloudRegion cloudRegion,
857             ServiceInstance serviceInstance, GenericVnf genericVnf, VfModule vfModule) throws IOException {
858         DeleteVfModuleRequest deleteVfModuleRequest = new DeleteVfModuleRequest();
859         deleteVfModuleRequest.setCloudSiteId(cloudRegion.getLcpCloudRegionId());
860         deleteVfModuleRequest.setCloudOwner(cloudRegion.getCloudOwner());
861         deleteVfModuleRequest.setTenantId(cloudRegion.getTenantId());
862         deleteVfModuleRequest.setVnfId(genericVnf.getVnfId());
863         deleteVfModuleRequest.setVfModuleId(vfModule.getVfModuleId());
864         if (!StringUtils.isEmpty(vfModule.getHeatStackId())) {
865             deleteVfModuleRequest.setVfModuleStackId(vfModule.getHeatStackId());// DoDVfMod_heatStackId
866         } else {
867             deleteVfModuleRequest.setVfModuleStackId(vfModule.getVfModuleName());
868         }
869
870         deleteVfModuleRequest.setSkipAAI(true);
871         setIdAndUrl(deleteVfModuleRequest);
872         MsoRequest msoRequest = buildMsoRequest(requestContext, serviceInstance);
873         deleteVfModuleRequest.setMsoRequest(msoRequest);
874         return deleteVfModuleRequest;
875     }
876
877     protected void setIdAndUrl(DeleteVfModuleRequest deleteVfModuleRequest) throws UnsupportedEncodingException {
878         String messageId = vnfAdapterObjectMapperUtils.getRandomUuid();
879         deleteVfModuleRequest.setMessageId(messageId);
880         deleteVfModuleRequest
881                 .setNotificationUrl(vnfAdapterObjectMapperUtils.createCallbackUrl("VNFAResponse", messageId));
882     }
883
884     private String convertToString(Object obj) {
885         String json;
886         try {
887             json = mapper.writeValueAsString(obj);
888         } catch (JsonProcessingException e) {
889             json = "{}";
890         }
891
892         return json;
893     }
894
895     private VfModule getBaseVfModule(GenericVnf genericVnf) {
896         List<VfModule> vfModules = genericVnf.getVfModules();
897         VfModule baseVfModule = null;
898         if (vfModules != null) {
899             for (int i = 0; i < vfModules.size(); i++) {
900                 if (vfModules.get(i).getModelInfoVfModule().getIsBaseBoolean()) {
901                     baseVfModule = vfModules.get(i);
902                     break;
903                 }
904             }
905         }
906         return baseVfModule;
907     }
908 }