2 * ============LICENSE_START=======================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ============LICENSE_END=========================================================
\r
21 package org.openecomp.mso.bpmn.common.scripts
\r
22 import org.camunda.bpm.engine.delegate.BpmnError
\r
23 import org.camunda.bpm.engine.runtime.Execution
\r
24 import org.openecomp.mso.bpmn.common.scripts.AbstractServiceTaskProcessor;
\r
25 import org.openecomp.mso.rest.APIResponse;
\r
26 import org.openecomp.mso.rest.RESTClient
\r
27 import org.openecomp.mso.rest.RESTConfig
\r
31 public MsoUtils utils = new MsoUtils()
\r
32 public static final String AAI_NAMESPACE_STRING = 'http://org.openecomp.aai.inventory/'
\r
33 public static final String DEFAULT_VERSION_KEY = 'URN_mso_workflow_global_default_aai_version'
\r
35 private AbstractServiceTaskProcessor taskProcessor
\r
37 public AaiUtil(AbstractServiceTaskProcessor taskProcessor) {
\r
38 this.taskProcessor = taskProcessor
\r
41 public String getNetworkGenericVnfEndpoint(Execution execution) {
\r
42 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
43 String endpoint = execution.getVariable("URN_aai_endpoint")
\r
44 def uri = getNetworkGenericVnfUri(execution)
\r
45 taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled)
\r
46 return endpoint + uri
\r
49 public String getNetworkGenericVnfUri(Execution execution) {
\r
50 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
51 def uri = getUri(execution, 'generic_vnf')
\r
52 taskProcessor.logDebug('AaiUtil.getNetworkGenericVnfUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
56 public String getNetworkVpnBindingUri(Execution execution) {
\r
57 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
58 def uri = getUri(execution, 'vpn_binding')
\r
59 taskProcessor.logDebug('AaiUtil.getNetworkVpnBindingUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
63 public String getNetworkPolicyUri(Execution execution) {
\r
64 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
65 def uri = getUri(execution, 'network_policy')
\r
66 taskProcessor.logDebug('AaiUtil.getNetworkPolicyUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
70 public String getNetworkTableReferencesUri(Execution execution) {
\r
71 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
72 def uri = getUri(execution, 'route_table_reference')
\r
73 taskProcessor.logDebug('AaiUtil.getNetworkTableReferencesUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
77 public String getNetworkVceUri(Execution execution) {
\r
78 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
79 def uri = getUri(execution, 'vce')
\r
80 taskProcessor.logDebug('AaiUtil.getNetworkVceUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
84 public String getNetworkL3NetworkUri(Execution execution) {
\r
85 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
86 def uri = getUri(execution, 'l3_network')
\r
87 taskProcessor.logDebug('AaiUtil.getNetworkL3NetworkUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
91 public String getBusinessCustomerUri(Execution execution) {
\r
92 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
93 def uri = getUri(execution, 'customer')
\r
94 taskProcessor.logDebug('AaiUtil.getBusinessCustomerUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
98 //public String getBusinessCustomerUriv7(Execution execution) {
\r
99 // def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
100 // //def uri = getUri(execution, BUSINESS_CUSTOMERV7)
\r
101 // def uri = getUri(execution, 'Customer')
\r
102 // taskProcessor.logDebug('AaiUtil.getBusinessCustomerUriv7() - AAI URI: ' + uri, isDebugLogEnabled)
\r
106 public String getCloudInfrastructureCloudRegionEndpoint(Execution execution) {
\r
107 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
108 String endpoint = execution.getVariable("URN_aai_endpoint")
\r
109 def uri = getCloudInfrastructureCloudRegionUri(execution)
\r
110 taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled)
\r
111 return endpoint + uri
\r
114 public String getCloudInfrastructureCloudRegionUri(Execution execution) {
\r
115 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
116 def uri = getUri(execution, 'cloud_region')
\r
117 taskProcessor.logDebug('AaiUtil.getCloudInfrastructureCloudRegionUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
121 public String getCloudInfrastructureTenantUri(Execution execution) {
\r
122 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
123 def uri = getUri(execution, 'tenant')
\r
124 taskProcessor.logDebug('AaiUtil.getCloudInfrastructureTenantUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
128 public String getSearchNodesQueryUri(Execution execution) {
\r
129 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
130 def uri = getUri(execution, 'nodes_query')
\r
131 taskProcessor.logDebug('AaiUtil.getSearchNodesQueryUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
135 public String getSearchNodesQueryEndpoint(Execution execution) {
\r
136 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
137 String endpoint = execution.getVariable("URN_aai_endpoint")
\r
138 def uri = getSearchNodesQueryUri(execution)
\r
139 taskProcessor.logDebug('AaiUtil.getSearchNodesQueryEndpoint() - AAI endpoint: ' + endpoint + uri, isDebugLogEnabled)
\r
140 return endpoint + uri
\r
143 public String getSearchGenericQueryUri(Execution execution) {
\r
144 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
145 def uri = getUri(execution, 'generic_query')
\r
146 taskProcessor.logDebug('AaiUtil.getSearchGenericQueryUri() - AAI URI: ' + uri, isDebugLogEnabled)
\r
150 public String getVersion(Execution execution, resourceName, processKey) {
\r
151 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
153 resourceName = resourceName.replaceAll('-', '_')
\r
155 def versionWithResourceKey = "URN_mso_workflow_default_aai_${resourceName}_version"
\r
156 def versionWithProcessKey = "URN_mso_workflow_custom_${processKey}_aai_version"
\r
158 def version = execution.getVariable(versionWithProcessKey)
\r
160 taskProcessor.logDebug("AaiUtil.getVersion() - using flow specific ${versionWithProcessKey}=${version}", isDebugLogEnabled)
\r
164 version = execution.getVariable(versionWithResourceKey)
\r
166 taskProcessor.logDebug("AaiUtil.getVersion() - using resource specific ${versionWithResourceKey}=${version}", isDebugLogEnabled)
\r
170 version = execution.getVariable(DEFAULT_VERSION_KEY)
\r
172 taskProcessor.logDebug("AaiUtil.getVersion() - using default version ${DEFAULT_VERSION_KEY}=${version}", isDebugLogEnabled)
\r
176 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, "Internal Error: One of the following should be defined in MSO URN properties file: ${versionWithResourceKey}, ${versionWithProcessKey}, ${DEFAULT_VERSION_KEY}")
\r
179 public String getUri(Execution execution, resourceName) {
\r
181 def isDebugLogEnabled = execution.getVariable('isDebugLogEnabled')
\r
182 def processKey = taskProcessor.getMainProcessKey(execution)
\r
184 resourceName = resourceName.replaceAll('-', '_')
\r
186 // Check for flow+resource specific first
\r
187 def key = "URN_mso_workflow_${processKey}_aai_${resourceName}_uri"
\r
188 def uri = execution.getVariable(key)
\r
190 taskProcessor.logDebug("AaiUtil.getUri() - using flow+resource specific key: ${key}=${uri}", isDebugLogEnabled)
\r
194 // Check for versioned key
\r
195 def version = getVersion(execution, resourceName, processKey)
\r
196 key = "URN_mso_workflow_default_aai_v${version}_${resourceName}_uri"
\r
197 uri = execution.getVariable(key)
\r
200 taskProcessor.logDebug("AaiUtil.getUri() - using versioned URI key: ${key}=${uri}", isDebugLogEnabled)
\r
204 (new ExceptionUtil()).buildAndThrowWorkflowException(execution, 9999, 'Internal Error: AAI URI entry for ' + key + ' not defined in the MSO URN properties file')
\r
207 public String getNamespaceFromUri(String uri) {
\r
208 String namespace = AAI_NAMESPACE_STRING
\r
210 return namespace + uri.substring(uri.indexOf("v"), uri.indexOf("v")+2)
\r
219 * This reusable method can be used for making AAI Get Calls. The url should
\r
220 * be passed as a parameter along with the execution. The method will
\r
221 * return an APIResponse.
\r
226 * @return APIResponse
\r
228 public APIResponse executeAAIGetCall(Execution execution, String url){
\r
229 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
230 taskProcessor.logDebug(" ======== STARTED Execute AAI Get Process ======== ", isDebugEnabled)
\r
232 String uuid = UUID.randomUUID()
\r
233 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
234 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
236 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
238 RESTConfig config = new RESTConfig(url);
\r
239 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
\r
241 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
242 client.addAuthorizationHeader(basicAuthCred)
\r
245 APIResponse apiResponse = client.get()
\r
248 }catch(Exception e){
\r
249 taskProcessor.logDebug("Exception occured while executing AAI Get Call. Exception is: \n" + e, isDebugEnabled)
\r
252 taskProcessor.logDebug( "======== COMPLETED Execute AAI Get Process ======== ", isDebugEnabled)
\r
256 * This reusable method can be used for making AAI httpPut Calls. The url should
\r
257 * be passed as a parameter along with the execution and payload. The method will
\r
258 * return an APIResponse.
\r
264 * @return APIResponse
\r
266 public APIResponse executeAAIPutCall(Execution execution, String url, String payload){
\r
267 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
268 taskProcessor.logDebug( " ======== Started Execute AAI Put Process ======== ", isDebugEnabled)
\r
270 String uuid = UUID.randomUUID()
\r
271 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
272 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
274 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
276 RESTConfig config = new RESTConfig(url);
\r
277 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/xml").addHeader("Accept","application/xml");
\r
278 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
279 client.addAuthorizationHeader(basicAuthCred)
\r
281 APIResponse apiResponse = client.httpPut(payload)
\r
284 }catch(Exception e){
\r
285 taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Put Call. Exception is: \n" + e, isDebugEnabled)
\r
288 taskProcessor.logDebug( "======== Completed Execute AAI Put Process ======== ", isDebugEnabled)
\r
292 * This reusable method can be used for making AAI httpPatch Calls. The url should
\r
293 * be passed as a parameter along with the execution and payload. The method will
\r
294 * return an APIResponse.
\r
300 * @return APIResponse
\r
302 public APIResponse executeAAIPatchCall(Execution execution, String url, String payload){
\r
303 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
304 taskProcessor.logDebug( " ======== Started Execute AAI Patch Process ======== ", isDebugEnabled)
\r
306 String uuid = UUID.randomUUID()
\r
307 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
309 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
311 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
313 RESTConfig config = new RESTConfig(url);
\r
314 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Content-Type", "application/merge-patch+json").addHeader("Accept","application/json");
\r
315 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
316 client.addAuthorizationHeader(basicAuthCred)
\r
318 APIResponse apiResponse = client.httpPatch(payload)
\r
321 }catch(Exception e){
\r
322 taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Patch Call. Exception is: \n" + e, isDebugEnabled)
\r
325 taskProcessor.logDebug( "======== Completed Execute AAI Patch Process ======== ", isDebugEnabled)
\r
330 * This reusable method can be used for making AAI Delete Calls. The url should
\r
331 * be passed as a parameter along with the execution. The method will
\r
332 * return an APIResponse.
\r
337 * @return APIResponse
\r
339 public APIResponse executeAAIDeleteCall(Execution execution, String url){
\r
340 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
341 taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
\r
343 String uuid = UUID.randomUUID()
\r
344 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
345 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
347 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
349 RESTConfig config = new RESTConfig(url);
\r
350 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
\r
351 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
352 client.addAuthorizationHeader(basicAuthCred)
\r
354 APIResponse apiResponse = client.delete()
\r
358 }catch(Exception e){
\r
359 taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)
\r
362 taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
\r
366 * This reusable method can be used for making AAI Delete Calls. The url should
\r
367 * be passed as a parameter along with the execution. The method will
\r
368 * return an APIResponse.
\r
374 * @return APIResponse
\r
376 public APIResponse executeAAIDeleteCall(Execution execution, String url, String payload, String authHeader){
\r
377 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
378 taskProcessor.logDebug( " ======== Started Execute AAI Delete Process ======== ", isDebugEnabled)
\r
380 String uuid = UUID.randomUUID()
\r
381 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
382 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
384 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
385 RESTConfig config = new RESTConfig(url);
\r
386 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml").addAuthorizationHeader(authHeader);
\r
387 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
388 client.addAuthorizationHeader(basicAuthCred)
\r
391 APIResponse apiResponse = client.httpDelete(payload)
\r
395 }catch(Exception e){
\r
396 taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Delete Call. Exception is: \n" + e, isDebugEnabled)
\r
399 taskProcessor.logDebug( "======== Completed Execute AAI Delete Process ======== ", isDebugEnabled)
\r
403 * This reusable method can be used for making AAI Post Calls. The url should
\r
404 * be passed as a parameter along with the execution. The method will
\r
405 * return an APIResponse.
\r
411 * @return APIResponse
\r
413 public APIResponse executeAAIPostCall(Execution execution, String url, String payload){
\r
414 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
415 taskProcessor.logDebug( " ======== Started Execute AAI Post Process ======== ", isDebugEnabled)
\r
417 String uuid = UUID.randomUUID()
\r
418 taskProcessor.logDebug( "Generated uuid is: " + uuid, isDebugEnabled)
\r
419 taskProcessor.logDebug( "URL to be used is: " + url, isDebugEnabled)
\r
421 String basicAuthCred = utils.getBasicAuth(execution.getVariable("URN_aai_auth"),execution.getVariable("URN_mso_msoKey"))
\r
422 RESTConfig config = new RESTConfig(url);
\r
423 RESTClient client = new RESTClient(config).addHeader("X-FromAppId", "MSO").addHeader("X-TransactionId", uuid).addHeader("Accept","application/xml");
\r
424 if (basicAuthCred != null && !"".equals(basicAuthCred)) {
\r
425 client.addAuthorizationHeader(basicAuthCred)
\r
427 APIResponse apiResponse = client.httpPost(payload)
\r
431 }catch(Exception e){
\r
432 taskProcessor.utils.log("ERROR", "Exception occured while executing AAI Post Call. Exception is: \n" + e, isDebugEnabled)
\r
435 taskProcessor.logDebug( "======== Completed Execute AAI Post Process ======== ", isDebugEnabled)
\r
438 /** Utilitty to get the Cloud Region from AAI
\r
439 * Returns String cloud region id, (ie, cloud-region-id)
\r
441 * @param url - url for AAI get cloud region
\r
442 * @param backend - "PO" - real region, or "SDNC" - v2.5 (fake region).
\r
445 //TODO: We should refactor this method to return WorkflowException instead of Error. Also to throw MSOWorkflowException which the calling flow will then catch.
\r
447 public String getAAICloudReqion(Execution execution, String url, String backend, inputCloudRegion){
\r
448 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
451 APIResponse apiResponse = executeAAIGetCall(execution, url)
\r
452 String returnCode = apiResponse.getStatusCode()
\r
453 String aaiResponseAsString = apiResponse.getResponseBodyAsString()
\r
454 taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Return code: " + returnCode, isDebugEnabled)
\r
455 execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionReturnCode", returnCode)
\r
456 //taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region Response: " + aaiResponseAsString, isDebugEnabled)
\r
457 //execution.setVariable(execution.getVariable("prefix")+"queryCloudRegionResponse", aaiResponseAsString)
\r
458 String regionId = ""
\r
459 if (returnCode == "200") {
\r
460 taskProcessor.utils.log("DEBUG", "Call AAI Cloud Region is Successful.", isDebugEnabled)
\r
462 String regionVersion = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-version")
\r
463 taskProcessor.utils.log("DEBUG", "Cloud Region Version from AAI for " + backend + " is: " + regionVersion, isDebugEnabled)
\r
464 if (backend == "PO") {
\r
465 regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id")
\r
466 } else { // backend not "PO"
\r
467 if (regionVersion == "2.5" ) {
\r
468 regionId = "AAIAIC25"
\r
470 regionId = taskProcessor.utils.getNodeText(aaiResponseAsString, "cloud-region-id")
\r
474 taskProcessor.utils.log("DEBUG", "Cloud Region Id from AAI " + backend + " is: " + regionId, isDebugEnabled)
\r
477 } catch (Exception e) {
\r
478 taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
\r
481 } else { // not 200
\r
482 if (returnCode == "404") {
\r
483 if (backend == "PO") {
\r
484 regionId = inputCloudRegion
\r
485 } else { // backend not "PO"
\r
486 regionId = "AAIAIC25"
\r
488 taskProcessor.utils.log("DEBUG", "Cloud Region value for code='404' of " + backend + " is: " + regionId, isDebugEnabled)
\r
491 taskProcessor.utils.log("ERROR", "Call AAI Cloud Region is NOT Successful.", isDebugEnabled)
\r
495 }catch(Exception e) {
\r
496 taskProcessor.utils.log("ERROR", "Exception occured while getting the Cloud Reqion. Exception is: \n" + e, isDebugEnabled)
\r
501 /* returns xml Node with service-type of searchValue */
\r
502 def searchServiceType(xmlInput, searchValue){
\r
503 def fxml= new XmlSlurper().parseText(xmlInput)
\r
504 def ret = fxml.'**'.find {it.'service-type' == searchValue}
\r
508 /* returns xml Node with service-instance-id of searchValue */
\r
509 def searchServiceInstanceId(xmlInput, searchValue){
\r
510 def ret = xmlInput.'**'.find {it.'service-instance-id' == searchValue}
\r
516 * Get the lowest unused VF Module index from AAI response for a given module type. The criteria for
\r
517 * determining module type is specified by "key" parameter (for example, "persona-model-id"),
\r
518 * the value for filtering is specified in "value" parameter
\r
521 * @param aaiVnfResponse
\r
525 * @return moduleIndex
\r
528 public int getLowestUnusedVfModuleIndexFromAAIVnfResponse(Execution execution, String aaiVnfResponse, String key, String value) {
\r
529 def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
\r
530 if (aaiVnfResponse != null) {
\r
531 String vfModulesText = taskProcessor.utils.getNodeXml(aaiVnfResponse, "vf-modules")
\r
532 if (vfModulesText == null || vfModulesText.isEmpty()) {
\r
533 taskProcessor.utils.log("DEBUG", "There are no VF modules in this VNF yet", isDebugEnabled)
\r
537 def xmlVfModules= new XmlSlurper().parseText(vfModulesText)
\r
538 def vfModules = xmlVfModules.'**'.findAll {it.name() == "vf-module"}
\r
539 int vfModulesSize = 0
\r
540 if (vfModules != null) {
\r
541 vfModulesSize = vfModules.size()
\r
543 String matchingVfModules = "<vfModules>"
\r
544 for (i in 0..vfModulesSize-1) {
\r
545 def vfModuleXml = groovy.xml.XmlUtil.serialize(vfModules[i])
\r
546 def keyFromAAI = taskProcessor.utils.getNodeText(vfModuleXml, key)
\r
547 if (keyFromAAI != null && keyFromAAI.equals(value)) {
\r
548 matchingVfModules = matchingVfModules + taskProcessor.utils.removeXmlPreamble(vfModuleXml)
\r
551 matchingVfModules = matchingVfModules + "</vfModules>"
\r
552 taskProcessor.utils.log("DEBUG", "Matching VF Modules: " + matchingVfModules, isDebugEnabled)
\r
553 String lowestUnusedIndex = taskProcessor.utils.getLowestUnusedIndex(matchingVfModules)
\r
554 return Integer.parseInt(lowestUnusedIndex)
\r