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