diff options
16 files changed, 718 insertions, 599 deletions
diff --git a/.gitignore b/.gitignore index 79d2c94622..c57b142a05 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ packages/root-pack-extras/config-resources/mariadb/db-sql-scripts/main-schemas/M **/bin/ /tattletale/ /.metadata/ +**/.sts4-cache +**/.java-version diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java index c33160d255..a7c47f8f53 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java @@ -24,6 +24,7 @@ package org.onap.so.openstack.utils; import java.io.IOException; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -124,10 +125,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { // Properties names and variables (with default values) protected String createPollIntervalProp = "org.onap.so.adapters.po.pollInterval"; - private String pollingMultiplierProp = "org.onap.so.adapters.po.pollMultiplier"; protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15"; - private static final String POLLING_MULTIPLIER_DEFAULT = "60"; private static final ObjectMapper JSON_MAPPER = new ObjectMapper(); @@ -348,9 +347,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { String tenantId, boolean notFoundIsSuccess) throws MsoException { int pollingFrequency = Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT)); - int pollingMultiplier = - Integer.parseInt(this.environment.getProperty(pollingMultiplierProp, POLLING_MULTIPLIER_DEFAULT)); - int numberOfPollingAttempts = Math.floorDiv((timeoutMinutes * pollingMultiplier), pollingFrequency); + LocalDateTime stopPolling = LocalDateTime.now().plusMinutes(timeoutMinutes); + if (pollingFrequency > timeoutMinutes * 60) { + logger.debug("Will not poll. Poll interval {} sec is greater then timeout {} sec", pollingFrequency, + timeoutMinutes * 60); + stopPolling = LocalDateTime.now().minusMinutes(1); + } Heat heatClient = getHeatClient(cloudSiteId, tenantId); while (true) { String stackName = stack.getStackName() + "/" + stack.getId(); @@ -363,12 +365,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin { } else if (latestStack != null) { statusHandler.updateStackStatus(latestStack); if (stackStatus.equals(latestStack.getStackStatus())) { - if (numberOfPollingAttempts <= 0) { + if (LocalDateTime.now().isAfter(stopPolling)) { logger.error("Polling of stack timed out with Status: {}", latestStack.getStackStatus()); return latestStack; } + logger.debug("Will poll again until {}", stopPolling); sleep(pollingFrequency * 1000L); - numberOfPollingAttempts -= 1; } else { return latestStack; } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 4938bff748..4f7fed7df4 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -36,6 +36,7 @@ import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.junit.Before; +import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; @@ -106,7 +107,6 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { @Before public void setup() { doReturn("15").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15"); - doReturn("1").when(env).getProperty("org.onap.so.adapters.po.pollMultiplier", "60"); } @Test @@ -130,9 +130,8 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { assertEquals(true, actual != null); } - @Test - public final void pollStackForStatus_Polling_Exhausted_Test() throws MsoException, IOException { + public final void pollStackForStatus_No_Polling_Test() throws MsoException, IOException { Stack stack = new Stack(); stack.setId("id"); stack.setStackName("stackName"); @@ -141,6 +140,7 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { doNothing().when(stackStatusHandler).updateStackStatus(stack); doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id")); doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); + doReturn("61").when(env).getProperty("org.onap.so.adapters.po.pollInterval", "15"); Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false); Mockito.verify(stackStatusHandler, times(1)).updateStackStatus(stack); Mockito.verify(heatUtils, times(1)).queryHeatStack(isA(Heat.class), eq("stackName/id")); @@ -148,6 +148,22 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { } @Test + public final void pollStackForStatus_Polling_Exhausted_Test() throws MsoException, IOException { + Stack stack = new Stack(); + stack.setId("id"); + stack.setStackName("stackName"); + stack.setStackStatus("CREATE_IN_PROGRESS"); + stack.setStackStatusReason("Stack Finished"); + doNothing().when(stackStatusHandler).updateStackStatus(stack); + doReturn(stack).when(heatUtils).queryHeatStack(isA(Heat.class), eq("stackName/id")); + doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); + Stack actual = heatUtils.pollStackForStatus(1, stack, "CREATE_IN_PROGRESS", cloudSiteId, tenantId, false); + Mockito.verify(stackStatusHandler, times(5)).updateStackStatus(stack); + Mockito.verify(heatUtils, times(5)).queryHeatStack(isA(Heat.class), eq("stackName/id")); + assertEquals(true, actual != null); + } + + @Test public final void postProcessStackCreate_CREATE_IN_PROGRESS_Test() throws MsoException, IOException { Stack stack = new Stack(); stack.setId("id"); @@ -255,12 +271,9 @@ public class MsoHeatUtilsTest extends MsoHeatUtils { CreateStackParam createStackParam = new CreateStackParam(); createStackParam.setStackName("stackName"); doReturn(heatClient).when(heatUtils).getHeatClient(cloudSiteId, tenantId); - doNothing().when(heatUtils).postProcessStackDelete(deletedStack); doReturn(null).when(heatUtils).executeAndRecordOpenstackRequest(mockDeleteStack); doReturn(stackResource).when(heatClient).getStacks(); doReturn(mockDeleteStack).when(stackResource).deleteByName("stackName/id"); - doReturn(deletedStack).when(heatUtils).pollStackForStatus(120, stack, "DELETE_IN_PROGRESS", cloudSiteId, - tenantId, true); heatUtils.handleUnknownCreateStackFailure(stack, 120, cloudSiteId, tenantId); Mockito.verify(heatUtils, times(1)).executeAndRecordOpenstackRequest(mockDeleteStack); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 7d30c87101..5cb870e0d7 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -46,6 +46,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import javax.ws.rs.NotFoundException; import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.UriBuilder; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.validator.routines.InetAddressValidator; import org.onap.aai.domain.yang.Flavor; @@ -59,7 +60,6 @@ import org.onap.aai.domain.yang.Pserver; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovPf; -import org.onap.aai.domain.yang.SriovPfs; import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.VfModule; @@ -80,12 +80,12 @@ import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; import org.onap.aaiclient.client.graphinventory.entities.Node; +import org.onap.aaiclient.client.graphinventory.entities.Pathed; import org.onap.aaiclient.client.graphinventory.entities.Start; import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; import org.onap.aaiclient.client.graphinventory.entities.__; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; -import org.onap.logging.filter.base.ErrorCode; import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.ServerType; @@ -95,8 +95,6 @@ import org.onap.so.heatbridge.helpers.AaiHelper; import org.onap.so.heatbridge.openstack.api.OpenstackClient; import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; -import org.onap.so.logger.LoggingAnchor; -import org.onap.so.logger.MessageEnum; import org.onap.so.spring.SpringContextHelper; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; @@ -582,69 +580,67 @@ public class HeatBridgeImpl implements HeatBridgeApi { * * @param port Openstack port object * @param lIf AAI l-interface object + * @throws HeatBridgeException */ - private void updateSriovPfToPserver(final Port port, final LInterface lIf) { + protected void updateSriovPfToPserver(final Port port, final LInterface lIf) throws HeatBridgeException { if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { - if (port.getProfile() == null || Strings - .isNullOrEmpty(port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString())) { - logger.debug("The SRIOV port:" + port.getName() + " is missing physical-network-id, cannot update " - + "sriov-pf object for host pserver: " + port.getHostId()); - return; - } - Optional<String> matchingPifName = HeatBridgeUtils.getMatchingPserverPifName( - port.getProfile().get(HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY).toString()); - if (matchingPifName.isPresent()) { - // Update l-interface description - String pserverHostName = port.getHostId(); - lIf.setInterfaceDescription( - "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); - try { - AAIResourceUri pInterfaceUri = - AAIUriFactory - .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() - .pserver(pserverHostName).pInterface(matchingPifName.get())) - .depth(Depth.ONE); - if (resourcesClient.exists(pInterfaceUri)) { - PInterface matchingPIf = resourcesClient.get(PInterface.class, pInterfaceUri).get(); - - String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString(); - - if (matchingPIf.getSriovPfs() == null - || CollectionUtils.isEmpty(matchingPIf.getSriovPfs().getSriovPf()) - || matchingPIf.getSriovPfs().getSriovPf().stream() - .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) { - - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); - - AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri( - AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName) - .pInterface(matchingPifName.get()).sriovPf(sriovPf.getPfPciId())); - - // TODO if it does exist, should check if relationship is there, if not then create? - if (!resourcesClient.exists(sriovPfUri)) { - transaction.create(sriovPfUri, sriovPf); - - AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder - .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId) - .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf( - port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString())); - transaction.connect(sriovPfUri, sriovVfUri); - } - } + + AAIResourceUri sriovVfUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId) + .tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()) + .sriovVf(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString())); + + boolean relationshipExist = sriovVfHasSriovPfRelationship(sriovVfUri); + + String pserverHostName = port.getHostId(); + lIf.setInterfaceDescription("Attached to SR-IOV port: " + pserverHostName); + + if (!relationshipExist) { + AAIResourceUri pserverUri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName)); + if (resourcesClient.exists(pserverUri)) { + String pfPciId = port.getProfile().get(HeatBridgeConstants.OS_PF_PCI_SLOT_KEY).toString(); + + DSLQueryBuilder<Start, Node> builder = TraversalBuilder + .fragment(new DSLStartNode(Types.PSERVER, __.key("hostname", pserverHostName))) + .to(__.node(Types.P_INTERFACE) + .to(__.node(Types.SRIOV_PF, __.key("pf-pci-id", pfPciId)).output())); + + List<Pathed> results = getAAIDSLClient().queryPathed(new DSLQuery(builder.build())); + + if (results.size() == 1) { + + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceFromExistingURI(Types.SRIOV_PF, + UriBuilder.fromUri(results.get(0).getResourceLink()).build()); + + transaction.connect(sriovPfUri, sriovVfUri); + } else { - logger.warn( - "PInterface {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.", - matchingPifName.get()); + throw new HeatBridgeException("Unable to find sriov-pf related link " + pfPciId + + ". Unexpected results size" + results.size()); } - } catch (WebApplicationException e) { - // Silently log that we failed to update the Pserver p-interface with PCI-ID - logger.error(LoggingAnchor.NINE, MessageEnum.GENERAL_EXCEPTION, pserverHostName, - matchingPifName.get(), cloudOwner, tenantId, "OpenStack", "Heatbridge", - ErrorCode.DataError.getValue(), "Exception - Failed to add sriov-pf object to pserver", e); + } else { + logger.error("Pserver {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.", + pserverHostName); + throw new HeatBridgeException("Pserver " + pserverHostName + " does not exist in AAI"); + } + } + } + } + + protected boolean sriovVfHasSriovPfRelationship(AAIResourceUri sriovVfUri) { + boolean pfRelationshipsExist = false; + if (resourcesClient.exists(sriovVfUri)) { + Optional<Relationships> sriovVfRelationships = resourcesClient.get(sriovVfUri).getRelationships(); + + if (sriovVfRelationships.isPresent()) { + List<AAIResourceUri> sriovPfUris = sriovVfRelationships.get().getRelatedUris(Types.SRIOV_PF); + if (sriovPfUris.size() != 0) { + pfRelationshipsExist = true; } } } + return pfRelationshipsExist; } protected void updateLInterfaceIps(final Port port, final LInterface lIf) { diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java index 71c6a96cd6..c8a39a5795 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/constants/HeatBridgeConstants.java @@ -43,6 +43,7 @@ public class HeatBridgeConstants { public static final String OS_NEUTRON_PROVIDERNET = "OS::Neutron::ProviderNet"; public static final String OS_SRIOV_PORT_TYPE = "direct"; public static final String OS_PCI_SLOT_KEY = "pci_slot"; + public static final String OS_PF_PCI_SLOT_KEY = "pf_pci_slot"; public static final String OS_PHYSICAL_NETWORK_KEY = "physical_network"; public static final String OS_PHYSICAL_INTERFACE_KEY = "physical-interface"; public static final String OS_VLAN_NETWORK_KEY = "vlan"; 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 a9c31128ad..531496cc8f 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 @@ -42,6 +42,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doNothing; +import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -49,9 +50,10 @@ import static org.mockito.Mockito.when; import java.io.File; import java.io.IOException; import java.nio.charset.Charset; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Objects; @@ -60,7 +62,6 @@ import java.util.Set; import org.apache.commons.io.FileUtils; import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -75,9 +76,12 @@ import org.onap.aai.domain.yang.SriovPf; import org.onap.aaiclient.client.aai.AAIDSLQueryClient; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; +import org.onap.aaiclient.client.aai.entities.Results; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; +import org.onap.aaiclient.client.graphinventory.entities.Pathed; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; @@ -100,6 +104,7 @@ import org.openstack4j.openstack.heat.domain.HeatResource; import org.openstack4j.openstack.heat.domain.HeatResource.Resources; import org.springframework.core.env.Environment; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.collect.ImmutableMap; @@ -133,6 +138,9 @@ public class HeatBridgeImplTest { @Mock private Server server; + @Mock + private AAIDSLQueryClient dSLQueryClient; + @Spy @InjectMocks private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, @@ -342,11 +350,13 @@ public class HeatBridgeImplTest { } @Test - public void testUpdateVserverLInterfacesToAai() throws HeatBridgeException { + public void testUpdateVserverLInterfacesToAai() + throws HeatBridgeException, JsonParseException, JsonMappingException, IOException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); Port port = mock(Port.class); when(port.getId()).thenReturn("test-port-id"); + when(port.getHostId()).thenReturn("pserverId"); when(port.getName()).thenReturn("test-port-name"); when(port.getvNicType()).thenReturn(HeatBridgeConstants.OS_SRIOV_PORT_TYPE); when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); @@ -357,7 +367,7 @@ public class HeatBridgeImplTest { when(server.getHypervisorHostname()).thenReturn("test.server.name"); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, - HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); + HeatBridgeConstants.OS_PF_PCI_SLOT_KEY, "testPfPciId")); IP ip = mock(IP.class); @@ -386,10 +396,14 @@ public class HeatBridgeImplTest { SriovPf sriovPf = new SriovPf(); sriovPf.setPfPciId(pfPciId); - PInterface pIf = mock(PInterface.class); - when(pIf.getInterfaceName()).thenReturn("test-port-id"); - when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + + when(resourcesClient.exists(any(AAIResourceUri.class))).thenReturn(true); when(env.getProperty("mso.cloudOwner.included", "")).thenReturn("CloudOwner"); + doReturn(dSLQueryClient).when(heatbridge).getAAIDSLClient(); + List<Pathed> pathed = ((Results<Pathed>) MAPPER.readValue(getJson("pathed-sriov-pf.json"), + new TypeReference<Results<Pathed>>() {})).getResult(); + when(dSLQueryClient.queryPathed(any(DSLQuery.class))).thenReturn(pathed); + doReturn(false).when(heatbridge).sriovVfHasSriovPfRelationship(any()); // Act heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); @@ -399,6 +413,7 @@ public class HeatBridgeImplTest { verify(osClient, times(5)).getPortById(anyString()); verify(osClient, times(5)).getSubnetById("testSubnetId"); verify(osClient, times(10)).getNetworkById(anyString()); + verify(transaction, times(5)).connect(any(AAIResourceUri.class), any(AAIResourceUri.class)); } @Test @@ -571,7 +586,8 @@ public class HeatBridgeImplTest { } @Test - public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException { + public void testUpdateVserverLInterfacesToAai_skipVlans() + throws HeatBridgeException, JsonParseException, JsonMappingException, IOException { // Arrange List<Resource> stackResources = (List<Resource>) extractTestStackResources(); Port port = mock(Port.class); @@ -597,11 +613,9 @@ public class HeatBridgeImplTest { when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port); when(osClient.getNetworkById(anyString())).thenReturn(network); - SriovPf sriovPf = new SriovPf(); - sriovPf.setPfPciId(pfPciId); PInterface pIf = mock(PInterface.class); when(pIf.getInterfaceName()).thenReturn("test-port-id"); - when(resourcesClient.get(eq(PInterface.class), any(AAIResourceUri.class))).thenReturn(Optional.of(pIf)); + doNothing().when(heatbridge).updateSriovPfToPserver(any(), any()); // Act heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner"); @@ -636,5 +650,9 @@ public class HeatBridgeImplTest { return content; } + private String getJson(String filename) throws IOException { + return new String(Files.readAllBytes(Paths.get("src/test/resources/__files/" + filename))); + } + } diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json new file mode 100644 index 0000000000..cccad4c6d3 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/pathed-sriov-pf.json @@ -0,0 +1,8 @@ +{ + "results" : [ + { + "resource-type" : "sriov-pf", + "resource-link" : "/cloud-infrastructure/pservers/pserver/id1/p-interfaces/p-interface/id2/sriov-pfs/sriov-pf/id3" + } + ] +}
\ No newline at end of file diff --git a/adapters/mso-requests-db-adapter/pom.xml b/adapters/mso-requests-db-adapter/pom.xml index ca13895848..9a2df1bd51 100644 --- a/adapters/mso-requests-db-adapter/pom.xml +++ b/adapters/mso-requests-db-adapter/pom.xml @@ -159,7 +159,7 @@ <dependency> <groupId>org.glassfish.jaxb</groupId> <artifactId>jaxb-runtime</artifactId> - <version>2.4.0-b180725.0644</version> + <version>2.4.0-b180830.0438</version> </dependency> </dependencies> <executions> diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy index c7fe7e36a6..eabe58488e 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ActivateSliceSubnet.groovy @@ -32,150 +32,148 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ActivateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ActSS" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI ID - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - //operationType = deactivateInstance/activateInstance - String operationType = execution.getVariable("requestAction") - if (isBlank(operationType)) { - msg = "Input operationType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("operationType", operationType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - String operationType = execution.getVariable("operationType") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType(operationType) - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) - sendWorkflowResponse(execution, 202, activateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="ActivateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ActivateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI ID + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + //operationType = deactivateInstance/activateInstance + String operationType = execution.getVariable("requestAction") + if (isBlank(operationType)) { + msg = "Input operationType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("operationType", operationType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ActivateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + String operationType = execution.getVariable("operationType") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType(operationType) + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String activateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + activateSyncResponse) + sendWorkflowResponse(execution, 202, activateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy index 5a7722d679..9100f2773b 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/AllocateSliceSubnet.groovy @@ -33,158 +33,158 @@ import static org.apache.commons.lang3.StringUtils.isBlank class AllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="ASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - RequestDBUtil requestDBUtil = new RequestDBUtil() - JsonUtils jsonUtil = new JsonUtils() - private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //modelInfo - String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") - if (isBlank(modelInvariantUuid)) { - msg = "Input modelInvariantUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelInvariantUuid", modelInvariantUuid) - } - - logger.debug("modelInvariantUuid: " + modelInvariantUuid) - - String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") - if (isBlank(modelUuid)) { - msg = "Input modelUuid is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("modelUuid", modelUuid) - } - - logger.debug("modelUuid: " + modelUuid) - - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - String dummyServiceId = new UUID(0,0).toString(); - execution.setVariable("dummyServiceId", dummyServiceId) - logger.debug("dummyServiceId: " + dummyServiceId) - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("dummyServiceId") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Allocate") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "").trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) - sendWorkflowResponse(execution, 202, allocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } - + String Prefix="AllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + RequestDBUtil requestDBUtil = new RequestDBUtil() + JsonUtils jsonUtil = new JsonUtils() + private static final Logger logger = LoggerFactory.getLogger(AllocateSliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //modelInfo + String modelInvariantUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelInvariantUuid") + if (isBlank(modelInvariantUuid)) { + msg = "Input modelInvariantUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelInvariantUuid", modelInvariantUuid) + } + + logger.debug("modelInvariantUuid: " + modelInvariantUuid) + + String modelUuid = jsonUtil.getJsonValue(subnetInstanceReq, "modelUuid") + if (isBlank(modelUuid)) { + msg = "Input modelUuid is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("modelUuid", modelUuid) + } + + logger.debug("modelUuid: " + modelUuid) + + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + String dummyServiceId = new UUID(0,0).toString(); + execution.setVariable("dummyServiceId", dummyServiceId) + logger.debug("dummyServiceId: " + dummyServiceId) + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in AllocateSliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("dummyServiceId") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Allocate") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String allocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "").trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + allocateSyncResponse) + sendWorkflowResponse(execution, 202, allocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } + } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy index 964baa7a9d..65885f3516 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DeAllocateSliceSubnet.groovy @@ -32,14 +32,13 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="DeASS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) - - @Override + String Prefix="DeAllocateSliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + private static final Logger logger = LoggerFactory.getLogger(DeAllocateSliceSubnet.class) + + @Override void preProcessRequest(DelegateExecution execution) { logger.debug(Prefix + "preProcessRequest Start") execution.setVariable("prefix", Prefix) @@ -62,8 +61,8 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } else { execution.setVariable("globalSubscriberId", globalSubscriberId) } - - //NSSI ID + + //NSSI ID String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") if (isBlank(serviceInstanceID)) { msg = "Input serviceInstanceID is null" @@ -73,27 +72,27 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { { execution.setVariable("serviceInstanceID", serviceInstanceID) } - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + //requestParameters, subscriptionServiceType is 5G String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") if (isBlank(subscriptionServiceType)) { @@ -106,9 +105,9 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String jobId = UUID.randomUUID().toString() execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) } catch(BpmnError e) { throw e @@ -131,13 +130,13 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { String serviceId = execution.getVariable("serviceInstanceID") String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") + String nsiId = execution.getVariable("nsiId") logger.debug("Generated new job for Service Instance serviceId:" + serviceId + " jobId:" + jobId) ResourceOperationStatus initStatus = new ResourceOperationStatus() initStatus.setServiceId(serviceId) initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) + initStatus.setResourceTemplateUUID(nsiId) initStatus.setOperType("Deallocate") requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) @@ -145,26 +144,26 @@ class DeAllocateSliceSubnet extends AbstractServiceTaskProcessor { } - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") - - logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) - sendWorkflowResponse(execution, 202, deAllocateSyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String deAllocateSyncResponse = """{"jobId": "${jobId}","status": "processing"}""".trim().replaceAll(" ", "") + + logger.debug("sendSyncResponse to APIH:" + "\n" + deAllocateSyncResponse) + sendWorkflowResponse(execution, 202, deAllocateSyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy index 47489b7b84..0465a433eb 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy +++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/ModifySliceSubnet.groovy @@ -32,142 +32,142 @@ import org.slf4j.LoggerFactory import static org.apache.commons.lang3.StringUtils.isBlank class ModifySliceSubnet extends AbstractServiceTaskProcessor { - String Prefix="MSS_" - ExceptionUtil exceptionUtil = new ExceptionUtil() - JsonUtils jsonUtil = new JsonUtils() - RequestDBUtil requestDBUtil = new RequestDBUtil() - - private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) - - @Override - void preProcessRequest(DelegateExecution execution) { - logger.debug(Prefix + "preProcessRequest Start") - execution.setVariable("prefix", Prefix) - execution.setVariable("startTime", System.currentTimeMillis()) - def msg - try { - // get request input - String subnetInstanceReq = execution.getVariable("bpmnRequest") - logger.debug(subnetInstanceReq) - - String requestId = execution.getVariable("mso-request-id") - execution.setVariable("msoRequestId", requestId) - logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) - - //subscriberInfo - String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") - if (isBlank(globalSubscriberId)) { - msg = "Input globalSubscriberId' is null" - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("globalSubscriberId", globalSubscriberId) - } - - //NSSI Info - String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") - if (isBlank(serviceInstanceID)) { - msg = "Input serviceInstanceID is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("serviceInstanceID", serviceInstanceID) - } - - String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") - execution.setVariable("servicename", servicename) - - String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") - if (isBlank(nsiId)) { - msg = "Input nsiId is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("nsiId", nsiId) - } - - String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") - if (isBlank(networkType)) { - msg = "Input networkType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else - { - execution.setVariable("networkType", networkType.toUpperCase()) - } - - //requestParameters, subscriptionServiceType is 5G - String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") - if (isBlank(subscriptionServiceType)) { - msg = "Input subscriptionServiceType is null" - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) - } else { - execution.setVariable("subscriptionServiceType", subscriptionServiceType) - } - - String jobId = UUID.randomUUID().toString() - execution.setVariable("jobId", jobId) - - String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") - execution.setVariable("sliceParams", sliceParams) - - } catch(BpmnError e) { - throw e - } catch(Exception ex) { - msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "preProcessRequest Exit") - } - - - /** - * create operation status in request db - * - * Init the Operation Status - */ - def prepareInitOperationStatus = { DelegateExecution execution -> - logger.debug(Prefix + "prepareInitOperationStatus Start") - - String serviceId = execution.getVariable("serviceInstanceID") - String jobId = execution.getVariable("jobId") - String nsiId = execution.getVariable("nsiId") - logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) - - ResourceOperationStatus initStatus = new ResourceOperationStatus() - initStatus.setServiceId(serviceId) - initStatus.setOperationId(jobId) - initStatus.setResourceTemplateUUID(nsiId) - initStatus.setOperType("Modify") - requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) - - logger.debug(Prefix + "prepareInitOperationStatus Exit") - } - - - - /** - * return sync response - */ - def sendSyncResponse = { DelegateExecution execution -> - logger.debug(Prefix + "sendSyncResponse Start") - try { - String jobId = execution.getVariable("jobId") - String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" - .trim().replaceAll(" ", "") - logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) - sendWorkflowResponse(execution, 202, modifySyncResponse) - - execution.setVariable("sentSyncResponse", true) - } catch (Exception ex) { - String msg = "Exception in sendSyncResponse:" + ex.getMessage() - logger.debug(msg) - exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) - } - logger.debug(Prefix + "sendSyncResponse Exit") - } + String Prefix="ModifySliceSubnet_" + ExceptionUtil exceptionUtil = new ExceptionUtil() + JsonUtils jsonUtil = new JsonUtils() + RequestDBUtil requestDBUtil = new RequestDBUtil() + + private static final Logger logger = LoggerFactory.getLogger(ModifySliceSubnet.class) + + @Override + void preProcessRequest(DelegateExecution execution) { + logger.debug(Prefix + "preProcessRequest Start") + execution.setVariable("prefix", Prefix) + execution.setVariable("startTime", System.currentTimeMillis()) + def msg + try { + // get request input + String subnetInstanceReq = execution.getVariable("bpmnRequest") + logger.debug(subnetInstanceReq) + + String requestId = execution.getVariable("mso-request-id") + execution.setVariable("msoRequestId", requestId) + logger.debug("Input Request:" + subnetInstanceReq + " reqId:" + requestId) + + //subscriberInfo + String globalSubscriberId = jsonUtil.getJsonValue(subnetInstanceReq, "globalSubscriberId") + if (isBlank(globalSubscriberId)) { + msg = "Input globalSubscriberId' is null" + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("globalSubscriberId", globalSubscriberId) + } + + //NSSI Info + String serviceInstanceID = jsonUtil.getJsonValue(subnetInstanceReq, "serviceInstanceID") + if (isBlank(serviceInstanceID)) { + msg = "Input serviceInstanceID is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("serviceInstanceID", serviceInstanceID) + } + + String servicename = jsonUtil.getJsonValue(subnetInstanceReq, "name") + execution.setVariable("servicename", servicename) + + String nsiId = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties.nsiInfo.nsiId") + if (isBlank(nsiId)) { + msg = "Input nsiId is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("nsiId", nsiId) + } + + String networkType = jsonUtil.getJsonValue(subnetInstanceReq, "networkType") + if (isBlank(networkType)) { + msg = "Input networkType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else + { + execution.setVariable("networkType", networkType.toUpperCase()) + } + + //requestParameters, subscriptionServiceType is 5G + String subscriptionServiceType = jsonUtil.getJsonValue(subnetInstanceReq, "subscriptionServiceType") + if (isBlank(subscriptionServiceType)) { + msg = "Input subscriptionServiceType is null" + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 500, msg) + } else { + execution.setVariable("subscriptionServiceType", subscriptionServiceType) + } + + String jobId = UUID.randomUUID().toString() + execution.setVariable("jobId", jobId) + + String sliceParams = jsonUtil.getJsonValue(subnetInstanceReq, "additionalProperties") + execution.setVariable("sliceParams", sliceParams) + + } catch(BpmnError e) { + throw e + } catch(Exception ex) { + msg = "Exception in ModifySliceSubnet.preProcessRequest " + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "preProcessRequest Exit") + } + + + /** + * create operation status in request db + * + * Init the Operation Status + */ + def prepareInitOperationStatus = { DelegateExecution execution -> + logger.debug(Prefix + "prepareInitOperationStatus Start") + + String serviceId = execution.getVariable("serviceInstanceID") + String jobId = execution.getVariable("jobId") + String nsiId = execution.getVariable("nsiId") + logger.debug("Generated new job for Service Instance serviceId:" + serviceId + "jobId:" + jobId) + + ResourceOperationStatus initStatus = new ResourceOperationStatus() + initStatus.setServiceId(serviceId) + initStatus.setOperationId(jobId) + initStatus.setResourceTemplateUUID(nsiId) + initStatus.setOperType("Modify") + requestDBUtil.prepareInitResourceOperationStatus(execution, initStatus) + + logger.debug(Prefix + "prepareInitOperationStatus Exit") + } + + + + /** + * return sync response + */ + def sendSyncResponse = { DelegateExecution execution -> + logger.debug(Prefix + "sendSyncResponse Start") + try { + String jobId = execution.getVariable("jobId") + String modifySyncResponse = """{"jobId": "${jobId}","status": "processing"}""" + .trim().replaceAll(" ", "") + logger.debug("sendSyncResponse to APIH:" + "\n" + modifySyncResponse) + sendWorkflowResponse(execution, 202, modifySyncResponse) + + execution.setVariable("sentSyncResponse", true) + } catch (Exception ex) { + String msg = "Exception in sendSyncResponse:" + ex.getMessage() + logger.debug(msg) + exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg) + } + logger.debug(Prefix + "sendSyncResponse Exit") + } } diff --git a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn index 450faaebca..29f024991d 100644 --- a/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn +++ b/bpmn/so-bpmn-infrastructure-flows/src/main/resources/process/AllocateSliceSubnet.bpmn @@ -91,13 +91,6 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmn:scriptTask> <bpmn:sequenceFlow id="Flow_0ou7wr9" sourceRef="Activity_1hyt0pb" targetRef="Activity_1ydx2rx" /> <bpmn:sequenceFlow id="Flow_18cgkru" sourceRef="Activity_1ydx2rx" targetRef="Activity_0qlstj2" /> - <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> - <bpmn:extensionElements> - <camunda:in source="servicename" target="servicename" /> - </bpmn:extensionElements> - <bpmn:incoming>Flow_0g7721r</bpmn:incoming> - <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> - </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_189zwjw" sourceRef="CallDoAllocateTransportNSSI" targetRef="Event_18u424w" /> <bpmn:callActivity id="CallDoAllocateCoreNSSI" name="Call CNAllocateNSSI" calledElement="DoAllocateCoreNSSI"> <bpmn:extensionElements> @@ -118,6 +111,24 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmn:outgoing>Flow_1coedjo</bpmn:outgoing> </bpmn:callActivity> <bpmn:sequenceFlow id="Flow_1coedjo" sourceRef="CallDoAllocateCoreNSSI" targetRef="Event_18u424w" /> + <bpmn:callActivity id="CallDoAllocateTransportNSSI" name="Call TNAllocateNSSI" calledElement="DoAllocateTransportNSSI"> + <bpmn:extensionElements> + <camunda:in source="msoRequestId" target="msoRequestId" /> + <camunda:in source="modelInvariantUuid" target="modelInvariantUuid" /> + <camunda:in source="modelUuid" target="modelUuid" /> + <camunda:in source="globalSubscriberId" target="globalSubscriberId" /> + <camunda:in source="dummyServiceId" target="dummyServiceId" /> + <camunda:in source="nsiId" target="nsiId" /> + <camunda:in source="networkType" target="networkType" /> + <camunda:in source="subscriptionServiceType" target="subscriptionServiceType" /> + <camunda:in source="jobId" target="jobId" /> + <camunda:in source="sliceParams" target="sliceParams" /> + <camunda:out source="WorkflowException" target="WorkflowException" /> + <camunda:in source="servicename" target="servicename" /> + </bpmn:extensionElements> + <bpmn:incoming>Flow_0g7721r</bpmn:incoming> + <bpmn:outgoing>Flow_189zwjw</bpmn:outgoing> + </bpmn:callActivity> </bpmn:process> <bpmndi:BPMNDiagram id="BPMNDiagram_1"> <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="AllocateSliceSubnet"> @@ -126,8 +137,8 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <di:waypoint x="1152" y="190" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_189zwjw_di" bpmnElement="Flow_189zwjw"> - <di:waypoint x="1080" y="300" /> - <di:waypoint x="1170" y="300" /> + <di:waypoint x="1080" y="290" /> + <di:waypoint x="1170" y="290" /> <di:waypoint x="1170" y="208" /> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_18cgkru_di" bpmnElement="Flow_18cgkru"> @@ -153,10 +164,10 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_0g7721r_di" bpmnElement="Flow_0g7721r"> <di:waypoint x="890" y="215" /> - <di:waypoint x="890" y="300" /> - <di:waypoint x="980" y="300" /> + <di:waypoint x="890" y="290" /> + <di:waypoint x="980" y="290" /> <bpmndi:BPMNLabel> - <dc:Bounds x="912" y="273" width="36" height="14" /> + <dc:Bounds x="912" y="263" width="36" height="14" /> </bpmndi:BPMNLabel> </bpmndi:BPMNEdge> <bpmndi:BPMNEdge id="Flow_1fij4ds_di" bpmnElement="Flow_1fij4ds"> @@ -208,12 +219,13 @@ nss.prepareInitOperationStatus(execution)</bpmn:script> <bpmndi:BPMNShape id="Activity_1ydx2rx_di" bpmnElement="Activity_1ydx2rx"> <dc:Bounds x="380" y="150" width="100" height="80" /> </bpmndi:BPMNShape> - <bpmndi:BPMNShape id="Activity_008nbm9_di" bpmnElement="CallDoAllocateTransportNSSI"> - <dc:Bounds x="980" y="260" width="100" height="80" /> - </bpmndi:BPMNShape> <bpmndi:BPMNShape id="Activity_01669p4_di" bpmnElement="CallDoAllocateCoreNSSI"> <dc:Bounds x="980" y="150" width="100" height="80" /> </bpmndi:BPMNShape> + <bpmndi:BPMNShape id="Activity_00awuik_di" bpmnElement="CallDoAllocateTransportNSSI"> + <dc:Bounds x="980" y="250" width="100" height="80" /> + </bpmndi:BPMNShape> </bpmndi:BPMNPlane> </bpmndi:BPMNDiagram> </bpmn:definitions> + diff --git a/graph-inventory/fluent-builder-maven-plugin/pom.xml b/graph-inventory/fluent-builder-maven-plugin/pom.xml index 87f5138b4b..6e59d0d893 100644 --- a/graph-inventory/fluent-builder-maven-plugin/pom.xml +++ b/graph-inventory/fluent-builder-maven-plugin/pom.xml @@ -9,6 +9,36 @@ <artifactId>fluent-builder-maven-plugin</artifactId> <packaging>maven-plugin</packaging> <build> + <pluginManagement> + <plugins> + <plugin> + <groupId>org.eclipse.m2e</groupId> + <artifactId>lifecycle-mapping</artifactId> + <version>1.0.0</version> + <configuration> + <lifecycleMappingMetadata> + <pluginExecutions> + <pluginExecution> + <pluginExecutionFilter> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <goals> + <goal>descriptor</goal> + </goals> + <versionRange>[3.6.0,)</versionRange> + </pluginExecutionFilter> + <action> + <execute> + <runOnIncremental>false</runOnIncremental> + </execute> + </action> + </pluginExecution> + </pluginExecutions> + </lifecycleMappingMetadata> + </configuration> + </plugin> + </plugins> + </pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java index 17b22ec216..9b42eacfc2 100644 --- a/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java +++ b/mso-api-handlers/mso-requests-db/src/main/java/org/onap/so/db/request/client/RequestsDbClient.java @@ -29,6 +29,7 @@ import javax.annotation.PostConstruct; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; +import org.onap.logging.filter.spring.SpringClientPayloadFilter; import org.onap.so.db.request.beans.ArchivedInfraRequests; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.OperationStatus; @@ -42,6 +43,7 @@ import org.onap.so.db.request.beans.WatchdogComponentDistributionStatus; import org.onap.so.db.request.beans.WatchdogDistributionStatus; import org.onap.so.db.request.beans.WatchdogServiceModVerIdLookup; import org.onap.so.db.request.data.controller.InstanceNameDuplicateCheckRequest; +import org.onap.so.logging.jaxrs.filter.SOSpringClientFilter; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Primary; @@ -297,17 +299,55 @@ public class RequestsDbClient { restTemplate.exchange(uri, HttpMethod.PATCH, entity, String.class); } + /** + * Required for groovy usage. Cannot use Spring Autowired variables + * + * @param requestId + * @param basicAuth + * @param host + * @return + */ public InfraActiveRequests getInfraActiveRequests(String requestId, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); URI uri = getUri(host + "/infraActiveRequests/" + requestId); - - return getSingleResponse(uri, InfraActiveRequests.class); + try { + InfraActiveRequests infraActiveRequests = template + .exchange(uri, HttpMethod.GET, new HttpEntity<>(headers), InfraActiveRequests.class).getBody(); + if (infraActiveRequests != null) { + infraActiveRequests.setRequestId(requestId); + } + return infraActiveRequests; + } catch (HttpClientErrorException e) { + if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { + return null; + } + throw e; + } } + /** + * Required for groovy usage. Cannot use Spring Autowired variables + * + * @param request + * @param basicAuth + * @param host + */ public void updateInfraActiveRequests(InfraActiveRequests request, String basicAuth, String host) { + RestTemplate template = new RestTemplate(); + template.getInterceptors().add(new SOSpringClientFilter()); + template.getInterceptors().add(new SpringClientPayloadFilter()); + HttpHeaders headers = new HttpHeaders(); + headers.set(HttpHeaders.AUTHORIZATION, basicAuth); + headers.set(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON); + headers.set(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON); URI uri = getUri(host + "/infraActiveRequests/" + request.getRequestId()); - HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, getHttpHeaders()); - restTemplate.put(uri, entity); + HttpEntity<InfraActiveRequests> entity = new HttpEntity<>(request, headers); + template.put(uri, entity); } protected URI getUri(String uri) { diff --git a/version.properties b/version.properties index f56901fc20..e783874dbf 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=7 -patch=2 +patch=3 base_version=${major}.${minor}.${patch} |