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.util.ArrayList;
27 import java.util.List;
29 import java.util.Optional;
30 import org.onap.aai.domain.yang.CloudRegion;
31 import org.onap.aai.domain.yang.Configuration;
32 import org.onap.aai.domain.yang.Configurations;
33 import org.onap.aai.domain.yang.GenericVnf;
34 import org.onap.aai.domain.yang.GenericVnfs;
35 import org.onap.aai.domain.yang.InstanceGroup;
36 import org.onap.aai.domain.yang.L3Network;
37 import org.onap.aai.domain.yang.L3Networks;
38 import org.onap.aai.domain.yang.ServiceInstance;
39 import org.onap.aai.domain.yang.ServiceInstances;
40 import org.onap.aai.domain.yang.ServiceSubscription;
41 import org.onap.aai.domain.yang.VfModule;
42 import org.onap.aai.domain.yang.VolumeGroup;
43 import org.onap.aai.domain.yang.VolumeGroups;
44 import org.onap.aai.domain.yang.VpnBinding;
45 import org.onap.so.bpmn.common.InjectionHelper;
46 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
47 import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
48 import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException;
49 import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException;
50 import org.onap.so.client.aai.AAIObjectPlurals;
51 import org.onap.so.client.aai.AAIObjectType;
52 import org.onap.so.client.aai.AAIResourcesClient;
53 import org.onap.so.client.aai.entities.AAIResultWrapper;
54 import org.onap.so.client.aai.entities.uri.AAIResourceUri;
55 import org.onap.so.client.aai.entities.uri.AAIUriFactory;
56 import org.onap.so.client.graphinventory.entities.uri.Depth;
57 import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
58 import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization;
59 import org.onap.so.db.catalog.beans.CvnfcConfigurationCustomization;
60 import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization;
61 import org.onap.so.db.catalog.beans.Service;
62 import org.onap.so.db.catalog.beans.VfModuleCustomization;
63 import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
64 import org.onap.so.db.catalog.client.CatalogDbClient;
65 import org.onap.so.db.request.beans.InfraActiveRequests;
66 import org.onap.so.db.request.beans.RequestProcessingData;
67 import org.onap.so.db.request.client.RequestsDbClient;
68 import org.onap.so.serviceinstancebeans.CloudConfiguration;
69 import org.onap.so.serviceinstancebeans.ModelType;
70 import org.onap.so.serviceinstancebeans.RelatedInstance;
71 import org.onap.so.serviceinstancebeans.RelatedInstanceList;
72 import org.onap.so.serviceinstancebeans.RequestDetails;
73 import org.slf4j.Logger;
74 import org.slf4j.LoggerFactory;
75 import org.springframework.beans.factory.annotation.Autowired;
76 import org.springframework.stereotype.Component;
77 import com.fasterxml.jackson.core.JsonProcessingException;
78 import com.fasterxml.jackson.databind.DeserializationFeature;
79 import com.fasterxml.jackson.databind.ObjectMapper;
80 import com.fasterxml.jackson.databind.SerializationFeature;
81 import com.fasterxml.jackson.databind.type.TypeFactory;
83 @Component("BBInputSetupUtils")
84 public class BBInputSetupUtils {
86 private static final Logger logger = LoggerFactory.getLogger(BBInputSetupUtils.class);
87 private ObjectMapper objectMapper = new ObjectMapper();
88 private static final String REQUEST_ERROR = "Could not find request.";
89 private static final String DATA_LOAD_ERROR = "Could not process loading data from database";
90 private static final String DATA_PARSE_ERROR = "Could not parse data";
91 private static final String PROCESSING_DATA_NAME_EXECUTION_FLOWS = "flowExecutionPath";
94 protected CatalogDbClient catalogDbClient;
97 protected RequestsDbClient requestsDbClient;
100 protected InjectionHelper injectionHelper;
102 public RelatedInstance getRelatedInstanceByType(RequestDetails requestDetails, ModelType modelType) {
103 if (requestDetails.getRelatedInstanceList() != null) {
104 for (RelatedInstanceList relatedInstanceList : requestDetails.getRelatedInstanceList()) {
105 RelatedInstance relatedInstance = relatedInstanceList.getRelatedInstance();
106 if (relatedInstance != null && relatedInstance.getModelInfo() != null
107 && relatedInstance.getModelInfo().getModelType() != null
108 && relatedInstance.getModelInfo().getModelType().equals(modelType)) {
109 return relatedInstance;
116 public void updateInfraActiveRequestVnfId(InfraActiveRequests request, String vnfId) {
117 if (request != null) {
118 request.setVnfId(vnfId);
119 this.requestsDbClient.updateInfraActiveRequests(request);
121 logger.debug(REQUEST_ERROR);
125 public void updateInfraActiveRequestVfModuleId(InfraActiveRequests request, String vfModuleId) {
126 if (request != null) {
127 request.setVfModuleId(vfModuleId);
128 this.requestsDbClient.updateInfraActiveRequests(request);
130 logger.debug(REQUEST_ERROR);
134 public void updateInfraActiveRequestVolumeGroupId(InfraActiveRequests request, String volumeGroupId) {
135 if (request != null) {
136 request.setVolumeGroupId(volumeGroupId);
137 this.requestsDbClient.updateInfraActiveRequests(request);
139 logger.debug(REQUEST_ERROR);
143 public void updateInfraActiveRequestNetworkId(InfraActiveRequests request, String networkId) {
144 if (request != null) {
145 request.setNetworkId(networkId);
146 this.requestsDbClient.updateInfraActiveRequests(request);
148 logger.debug(REQUEST_ERROR);
152 public void persistFlowExecutionPath(String requestId, List<ExecuteBuildingBlock> flowsToExecute) {
154 if (requestId != null) {
155 List<String> flows = new ArrayList<>();
156 ObjectMapper om = new ObjectMapper();
158 for (ExecuteBuildingBlock ebb : flowsToExecute) {
159 flows.add(om.writeValueAsString(ebb));
161 } catch (JsonProcessingException e) {
162 logger.error(DATA_PARSE_ERROR, e);
165 this.requestsDbClient.persistProcessingData(flows.toString(), requestId);
167 logger.debug(REQUEST_ERROR);
171 public InfraActiveRequests loadInfraActiveRequestById(String requestId) {
173 return this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
176 public InfraActiveRequests loadOriginalInfraActiveRequestById(String requestId) {
177 return this.requestsDbClient.getInfraActiveRequestbyRequestId(
178 this.requestsDbClient.getInfraActiveRequestbyRequestId(requestId).getOriginalRequestId());
181 public List<ExecuteBuildingBlock> loadOriginalFlowExecutionPath(String requestId) {
182 if (requestId != null) {
183 InfraActiveRequests request = loadInfraActiveRequestById(requestId);
184 if (request.getOriginalRequestId() != null) {
185 RequestProcessingData requestProcessingData =
186 this.requestsDbClient.getRequestProcessingDataBySoRequestIdAndName(
187 request.getOriginalRequestId(), PROCESSING_DATA_NAME_EXECUTION_FLOWS);
189 ObjectMapper om = new ObjectMapper();
190 TypeFactory typeFactory = objectMapper.getTypeFactory();
191 return om.readValue(requestProcessingData.getValue(),
192 typeFactory.constructCollectionType(List.class, ExecuteBuildingBlock.class));
193 } catch (Exception e) {
194 logger.error(DATA_LOAD_ERROR, e);
195 throw new RuntimeException("Error Loading Original Request Data", e);
198 throw new RuntimeException("Original Request Id is null for record: " + requestId);
201 throw new RuntimeException("Null Request Id Passed in");
205 public Service getCatalogServiceByModelUUID(String modelUUID) {
206 return catalogDbClient.getServiceByID(modelUUID);
209 public Service getCatalogServiceByModelVersionAndModelInvariantUUID(String modelVersion,
210 String modelInvariantUUID) {
211 return catalogDbClient.getServiceByModelVersionAndModelInvariantUUID(modelVersion, modelInvariantUUID);
214 public CollectionNetworkResourceCustomization getCatalogCollectionNetworkResourceCustByID(String key) {
215 return catalogDbClient.getCollectionNetworkResourceCustomizationByID(key);
218 public NetworkCollectionResourceCustomization getCatalogNetworkCollectionResourceCustByID(
219 String collectionCustomizationId) {
220 return catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustomizationId);
223 public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) {
224 return catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUUID);
227 public CvnfcConfigurationCustomization getCvnfcConfigurationCustomization(String serviceModelUUID,
228 String vnfCustomizationUuid, String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) {
229 return catalogDbClient.getCvnfcCustomization(serviceModelUUID, vnfCustomizationUuid, vfModuleCustomizationUuid,
230 cvnfcCustomizationUuid);
233 public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) {
234 return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID);
237 public Map<String, String> getURIKeysFromServiceInstance(String serviceInstanceId) {
238 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
239 return uri.getURIKeys();
242 protected RequestDetails getRequestDetails(String requestId) throws IOException {
243 if (requestId != null && !requestId.isEmpty()) {
244 InfraActiveRequests activeRequest = this.getInfraActiveRequest(requestId);
245 String requestBody = activeRequest.getRequestBody().replaceAll("\\\\", "");
246 objectMapper.configure(SerializationFeature.WRAP_ROOT_VALUE, true);
247 objectMapper.configure(DeserializationFeature.UNWRAP_ROOT_VALUE, true);
248 return objectMapper.readValue(requestBody, RequestDetails.class);
254 protected InfraActiveRequests getInfraActiveRequest(String requestId) {
255 if (requestId != null && !requestId.isEmpty()) {
256 return requestsDbClient.getInfraActiveRequestbyRequestId(requestId);
262 protected CloudRegion getCloudRegion(CloudConfiguration cloudConfiguration) {
263 if (cloudConfiguration != null) {
264 String cloudRegionId = cloudConfiguration.getLcpCloudRegionId();
265 String cloudOwner = cloudConfiguration.getCloudOwner();
266 if (cloudRegionId != null && cloudOwner != null && !cloudRegionId.isEmpty() && !cloudOwner.isEmpty()) {
267 return injectionHelper.getAaiClient().get(CloudRegion.class, AAIUriFactory
268 .createResourceUri(AAIObjectType.CLOUD_REGION, cloudOwner, cloudRegionId).depth(Depth.TWO))
279 protected InstanceGroup getAAIInstanceGroup(String instanceGroupId) {
280 return injectionHelper.getAaiClient().get(InstanceGroup.class,
281 AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId)).orElse(null);
284 public org.onap.aai.domain.yang.Customer getAAICustomer(String globalSubscriberId) {
285 return injectionHelper.getAaiClient().get(org.onap.aai.domain.yang.Customer.class,
286 AAIUriFactory.createResourceUri(AAIObjectType.CUSTOMER, globalSubscriberId)).orElse(null);
289 public ServiceSubscription getAAIServiceSubscription(String globalSubscriberId, String subscriptionServiceType) {
291 if (globalSubscriberId == null || globalSubscriberId.equals("") || subscriptionServiceType == null
292 || subscriptionServiceType.equals("")) {
295 return injectionHelper.getAaiClient().get(ServiceSubscription.class, AAIUriFactory
296 .createResourceUri(AAIObjectType.SERVICE_SUBSCRIPTION, globalSubscriberId, subscriptionServiceType))
302 public ServiceInstance getAAIServiceInstanceById(String serviceInstanceId) {
303 return injectionHelper.getAaiClient()
304 .get(ServiceInstance.class, AAIUriFactory
305 .createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId).depth(Depth.TWO))
309 protected ServiceInstance getAAIServiceInstanceByIdAndCustomer(String globalCustomerId, String serviceType,
310 String serviceInstanceId) {
311 return injectionHelper.getAaiClient().get(ServiceInstance.class, AAIUriFactory
312 .createResourceUri(AAIObjectType.SERVICE_INSTANCE, globalCustomerId, serviceType, serviceInstanceId)
313 .depth(Depth.TWO)).orElse(null);
316 protected org.onap.aai.domain.yang.ServiceInstances getAAIServiceInstancesByName(String serviceInstanceName,
319 return injectionHelper.getAaiClient()
320 .get(org.onap.aai.domain.yang.ServiceInstances.class,
322 .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, customer.getGlobalCustomerId(),
323 customer.getServiceSubscription().getServiceType())
324 .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO))
326 logger.debug("No Service Instance matched by name");
331 public org.onap.aai.domain.yang.ServiceInstance getAAIServiceInstanceByName(String serviceInstanceName,
332 Customer customer) throws Exception {
333 org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = null;
334 org.onap.aai.domain.yang.ServiceInstances aaiServiceInstances = null;
335 aaiServiceInstances = getAAIServiceInstancesByName(serviceInstanceName, customer);
337 if (aaiServiceInstances == null) {
339 } else if (aaiServiceInstances.getServiceInstance().size() > 1) {
340 throw new Exception("Multiple Service Instances Returned");
342 aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0);
344 return aaiServiceInstance;
347 protected ServiceInstances getAAIServiceInstancesByName(String globalCustomerId, String serviceType,
348 String serviceInstanceName) {
350 return injectionHelper.getAaiClient()
351 .get(ServiceInstances.class,
353 .createResourceUri(AAIObjectPlurals.SERVICE_INSTANCE, globalCustomerId, serviceType)
354 .queryParam("service-instance-name", serviceInstanceName).depth(Depth.TWO))
356 logger.debug("No Service Instance matched by name");
361 public Optional<ServiceInstance> getAAIServiceInstanceByName(String globalCustomerId, String serviceType,
362 String serviceInstanceName) throws Exception {
363 ServiceInstance aaiServiceInstance = null;
364 ServiceInstances aaiServiceInstances = null;
365 aaiServiceInstances = getAAIServiceInstancesByName(globalCustomerId, serviceType, serviceInstanceName);
367 if (aaiServiceInstances == null) {
368 return Optional.empty();
369 } else if (aaiServiceInstances.getServiceInstance().size() > 1) {
370 throw new Exception("Multiple Service Instances Returned");
372 aaiServiceInstance = aaiServiceInstances.getServiceInstance().get(0);
374 return Optional.of(aaiServiceInstance);
377 public org.onap.so.db.catalog.beans.InstanceGroup getCatalogInstanceGroup(String modelUUID) {
378 return this.catalogDbClient.getInstanceGroupByModelUUID(modelUUID);
381 public List<CollectionResourceInstanceGroupCustomization> getCollectionResourceInstanceGroupCustomization(
382 String modelCustomizationUUID) {
383 return this.catalogDbClient
384 .getCollectionResourceInstanceGroupCustomizationByModelCustUUID(modelCustomizationUUID);
387 public AAIResultWrapper getAAIResourceDepthOne(AAIResourceUri aaiResourceUri) {
388 AAIResourceUri clonedUri = aaiResourceUri.clone();
389 return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.ONE));
392 public AAIResultWrapper getAAIResourceDepthTwo(AAIResourceUri aaiResourceUri) {
393 AAIResourceUri clonedUri = aaiResourceUri.clone();
394 return this.injectionHelper.getAaiClient().get(clonedUri.depth(Depth.TWO));
397 public Configuration getAAIConfiguration(String configurationId) {
398 return this.injectionHelper.getAaiClient()
399 .get(Configuration.class,
400 AAIUriFactory.createResourceUri(AAIObjectType.CONFIGURATION, configurationId).depth(Depth.ONE))
402 logger.debug("No Configuration matched by id");
407 public GenericVnf getAAIGenericVnf(String vnfId) {
409 return this.injectionHelper.getAaiClient()
410 .get(GenericVnf.class,
411 AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId).depth(Depth.ONE))
413 logger.debug("No Generic Vnf matched by id");
418 public VpnBinding getAAIVpnBinding(String vpnBindingId) {
420 return this.injectionHelper.getAaiClient()
421 .get(VpnBinding.class,
422 AAIUriFactory.createResourceUri(AAIObjectType.VPN_BINDING, vpnBindingId).depth(Depth.ONE))
424 logger.debug("No VpnBinding matched by id");
429 public VolumeGroup getAAIVolumeGroup(String cloudOwnerId, String cloudRegionId, String volumeGroupId) {
430 return this.injectionHelper.getAaiClient()
431 .get(VolumeGroup.class, AAIUriFactory
432 .createResourceUri(AAIObjectType.VOLUME_GROUP, cloudOwnerId, cloudRegionId, volumeGroupId)
435 logger.debug("No Generic Vnf matched by id");
440 public VfModule getAAIVfModule(String vnfId, String vfModuleId) {
441 return this.injectionHelper.getAaiClient()
443 AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE))
445 logger.debug("No Generic Vnf matched by id");
450 public L3Network getAAIL3Network(String networkId) {
452 return this.injectionHelper.getAaiClient()
453 .get(L3Network.class,
454 AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, networkId).depth(Depth.ONE))
456 logger.debug("No Generic Vnf matched by id");
462 public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId)
464 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId);
465 uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE);
466 Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri);
467 ServiceInstance serviceInstance = null;
468 if (!serviceInstances.isPresent()) {
469 logger.debug("No ServiceInstances were found");
470 return Optional.empty();
472 if (serviceInstances.get().getServiceInstance().isEmpty()) {
473 throw new NoServiceInstanceFoundException("No ServiceInstances Returned");
474 } else if (serviceInstances.get().getServiceInstance().size() > 1) {
475 throw new MultipleObjectsFoundException("Multiple ServiceInstances Returned");
477 serviceInstance = serviceInstances.get().getServiceInstance().get(0);
479 return Optional.of(serviceInstance);
483 public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName)
485 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
486 uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
487 Optional<L3Networks> networks = injectionHelper.getAaiClient().get(L3Networks.class, uri);
488 L3Network network = null;
489 if (!networks.isPresent()) {
490 logger.debug("No Networks matched by name");
491 return Optional.empty();
493 if (networks.get().getL3Network().size() > 1) {
494 throw new Exception("Multiple Networks Returned");
496 network = networks.get().getL3Network().get(0);
498 return Optional.of(network);
502 public Optional<GenericVnf> getRelatedVnfByNameFromServiceInstance(String serviceInstanceId, String vnfName)
504 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
505 uri.relatedTo(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName);
506 Optional<GenericVnfs> vnfs = injectionHelper.getAaiClient().get(GenericVnfs.class, uri);
507 GenericVnf vnf = null;
508 if (!vnfs.isPresent()) {
509 logger.debug("No Vnfs matched by name");
510 return Optional.empty();
512 if (vnfs.get().getGenericVnf().size() > 1) {
513 throw new Exception("Multiple Vnfs Returned");
515 vnf = vnfs.get().getGenericVnf().get(0);
517 return Optional.of(vnf);
521 public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVnf(String vnfId, String volumeGroupName)
523 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, vnfId);
524 uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName);
525 Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri);
526 VolumeGroup volumeGroup = null;
527 if (!volumeGroups.isPresent()) {
528 logger.debug("No VolumeGroups matched by name");
529 return Optional.empty();
531 if (volumeGroups.get().getVolumeGroup().size() > 1) {
532 throw new Exception("Multiple VolumeGroups Returned");
534 volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
536 return Optional.of(volumeGroup);
540 public Optional<VolumeGroup> getRelatedVolumeGroupByNameFromVfModule(String vnfId, String vfModuleId,
541 String volumeGroupName) throws Exception {
542 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId);
543 uri.relatedTo(AAIObjectPlurals.VOLUME_GROUP).queryParam("volume-group-name", volumeGroupName);
544 Optional<VolumeGroups> volumeGroups = injectionHelper.getAaiClient().get(VolumeGroups.class, uri);
545 VolumeGroup volumeGroup = null;
546 if (!volumeGroups.isPresent()) {
547 logger.debug("No VolumeGroups matched by name");
548 return Optional.empty();
550 if (volumeGroups.get().getVolumeGroup().size() > 1) {
551 throw new Exception("Multiple VolumeGroups Returned");
553 volumeGroup = volumeGroups.get().getVolumeGroup().get(0);
555 return Optional.of(volumeGroup);
559 public Optional<org.onap.aai.domain.yang.VpnBinding> getAICVpnBindingFromNetwork(
560 org.onap.aai.domain.yang.L3Network aaiLocalNetwork) {
561 AAIResultWrapper networkWrapper = new AAIResultWrapper(aaiLocalNetwork);
562 if (networkWrapper.getRelationships().isPresent()
563 && !networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).isEmpty()) {
564 return getAAIResourceDepthOne(
565 networkWrapper.getRelationships().get().getRelatedUris(AAIObjectType.VPN_BINDING).get(0))
566 .asBean(org.onap.aai.domain.yang.VpnBinding.class);
568 return Optional.empty();
571 public ServiceInstances getAAIServiceInstancesGloballyByName(String serviceInstanceName) {
573 return injectionHelper.getAaiClient()
574 .get(ServiceInstances.class, AAIUriFactory.createNodesUri(AAIObjectPlurals.SERVICE_INSTANCE)
575 .queryParam("service-instance-name", serviceInstanceName))
577 logger.debug("No Service Instance matched by name");
582 public boolean existsAAINetworksGloballyByName(String networkName) {
584 AAIResourceUri l3networkUri =
585 AAIUriFactory.createResourceUri(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName);
586 AAIResourcesClient aaiRC = injectionHelper.getAaiClient();
587 return aaiRC.exists(l3networkUri);
590 public boolean existsAAIVfModuleGloballyByName(String vfModuleName) {
591 AAIResourceUri vfModuleUri =
592 AAIUriFactory.createNodesUri(AAIObjectPlurals.VF_MODULE).queryParam("vf-module-name", vfModuleName);
593 return injectionHelper.getAaiClient().exists(vfModuleUri);
596 public boolean existsAAIConfigurationGloballyByName(String configurationName) {
597 AAIResourceUri configUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.CONFIGURATION)
598 .queryParam("configuration-name", configurationName);
599 return injectionHelper.getAaiClient().exists(configUri);
602 public boolean existsAAIVolumeGroupGloballyByName(String volumeGroupName) {
603 AAIResourceUri volumeGroupUri = AAIUriFactory.createNodesUri(AAIObjectPlurals.VOLUME_GROUP)
604 .queryParam("volume-group-name", volumeGroupName);
605 return injectionHelper.getAaiClient().exists(volumeGroupUri);
608 public GenericVnfs getAAIVnfsGloballyByName(String vnfName) {
610 return injectionHelper.getAaiClient()
611 .get(GenericVnfs.class,
612 AAIUriFactory.createNodesUri(AAIObjectPlurals.GENERIC_VNF).queryParam("vnf-name", vnfName))
614 logger.debug("No GenericVnfs matched by name");
619 public Optional<Configuration> getRelatedConfigurationByNameFromServiceInstance(String serviceInstanceId,
620 String configurationName) throws Exception {
621 AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId);
622 uri.relatedTo(AAIObjectPlurals.CONFIGURATION).queryParam("configuration-name", configurationName);
623 Optional<Configurations> configurations = injectionHelper.getAaiClient().get(Configurations.class, uri);
624 Configuration configuration = null;
625 if (!configurations.isPresent()) {
626 logger.debug("No Configurations matched by name");
627 return Optional.empty();
629 if (configurations.get().getConfiguration().size() > 1) {
630 throw new Exception("Multiple Configurations Returned");
632 configuration = configurations.get().getConfiguration().get(0);
634 return Optional.of(configuration);