diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-10 10:56:41 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-03-12 09:54:12 -0400 |
commit | f99e4a56e6b9ec09ece48a7b111c9ec286220264 (patch) | |
tree | aa6b58ca16295b592cb4343da52c3ac6465a0351 /bpmn/MSOCommonBPMN/src/main/java/org | |
parent | 308c3c2085864e04848e53a589773ff2e6e2c76a (diff) |
add instance group support to SO
add create support
add delete support
added naming service support
Change-Id: Iaf4f2bdae8ea55aca71d6e9b818a76e90db0b012
Issue-ID: SO-1616
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN/src/main/java/org')
9 files changed, 264 insertions, 16 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java index deb8c8e393..7a58f6db6b 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/InstanceGroup.java @@ -30,6 +30,7 @@ import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.onap.so.bpmn.servicedecomposition.ShallowCopy; import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup; +import org.onap.so.db.catalog.beans.OrchestrationStatus; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; @@ -48,10 +49,14 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> private String resourceVersion; @JsonProperty("instance-group-name") private String instanceGroupName; + @JsonProperty("orchestration-status") + private OrchestrationStatus orchestrationStatus = OrchestrationStatus.PRECREATED; @JsonProperty("model-info-instance-group") private ModelInfoInstanceGroup modelInfoInstanceGroup; @JsonProperty("instance-group-function") private String instanceGroupFunction; + @JsonProperty("vnfs") + private List<GenericVnf> vnfs = new ArrayList<>(); public String getId() { return id; @@ -76,6 +81,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> } public void setInstanceGroupName(String instanceGroupName) { this.instanceGroupName = instanceGroupName; + } + public OrchestrationStatus getOrchestrationStatus() { + return orchestrationStatus; + } + public void setOrchestrationStatus(OrchestrationStatus orchestrationStatus) { + this.orchestrationStatus = orchestrationStatus; } public ModelInfoInstanceGroup getModelInfoInstanceGroup() { return modelInfoInstanceGroup; @@ -89,6 +100,12 @@ public class InstanceGroup implements Serializable, ShallowCopy<InstanceGroup> public void setInstanceGroupFunction(String instanceGroupFunction) { this.instanceGroupFunction = instanceGroupFunction; } + public List<GenericVnf> getVnfs() { + return vnfs; + } + public void setVnfs(List<GenericVnf> vnfs) { + this.vnfs = vnfs; + } @Override public boolean equals(final Object other) { if (!(other instanceof InstanceGroup)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java index 259a988262..e2a8688395 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java @@ -79,6 +79,8 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc private SolutionInfo solutionInfo; @JsonProperty("model-info-service-instance") private ModelInfoServiceInstance modelInfoServiceInstance; + @JsonProperty("instance-groups") + private List<InstanceGroup> instanceGroups = new ArrayList<>(); public List<GenericVnf> getVnfs() { return vnfs; @@ -191,6 +193,12 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc public void setSolutionInfo(SolutionInfo solutionInfo) { this.solutionInfo = solutionInfo; } + public List<InstanceGroup> getInstanceGroups() { + return instanceGroups; + } + public void setInstanceGroups(List<InstanceGroup> instanceGroups) { + this.instanceGroups = instanceGroups; + } @Override public boolean equals(final Object other) { if (!(other instanceof ServiceInstance)) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java index 433315b2ed..15dfe85c1a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/entities/WorkflowResourceIds.java @@ -36,6 +36,7 @@ public class WorkflowResourceIds implements Serializable { private String vfModuleId; private String networkCollectionId; private String configurationId; + private String instanceGroupId; @Override public String toString() { @@ -100,4 +101,12 @@ public class WorkflowResourceIds implements Serializable { public void setConfigurationId(String configurationId) { this.configurationId = configurationId; } + + public String getInstanceGroupId() { + return instanceGroupId; + } + + public void setInstanceGroupId(String instanceGroupId) { + this.instanceGroupId = instanceGroupId; + } } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java index 77372bcd88..c80cd3d2a0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetup.java @@ -59,6 +59,7 @@ import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; import org.onap.so.bpmn.servicedecomposition.entities.WorkflowResourceIds; import org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext; import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAICommonObjectMapperProvider; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -225,6 +226,7 @@ public class BBInputSetup implements JavaDelegate { lookupKeyMap.put(ResourceKey.VF_MODULE_ID, workflowResourceIds.getVfModuleId()); lookupKeyMap.put(ResourceKey.VOLUME_GROUP_ID, workflowResourceIds.getVolumeGroupId()); lookupKeyMap.put(ResourceKey.CONFIGURATION_ID, workflowResourceIds.getConfigurationId()); + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, workflowResourceIds.getInstanceGroupId()); } protected GeneralBuildingBlock getGBBALaCarteNonService(ExecuteBuildingBlock executeBB, @@ -244,7 +246,7 @@ public class BBInputSetup implements JavaDelegate { ServiceInstance serviceInstance = this.getExistingServiceInstance(aaiServiceInstance); serviceInstance.setModelInfoServiceInstance(this.mapperLayer.mapCatalogServiceIntoServiceInstance(service)); this.populateObjectsOnAssignAndCreateFlows(requestDetails, service, bbName, serviceInstance, lookupKeyMap, - resourceId, vnfType); + resourceId, vnfType, executeBB.getBuildingBlock().getKey(), executeBB.getConfigurationResourceKeys()); return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, null); } else { logger.debug("Related Service Instance from AAI: {}", aaiServiceInstance); @@ -255,25 +257,59 @@ public class BBInputSetup implements JavaDelegate { protected GeneralBuildingBlock getGBBCM(ExecuteBuildingBlock executeBB, RequestDetails requestDetails, Map<ResourceKey, String> lookupKeyMap, String requestAction, - String resourceId) throws Exception { + String resourceId) throws Exception { ServiceInstance serviceInstance = new ServiceInstance(); String serviceInstanceId = lookupKeyMap.get(ResourceKey.SERVICE_INSTANCE_ID); - serviceInstance.setServiceInstanceId(serviceInstanceId); - + serviceInstance.setServiceInstanceId(serviceInstanceId); + Customer customer = new Customer(); List<GenericVnf> genericVnfs = serviceInstance.getVnfs(); String vnfId = lookupKeyMap.get(ResourceKey.GENERIC_VNF_ID); - org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); - - GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); - genericVnfs.add(genericVnf); - - return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, new Customer()); + if(vnfId != null) { + org.onap.aai.domain.yang.GenericVnf aaiGenericVnf = bbInputSetupUtils.getAAIGenericVnf(vnfId); + GenericVnf genericVnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiGenericVnf); + genericVnfs.add(genericVnf); + } + String instanceGroupId = lookupKeyMap.get(ResourceKey.INSTANCE_GROUP_ID); + if(instanceGroupId != null) { + org.onap.aai.domain.yang.InstanceGroup aaiInstancegroup = bbInputSetupUtils.getAAIInstanceGroup(instanceGroupId); + InstanceGroup instanceGroup = this.mapperLayer.mapAAIInstanceGroupIntoInstanceGroup(aaiInstancegroup); + instanceGroup.setOrchestrationStatus(OrchestrationStatus.INVENTORIED); + + if(serviceInstanceId == null) { + Optional<org.onap.aai.domain.yang.ServiceInstance> aaiServiceInstanceOpt = bbInputSetupUtils.getRelatedServiceInstanceFromInstanceGroup(instanceGroupId); + if(aaiServiceInstanceOpt.isPresent()) { + org.onap.aai.domain.yang.ServiceInstance aaiServiceInstance = aaiServiceInstanceOpt.get(); + serviceInstance = this.mapperLayer.mapAAIServiceInstanceIntoServiceInstance(aaiServiceInstance); + WorkflowResourceIds workflowResourceIds = executeBB.getWorkflowResourceIds(); + workflowResourceIds.setServiceInstanceId(serviceInstance.getServiceInstanceId()); + lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, workflowResourceIds.getServiceInstanceId()); + } else { + throw new NoServiceInstanceFoundException("Related ServiceInstance not found in A&AI."); + } + } + RelatedInstanceList[] relatedInstanceList = requestDetails.getRelatedInstanceList(); + if (relatedInstanceList != null) { + for (RelatedInstanceList relatedInstList : relatedInstanceList) { + RelatedInstance relatedInstance = relatedInstList.getRelatedInstance(); + if (relatedInstance.getModelInfo().getModelType().equals(ModelType.vnf)) { + org.onap.aai.domain.yang.GenericVnf aaiVnf = bbInputSetupUtils.getAAIGenericVnf(relatedInstance.getInstanceId()); + GenericVnf vnf = this.mapperLayer.mapAAIGenericVnfIntoGenericVnf(aaiVnf); + instanceGroup.getVnfs().add(vnf); + } + } + } + + serviceInstance.getInstanceGroups().add(instanceGroup); + customer.setServiceSubscription(new ServiceSubscription()); + } + return this.populateGBBWithSIAndAdditionalInfo(requestDetails, serviceInstance, executeBB, requestAction, customer); } protected void populateObjectsOnAssignAndCreateFlows(RequestDetails requestDetails, Service service, String bbName, - ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType) + ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String vnfType, + String configurationKey, ConfigurationResourceKeys configurationResourceKeys) throws Exception { ModelInfo modelInfo = requestDetails.getModelInfo(); String instanceName = requestDetails.getRequestInfo().getInstanceName(); @@ -296,13 +332,36 @@ public class BBInputSetup implements JavaDelegate { this.populateVolumeGroup(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, relatedInstanceList, instanceName, vnfType, null); } else if (modelType.equals(ModelType.vfModule)) { - lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); - this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, - relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + if(bbName.contains("Configuration")) { + ModelInfo configurationModelInfo = new ModelInfo(); + configurationModelInfo.setModelCustomizationUuid(configurationKey); + populateConfiguration(configurationModelInfo, service, bbName, serviceInstance, + lookupKeyMap, resourceId, instanceName, configurationResourceKeys); + } else { + lookupKeyMap.put(ResourceKey.VF_MODULE_ID, resourceId); + this.populateVfModule(modelInfo, service, bbName, serviceInstance, lookupKeyMap, resourceId, + relatedInstanceList, instanceName, null, requestDetails.getCloudConfiguration()); + } + } else if (modelType.equals(ModelType.instanceGroup)) { + lookupKeyMap.put(ResourceKey.INSTANCE_GROUP_ID, resourceId); + this.populateInstanceGroup(modelInfo, service, serviceInstance, resourceId, instanceName); } else { return; } } + + protected void populateInstanceGroup(ModelInfo modelInfo, Service service, ServiceInstance serviceInstance, String instanceGroupId, String instanceName) { + InstanceGroup instanceGroup = new InstanceGroup(); + instanceGroup.setId(instanceGroupId); + instanceGroup.setInstanceGroupName(instanceName); + mapCatalogInstanceGroup(instanceGroup, modelInfo, service); + serviceInstance.getInstanceGroups().add(instanceGroup); + } + + protected void mapCatalogInstanceGroup(InstanceGroup instanceGroup, ModelInfo modelInfo, Service service) { + // @TODO: this will populate the instanceGroup model info. + // Dependent on MSO-5821 653458 US - MSO - Enhance Catalog DB Schema & Adapter to support VNF Groups + } protected void populateConfiguration(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, String instanceName, ConfigurationResourceKeys configurationResourceKeys) { @@ -344,13 +403,19 @@ public class BBInputSetup implements JavaDelegate { if (configurationResourceCustomization != null && vnfVfmoduleCvnfcConfigurationCustomization != null) { configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(configurationResourceCustomization , vnfVfmoduleCvnfcConfigurationCustomization)); + } else { + logger.debug("for Fabric configuration mapping by VF MODULE CUST UUID: " + configurationResourceKeys.getVfModuleCustomizationUUID()); + vnfVfmoduleCvnfcConfigurationCustomization = findVnfVfmoduleCvnfcConfigurationCustomization(configurationResourceKeys.getVfModuleCustomizationUUID(), + configurationResourceKeys.getVnfResourceCustomizationUUID(), configurationResourceKeys.getCvnfcCustomizationUUID()); + if (vnfVfmoduleCvnfcConfigurationCustomization != null){ + configuration.setModelInfoConfiguration(this.mapperLayer.mapCatalogConfigurationToConfiguration(vnfVfmoduleCvnfcConfigurationCustomization)); + } } } protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vfModuleCustomizationUUID, String vnfResourceCustomizationUUID, String cvnfcCustomizationUUID, ConfigurationResourceCustomization configurationResourceCustomization) { - - if(configurationResourceCustomization.getConfigurationResource() != null) + if(configurationResourceCustomization != null && configurationResourceCustomization.getConfigurationResource() != null) for(VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization : configurationResourceCustomization.getConfigurationResource().getVnfVfmoduleCvnfcConfigurationCustomization()) { if(vnfVfmoduleCvnfcConfigurationCustomization.getVfModuleCustomization().getModelCustomizationUUID().equalsIgnoreCase(vfModuleCustomizationUUID) @@ -370,6 +435,13 @@ public class BBInputSetup implements JavaDelegate { } return null; } + + protected VnfVfmoduleCvnfcConfigurationCustomization findVnfVfmoduleCvnfcConfigurationCustomization(String vnfResourceCustomizationUUID, + String vfModuleCustomizationUUID, String cvnfcCustomizationUUID) { + return bbInputSetupUtils.getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(vnfResourceCustomizationUUID, + vfModuleCustomizationUUID, cvnfcCustomizationUUID); + + } protected void populateVfModule(ModelInfo modelInfo, Service service, String bbName, ServiceInstance serviceInstance, Map<ResourceKey, String> lookupKeyMap, String resourceId, diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index a838ffdbae..fac2e9b8c3 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -496,6 +496,16 @@ public class BBInputSetupMapperLayer { modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName()); return modelInfoConfiguration; } + + protected ModelInfoConfiguration mapCatalogConfigurationToConfiguration( + VnfVfmoduleCvnfcConfigurationCustomization vnfVfmoduleCvnfcConfigurationCustomization) { + ModelInfoConfiguration modelInfoConfiguration = new ModelInfoConfiguration(); + modelInfoConfiguration.setModelVersionId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelUUID()); + modelInfoConfiguration.setModelCustomizationId(vnfVfmoduleCvnfcConfigurationCustomization.getModelCustomizationUUID()); + modelInfoConfiguration.setModelInvariantId(vnfVfmoduleCvnfcConfigurationCustomization.getConfigurationResource().getModelInvariantUUID()); + modelInfoConfiguration.setPolicyName(vnfVfmoduleCvnfcConfigurationCustomization.getPolicyName()); + return modelInfoConfiguration; + } public NetworkResourceCustomization mapCollectionNetworkResourceCustToNetworkResourceCust( CollectionNetworkResourceCustomization collectionNetworkResourceCust) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java index 486164e75f..a71c38f127 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtils.java @@ -42,6 +42,8 @@ import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.client.aai.AAIObjectPlurals; import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; @@ -53,6 +55,8 @@ import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.NetworkCollectionResourceCustomization; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VfModuleCustomization; +import org.onap.so.db.catalog.beans.VnfVfmoduleCvnfcConfigurationCustomization; import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; @@ -137,6 +141,16 @@ public class BBInputSetupUtils { return catalogDbClient.getNetworkCollectionResourceCustomizationByID(collectionCustomizationId); } + public VfModuleCustomization getVfModuleCustomizationByModelCuztomizationUUID(String modelCustomizationUUID) { + return catalogDbClient.getVfModuleCustomizationByModelCuztomizationUUID(modelCustomizationUUID); + } + + public VnfVfmoduleCvnfcConfigurationCustomization getVnfVfmoduleCvnfcConfigurationCustomizationByActionAndIsALaCarteAndRequestScopeAndCloudOwner(String vnfCustomizationUuid, + String vfModuleCustomizationUuid, String cvnfcCustomizationUuid) { + return catalogDbClient.getVnfVfmoduleCvnfcConfigurationCustomizationByVnfCustomizationUuidAndVfModuleCustomizationUuidAndCvnfcCustomizationUuid(vnfCustomizationUuid, + vfModuleCustomizationUuid, cvnfcCustomizationUuid); + } + public List<VnfcInstanceGroupCustomization> getVnfcInstanceGroups(String modelCustomizationUUID) { return catalogDbClient.getVnfcInstanceGroupsByVnfResourceCust(modelCustomizationUUID); } @@ -346,6 +360,26 @@ public class BBInputSetupUtils { } + public Optional<ServiceInstance> getRelatedServiceInstanceFromInstanceGroup(String instanceGroupId) throws Exception { + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.INSTANCE_GROUP, instanceGroupId); + uri.relatedTo(AAIObjectPlurals.SERVICE_INSTANCE); + Optional<ServiceInstances> serviceInstances = injectionHelper.getAaiClient().get(ServiceInstances.class, uri); + ServiceInstance serviceInstance = null; + if (!serviceInstances.isPresent()) { + logger.debug("No ServiceInstances were found"); + return Optional.empty(); + } else { + if (serviceInstances.get().getServiceInstance().isEmpty()) { + throw new NoServiceInstanceFoundException("No ServiceInstances Returned"); + } else if (serviceInstances.get().getServiceInstance().size() > 1) { + throw new MultipleObjectsFoundException("Multiple ServiceInstances Returned"); + } else { + serviceInstance = serviceInstances.get().getServiceInstance().get(0); + } + return Optional.of(serviceInstance); + } + } + public Optional<L3Network> getRelatedNetworkByNameFromServiceInstance(String serviceInstanceId, String networkName) throws Exception{ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE, serviceInstanceId); uri.relatedTo(AAIObjectPlurals.L3_NETWORK).queryParam("network-name", networkName); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java index 79f4a07974..d2d321f8f4 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/ExtractPojosForBB.java @@ -90,6 +90,10 @@ public class ExtractPojosForBB { serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); result = lookupObjectInList(serviceInstance.getVpnBondingLinks(),value); break; + case INSTANCE_GROUP_ID: + serviceInstance = extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID, execution.getLookupMap().get(ResourceKey.SERVICE_INSTANCE_ID)); + result = lookupObjectInList(serviceInstance.getInstanceGroups(), value); + break; default: throw new BBObjectNotFoundException(key, value); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java new file mode 100644 index 0000000000..d63f98b6ce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/MultipleObjectsFoundException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +public class MultipleObjectsFoundException extends Exception { + + private static final long serialVersionUID = -5045275644426587447L; + + public MultipleObjectsFoundException() { + super(); + } + + public MultipleObjectsFoundException(String message) { + super(message); + } + + public MultipleObjectsFoundException(String message, Throwable cause) { + super(message, cause); + } + + public MultipleObjectsFoundException(Throwable cause) { + super(cause); + } + + public MultipleObjectsFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java new file mode 100644 index 0000000000..2ef1a80cce --- /dev/null +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/exceptions/NoServiceInstanceFoundException.java @@ -0,0 +1,47 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.servicedecomposition.tasks.exceptions; + +public class NoServiceInstanceFoundException extends Exception { + + private static final long serialVersionUID = 3270499954054029908L; + + public NoServiceInstanceFoundException() { + super(); + } + + public NoServiceInstanceFoundException(String message) { + super(message); + } + + public NoServiceInstanceFoundException(String message, Throwable cause) { + super(message, cause); + } + + public NoServiceInstanceFoundException(Throwable cause) { + super(cause); + } + + public NoServiceInstanceFoundException(String message, Throwable cause, boolean enableSuppression, + boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} |