diff options
13 files changed, 290 insertions, 127 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql index e27ec2ef27..9e3deaf612 100644 --- a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/R__MacroData.sql @@ -915,3 +915,6 @@ VALUES ('VNFUnsetInMaintFlagActivity','*','*','*','*','Manual','Abort','*', '*'), ('VNFUnsetClosedLoopDisabledActivity','*','*','*','*','Manual','Abort','*', '*'); +UPDATE vnf_recipe +SET ORCHESTRATION_URI = '/mso/async/services/VnfInPlaceUpdate' +WHERE NF_ROLE = 'GR-API-DEFAULT' AND ACTION = 'inPlaceSoftwareUpdate'; diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 727cdccff5..f18279d5d3 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -41,6 +41,7 @@ import java.util.List; import java.util.Map; import java.util.stream.Collectors; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import org.onap.aai.domain.yang.Flavor; import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.PInterface; @@ -75,11 +76,12 @@ public class AaiHelper { List<Relationship> relationships = relationshipList.getRelationship(); // vserver to pserver relationship - Relationship pserverRelationship = - buildRelationship(HeatBridgeConstants.AAI_PSERVER, ImmutableMap.<String, String>builder() - .put(HeatBridgeConstants.AAI_PSERVER_HOSTNAME, server.getHypervisorHostname()).build()); - relationships.add(pserverRelationship); - + if (!StringUtils.isEmpty(server.getHypervisorHostname())) { + Relationship pserverRelationship = + buildRelationship(HeatBridgeConstants.AAI_PSERVER, ImmutableMap.<String, String>builder() + .put(HeatBridgeConstants.AAI_PSERVER_HOSTNAME, server.getHypervisorHostname()).build()); + relationships.add(pserverRelationship); + } // vserver to vf-module relationship Relationship vfModuleRelationship = buildRelationship(HeatBridgeConstants.AAI_VF_MODULE, ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_GENERIC_VNF_ID, genericVnfId) @@ -96,11 +98,13 @@ public class AaiHelper { } // vserver to flavor relationship - Relationship flavorRel = buildRelationship(HeatBridgeConstants.AAI_FLAVOR, - ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner) - .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId) - .put(HeatBridgeConstants.AAI_FLAVOR_ID, server.getFlavor().getId()).build()); - relationships.add(flavorRel); + if (server.getFlavor() != null) { + Relationship flavorRel = buildRelationship(HeatBridgeConstants.AAI_FLAVOR, + ImmutableMap.<String, String>builder().put(HeatBridgeConstants.AAI_CLOUD_OWNER, cloudOwner) + .put(HeatBridgeConstants.AAI_CLOUD_REGION_ID, cloudRegionId) + .put(HeatBridgeConstants.AAI_FLAVOR_ID, server.getFlavor().getId()).build()); + relationships.add(flavorRel); + } return relationshipList; } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index e2f5531280..988e78b9a3 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -72,6 +72,7 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.heatbridge.constants.HeatBridgeConstants; +import org.onap.so.heatbridge.helpers.AaiHelper; import org.onap.so.heatbridge.openstack.api.OpenstackClient; import org.onap.so.heatbridge.openstack.api.OpenstackClientException; import org.openstack4j.model.compute.Flavor; @@ -87,7 +88,6 @@ import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; - @RunWith(MockitoJUnitRunner.class) public class HeatBridgeImplTest { @@ -228,7 +228,7 @@ public class HeatBridgeImplTest { Server server2 = mock(Server.class); when(server2.getId()).thenReturn("test-server2-id"); - when(server2.getHypervisorHostname()).thenReturn("test-hypervisor"); + when(server2.getHypervisorHostname()).thenReturn(""); when(server2.getName()).thenReturn("test-server2-name"); when(server2.getStatus()).thenReturn(Status.ACTIVE); when(server2.getLinks()).thenReturn(new ArrayList<>()); @@ -245,6 +245,49 @@ public class HeatBridgeImplTest { when(server2.getFlavor()).thenReturn(flavor); when(flavor.getId()).thenReturn("test-flavor-id"); + // Act + heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers); + + // Assert + ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class); + verify(transaction, times(2)).create(captor.capture(), any(Vserver.class)); + + List<AAIResourceUri> uris = captor.getAllValues(); + assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, + server1.getId()), uris.get(0)); + assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, + server2.getId()), uris.get(1)); + + } + + @Test + public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException { + // Arrange + Server server1 = mock(Server.class); + + when(server1.getId()).thenReturn("test-server1-id"); + when(server1.getHypervisorHostname()).thenReturn(""); + when(server1.getName()).thenReturn("test-server1-name"); + when(server1.getStatus()).thenReturn(Status.ACTIVE); + when(server1.getLinks()).thenReturn(new ArrayList<>()); + + Server server2 = mock(Server.class); + when(server2.getId()).thenReturn("test-server2-id"); + when(server2.getName()).thenReturn("test-server2-name"); + when(server2.getStatus()).thenReturn(Status.ACTIVE); + when(server2.getLinks()).thenReturn(new ArrayList<>()); + + List<Server> servers = Arrays.asList(server1, server2); + + Image image = mock(Image.class); + when(server1.getImage()).thenReturn(image); + when(server2.getImage()).thenReturn(image); + when(image.getId()).thenReturn("test-image-id"); + + Flavor flavor = mock(Flavor.class); + when(server1.getFlavor()).thenReturn(flavor); + when(server2.getFlavor()).thenReturn(flavor); + when(flavor.getId()).thenReturn("test-flavor-id"); // Act heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers); @@ -258,7 +301,34 @@ public class HeatBridgeImplTest { server1.getId()), uris.get(0)); assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID, server2.getId()), uris.get(1)); + } + + @Test + public void testCreateRelationships() throws HeatBridgeException { + AaiHelper aaiHelper = new AaiHelper(); + // Arrange + Server server1 = mock(Server.class); + + when(server1.getHypervisorHostname()).thenReturn("test-hypervisor"); + + // HypervisorHostname is not set + Server server2 = mock(Server.class); + + // HypervisorHostname is empty string + Server server3 = mock(Server.class); + when(server3.getHypervisorHostname()).thenReturn(""); + + org.onap.aai.domain.yang.RelationshipList relList = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID, + "test-genericVnf-id", "test-vfModule-id", server1); + assertEquals(2, relList.getRelationship().size()); + + org.onap.aai.domain.yang.RelationshipList relList2 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, + REGION_ID, "test-genericVnf-id", "test-vfModule-id", server2); + assertEquals(1, relList2.getRelationship().size()); + org.onap.aai.domain.yang.RelationshipList relList3 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, + REGION_ID, "test-genericVnf-id", "test-vfModule-id", server3); + assertEquals(1, relList3.getRelationship().size()); } @Test diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java index f25d4b440a..5f0cab3da8 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java @@ -52,7 +52,7 @@ public class OofInfraUtils { getCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/")) .orElse(new CloudSite()); if (!cloudSite.getId().equals(getCloudsite.getId())) { - client.postCloudSite(cloudSite); + client.postOofHomingCloudSite(cloudSite); logger.debug("Did not findd cloudsite : {}", cloudSite.getId()); logger.debug("Will create cloudSite: {}", cloudSite.toString()); } else { 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 4b35371594..8ec780479a 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 @@ -105,9 +105,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/CheckServiceProcessStatus.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy index 3233bfff61..17b37bfd86 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/CheckServiceProcessStatus.groovy @@ -128,8 +128,8 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * check service status through request operation id, update operation status - */ - def preCheckServiceStatusReq = { DelegateExecution execution -> + */ + void preCheckServiceStatusReq(DelegateExecution execution) { logger.trace(Prefix + "preCheckServiceStatusReq Start") String serviceInstanceId = execution.getVariable("serviceInstanceId") as String String operationId = execution.getVariable("operationId") as String @@ -142,7 +142,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { * handle service status, if service status is finished or error, set the service status * @param execution */ - def handlerServiceStatusResp = { DelegateExecution execution -> + void handlerServiceStatusResp(DelegateExecution execution) { logger.trace(Prefix + "handlerServiceStatusResp Start") String msg try { @@ -203,7 +203,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def timeWaitDelay = { DelegateExecution execution -> + void timeWaitDelay(DelegateExecution execution) { Long startTime = execution.getVariable("startTime") as Long Long timeOut = execution.getVariable("timeOut") as Long @@ -221,7 +221,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerTimeOut = { DelegateExecution execution -> + private handlerTimeOut(DelegateExecution execution) { Map<String, Object> paramMap = execution.getVariable("timeOutParamMap") as Map @@ -229,7 +229,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerSuccess = { DelegateExecution execution, String result -> + private handlerSuccess(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("successParamMap") as Map @@ -237,7 +237,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerError = { DelegateExecution execution, String result -> + private handlerError(DelegateExecution execution, String result) { Map<String, Object> paramMap = execution.getVariable("errorParamMap") as Map @@ -245,7 +245,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - private handlerProcess = { DelegateExecution execution, String result, def paramMap, def status, def msg -> + private handlerProcess(DelegateExecution execution, String result, def paramMap, def status, def msg) { if (paramMap != null) { for (Map.Entry<String, Object> entry : paramMap.entrySet()) { @@ -260,7 +260,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { if (isBlank(execution.getVariable("operationContent") as String)) { - String operationContent = execution.getVariable("processServiceType") + " " + + String operationContent = execution.getVariable("processServiceType") + " " + execution.getVariable("operationType") + " operation finished " + msg execution.setVariable("operationContent", operationContent) } @@ -275,7 +275,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing success finished */ - private isSuccessCompleted = { DelegateExecution execution, String result -> + private Boolean isSuccessCompleted(DelegateExecution execution, String result) { //successConditions: processing end success conditions List<String> successConditions = execution.getVariable("successConditions") as List @@ -291,7 +291,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { /** * judge if the service processing error finished */ - private isErrorCompleted = { DelegateExecution execution, String result -> + private Boolean isErrorCompleted(DelegateExecution execution, String result) { //errorConditions: processing end error conditions List<String> errorConditions = execution.getVariable("errorConditions") as List @@ -304,7 +304,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { } - def preUpdateOperationProgress = { DelegateExecution execution -> + void preUpdateOperationProgress(DelegateExecution execution) { logger.trace(Prefix + "prepareUpdateOperationStatus Start") def progress = execution.getVariable("progress") as Integer @@ -314,7 +314,7 @@ class CheckServiceProcessStatus extends AbstractServiceTaskProcessor { def resProgress = (initProgress + (endProgress - initProgress) / 100 * progress) as Integer def operationType = execution.getVariable("operationType") - def operationContent = execution.getVariable("processServiceType") + " " + + def operationContent = execution.getVariable("processServiceType") + " " + operationType + " operation processing " + resProgress // update status creating 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 680bcca837..2fd17d84d5 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-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy index 4ab6647a38..00d986c68d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateNSSI.groovy @@ -324,6 +324,7 @@ class DoAllocateNSSI extends org.onap.so.bpmn.common.scripts.AbstractServiceTask sliceProfile.setExpDataRate(0) sliceProfile.setTrafficDensity(0) sliceProfile.setConnDensity(0) + sliceProfile.setSNssai(sliceProfileMap.get("sNSSAI").toString()) sliceProfile.setExpDataRateUL(Integer.parseInt(sliceProfileMap.get("expDataRateUL").toString())) sliceProfile.setExpDataRateDL(Integer.parseInt(sliceProfileMap.get("expDataRateDL").toString())) sliceProfile.setActivityFactor(Integer.parseInt(sliceProfileMap.get("activityFactor").toString())) diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy index a4b360276d..8eb367eea9 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateSliceServiceOption.groovy @@ -136,7 +136,6 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ String OOFResponse = httpResponse.readEntity(String.class) logger.debug("NSI OOFResponse is: " + OOFResponse) execution.setVariable("OOFResponse", OOFResponse) - int index = 0 //This needs to be changed to derive a value when we add policy to decide the solution options. Map OOFResponseObject = new JsonSlurper().parseText(OOFResponse) Map solutions = OOFResponseObject.get("solutions") @@ -145,41 +144,12 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ Boolean isSharable = resourceSharingLevel.equals("shared") if (solutions != null) { - if (isSharable) { + if (isSharable && hasSharedNSIsolutions(solutions)) { //sharedNSISolution processSharedNSISolutions(solutions, execution) - } else { - //TODO test OOF - if (solutions.containsKey("newNSISolutions")) { - List<Map> newNSISolutions = solutions.get("newNSISolutions") - List<Map> NSSImap = new ArrayList<>() - if (newNSISolutions != null && newNSISolutions.size() > 0) { - NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map> - } - for (Map nssi : NSSImap) { - def nssiSolution = nssi.get("NSSISolution") as Map<String, ?> - String nssiName = nssiSolution.getOrDefault("NSSIName", "") - String nssiId = nssiSolution.getOrDefault("NSSIId", "") - String domain = nssiSolution.getOrDefault("domainName", "").toString().toUpperCase() - switch (domain) { - case "AN": - sliceTaskParams.setAnSuggestNssiId(nssiId) - sliceTaskParams.setAnSuggestNssiName(nssiName) - break - case "CN": - sliceTaskParams.setCnSuggestNssiId(nssiId) - sliceTaskParams.setCnSuggestNssiName(nssiName) - break - case "TN": - sliceTaskParams.setTnSuggestNssiId(nssiId) - sliceTaskParams.setTnSuggestNssiName(nssiName) - break - default: - break - } - } - //TODO sliceProfile - } + } + else if(solutions.containsKey("newNSISolutions")) { + processNewNSISolutions(solutions, execution) } } execution.setVariable("sliceTaskParams", sliceTaskParams) @@ -188,17 +158,45 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ logger.debug("*** Completed options Call to OOF ***") } - private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { - if (!solutions.containsKey("sharedNSISolutions")) - { - logger.error("OOF don't return sharedNSISolutions") - return + private boolean hasSharedNSIsolutions( Map solutions){ + if(solutions.containsKey("sharedNSISolutions")){ + List sharedNSIsolutions = solutions.get("sharedNSISolutions") + if (sharedNSIsolutions != null && !sharedNSIsolutions.isEmpty()) { + return true + } + } + return false + } + + private void processNewNSISolutions(Map solutions, DelegateExecution execution) { + int index = 0 + List<Map> newNSISolutions = solutions.get("newNSISolutions") + List<Map> NSSImap = new ArrayList<>() + if (newNSISolutions != null && newNSISolutions.size() > 0) { + NSSImap = newNSISolutions.get(index).get("NSSISolutions") as List<Map> + for (Map nssi : NSSImap) { + Map oofSliceProfile = nssi.get("sliceProfile") + String domain = oofSliceProfile.getOrDefault("domainType","") + logger.debug("OOF newNSISolutions SliceProfile: " +oofSliceProfile.toString()+",domain:${domain}") + if(null != domain){ + //TODO +// def nssiSolution = nssi.get("NSSISolution") as Map<String, ?> +// String nssiName = nssiSolution.getOrDefault("NSSIName", "") +// String nssiId = nssiSolution.getOrDefault("NSSIId", "") +// saveNSSIId(nssi, sliceTaskParams) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + + } + } } + } + + private void processSharedNSISolutions(Map solutions, DelegateExecution execution) { String nsiName, nsiInstanceId, nssiId, nssiName - Map sliceProfile SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") - Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions")).get(0) + Map sharedNSIsolution = ((List) solutions.get("sharedNSISolutions"))?.get(0) nsiInstanceId = sharedNSIsolution.getOrDefault("NSIId", "") nsiName = sharedNSIsolution.getOrDefault("NSIName", "") sliceTaskParams.setSuggestNsiId(nsiInstanceId) @@ -206,77 +204,102 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ //Temporary modification List NSSIs = sharedNSIsolution.get("NSSIs") - if(NSSIs.size()==1){ - Map nssi = NSSIs.get(0) + for(Map nssi : NSSIs){ + Map oofSliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) + String domain = oofSliceProfile.getOrDefault("domainType","") nssiId = nssi.getOrDefault("NSSIId","") nssiName = nssi.getOrDefault("NSSIName","") - sliceTaskParams.setCnSuggestNssiId(nssiId) - //TODO Need update after OOF return camel key and domainType - sliceProfile = ((List)nssi.get("sliceProfile"))?.get(0) - sliceTaskParams.setCnSuggestNssiName(nssiName) -// execution.setVariable("sliceProfileCn", sliceProfile) -// sliceTaskParams.setSliceProfileCn(sliceProfile) + saveNSSIId(domain, nssiId, nssiName,execution) + Map<String, Object> sliceProfile = getSliceProfile(domain, execution, oofSliceProfile) + saveSliceProfile(execution, domain, sliceProfile) + logger.debug("OOF sharedNSISolution SliceProfile:"+oofSliceProfile.toString()+",domain:${domain}") + logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") } - logger.debug("OOF sharedNSISolution nsiInstanceId:${nsiInstanceId}, nsiName:${nsiName}, nssiId:${nssiId}, nssiName:${nssiName}") - logger.debug("OOF SliceProfile:"+sliceProfile.toString()) } - void parseServiceProfile(DelegateExecution execution) { + private void parseServiceProfile(DelegateExecution execution) { logger.debug("Start parseServiceProfile") String serviceType = execution.getVariable("serviceType") Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") // set sliceProfile for three domains if(!sliceTaskParams.getSliceProfileAn()){ - Map<String, Object> sliceProfileAn = getSliceProfile(serviceType, "AN", serviceProfile) - execution.setVariable("sliceProfileAn", sliceProfileAn) - sliceTaskParams.setSliceProfileAn(sliceProfileAn) - logger.debug("sliceProfileAn: " + sliceProfileAn) + Map<String, Object> sliceProfileAn = getSliceProfile( "AN", execution,null) + saveSliceProfile(execution,"AN",sliceProfileAn) } if(!sliceTaskParams.getSliceProfileTn()){ - Map<String, Object> sliceProfileTn = getSliceProfile(serviceType, "TN", serviceProfile) - execution.setVariable("sliceProfileTn", sliceProfileTn) - sliceTaskParams.setSliceProfileTn(sliceProfileTn) - logger.debug("sliceProfileTn: " + sliceProfileTn) + Map<String, Object> sliceProfileTn = getSliceProfile( "TN", execution,null) + saveSliceProfile(execution,"TN",sliceProfileTn) } if(!sliceTaskParams.getSliceProfileCn()){ - Map<String, Object> sliceProfileCn = getSliceProfile(serviceType, "CN", serviceProfile) - execution.setVariable("sliceProfileCn", sliceProfileCn) - sliceTaskParams.setSliceProfileCn(sliceProfileCn) - logger.debug("sliceProfileCn: " + sliceProfileCn) + Map<String, Object> sliceProfileCn = getSliceProfile( "CN", execution,null, ) + saveSliceProfile(execution,"CN",sliceProfileCn) } logger.debug("Finish parseServiceProfile") } - Map getSliceProfile(String serviceType, String domain, Map<String, Object> serviceProfile) { + private void saveSliceProfile(DelegateExecution execution, String domain, Map<String, Object> sliceProfile){ + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + execution.setVariable("sliceProfileAn", sliceProfile) + sliceTaskParams.setSliceProfileAn(sliceProfile) + logger.debug("sliceProfileAn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("TN")){ + execution.setVariable("sliceProfileTn", sliceProfile) + sliceTaskParams.setSliceProfileTn(sliceProfile) + logger.debug("sliceProfileTn: " + sliceProfile) + } + else if(domain.equalsIgnoreCase("CN")){ + execution.setVariable("sliceProfileCn", sliceProfile) + sliceTaskParams.setSliceProfileCn(sliceProfile) + logger.debug("sliceProfileCn: " + sliceProfile) + } + } + + private void saveNSSIId(String domain, String nssiId, String nssiName, DelegateExecution execution) { + SliceTaskParams sliceTaskParams = execution.getVariable("sliceTaskParams") + if(domain.equalsIgnoreCase("AN")){ + sliceTaskParams.setAnSuggestNssiId(nssiId) + sliceTaskParams.setAnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("CN")){ + sliceTaskParams.setCnSuggestNssiId(nssiId) + sliceTaskParams.setCnSuggestNssiName(nssiName) + } + else if(domain.equalsIgnoreCase("TN")){ + sliceTaskParams.setTnSuggestNssiId(nssiId) + sliceTaskParams.setTnSuggestNssiName(nssiName) + } + } + + private Map getSliceProfile(String domain, DelegateExecution execution, Map<String, Object> oofSliceProfile) { String profileMapStr + Map<String, Object> serviceProfile = execution.getVariable("serviceProfile") Integer domainLatency = (Integer) serviceProfile.get("latency")/3 - switch (domain) { - case "AN": - profileMapStr = """ { + if(domain.equalsIgnoreCase("AN")){ + profileMapStr = """ { "latency": ${domainLatency}, "sNSSAI": "sNSSAI", "uEMobilityLevel": "uEMobilityLevel", "coverageAreaTAList": "coverageAreaTAList", "5QI": 100 - } - """.trim().replaceAll(" ", "") - break - case "TN": - profileMapStr =""" { + }""" + } + else if(domain.equalsIgnoreCase("TN")){ + profileMapStr =""" { "latency":${domainLatency}, "sNSSAI":"sNSSAI", "e2eLatency":"latency", "bandwidth": 100 - } - """.trim().replaceAll(" ", "") - break - case "CN": - profileMapStr = """ { + }""" + } + else if(domain.equalsIgnoreCase("CN")){ + profileMapStr = """ { "areaTrafficCapDL":"areaTrafficCapDL", "maxNumberofUEs":"maxNumberofUEs", "latency":${domainLatency}, @@ -287,27 +310,26 @@ class DoCreateSliceServiceOption extends AbstractServiceTaskProcessor{ "expDataRateDL":"expDataRateDL", "activityFactor":"activityFactor", "resourceSharingLevel":"resourceSharingLevel" - } - """.trim().replaceAll(" ", "") - break - default: - break - } + }""" + } logger.debug("Profile map for " + domain + " : " + profileMapStr) - Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr, new TypeReference<Map<String, String>>(){}) + Map<String, Object> profileMaps = objectMapper.readValue(profileMapStr.trim().replaceAll(" ", ""), new TypeReference<Map<String, String>>(){}) Map<String, Object> sliceProfile = [:] for (Map.Entry<String, String> profileMap : profileMaps) { String key = profileMap.key String value = profileMaps.get(key) - if(serviceProfile.keySet().contains(value)){ + if(null != oofSliceProfile && oofSliceProfile.keySet().contains(key)){ + sliceProfile.put(key, oofSliceProfile.get(key)) + logger.debug("Get from oof, key:${key}, value: ${oofSliceProfile.get(key)}") + } + else if(serviceProfile.keySet().contains(value)){ sliceProfile.put(key, serviceProfile.get(value)) } else{ sliceProfile.put(key, profileMaps.get(key)) } } - return sliceProfile } diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java index cd7edb007d..0989c627cd 100644 --- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java +++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java @@ -787,6 +787,11 @@ public class CatalogDbClient { return this.getSingleResource(cloudSiteClient, getUri(uri + id)); } + // Bring back old version of methind since the caller - OofInfraUtils.java - is not running in a spring context + public void postOofHomingCloudSite(CloudSite cloudSite) { + this.postSingleResource(cloudSiteClient, cloudSite); + } + public CloudSite postCloudSite(CloudSite cloudSite) { if (cloudSite == null) { throw new EntityNotFoundException("CloudSite passed as null"); |