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