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