2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
23 package org.onap.so.bpmn.servicedecomposition.tasks;
25 import java.io.IOException;
26 import java.io.ObjectOutputStream;
27 import java.util.ArrayList;
28 import java.util.Arrays;
29 import java.util.List;
31 import java.util.Optional;
32 import org.onap.aai.domain.yang.CloudRegion;
33 import org.onap.aai.domain.yang.Configuration;
34 import org.onap.aai.domain.yang.Configurations;
35 import org.onap.aai.domain.yang.GenericVnf;
36 import org.onap.aai.domain.yang.GenericVnfs;
37 import org.onap.aai.domain.yang.InstanceGroup;
38 import org.onap.aai.domain.yang.L3Network;
39 import org.onap.aai.domain.yang.L3Networks;
40 import org.onap.aai.domain.yang.ServiceInstance;
41 import org.onap.aai.domain.yang.ServiceInstances;
42 import org.onap.aai.domain.yang.ServiceSubscription;
43 import org.onap.aai.domain.yang.VfModule;
44 import org.onap.aai.domain.yang.VolumeGroup;
45 import org.onap.aai.domain.yang.VolumeGroups;
46 import org.onap.aai.domain.yang.VpnBinding;
47 import org.onap.so.bpmn.common.InjectionHelper;
48 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
49 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
50 import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
51 import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
52 import org.onap.so.client.aai.AAIObjectPlurals;
53 import org.onap.so.client.aai.AAIObjectType;
54 import org.onap.so.client.aai.AAIResourcesClient;
55 import org.onap.so.client.aai.entities.AAIResultWrapper;
56 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
57 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
58 import org.onap.so.client.graphinventory.entities.uri.Depth;
59 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
60 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
61 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
62 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
63 import org.onap.so.db.catalog.beans.Service;
64 import org.onap.so.db.catalog.beans.VfModuleCustomization;
65 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
66 import org.onap.so.db.catalog.client.CatalogDbClient;
67 import org.onap.so.db.request.beans.InfraActiveRequests;
68 import org.onap.so.db.request.beans.RequestProcessingData;
69 import org.onap.so.db.request.client.RequestsDbClient;
70 import org.onap.so.serviceinstancebeans.CloudConfiguration;
71 import org.onap.so.serviceinstancebeans.ModelType;
72 import org.onap.so.serviceinstancebeans.RelatedInstance;
73 import org.onap.so.serviceinstancebeans.RelatedInstanceList;
74 import org.onap.so.serviceinstancebeans.RequestDetails;
75 import org.slf4j.Logger;
76 import org.slf4j.LoggerFactory;
77 import org.springframework.beans.factory.annotation.Autowired;
78 import org.springframework.stereotype.Component;
79 import com.fasterxml.jackson.core.JsonParseException;
80 import com.fasterxml.jackson.core.JsonProcessingException;
81 import com.fasterxml.jackson.databind.DeserializationFeature;
82 import com.fasterxml.jackson.databind.JsonMappingException;
83 import com.fasterxml.jackson.databind.ObjectMapper;
84 import com.fasterxml.jackson.databind.SerializationFeature;
86 @Component("BBInputSetupUtils")
87 public class BBInputSetupUtils {
89 private static final Logger logger = LoggerFactory.getLogger(BBInputSetupUtils.class);
90 private ObjectMapper objectMapper = new ObjectMapper();
91 private static final String REQUEST_ERROR = "Could not find request.";
92 private static final String DATA_LOAD_ERROR = "Could not process loading data from database";
93 private static final String DATA_PARSE_ERROR = "Could not parse data";
94 private static final String PROCESSING_DATA_NAME_EXECUTION_FLOWS = "flowExecutionPath";
97 protected CatalogDbClient catalogDbClient;
100 protected RequestsDbClient requestsDbClient;
103 protected InjectionHelper injectionHelper;
105 public RelatedInstance getRelatedInstanceByType(RequestDetails requestDetails, ModelType modelType) {
106 if (requestDetails.getRelatedInstanceList() != null) {
107 for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
108 RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
109 if (relatedInstance != null && relatedInstance.getModelInfo() != null
110 && relatedInstance.getModelInfo().getModelType() != null
111 && relatedInstance.getModelInfo().getModelType().equals(modelType)) {
112 return relatedInstance;
119 public void updateInfraActiveRequestVnfId(InfraActiveRequests request, String vnfId) {
120 if (request != null) {
121 request.setVnfId(vnfId);
122 this.requestsDbClient.updateInfraActiveRequests(request);
124 logger.debug(REQUEST_ERROR);
128 public void updateInfraActiveRequestVfModuleId(InfraActiveRequests request, String vfModuleId) {
129 if (request != null) {
130 request.setVfModuleId(vfModuleId);
131 this.requestsDbClient.updateInfraActiveRequests(request);
133 logger.debug(REQUEST_ERROR);
137 public void updateInfraActiveRequestVolumeGroupId(InfraActiveRequests request, String volumeGroupId) {
138 if (request != null) {
139 request.setVolumeGroupId(volumeGroupId);
140 this.requestsDbClient.updateInfraActiveRequests(request);
142 logger.debug(REQUEST_ERROR);
146 public void updateInfraActiveRequestNetworkId(InfraActiveRequests request, String networkId) {
147 if (request != null) {
148 request.setNetworkId(networkId);
149 this.requestsDbClient.updateInfraActiveRequests(request);
151 logger.debug(REQUEST_ERROR);
155 public void persistFlowExecutionPath(String requestId, List<ExecuteBuildingBlock> flowsToExecute) {
157 if (requestId != null) {
158 List<String> flows = new ArrayList<>();
159 ObjectMapper om = new ObjectMapper();
161 for (ExecuteBuildingBlock ebb : flowsToExecute) {
162 flows.add(om.writeValueAsString(ebb));
164 } catch (JsonProcessingException e) {
165 logger.error(DATA_PARSE_ERROR, e);
168 this.requestsDbClient.persistProcessingData(flows.toString(), requestId);
170 logger.debug(REQUEST_ERROR);
174 public InfraActiveRequests loadInfraActiveRequestById(String requestId) {
176 return this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
179 public InfraActiveRequests loadOriginalInfraActiveRequestById(String requestId) {
181 return this.requestsDbClient.getInfraActiveRequestbyRequestId(
182 this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId).getOriginalRequestId());
185 public List<ExecuteBuildingBlock> loadOriginalFlowExecutionPath(String requestId) {
187 List<ExecuteBuildingBlock> asList = null;
188 if (requestId != null) {
190 InfraActiveRequests request = loadInfraActiveRequestById(requestId);
192 if (request.getOriginalRequestId() != null) {
194 RequestProcessingData requestProcessingData =
195 this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName(
196 request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS);
198 ObjectMapper om = new ObjectMapper();
200 ExecuteBuildingBlock[] asArray =
201 om.readValue(requestProcessingData.getValue(), ExecuteBuildingBlock[].class);
202 asList = Arrays.asList(asArray);
203 } catch (Exception e) {
204 logger.error(DATA_LOAD_ERROR, e);
209 logger.debug(REQUEST_ERROR);
215 public Service getCatalogServiceByModelUUID(String modelUUID) {
216 return catalogDbClient.getServiceByID(modelUUID);
219 public Service getCatalogServiceByModelVersionAndModelInvariantUUID(String modelVersion,
220 String modelInvariantUUID) {
221 return catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(modelVersion, modelInvariantUUID);
224 public CollectionNetworkResourceCustomization getCatalogCollectionNetworkResourceCustByID(String key) {
225 return catalogDbClient.getCollectionNetworkResourceCustomizationByID(key);
228 public NetworkCollectionResourceCustomization getCatalogNetworkCollectionResourceCustByID(
229 String collectionCustomizationId) {
230 return catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustomizationId);
233 public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) {
234 return catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUUID);
237 public CvnfcConfigurationCustomization getCvnfcConfigurationCustomization(String serviceModelUUID,
238 String vnfCustomizationUuid, String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) {
239 return catalogDbClient.getCvnfcCustomization(serviceModelUUID, vnfCustomizationUuid, vfModuleCustomizationUuid,
240 cvnfcCustomizationUuid);
243 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) {
244 return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID);
247 public Map<String, String> getURIKeysFromServiceInstance(String serviceInstanceId) {
248 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
249 return uri.getURIKeys();
252 protected RequestDetails getRequestDetails(String requestId) throws IOException {
253 if (requestId != null && !requestId.isEmpty()) {
254 InfraActiveRequests activeRequest = this.getInfraActiveRequest(requestId);
255 String requestBody = activeRequest.getRequestBody().replaceAll("\\\\", "");
256 objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
257 objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
258 return objectMapper.readValue(requestBody, RequestDetails.class);
264 protected InfraActiveRequests getInfraActiveRequest(String requestId) {
265 if (requestId != null && !requestId.isEmpty()) {
266 return requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
272 protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration) {
273 if (cloudConfiguration != null) {
274 String cloudRegionId = cloudConfiguration.getLcpCloudRegionId();
275 String cloudOwner = cloudConfiguration.getCloudOwner();
276 if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) {
277 return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory
278 .createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, cloudRegionId).depth(Depth.TWO))
289 protected InstanceGroup getAAIInstanceGroup(String instanceGroupId) {
290 return injectionHelper.getAaiClient().get(InstanceGroup.class,
291 AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)).orElse(null);
294 public org.onap.aai.domain.yang.Customer getAAICustomer(String globalSubscriberId) {
295 return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Customer.class,
296 AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId)).orElse(null);
299 public ServiceSubscription getAAIServiceSubscription(String globalSubscriberId, String subscriptionServiceType) {
301 if (globalSubscriberId == null || globalSubscriberId.equals("") || subscriptionServiceType == null
302 || subscriptionServiceType.equals("")) {
305 return injectionHelper.getAaiClient().get(ServiceSubscription.class, AAIUriFactory
306 .createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, subscriptionServiceType))
312 public ServiceInstance getAAIServiceInstanceById(String serviceInstanceId) {
313 return injectionHelper.getAaiClient()
314 .get(ServiceInstance.class, AAIUriFactory
315 .createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId).depth(Depth.TWO))
319 protected ServiceInstance getAAIServiceInstanceByIdAndCustomer(String globalCustomerId, String serviceType,
320 String serviceInstanceId) {
321 return injectionHelper.getAaiClient().get(ServiceInstance.class, AAIUriFactory
322 .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId)
323 .depth(Depth.TWO)).orElse(null);
326 protected org.onap.aai.domain.yang.ServiceInstances getAAIServiceInstancesByName(String serviceInstanceName,
329 return injectionHelper.getAaiClient()
330 .get(org.onap.aai.domain.yang.ServiceInstances.class,
332 .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
333 customer.getServiceSubscription().getServiceType())
334 .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO))
336 logger.debug("No Service Instance matched by name");
341 public org.onap.aai.domain.yang.ServiceInstance getAAIServiceInstanceByName(String serviceInstanceName,
342 Customer customer) throws Exception {
343 org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
344 org.onap.aai.domain.yang.ServiceInstances aaiServiceInstances = null;
345 aaiServiceInstances = getAAIServiceInstancesByName(serviceInstanceName, customer);
347 if (aaiServiceInstances == null) {
349 } else if (aaiServiceInstances.getServiceInstance().size() > 1) {
350 throw new Exception("Multiple Service Instances Returned");
352 aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0);
354 return aaiServiceInstance;
357 protected ServiceInstances getAAIServiceInstancesByName(String globalCustomerId, String serviceType,
358 String serviceInstanceName) {
360 return injectionHelper.getAaiClient()
361 .get(ServiceInstances.class,
363 .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType)
364 .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO))
366 logger.debug("No Service Instance matched by name");
371 public Optional<ServiceInstance> getAAIServiceInstanceByName(String globalCustomerId, String serviceType,
372 String serviceInstanceName) throws Exception {
373 ServiceInstance aaiServiceInstance = null;
374 ServiceInstances aaiServiceInstances = null;
375 aaiServiceInstances = getAAIServiceInstancesByName(globalCustomerId, serviceType, serviceInstanceName);
377 if (aaiServiceInstances == null) {
378 return Optional.empty();
379 } else if (aaiServiceInstances.getServiceInstance().size() > 1) {
380 throw new Exception("Multiple Service Instances Returned");
382 aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0);
384 return Optional.of(aaiServiceInstance);
387 public org.onap.so.db.catalog.beans.InstanceGroup getCatalogInstanceGroup(String modelUUID) {
388 return this.catalogDbClient.getInstanceGroupByModelUUID(modelUUID);
391 public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomization(
392 String modelCustomizationUUID) {
393 return this.catalogDbClient
394 .getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID);
397 public AAIResultWrapper getAAIResourceDepthOne(AAIResourceUri aaiResourceUri) {
398 AAIResourceUri clonedUri = aaiResourceUri.clone();
399 return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.ONE));
402 public AAIResultWrapper getAAIResourceDepthTwo(AAIResourceUri aaiResourceUri) {
403 AAIResourceUri clonedUri = aaiResourceUri.clone();
404 return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.TWO));
407 public Configuration getAAIConfiguration(String configurationId) {
408 return this.injectionHelper.getAaiClient()
409 .get(Configuration.class,
410 AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE))
412 logger.debug("No Configuration matched by id");
417 public GenericVnf getAAIGenericVnf(String vnfId) {
419 return this.injectionHelper.getAaiClient()
420 .get(GenericVnf.class,
421 AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE))
423 logger.debug("No Generic Vnf matched by id");
428 public VpnBinding getAAIVpnBinding(String vpnBindingId) {
430 return this.injectionHelper.getAaiClient()
431 .get(VpnBinding.class,
432 AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId).depth(Depth.ONE))
434 logger.debug("No VpnBinding matched by id");
439 public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) {
440 return this.injectionHelper.getAaiClient()
441 .get(VolumeGroup.class, AAIUriFactory
442 .createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId, volumeGroupId)
445 logger.debug("No Generic Vnf matched by id");
450 public VfModule getAAIVfModule(String vnfId, String vfModuleId) {
451 return this.injectionHelper.getAaiClient()
453 AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE))
455 logger.debug("No Generic Vnf matched by id");
460 public L3Network getAAIL3Network(String networkId) {
462 return this.injectionHelper.getAaiClient()
463 .get(L3Network.class,
464 AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE))
466 logger.debug("No Generic Vnf matched by id");
472 public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId)
474 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
475 uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE);
476 Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri);
477 ServiceInstance serviceInstance = null;
478 if (!serviceInstances.isPresent()) {
479 logger.debug("No ServiceInstances were found");
480 return Optional.empty();
482 if (serviceInstances.get().getServiceInstance().isEmpty()) {
483 throw new NoServiceInstanceFoundException("No ServiceInstances Returned");
484 } else if (serviceInstances.get().getServiceInstance().size() > 1) {
485 throw new MultipleObjectsFoundException("Multiple ServiceInstances Returned");
487 serviceInstance = serviceInstances.get().getServiceInstance().get(0);
489 return Optional.of(serviceInstance);
493 public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName)
495 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
496 uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
497 Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
498 L3Network network = null;
499 if (!networks.isPresent()) {
500 logger.debug("No Networks matched by name");
501 return Optional.empty();
503 if (networks.get().getL3Network().size() > 1) {
504 throw new Exception("Multiple Networks Returned");
506 network = networks.get().getL3Network().get(0);
508 return Optional.of(network);
512 public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName)
514 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
515 uri.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName);
516 Optional<GenericVnfs> vnfs = injectionHelper.getAaiClient().get(GenericVnfs.class, uri);
517 GenericVnf vnf = null;
518 if (!vnfs.isPresent()) {
519 logger.debug("No Vnfs matched by name");
520 return Optional.empty();
522 if (vnfs.get().getGenericVnf().size() > 1) {
523 throw new Exception("Multiple Vnfs Returned");
525 vnf = vnfs.get().getGenericVnf().get(0);
527 return Optional.of(vnf);
531 public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName)
533 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
534 uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName);
535 Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri);
536 VolumeGroup volumeGroup = null;
537 if (!volumeGroups.isPresent()) {
538 logger.debug("No VolumeGroups matched by name");
539 return Optional.empty();
541 if (volumeGroups.get().getVolumeGroup().size() > 1) {
542 throw new Exception("Multiple VolumeGroups Returned");
544 volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
546 return Optional.of(volumeGroup);
550 public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId,
551 String volumeGroupName) throws Exception {
552 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
553 uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName);
554 Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri);
555 VolumeGroup volumeGroup = null;
556 if (!volumeGroups.isPresent()) {
557 logger.debug("No VolumeGroups matched by name");
558 return Optional.empty();
560 if (volumeGroups.get().getVolumeGroup().size() > 1) {
561 throw new Exception("Multiple VolumeGroups Returned");
563 volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
565 return Optional.of(volumeGroup);
569 public Optional<org.onap.aai.domain.yang.VpnBinding> getAICVpnBindingFromNetwork(
570 org.onap.aai.domain.yang.L3Network aaiLocalNetwork) {
571 AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork);
572 if (networkWrapper.getRelationships().isPresent()
573 && !networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).isEmpty()) {
574 return getAAIResourceDepthOne(
575 networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).get(0))
576 .asBean(org.onap.aai.domain.yang.VpnBinding.class);
578 return Optional.empty();
581 public ServiceInstances getAAIServiceInstancesGloballyByName(String serviceInstanceName) {
583 return injectionHelper.getAaiClient()
584 .get(ServiceInstances.class, AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE)
585 .queryParam("service-instance-name", serviceInstanceName))
587 logger.debug("No Service Instance matched by name");
592 public boolean existsAAINetworksGloballyByName(String networkName) {
594 AAIResourceUri l3networkUri =
595 AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
596 AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
597 return aaiRC.exists(l3networkUri);
600 public GenericVnfs getAAIVnfsGloballyByName(String vnfName) {
602 return injectionHelper.getAaiClient()
603 .get(GenericVnfs.class,
604 AAIUriFactory.createNodesUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName))
606 logger.debug("No GenericVnfs matched by name");
611 public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId,
612 String configurationName) throws Exception {
613 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
614 uri.relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName);
615 Optional<Configurations> configurations = injectionHelper.getAaiClient().get(Configurations.class, uri);
616 Configuration configuration = null;
617 if (!configurations.isPresent()) {
618 logger.debug("No Configurations matched by name");
619 return Optional.empty();
621 if (configurations.get().getConfiguration().size() > 1) {
622 throw new Exception("Multiple Configurations Returned");
624 configuration = configurations.get().getConfiguration().get(0);
626 return Optional.of(configuration);