diff options
19 files changed, 564 insertions, 50 deletions
diff --git a/adapters/mso-adapter-utils/pom.xml b/adapters/mso-adapter-utils/pom.xml index b8dec73f80..a121d2d89b 100644 --- a/adapters/mso-adapter-utils/pom.xml +++ b/adapters/mso-adapter-utils/pom.xml @@ -152,5 +152,13 @@ <artifactId>mso-requests-db</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-cache</artifactId> + </dependency> + <dependency> + <groupId>com.github.ben-manes.caffeine</groupId> + <artifactId>caffeine</artifactId> + </dependency> </dependencies> </project> diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java new file mode 100644 index 0000000000..2f7d19ff1d --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaCacheConfig.java @@ -0,0 +1,42 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.openstack.utils; + +import java.util.concurrent.TimeUnit; +import org.springframework.cache.CacheManager; +import org.springframework.cache.caffeine.CaffeineCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import com.github.benmanes.caffeine.cache.Caffeine; + +@Configuration +public class NovaCacheConfig { + + @Bean + public CacheManager cacheManager() { + CaffeineCacheManager cacheManager = new CaffeineCacheManager("novaClient"); + cacheManager.setCaffeine(caffeineCacheBuilder()); + return cacheManager; + } + + private Caffeine<Object, Object> caffeineCacheBuilder() { + return Caffeine.newBuilder().initialCapacity(100).maximumSize(500).expireAfterWrite(90, TimeUnit.MINUTES); + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java new file mode 100644 index 0000000000..c5eeb34157 --- /dev/null +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClient.java @@ -0,0 +1,52 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2020 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.openstack.utils; + +import org.onap.so.cloud.authentication.KeystoneAuthHolder; +import org.onap.so.openstack.exceptions.MsoException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Component; +import com.woorea.openstack.nova.Nova; + + +@Component +public class NovaClient extends MsoCommonUtils { + + private static final Logger logger = LoggerFactory.getLogger(NovaClient.class); + + /** + * Gets the Nova client + * + * @param cloudSiteId id of the cloud site + * @param tenantId the tenant id + * @return the Nova client + * @throws MsoException the mso exception + */ + @Cacheable(value = "novaClient") + public Nova getNovaClient(String cloudSiteId, String tenantId) throws MsoException { + KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "compute"); + Nova novaClient = new Nova(keystone.getServiceUrl()); + novaClient.token(keystone.getId()); + return novaClient; + } +} diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java index 5d28eaaf71..dc276d9b8f 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/NovaClientImpl.java @@ -21,11 +21,11 @@ package org.onap.so.openstack.utils; import java.io.IOException; -import org.onap.so.cloud.authentication.KeystoneAuthHolder; import org.onap.so.openstack.exceptions.MsoCloudSiteNotFound; import org.onap.so.openstack.exceptions.MsoException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; @@ -50,21 +50,8 @@ public class NovaClientImpl extends MsoCommonUtils { /** The logger. */ private static final Logger logger = LoggerFactory.getLogger(NovaClientImpl.class); - /** - * Gets the Nova client - * - * @param cloudSiteId id of the cloud site - * @param tenantId the tenant id - * @return the Nova client - * @throws MsoException the mso exception - */ - private Nova getNovaClient(String cloudSiteId, String tenantId) throws MsoException { - KeystoneAuthHolder keystone = getKeystoneAuthHolder(cloudSiteId, tenantId, "compute"); - Nova novaClient = new Nova(keystone.getServiceUrl()); - novaClient.token(keystone.getId()); - return novaClient; - } - + @Autowired + private NovaClient client; /** * Query Networks @@ -83,7 +70,7 @@ public class NovaClientImpl extends MsoCommonUtils { public Flavors queryFlavors(String cloudSiteId, String tenantId, int limit, String marker) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Flavors> request = novaClient.flavors().list(false).queryParam("limit", limit).queryParam("marker", marker); return executeAndRecordOpenstackRequest(request, false); @@ -108,8 +95,7 @@ public class NovaClientImpl extends MsoCommonUtils { public Flavor queryFlavorById(String cloudSiteId, String tenantId, String id) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); - novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Flavor> request = novaClient.flavors().show(id); return executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -133,7 +119,7 @@ public class NovaClientImpl extends MsoCommonUtils { public HostAggregates queryHostAggregates(String cloudSiteId, String tenantId, int limit, String marker) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<HostAggregates> request = novaClient.aggregates().list().queryParam("limit", limit).queryParam("marker", marker); return executeAndRecordOpenstackRequest(request, false); @@ -158,7 +144,7 @@ public class NovaClientImpl extends MsoCommonUtils { public HostAggregate queryHostAggregateById(String cloudSiteId, String tenantId, String id) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<HostAggregate> request = novaClient.aggregates().showAggregate(id); return executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -182,7 +168,7 @@ public class NovaClientImpl extends MsoCommonUtils { public QuotaSet queryOSQuotaSet(String cloudSiteId, String tenantId) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<QuotaSet> request = novaClient.quotaSets().showQuota(tenantId); return executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -204,7 +190,7 @@ public class NovaClientImpl extends MsoCommonUtils { public void deleteKeyPair(String cloudSiteId, String tenantId, String keyPairName) throws MsoCloudSiteNotFound, NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Void> request = novaClient.keyPairs().delete(keyPairName); executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -215,7 +201,7 @@ public class NovaClientImpl extends MsoCommonUtils { public Server queryServerById(String cloudSiteId, String tenantId, String id) throws NovaClientException { try { - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Server> request = novaClient.servers().show(id); return executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -230,7 +216,7 @@ public class NovaClientImpl extends MsoCommonUtils { JsonNode actualObj = mapper.readTree(request); Entity<JsonNode> openstackEntity = new Entity<>(actualObj, "application/json"); CharSequence actionPath = "/servers/" + id + "/action"; - Nova novaClient = getNovaClient(cloudSiteId, tenantId); + Nova novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Void> OSRequest = new OpenStackRequest<>(novaClient, HttpMethod.POST, actionPath, openstackEntity, Void.class); executeAndRecordOpenstackRequest(OSRequest, false); @@ -240,7 +226,7 @@ public class NovaClientImpl extends MsoCommonUtils { throws NovaClientException { Nova novaClient; try { - novaClient = getNovaClient(cloudSiteId, tenantId); + novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Void> request = novaClient.servers().attachVolume(serverId, volumeAttachment.getVolumeId(), volumeAttachment.getDevice()); executeAndRecordOpenstackRequest(request, false); @@ -254,7 +240,7 @@ public class NovaClientImpl extends MsoCommonUtils { throws NovaClientException { Nova novaClient; try { - novaClient = getNovaClient(cloudSiteId, tenantId); + novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Void> request = novaClient.servers().detachVolume(serverId, volumeId); executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { @@ -266,7 +252,7 @@ public class NovaClientImpl extends MsoCommonUtils { public Hypervisors getHypervisorDetails(String cloudSiteId, String tenantId) throws NovaClientException { Nova novaClient; try { - novaClient = getNovaClient(cloudSiteId, tenantId); + novaClient = client.getNovaClient(cloudSiteId, tenantId); OpenStackRequest<Hypervisors> request = novaClient.hypervisors().listDetail(); return executeAndRecordOpenstackRequest(request, false); } catch (MsoException e) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java index c2874fe23d..478b65c349 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VfModuleCDSRequestProvider.java @@ -104,9 +104,10 @@ public class VfModuleCDSRequestProvider implements CDSRequestProvider { final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock(); List<Map<String, Object>> userParamsFromRequest = buildingBlock.getRequestContext().getRequestParameters().getUserParams(); - - configureInstanceParamsForVfModule.populateInstanceParams(vfModuleObject, userParamsFromRequest, - modelCustomizationUuidForVnf, modelCustomizationUuidForVfModule); + if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) { + configureInstanceParamsForVfModule.populateInstanceParams(vfModuleObject, userParamsFromRequest, + modelCustomizationUuidForVnf, modelCustomizationUuidForVfModule); + } } catch (Exception e) { throw new PayloadGenerationException("Failed to buildPropertyObject for VF-Module", e); } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java index 7425d09721..6251eb6fad 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/VnfCDSRequestProvider.java @@ -93,9 +93,10 @@ public class VnfCDSRequestProvider implements CDSRequestProvider { final GeneralBuildingBlock buildingBlock = execution.getGeneralBuildingBlock(); List<Map<String, Object>> userParamsFromRequest = buildingBlock.getRequestContext().getRequestParameters().getUserParams(); - - configureInstanceParamsForVnf.populateInstanceParams(vnfObject, userParamsFromRequest, - modelCustomizationUuid); + if (userParamsFromRequest != null && userParamsFromRequest.size() != 0) { + configureInstanceParamsForVnf.populateInstanceParams(vnfObject, userParamsFromRequest, + modelCustomizationUuid); + } } catch (Exception e) { throw new PayloadGenerationException("Failed to buildPropertyObjectForVnf", e); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java index 9c3ce60400..06defaa84c 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/AbstractVnfCDSRequestProviderTest.java @@ -44,6 +44,7 @@ import org.onap.so.serviceinstancebeans.*; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.LinkedList; import java.util.Map; @RunWith(MockitoJUnitRunner.Silent.class) @@ -202,4 +203,10 @@ public abstract class AbstractVnfCDSRequestProviderTest { executeBuildingBlock.setBuildingBlock(buildingBlock); buildingBlockExecution.setVariable(BUILDING_BLOCK, executeBuildingBlock); } + + protected void setScopeAndActionWithoutUserParams(String scope, String action) { + buildingBlockExecution.getGeneralBuildingBlock().getRequestContext().getRequestParameters() + .setUserParams(new LinkedList<>()); + setScopeAndAction(scope, action); + } } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java index 2ca09d9ab3..f224ebf21e 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/cds/VfModuleCDSRequestProviderTest.java @@ -25,8 +25,14 @@ import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; +import org.mockito.Spy; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.client.exception.PayloadGenerationException; +import org.onap.so.serviceinstancebeans.Service; +import org.springframework.beans.factory.annotation.Autowired; +import java.util.List; +import java.util.Map; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; @@ -34,11 +40,19 @@ import static org.mockito.Mockito.*; public class VfModuleCDSRequestProviderTest extends AbstractVnfCDSRequestProviderTest { + @Autowired + private ObjectMapper objectMapper; + + @Spy + protected ExtractServiceFromUserParameters extractServiceFromUserParameters; + + @Spy + @InjectMocks + protected ConfigureInstanceParamsForVfModule configureInstanceParamsForVfModule; + @InjectMocks private VfModuleCDSRequestProvider vfModuleCDSRequestProvider; - @Mock - protected ConfigureInstanceParamsForVfModule configureInstanceParamsForVfModule; @Test public void testRequestPayloadForConfigDeployVfModule() throws Exception { @@ -52,7 +66,8 @@ public class VfModuleCDSRequestProviderTest extends AbstractVnfCDSRequestProvide ResourceKey.GENERIC_VNF_ID); doReturn(createVfModule()).when(extractPojosForBB).extractByKey(buildingBlockExecution, ResourceKey.VF_MODULE_ID); - doNothing().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(), + doReturn(getUserParams()).when(extractServiceFromUserParameters).getServiceFromRequestUserParams(anyList()); + doCallRealMethod().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(), anyString()); // when @@ -76,5 +91,39 @@ public class VfModuleCDSRequestProviderTest extends AbstractVnfCDSRequestProvide assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID); } + @Test + public void testRequestPayloadForConfigDeployVfModuleWithoutUserParams() throws Exception { + // given + setScopeAndActionWithoutUserParams(VF_SCOPE, DEPLOY_ACTION); + ServiceInstance serviceInstance = createServiceInstance(); + + doReturn(serviceInstance).when(extractPojosForBB).extractByKey(buildingBlockExecution, + ResourceKey.SERVICE_INSTANCE_ID); + doReturn(createGenericVnf()).when(extractPojosForBB).extractByKey(buildingBlockExecution, + ResourceKey.GENERIC_VNF_ID); + doReturn(createVfModule()).when(extractPojosForBB).extractByKey(buildingBlockExecution, + ResourceKey.VF_MODULE_ID); + doReturn(getUserParams()).when(extractServiceFromUserParameters).getServiceFromRequestUserParams(anyList()); + doCallRealMethod().when(configureInstanceParamsForVfModule).populateInstanceParams(any(), any(), anyString(), + anyString()); + + vfModuleCDSRequestProvider.setExecutionObject(buildingBlockExecution); + String payload = vfModuleCDSRequestProvider.buildRequestPayload(DEPLOY_ACTION).get(); + // verify + ObjectMapper mapper = new ObjectMapper(); + JsonNode payloadJson = mapper.readTree(payload); + JsonNode requestNode = payloadJson.findValue("configDeploy-request"); + JsonNode propertiesNode = payloadJson.findValue("configDeploy-properties"); + + assertNotNull(payload); + assertTrue(verfiyJsonFromString(payload)); + assertThat(requestNode.get("resolution-key").asText()).isEqualTo(VF_MODULE_NAME); + assertThat(propertiesNode.get("service-instance-id").asText()).isEqualTo(SERVICE_INSTANCE_ID); + assertThat(propertiesNode.get("vf-module-id").asText()).isEqualTo(VF_MODULE_ID); + assertThat(propertiesNode.get("vf-module-name").asText()).isEqualTo(VF_MODULE_NAME); + assertThat(propertiesNode.get("vf-module-customization-uuid").asText()).isEqualTo(VF_MODULE_CUSTOMIZATION_UUID); + assertThat(propertiesNode.get("service-model-uuid").asText()).isEqualTo(SERVICE_MODEL_UUID); + assertThat(propertiesNode.get("vnf-id").asText()).isEqualTo(GENERIC_VNF_ID); + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy index 89c3ab7c8b..12cd0dde0b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CreateCommunicationService.groovy @@ -293,11 +293,11 @@ class CreateCommunicationService extends AbstractServiceTaskProcessor { //2. profile info - Integer expDataRateDL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL") - Integer expDataRateUL = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL") - Integer latency = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.latency") - Integer maxNumberOfUEs = jsonUtil.getJsonIntValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs") - String uEMobilityLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.uemobilityLevel") + Integer expDataRateDL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateDL") as Integer + Integer expDataRateUL = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.expDataRateUL") as Integer + Integer latency = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.latency") as Integer + Integer maxNumberOfUEs = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.maxNumberofUEs") as Integer + String uEMobilityLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.uEMobilityLevel") String resourceSharingLevel = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.resourceSharingLevel") String coverageArea = jsonUtil.getJsonValue(uuiRequest, "service.parameters.requestInputs.coverageAreaList") diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java index b8562ba6b5..7184bba377 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/orchestration/AAIPnfResources.java @@ -22,6 +22,9 @@ package org.onap.so.client.orchestration; import com.google.common.base.Strings; import java.util.Optional; +import org.onap.aai.domain.yang.RelatedToProperty; +import org.onap.aai.domain.yang.Relationship; +import org.onap.aai.domain.yang.RelationshipData; import org.onap.so.bpmn.common.InjectionHelper; import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -68,8 +71,15 @@ public class AAIPnfResources { public void checkIfPnfExistsInAaiAndCanBeUsed(String pnfName) throws Exception { Optional<org.onap.aai.domain.yang.Pnf> pnfFromAai = injectionHelper.getAaiClient() .get(org.onap.aai.domain.yang.Pnf.class, AAIUriFactory.createResourceUri(AAIObjectType.PNF, pnfName)); - if (pnfFromAai.isPresent() && isOrchestrationStatusSet(pnfFromAai.get())) { - checkOrchestrationStatusOfExistingPnf(pnfFromAai.get()); + if (pnfFromAai.isPresent()) { + checkIfPnfCanBeUsed(pnfFromAai.get()); + } + } + + private void checkIfPnfCanBeUsed(org.onap.aai.domain.yang.Pnf pnfFromAai) throws Exception { + isRelatedToService(pnfFromAai); + if (isOrchestrationStatusSet(pnfFromAai)) { + checkOrchestrationStatusOfExistingPnf(pnfFromAai); } } @@ -92,7 +102,39 @@ public class AAIPnfResources { pnfFromAai.getPnfName(), pnfFromAai.getOrchestrationStatus()); logger.error(errorMessage); throw new Exception(errorMessage); + } + } + private void isRelatedToService(org.onap.aai.domain.yang.Pnf pnfFromAai) throws Exception { + if (pnfFromAai.getRelationshipList() != null) { + for (Relationship relationship : pnfFromAai.getRelationshipList().getRelationship()) { + if (relationship.getRelatedTo().equals("service-instance")) { + String errorMessage = prepareRelationErrorMessage(pnfFromAai, relationship); + logger.error(errorMessage); + throw new Exception(errorMessage); + } + } + } + } + + private String prepareRelationErrorMessage(org.onap.aai.domain.yang.Pnf pnfFromAai, Relationship relationship) { + String serviceInstanceName = ""; + String serviceInstanceId = ""; + + for (RelationshipData relationshipData : relationship.getRelationshipData()) { + if (relationshipData.getRelationshipKey().equals("service-instance.service-instance-id")) { + serviceInstanceId = relationshipData.getRelationshipValue(); + break; + } + } + for (RelatedToProperty relatedToProperty : relationship.getRelatedToProperty()) { + if (relatedToProperty.getPropertyKey().equals("service-instance.service-instance-name")) { + serviceInstanceName = relatedToProperty.getPropertyValue(); + break; + } } + return String.format( + "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s", + pnfFromAai.getPnfName(), pnfFromAai.getOrchestrationStatus(), serviceInstanceName, serviceInstanceId); } } diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java index 15c4b48d66..5e9b4c7592 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/client/orchestration/AAIPnfResourcesTest.java @@ -29,7 +29,10 @@ import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import java.io.File; +import java.io.IOException; import java.util.Optional; +import com.fasterxml.jackson.databind.ObjectMapper; import joptsimple.internal.Strings; import org.junit.Before; import org.junit.Test; @@ -151,6 +154,27 @@ public class AAIPnfResourcesTest extends TestDataSetup { } } + @Test + public void existingPnfInAaiIsRelatedToService() throws IOException { + // given + final String relatedTo = "service-instance"; + final String serviceInstanceId = "service-instance-id"; + final String path = "src/test/resources/__files/BuildingBlocks/aaiPnf.json"; + org.onap.aai.domain.yang.Pnf pnfFromAai = + new ObjectMapper().readValue(new File(path), org.onap.aai.domain.yang.Pnf.class); + when(injectionHelperMock.getAaiClient().get(org.onap.aai.domain.yang.Pnf.class, + AAIUriFactory.createResourceUri(AAIObjectType.PNF, PNF_NAME))).thenReturn(Optional.of(pnfFromAai)); + // when + try { + testedObject.checkIfPnfExistsInAaiAndCanBeUsed(PNF_NAME); + } catch (Exception e) { + // then + assertThat(e.getMessage()).isEqualTo(String.format( + "Pnf with name %s exist with orchestration status %s and is related to %s service with certain service-instance-id: %s", + PNF_NAME, OrchestrationStatus.ACTIVE, relatedTo, serviceInstanceId)); + } + } + private org.onap.aai.domain.yang.Pnf createPnf(String orchestrationStatus) { org.onap.aai.domain.yang.Pnf pnfFromAai = new org.onap.aai.domain.yang.Pnf(); pnfFromAai.setPnfName(PNF_NAME); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json new file mode 100644 index 0000000000..c4600d94a0 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/aaiPnf.json @@ -0,0 +1,31 @@ +{ + "pnfName": "pnfTest", + "pnfId": "pnfId", + "orchestrationStatus": "Active", + "resourceVersion": "resourceVersion", + "relationshipList": { + "relationship": [ + { + "relatedTo": "service-instance", + "relationshipLabel": "org.onap.relationships.inventory.ComposedOf", + "relatedLink": "relatedLink", + "relationshipData": [ + { + "relationshipKey": "relationshipKey", + "relationshipValue": "relationshipValue" + }, + { + "relationshipKey": "service-instance.service-instance-id", + "relationshipValue": "service-instance-id" + } + ], + "relatedToProperty": [ + { + "propertyKey": "service-instance.service-instance-name", + "propertyValue": "service-instance" + } + ] + } + ] + } +} diff --git a/docs/release-notes.rst b/docs/release-notes.rst index d052eb72fe..130fc6449a 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -9,6 +9,238 @@ Service Orchestrator Release Notes The SO provides the highest level of service orchestration in the ONAP architecture. +Version: 1.6.1 +----------------------- + +:Release Date: + +**Docker Images** + +**Dockers released for SO:** + + - onap/so/api-handler-infra + - onap/so/bpmn-infra + - onap/so/catalog-db-adapter + - onap/so/openstack-adapter + - onap/so/request-db-adapter + - onap/so/sdc-controller + - onap/so/sdnc-adapter + - onap/so/so-monitoring + - onap/so/vfc-adapter + - onap/so/vnfm-adapter + - onap/so/ve-vnfm-adapter + - onap/so/nssmf-adapter + +**Release Purpose** + +The main goal of the Frankfurt release was to: + - ETSI alignment improvements - CMCC, Ericcson, Huawei, Samsung, Verizon, ZTE. + - SOL005 adaptation + - SOL003 adaptation + - SOL002 adaptation + - SOL004 Package support by ETSI Catalog Manager and SOL003 Adapter + - PNF orchestration Enhancements - Ericcson, Huawei, Nokia + - PNF software upgrade + - PNF PNP enhancement + - CCVPN Enhancement + - MDONS support - Fujitsu + - Eline support - Bell, Huawei, CMCC + - 5G Slicing - ATT, Amdocs, CMCC, Huawei, Wipro + - CDS integration enhancement - ATT, Bell, Tech Mahindra + - (SO Multi Cloud plugin improvements - Intel) + - HPA - Intel (Testing effort) + +**New Features** + +Features Being considered for F release (As per the resource availability): + ++---------------------------------------------------------------------+ +|SOL005 Adapter supports communication security | ++---------------------------------------------------------------------+ +|SOL005 Adapter supports NS LCM | ++---------------------------------------------------------------------+ +|Multi-domain Optical Network Service Orchestration Support in SO | ++---------------------------------------------------------------------+ +|SOL002 Adapter - supports EM-triggered VNF/VNFC Management | ++---------------------------------------------------------------------+ +|SO Catalog Management Support | ++---------------------------------------------------------------------+ +|Frankfurt release planning milestone | ++---------------------------------------------------------------------+ +|Initiate/ Terminate slice service; Activate/deactivate Slice service | ++---------------------------------------------------------------------+ +|SO support of Network Slicing Demo in Frankfurt | ++---------------------------------------------------------------------+ +|ETSI Alignment Support - SOL003 Adapter Enhancement for Frankfurt | ++---------------------------------------------------------------------+ +|AAI update for VNF improvements | ++---------------------------------------------------------------------+ +|SO Multicloud plugin to Multicloud improvements | ++---------------------------------------------------------------------+ +|SO to CDS Enhancement for Generic Implementation | ++---------------------------------------------------------------------+ +|S3P improvement Requirements | ++---------------------------------------------------------------------+ +|Upgrade the APIs to Policy | ++---------------------------------------------------------------------+ + +**Epics** +- [`SO-2524 <https://jira.onap.org/browse/SO-2524>`__\ ] - Functionality and API Freeze +- [`SO-2519 <https://jira.onap.org/browse/SO-2519>`__\ ] - TSC must have for Frankfurt +- [`SO-2432 <https://jira.onap.org/browse/SO-2432>`__\ ] - Multi-domain Optical Network Service Orchestration Support in SO +- [`SO-2427 <https://jira.onap.org/browse/SO-2427>`__\ ] - SOL002 Adapter - supports EM-triggered VNF/VNFC Management +- [`SO-2404 <https://jira.onap.org/browse/SO-2404>`__\ ] - SO Catalog Management Support +- [`SO-2383 <https://jira.onap.org/browse/SO-2383>`__\ ] - Frankfurt release planning milestone +- [`SO-2368 <https://jira.onap.org/browse/SO-2368>`__\ ] - Support 5G slice orchestration +- [`SO-2281 <https://jira.onap.org/browse/SO-2281>`__\ ] - SO support of Network Slicing Demo in Frankfurt +- [`SO-2156 <https://jira.onap.org/browse/SO-2156>`__\ ] - ETSI Alignment Support - SOL003 Adapter Enhancement for Frankfurt +- [`SO-2087 <https://jira.onap.org/browse/SO-2087>`__\ ] - AAI update for VNF improvements +- [`SO-2086 <https://jira.onap.org/browse/SO-2086>`__\ ] - SO Multicloud plugin to Multicloud improvements +- [`SO-2046 <https://jira.onap.org/browse/SO-2046>`__\ ] - support Java 11 upgrade +- [`SO-1579 <https://jira.onap.org/browse/SO-1579>`__\ ] - SO supports ETSI SOL005 Alignment of its interfaces with NFVO + +**Stories** +- [`SO-2774 <https://jira.onap.org/browse/SO-2774>`__\ ] - simplify fabric into add/delete steps +- [`SO-2772 <https://jira.onap.org/browse/SO-2772>`__\ ] - Add validations to prevent out of order deletes +- [`SO-2770 <https://jira.onap.org/browse/SO-2770>`__\ ] - Added support for volume group request to +- [`SO-2768 <https://jira.onap.org/browse/SO-2768>`__\ ] - mso vnf configuration update composite flow +- [`SO-2767 <https://jira.onap.org/browse/SO-2767>`__\ ] - convert openstack to external tasks +- [`SO-2763 <https://jira.onap.org/browse/SO-2763>`__\ ] - Ingest and Process Service Function +- [`SO-2762 <https://jira.onap.org/browse/SO-2762>`__\ ] - Update Subprocess to use COMPLETE status +- [`SO-2761 <https://jira.onap.org/browse/SO-2761>`__\ ] - Use setVariablesLocal for setting task variables +- [`SO-2753 <https://jira.onap.org/browse/SO-2753>`__\ ] - mso to add support for creating the cloud region +- [`SO-2744 <https://jira.onap.org/browse/SO-2744>`__\ ] - reworked dsl client code to check for outputs +- [`SO-2743 <https://jira.onap.org/browse/SO-2743>`__\ ] - split single and plural graph inventory uris +- [`SO-2735 <https://jira.onap.org/browse/SO-2735>`__\ ] - update poms to be compatible with eclipse IDE +- [`SO-2726 <https://jira.onap.org/browse/SO-2726>`__\ ] - Added check to prevent camunda history lookup on +- [`SO-2717 <https://jira.onap.org/browse/SO-2717>`__\ ] - Added git attributes to convert line endings to +- [`SO-2715 <https://jira.onap.org/browse/SO-2715>`__\ ] - Enhance startTime filtering for OrchestrationRequests +- [`SO-2713 <https://jira.onap.org/browse/SO-2713>`__\ ] - create custom spring aop annotation for logging +- [`SO-2700 <https://jira.onap.org/browse/SO-2700>`__\ ] - mso to store the heat template timeout minutes and +- [`SO-2697 <https://jira.onap.org/browse/SO-2697>`__\ ] - Added simpleNotTaskInfo format modifier +- [`SO-2683 <https://jira.onap.org/browse/SO-2683>`__\ ] - Enhance CSIT for ETSI package management +- [`SO-2680 <https://jira.onap.org/browse/SO-2680>`__\ ] - enhance openstack library +- [`SO-2675 <https://jira.onap.org/browse/SO-2675>`__\ ] - Rename migration script +- [`SO-2674 <https://jira.onap.org/browse/SO-2674>`__\ ] - mso to add tenant name and product family name to +- [`SO-2662 <https://jira.onap.org/browse/SO-2662>`__\ ] - Updated pom to release version of logging library +- [`SO-2660 <https://jira.onap.org/browse/SO-2660>`__\ ] - SO API extension to retrieve all PNF workflow +- [`SO-2657 <https://jira.onap.org/browse/SO-2657>`__\ ] - mso to add support for creating the cloud region +- [`SO-2655 <https://jira.onap.org/browse/SO-2655>`__\ ] - added in graceful shutdown to spring boot +- [`SO-2653 <https://jira.onap.org/browse/SO-2653>`__\ ] - Initial commit to check client alive +- [`SO-2651 <https://jira.onap.org/browse/SO-2651>`__\ ] - Remove unused param +- [`SO-2647 <https://jira.onap.org/browse/SO-2647>`__\ ] - Create ConfigDeployPnfBB +- [`SO-2646 <https://jira.onap.org/browse/SO-2646>`__\ ] - Create ConfigAssignPnfBB +- [`SO-2644 <https://jira.onap.org/browse/SO-2644>`__\ ] - WaitForPnfReadyBB - set orchestration status to Register and then Registered +- [`SO-2642 <https://jira.onap.org/browse/SO-2642>`__\ ] - AssignPnfBB - set orchestration status to Assigned after successful assignment +- [`SO-2641 <https://jira.onap.org/browse/SO-2641>`__\ ] - Include AssignPnfBB, WaitForPnfReadyBB, ActivatePnfBB in Service-Macro-Create flow +- [`SO-2640 <https://jira.onap.org/browse/SO-2640>`__\ ] - AssignPnfBB - store model related PNF parameters in AAI +- [`SO-2637 <https://jira.onap.org/browse/SO-2637>`__\ ] - modifications to create network to add lob +- [`SO-2623 <https://jira.onap.org/browse/SO-2623>`__\ ] - Remove Valet from openstack adapter +- [`SO-2620 <https://jira.onap.org/browse/SO-2620>`__\ ] - Include stack Status Reason when rollback is +- [`SO-2616 <https://jira.onap.org/browse/SO-2616>`__\ ] - add manual handling to rainy day handling for bbs +- [`SO-2615 <https://jira.onap.org/browse/SO-2615>`__\ ] - convert bbinputsetup populate methods to use +- [`SO-2614 <https://jira.onap.org/browse/SO-2614>`__\ ] - Add Neutron Port and Nova Server to Proxy +- [`SO-2607 <https://jira.onap.org/browse/SO-2607>`__\ ] - Create ActivatePnfBB +- [`SO-2606 <https://jira.onap.org/browse/SO-2606>`__\ ] - Create WaitForPnfReadyBB +- [`SO-2605 <https://jira.onap.org/browse/SO-2605>`__\ ] - AssignPnfBB should make a link in AAI between PNF and service instance +- [`SO-2603 <https://jira.onap.org/browse/SO-2603>`__\ ] - Replaced annotation with RepositoryRestResource +- [`SO-2601 <https://jira.onap.org/browse/SO-2601>`__\ ] - Use the timeout from the heat template instead of +- [`SO-2597 <https://jira.onap.org/browse/SO-2597>`__\ ] - removed powermock dependecy and added it to +- [`SO-2596 <https://jira.onap.org/browse/SO-2596>`__\ ] - 1911 create appc adapter micro service +- [`SO-2591 <https://jira.onap.org/browse/SO-2591>`__\ ] - mso stores vnf application id from macro create +- [`SO-2590 <https://jira.onap.org/browse/SO-2590>`__\ ] - configurable aaf user expires +- [`SO-2584 <https://jira.onap.org/browse/SO-2584>`__\ ] - consolidated security configuration +- [`SO-2577 <https://jira.onap.org/browse/SO-2577>`__\ ] - Support for volume groups on replace VF Module. +- [`SO-2572 <https://jira.onap.org/browse/SO-2572>`__\ ] - Remove references to AIC +- [`SO-2571 <https://jira.onap.org/browse/SO-2571>`__\ ] - update so to use 1.6.3 snapshot from the logging +- [`SO-2570 <https://jira.onap.org/browse/SO-2570>`__\ ] - Add simple query format, to limit response content +- [`SO-2568 <https://jira.onap.org/browse/SO-2568>`__\ ] - Create AssignPnfBB +- [`SO-2566 <https://jira.onap.org/browse/SO-2566>`__\ ] - Updated simulator test files +- [`SO-2565 <https://jira.onap.org/browse/SO-2565>`__\ ] - Include service-instance-id and +- [`SO-2564 <https://jira.onap.org/browse/SO-2564>`__\ ] - Refactor WorkflowAction.valiadteResourceIdInAAI - +- [`SO-2561 <https://jira.onap.org/browse/SO-2561>`__\ ] - add application id support to so +- [`SO-2555 <https://jira.onap.org/browse/SO-2555>`__\ ] - refactor fallouthandler +- [`SO-2548 <https://jira.onap.org/browse/SO-2548>`__\ ] - Terminate Slice Instance +- [`SO-2547 <https://jira.onap.org/browse/SO-2547>`__\ ] - Deactivate Slice Instance +- [`SO-2546 <https://jira.onap.org/browse/SO-2546>`__\ ] - Activate Slice Instance +- [`SO-2545 <https://jira.onap.org/browse/SO-2545>`__\ ] - Instantiate Slice Service +- [`SO-2540 <https://jira.onap.org/browse/SO-2540>`__\ ] - SO API extension to retrieve PNF workflow +- [`SO-2523 <https://jira.onap.org/browse/SO-2523>`__\ ] - vnf and vf module replace requests to make +- [`SO-2516 <https://jira.onap.org/browse/SO-2516>`__\ ] - remove unused columns infra active requests +- [`SO-2515 <https://jira.onap.org/browse/SO-2515>`__\ ] - Create E2E workflow for software upgrade (PNF) +- [`SO-2514 <https://jira.onap.org/browse/SO-2514>`__\ ] - Create dispatcher class for PNF Software upgrade. +- [`SO-2511 <https://jira.onap.org/browse/SO-2511>`__\ ] - Updated to include getEntity extract +- [`SO-2510 <https://jira.onap.org/browse/SO-2510>`__\ ] - Updated to use getEntity API for ServiceProxy +- [`SO-2509 <https://jira.onap.org/browse/SO-2509>`__\ ] - Updated logging library version to 1.6.2-SNAPSHOT +- [`SO-2499 <https://jira.onap.org/browse/SO-2499>`__\ ] - Skip requestId lookup when uri is +- [`SO-2493 <https://jira.onap.org/browse/SO-2493>`__\ ] - update so to use most recent update of logging +- [`SO-2490 <https://jira.onap.org/browse/SO-2490>`__\ ] - add new query for requestdb +- [`SO-2488 <https://jira.onap.org/browse/SO-2488>`__\ ] - refactor repeated duplicate check code to RequestHandlerUtils +- [`SO-2463 <https://jira.onap.org/browse/SO-2463>`__\ ] - Add so-simulator project +- [`SO-2460 <https://jira.onap.org/browse/SO-2460>`__\ ] - MDONS: L1 Service Termination +- [`SO-2459 <https://jira.onap.org/browse/SO-2459>`__\ ] - MDONS: L1 Service Creation +- [`SO-2444 <https://jira.onap.org/browse/SO-2444>`__\ ] - update scheduled tasks to have mdc setup +- [`SO-2442 <https://jira.onap.org/browse/SO-2442>`__\ ] - Add column to catalog db +- [`SO-2439 <https://jira.onap.org/browse/SO-2439>`__\ ] - Authentication and Authorization support between SOL005 Adapter and NFVO +- [`SO-2438 <https://jira.onap.org/browse/SO-2438>`__\ ] - Secured communication support between SOL005 Adapter and NFVO +- [`SO-2428 <https://jira.onap.org/browse/SO-2428>`__\ ] - SOL002 Adapter subscribes and consumes VNF LCM notifications from VNFM (Frankfurt) +- [`SO-2426 <https://jira.onap.org/browse/SO-2426>`__\ ] - feature request to so to save name on deletes +- [`SO-2412 <https://jira.onap.org/browse/SO-2412>`__\ ] - SOL003 Adapter Package Management by leveraging ONAP-ETSI Catalog Manager +- [`SO-2406 <https://jira.onap.org/browse/SO-2406>`__\ ] - Enhance SO SDC Controller to invoke ONAP-ETSI Catalog APIs +- [`SO-2399 <https://jira.onap.org/browse/SO-2399>`__\ ] - Update PNF instance attributes in AAI during instantiation (PnP) workflow +- [`SO-2398 <https://jira.onap.org/browse/SO-2398>`__\ ] - Converted tests to use LATEST +- [`SO-2372 <https://jira.onap.org/browse/SO-2372>`__\ ] - Validate SO Multicloud plugin adapter with Macro call / gr-api +- [`SO-2339 <https://jira.onap.org/browse/SO-2339>`__\ ] - Refactor SO/DMaaP client - move BBS functionality to a workflow Task +- [`SO-2316 <https://jira.onap.org/browse/SO-2316>`__\ ] - SO to support CDS Actor for ScaleoutBB +- [`SO-2312 <https://jira.onap.org/browse/SO-2312>`__\ ] - SO to CDS Enhancement for Generic Implementation +- [`SO-2293 <https://jira.onap.org/browse/SO-2293>`__\ ] - vf-module details in SDNC-Directives to pass through GR-API with v2 +- [`SO-2208 <https://jira.onap.org/browse/SO-2208>`__\ ] - Load proper instanceParams of the object being processed to CDS properties +- [`SO-2165 <https://jira.onap.org/browse/SO-2165>`__\ ] - Add Config deploy to service-macro-delete and CDS transition directives for vnf +- [`SO-2091 <https://jira.onap.org/browse/SO-2091>`__\ ] - Create new SO building blocks - activateNESw +- [`SO-2090 <https://jira.onap.org/browse/SO-2090>`__\ ] - SO-CDS PNF Building Blocks back-end impl +- [`SO-2089 <https://jira.onap.org/browse/SO-2089>`__\ ] - Create a new SO building block - preCheck +- [`SO-2073 <https://jira.onap.org/browse/SO-2073>`__\ ] - Create a new SO building blocks - postCheck +- [`SO-2072 <https://jira.onap.org/browse/SO-2072>`__\ ] - Support PNF CM workflow execution +- [`SO-2071 <https://jira.onap.org/browse/SO-2071>`__\ ] - SO API extension to support PNF Upgrade +- [`SO-2070 <https://jira.onap.org/browse/SO-2070>`__\ ] - a generic decision points for API +- [`SO-2063 <https://jira.onap.org/browse/SO-2063>`__\ ] - AAF integration +- [`SO-1657 <https://jira.onap.org/browse/SO-1657>`__\ ] - Automated testing for the SO Monitoring component +- [`SO-1635 <https://jira.onap.org/browse/SO-1635>`__\ ] - Preload using user_param (without UI changes) +- [`SO-1420 <https://jira.onap.org/browse/SO-1420>`__\ ] - SO should be able to decompose a composite service +- [`SO-1277 <https://jira.onap.org/browse/SO-1277>`__\ ] - Adapt PNF PnP flow to support updated AAI PNF model +- [`SO-994 <https://jira.onap.org/browse/SO-994>`__\ ] - Sonar Issue: Replace duplicate strings with Constants in ServiceInstances +- [`SO-929 <https://jira.onap.org/browse/SO-929>`__\ ] - Removing Sonar reported Vulnerability in AAIObjectMapper file +- [`SO-2 <https://jira.onap.org/browse/SO-2>`__\ ] - MSO should mount vnfs in appc that appc has to manage + +**Key Issues Addressed** + + +**Security Notes** + + Quick Links: + + - `SO project page <https://wiki.onap.org/display/DW/Service+Orchestrator+Project>`_ + - `Passing Badge information for SO <https://bestpractices.coreinfrastructure.org/en/projects/1702>`_ + + +**Known Issues** + N/A + +OJSI Issues + + N/A + +**Upgrade Notes** + + N/A + +**Deprecation Notes** + + N/A + +**Other** + + N/A Version: 5.0.1 ----------------------- diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java index f75897dda1..89c5cbed9b 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/NetworkDeleteValidator.java @@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; - +@Component public class NetworkDeleteValidator implements RequestValidator { @Autowired diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java index 1dea57ad9c..50938e6826 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/RequestValidator.java @@ -24,7 +24,9 @@ import java.util.Map; import java.util.Optional; import org.onap.so.apihandlerinfra.Actions; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; +import org.springframework.stereotype.Component; +@Component public interface RequestValidator { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java index 61f757ba64..843d94ce6c 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/ServiceInstanceDeleteValidator.java @@ -8,8 +8,10 @@ import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component public class ServiceInstanceDeleteValidator implements RequestValidator { @Autowired @@ -17,8 +19,17 @@ public class ServiceInstanceDeleteValidator implements RequestValidator { @Override public boolean shouldRunFor(String requestUri, ServiceInstancesRequest request, Actions action) { + boolean isALaCarte = false; + if (request.getRequestDetails() != null && request.getRequestDetails().getRequestParameters() != null) { + if (request.getRequestDetails().getRequestParameters().getALaCarte() == null) { + isALaCarte = false; + } else { + isALaCarte = request.getRequestDetails().getRequestParameters().getALaCarte(); + } + + } return Pattern.compile("[Vv][5-8]/serviceInstances/[^/]+").matcher(requestUri).matches() - && action.equals(Action.deleteInstance); + && action.equals(Action.deleteInstance) && isALaCarte; } @Override diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java index d54e60d153..37e3f0cb2e 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VnfDeleteValidator.java @@ -8,8 +8,9 @@ import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; - +@Component public class VnfDeleteValidator implements RequestValidator { @Autowired diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java index f010d47f70..e3598af31d 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/validators/VolumeGroupDeleteValidator.java @@ -8,7 +8,9 @@ import org.onap.so.apihandlerinfra.Actions; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +@Component public class VolumeGroupDeleteValidator implements RequestValidator { @Autowired diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java index c334d522b6..f461df3720 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/infra/rest/validator/ServiceInstanceDeleteValidatorTest.java @@ -5,6 +5,7 @@ import static org.mockito.Mockito.when; import java.util.HashMap; import java.util.Map; import java.util.Optional; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -14,6 +15,8 @@ import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.apihandlerinfra.Action; import org.onap.so.apihandlerinfra.infra.rest.AAIDataRetrieval; import org.onap.so.apihandlerinfra.infra.rest.validators.ServiceInstanceDeleteValidator; +import org.onap.so.serviceinstancebeans.RequestDetails; +import org.onap.so.serviceinstancebeans.RequestParameters; import org.onap.so.serviceinstancebeans.ServiceInstancesRequest; @@ -30,22 +33,41 @@ public class ServiceInstanceDeleteValidatorTest { private Map<String, String> instanceIdMap = new HashMap<>(); + private ServiceInstancesRequest serviceInstancesRequest; + + @Before + public void before() { + serviceInstancesRequest = new ServiceInstancesRequest(); + RequestDetails requestDetails = new RequestDetails(); + RequestParameters requestParameters = new RequestParameters(); + requestParameters.setaLaCarte(true); + requestDetails.setRequestParameters(requestParameters); + serviceInstancesRequest.setRequestDetails(requestDetails); + } + @Test public void validateURIMatchTest() { - assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", new ServiceInstancesRequest(), + assertEquals(true, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest, Action.deleteInstance)); } @Test public void validateURINotMatchTest() { assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/vnfs/asdfasdf", - new ServiceInstancesRequest(), Action.deleteInstance)); + serviceInstancesRequest, Action.deleteInstance)); } @Test public void validateURINotMatch2Test() { assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf/update", - new ServiceInstancesRequest(), Action.deleteInstance)); + serviceInstancesRequest, Action.deleteInstance)); + } + + @Test + public void validateNotALaCarteTest() { + serviceInstancesRequest.getRequestDetails().getRequestParameters().setaLaCarte(false); + assertEquals(false, serviceValidator.shouldRunFor("v8/serviceInstances/uasdfasdf", serviceInstancesRequest, + Action.deleteInstance)); } @Test |