summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java44
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java60
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy700
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy129
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy32
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy176
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy100
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy49
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy79
11 files changed, 861 insertions, 514 deletions
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 90a578d3b4..7d30c87101 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
@@ -466,7 +466,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
resourcesClient.createIfNotExists(uri, Optional.of(pInterface));
}
- private void updateLInterfaceVlan(final Port port, final LInterface lIf, final String hostName)
+ protected void updateLInterfaceVlan(final Port port, final LInterface lIf, final String hostName)
throws HeatBridgeException {
// add back all vlan logic
Vlan vlan = new Vlan();
@@ -486,11 +486,13 @@ public class HeatBridgeImpl implements HeatBridgeApi {
Optional.of(vlan));
}
- if (nodeType == NodeType.GREENFIELD) {
- validatePhysicalNetwork(port, network);
- processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName());
- } else {
- processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName());
+ if (!lIf.getInterfaceType().equals(SRIOV)) {
+ if (nodeType == NodeType.GREENFIELD) {
+ validatePhysicalNetwork(port, network);
+ processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName());
+ } else {
+ processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName());
+ }
}
List<String> privateVlans = (ArrayList<String>) port.getProfile().get(PRIVATE_VLANS);
@@ -597,33 +599,29 @@ public class HeatBridgeImpl implements HeatBridgeApi {
lIf.setInterfaceDescription(
"Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get());
try {
- Optional<PInterface> matchingPIf = resourcesClient.get(PInterface.class,
+ AAIResourceUri pInterfaceUri =
AAIUriFactory
.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
.pserver(pserverHostName).pInterface(matchingPifName.get()))
- .depth(Depth.ONE));
- if (matchingPIf.isPresent()) {
- SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs();
- if (pIfSriovPfs == null) {
- pIfSriovPfs = new SriovPfs();
- }
- // Extract PCI-ID from OS port object
+ .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();
- List<SriovPf> existingSriovPfs = pIfSriovPfs.getSriovPf();
- if (CollectionUtils.isEmpty(existingSriovPfs) || existingSriovPfs.stream()
- .noneMatch(existingSriovPf -> existingSriovPf.getPfPciId().equals(pfPciId))) {
- // Add sriov-pf object with PCI-ID to AAI
+ 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);
- logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName
- + "/" + matchingPifName.get());
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);
@@ -634,6 +632,10 @@ public class HeatBridgeImpl implements HeatBridgeApi {
transaction.connect(sriovPfUri, sriovVfUri);
}
}
+ } else {
+ logger.warn(
+ "PInterface {} does not exist in AAI. Unable to build sriov-vf to sriov-pf relationship.",
+ matchingPifName.get());
}
} catch (WebApplicationException e) {
// Silently log that we failed to update the Pserver p-interface with PCI-ID
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
index 1667f980e1..c281dbd9e5 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/utils/HeatBridgeUtils.java
@@ -59,7 +59,7 @@ public final class HeatBridgeUtils {
public static Optional<String> getMatchingPserverPifName(@Nonnull final String physicalNetworkName) {
Preconditions.checkState(!Strings.isNullOrEmpty(physicalNetworkName),
- "Physical network name is null or " + "empty!");
+ "Physical network name is null or empty!");
if (physicalNetworkName.contains(OS_SIDE_DEDICATED_SRIOV_PREFIX)) {
return Optional.of(
physicalNetworkName.replace(OS_SIDE_DEDICATED_SRIOV_PREFIX, COMPUTE_SIDE_DEDICATED_SRIOV_PREFIX));
@@ -67,7 +67,7 @@ public final class HeatBridgeUtils {
return Optional
.of(physicalNetworkName.replace(OS_SIDE_SHARED_SRIOV_PREFIX, COMPUTE_SIDE_SHARED_SRIOV_PREFIX));
}
- return Optional.empty();
+ return Optional.of(physicalNetworkName);
}
public static List<String> extractPciIdsFromVServer(Vserver vserver) {
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 110faaf8ab..a9c31128ad 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
@@ -41,6 +41,7 @@ import static org.junit.Assert.assertTrue;
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.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
@@ -65,6 +66,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
+import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList;
import org.onap.aai.domain.yang.LInterface;
@@ -131,6 +133,7 @@ public class HeatBridgeImplTest {
@Mock
private Server server;
+ @Spy
@InjectMocks
private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID,
REGION_ID, TENANT_ID, NodeType.GREENFIELD);
@@ -463,6 +466,63 @@ public class HeatBridgeImplTest {
}
@Test
+ public void testUpdateLInterfaceVlan() throws HeatBridgeException {
+ // Arrange
+ List<Resource> stackResources = (List<Resource>) extractTestStackResources();
+ Port port = mock(Port.class);
+ when(port.getId()).thenReturn("test-port-id");
+ 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");
+ when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a");
+ when(port.getDeviceId()).thenReturn("test-device-id");
+
+ LInterface lIf = new LInterface();
+ lIf.setInterfaceId("test-port-id");
+ lIf.setInterfaceType("SRIOV");
+ lIf.setInterfaceName("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"));
+
+ IP ip = mock(IP.class);
+
+ Set<IP> ipSet = new HashSet<>();
+ ipSet.add(ip);
+ when(ip.getIpAddress()).thenReturn("2606:ae00:2e60:100::226");
+ when(ip.getSubnetId()).thenReturn("testSubnetId");
+ when(port.getFixedIps()).thenAnswer(x -> ipSet);
+
+ Subnet subnet = mock(Subnet.class);
+ when(subnet.getCidr()).thenReturn("169.254.100.0/24");
+ when(osClient.getSubnetById("testSubnetId")).thenReturn(subnet);
+
+ Network network = mock(Network.class);
+ when(network.getId()).thenReturn("test-network-id");
+ when(network.getNetworkType()).thenReturn(NetworkType.VLAN);
+ when(network.getProviderSegID()).thenReturn("2345");
+ when(network.getProviderPhyNet()).thenReturn("ovsnet");
+ doNothing().when(heatbridge).processOVS(any(), any(), any());
+
+ 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));
+
+ // Act
+ heatbridge.updateLInterfaceVlan(port, lIf, "hostname");
+
+ // Assert
+ verify(transaction, times(2)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(osClient, times(1)).getNetworkById(anyString());
+ verify(heatbridge, times(0)).processOVS(any(), any(), any());
+ }
+
+ @Test
public void testUpdateLInterfaceIps()
throws HeatBridgeException, JsonParseException, JsonMappingException, IOException {
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
index bbc99bd258..13a8cb21e7 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/utils/HeatBridgeUtilsTest.java
@@ -26,6 +26,6 @@ public class HeatBridgeUtilsTest {
@Test
public void matchServerName_unknown() {
Optional<String> serverName = HeatBridgeUtils.getMatchingPserverPifName("differentServerName");
- assertThat(serverName).isEmpty();
+ assertThat(serverName).isNotEmpty().hasValue("differentServerName");
}
}
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
index 55f1187d69..669441c320 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/SDNCAdapterRestV1.groovy
@@ -56,349 +56,359 @@ class SDNCAdapterRestV1 extends AbstractServiceTaskProcessor {
private static final Logger logger = LoggerFactory.getLogger( SDNCAdapterRestV1.class)
- ExceptionUtil exceptionUtil = new ExceptionUtil()
- JsonUtils jsonUtil = new JsonUtils()
-
- /**
- * Processes the incoming request.
- */
- public void preProcessRequest (DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.preProcessRequest(' +
- 'execution=' + execution.getId() +
- ')'
- logger.trace('Entered ' + method)
-
- def prefix="SDNCREST_"
- execution.setVariable("prefix", prefix)
- setSuccessIndicator(execution, false)
-
- try {
- // Determine the request type and log the request
-
- String request = validateRequest(execution, "mso-request-id")
- String requestType = jsonUtil.getJsonRootProperty(request)
- execution.setVariable(prefix + 'requestType', requestType)
- logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
-
- // Determine the SDNCAdapter endpoint
-
- String sdncAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.sdnc.rest.endpoint", execution)
-
- if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) {
- String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined'
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
-
- while (sdncAdapterEndpoint.endsWith('/')) {
- sdncAdapterEndpoint = sdncAdapterEndpoint.substring(0, sdncAdapterEndpoint.length()-1)
- }
-
- String sdncAdapterMethod = null
- String sdncAdapterUrl = null
- String sdncAdapterRequest = request
-
- if ('SDNCServiceRequest'.equals(requestType)) {
- // Get the sdncRequestId from the request
-
- String sdncRequestId = jsonUtil.getJsonValue(request, requestType + ".sdncRequestId")
-
- if (sdncRequestId == null || sdncRequestId.isEmpty()) {
- String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
-
- execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId)
- logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
-
- // Get the bpNotificationUrl from the request (just to make sure it's there)
-
- String bpNotificationUrl = jsonUtil.getJsonValue(request, requestType + ".bpNotificationUrl")
-
- if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) {
- String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
-
- sdncAdapterMethod = 'POST'
- sdncAdapterUrl = sdncAdapterEndpoint
-
- RollbackData rollbackData = new RollbackData()
- rollbackData.setRequestId(sdncRequestId)
- rollbackData.getAdditionalData().put("service", jsonUtil.getJsonValue(request, requestType + ".sdncService"))
- rollbackData.getAdditionalData().put("operation", jsonUtil.getJsonValue(request, requestType + ".sdncOperation"))
- execution.setVariable("RollbackData", rollbackData)
-
- } else {
- String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
-
- execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod)
- execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl)
- execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest)
-
- // Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials)
-
- String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
-
- if (basicAuthValue == null || basicAuthValue.isEmpty()) {
- logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
- getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN",
- ErrorCode.UnknownError.getValue())
- } else {
- try {
- def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
- execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString)
- } catch (IOException ex) {
- logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
- getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
- "BPMN", ErrorCode.UnknownError.getValue(), ex)
- }
- }
-
- // Set the timeout value, e.g. PT5M. It may be specified in the request as the
- // bpTimeout value. If it's not in the request, use the URN mapping value.
-
- String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout")
-
- // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S"
- String timerRegex = "PT[0-9]+[HMS]"
- if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) {
- logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
- timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
- }
-
- // the timeout could still be null at this point if the config parm is missing/undefined
- // forced to log (so OPs can fix the config) and temporarily use a hard coded value of 10 seconds
- if (timeout == null) {
- msoLogger.warnSimple('preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"')
- timeout = "PT10S"
- }
-
- execution.setVariable(prefix + 'timeout', timeout)
- logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
- } catch (BpmnError e) {
- throw e
- } catch (Exception e) {
- String msg = 'Caught exception in ' + method + ": " + e
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- }
-
- /**
- * Sends the request to the SDNC adapter.
- */
- public void sendRequestToSDNCAdapter(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' +
- 'execution=' + execution.getId() +
- ')'
- logger.trace('Entered ' + method)
-
- String prefix = execution.getVariable('prefix')
-
- try {
- String sdncAdapterMethod = execution.getVariable(prefix + 'sdncAdapterMethod')
- logger.debug("SDNC Method is: " + sdncAdapterMethod)
- String sdncAdapterUrl = execution.getVariable(prefix + 'sdncAdapterUrl')
- logger.debug("SDNC Url is: " + sdncAdapterUrl)
- String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest')
- logger.debug("SDNC Rest Request is: " + sdncAdapterRequest)
-
- URL url = new URL(sdncAdapterUrl)
-
- HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SDNC_ADAPTER)
- httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id"))
- httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id"))
- httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
-
- Response response
-
- if ("GET".equals(sdncAdapterMethod)) {
- response = httpClient.get()
- } else if ("PUT".equals(sdncAdapterMethod)) {
- response = httpClient.put(sdncAdapterRequest)
- } else if ("POST".equals(sdncAdapterMethod)) {
- response = httpClient.post(sdncAdapterRequest)
- } else if ("DELETE".equals(sdncAdapterMethod)) {
- response = httpClient.delete(sdncAdapterRequest)
- } else {
- String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
-
- execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus())
- if(response.hasEntity()){
- execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class))
- }
- } catch (BpmnError e) {
- throw e
- } catch (Exception e) {
- String msg = 'Caught exception in ' + method + ": " + e
- logger.debug(msg, e)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- }
-
- /**
- * Processes a callback.
- */
- public void processCallback(DelegateExecution execution){
- def method = getClass().getSimpleName() + '.processCallback(' +
- 'execution=' + execution.getId() +
- ')'
- logger.trace('Entered ' + method)
-
- String prefix = execution.getVariable('prefix')
- String callback = execution.getVariable('SDNCAResponse_MESSAGE')
- logger.debug("Incoming SDNC Rest Callback is: " + callback)
-
- try {
- int callbackNumber = 1
- while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) {
- ++callbackNumber
- }
-
- execution.setVariable(prefix + 'callback' + callbackNumber, callback)
- execution.removeVariable('SDNCAResponse_MESSAGE')
-
- String responseType = jsonUtil.getJsonRootProperty(callback)
-
- // Get the ackFinalIndicator and make sure it's either Y or N. Default to Y.
- String ackFinalIndicator = jsonUtil.getJsonValue(callback, responseType + ".ackFinalIndicator")
-
- if (!'N'.equals(ackFinalIndicator)) {
- ackFinalIndicator = 'Y'
- }
-
- execution.setVariable(prefix + "ackFinalIndicator", ackFinalIndicator)
-
- if (responseType.endsWith('Error')) {
- sdncAdapterBuildWorkflowException(execution, callback)
- }
- } catch (Exception e) {
- callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
- String msg = "Received error from SDNCAdapter: " + callback
- logger.debug(getProcessKey(execution) + ': ' + msg)
- exceptionUtil.buildWorkflowException(execution, 5300, msg)
- }
- }
-
- /**
- * Tries to parse the response as XML to extract the information to create
- * a WorkflowException. If the response cannot be parsed, a more generic
- * WorkflowException is created.
- */
- public void sdncAdapterBuildWorkflowException(DelegateExecution execution, String response) {
- try {
- String responseType = jsonUtil.getJsonRootProperty(response)
- String responseCode = jsonUtil.getJsonValue(response, responseType + ".responseCode")
- String responseMessage = jsonUtil.getJsonValue(response, responseType + ".responseMessage")
-
- String info = ""
-
- if (responseCode != null && !responseCode.isEmpty()) {
- info += " responseCode='" + responseCode + "'"
- }
-
- if (responseMessage != null && !responseMessage.isEmpty()) {
- info += " responseMessage='" + responseMessage + "'"
- }
-
- // Note: the mapping function handles a null or empty responseCode
- int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode))
- exceptionUtil.buildWorkflowException(execution, mappedResponseCode, "Received " + responseType +
- " from SDNCAdapter:" + info)
- } catch (Exception e) {
- response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response
- exceptionUtil.buildWorkflowException(execution, 5300, "Received error from SDNCAdapter: " + response)
- }
- }
-
- /**
- * Gets the last callback request from the execution, or null if there was no callback.
- */
- public String getLastCallback(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.getLastCallback(' +
- 'execution=' + execution.getId() +
- ')'
- logger.trace('Entered ' + method)
-
- String prefix = execution.getVariable('prefix')
-
- try {
- int callbackNumber = 1
- String callback = null
-
- while (true) {
- String thisCallback = (String) execution.getVariable(prefix + 'callback' + callbackNumber)
-
- if (thisCallback == null) {
- break
- }
-
- callback = thisCallback
- ++callbackNumber
- }
-
- return callback
- } catch (Exception e) {
- String msg = 'Caught exception in ' + method + ": " + e
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- }
-
- /**
- * Sets the timeout value to wait for the next notification.
- */
- public void setTimeoutValue(DelegateExecution execution) {
- def method = getClass().getSimpleName() + '.setTimeoutValue(' +
- 'execution=' + execution.getId() +
- ')'
- logger.trace('Entered ' + method)
-
- String prefix = execution.getVariable('prefix')
-
- try {
- def timeoutValue = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
-
- if (execution.getVariable(prefix + 'callback1') != null) {
- // Waiting for subsequent notifications
- }
- } catch (Exception e) {
- String msg = 'Caught exception in ' + method + ": " + e
- logger.debug(msg)
- logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
- ErrorCode.UnknownError.getValue())
- exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
- }
- }
-
- public Logger getLogger() {
- return logger
- }
+ ExceptionUtil exceptionUtil = new ExceptionUtil()
+ JsonUtils jsonUtil = new JsonUtils()
+
+ /**
+ * Processes the incoming request.
+ */
+ public void preProcessRequest (DelegateExecution execution) {
+ def method = getClass().getSimpleName() + '.preProcessRequest(' +
+ 'execution=' + execution.getId() +
+ ')'
+ logger.trace('Entered ' + method)
+
+ def prefix="SDNCREST_"
+ execution.setVariable("prefix", prefix)
+ setSuccessIndicator(execution, false)
+
+ try {
+ // Determine the request type and log the request
+
+ String request = validateRequest(execution, "mso-request-id")
+ String requestType = jsonUtil.getJsonRootProperty(request)
+ execution.setVariable(prefix + 'requestType', requestType)
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'requestType = ' + requestType)
+
+ // Determine the SDNCAdapter endpoint
+
+ String sdncAdapterEndpoint = UrnPropertiesReader.getVariable("mso.adapters.sdnc.rest.endpoint", execution)
+
+ if (sdncAdapterEndpoint == null || sdncAdapterEndpoint.isEmpty()) {
+ String msg = getProcessKey(execution) + ': mso:adapters:sdnc:rest:endpoint URN mapping is not defined'
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+
+ while (sdncAdapterEndpoint.endsWith('/')) {
+ sdncAdapterEndpoint = sdncAdapterEndpoint.substring(0, sdncAdapterEndpoint.length()-1)
+ }
+
+ String sdncAdapterMethod = null
+ String sdncAdapterUrl = null
+ String sdncAdapterRequest = request
+
+ if ('SDNCServiceRequest'.equals(requestType)) {
+ // Get the sdncRequestId from the request
+
+ String sdncRequestId = jsonUtil.getJsonValue(request, requestType + ".sdncRequestId")
+
+ if (sdncRequestId == null || sdncRequestId.isEmpty()) {
+ String msg = getProcessKey(execution) + ': no sdncRequestId in ' + requestType
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+
+ execution.setVariable('SDNCAResponse_CORRELATOR', sdncRequestId)
+ logger.debug(getProcessKey(execution) + ': SDNCAResponse_CORRELATOR = ' + sdncRequestId)
+
+ // Get the bpNotificationUrl from the request (just to make sure it's there)
+
+ String bpNotificationUrl = jsonUtil.getJsonValue(request, requestType + ".bpNotificationUrl")
+
+ if (bpNotificationUrl == null || bpNotificationUrl.isEmpty()) {
+ String msg = getProcessKey(execution) + ': no bpNotificationUrl in ' + requestType
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+
+ sdncAdapterMethod = 'POST'
+ sdncAdapterUrl = sdncAdapterEndpoint
+
+ RollbackData rollbackData = new RollbackData()
+ rollbackData.setRequestId(sdncRequestId)
+ rollbackData.getAdditionalData().put("service", jsonUtil.getJsonValue(request, requestType + ".sdncService"))
+ rollbackData.getAdditionalData().put("operation", jsonUtil.getJsonValue(request, requestType + ".sdncOperation"))
+ execution.setVariable("RollbackData", rollbackData)
+
+ } else {
+ String msg = getProcessKey(execution) + ': Unsupported request type: ' + requestType
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+
+ execution.setVariable(prefix + 'sdncAdapterMethod', sdncAdapterMethod)
+ execution.setVariable(prefix + 'sdncAdapterUrl', sdncAdapterUrl)
+ execution.setVariable(prefix + 'sdncAdapterRequest', sdncAdapterRequest)
+
+ // Get the Basic Auth credentials for the SDNCAdapter (yes... we ARE using the PO adapters credentials)
+
+ String basicAuthValue = UrnPropertiesReader.getVariable("mso.adapters.po.auth", execution)
+
+ if (basicAuthValue == null || basicAuthValue.isEmpty()) {
+ logger.debug(getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined")
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": mso:adapters:po:auth URN mapping is not defined", "BPMN",
+ ErrorCode.UnknownError.getValue())
+ } else {
+ try {
+ def encodedString = utils.getBasicAuth(basicAuthValue, UrnPropertiesReader.getVariable("mso.msoKey", execution))
+ execution.setVariable(prefix + 'basicAuthHeaderValue', encodedString)
+ } catch (IOException ex) {
+ logger.debug(getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter")
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(),
+ getProcessKey(execution) + ": Unable to encode BasicAuth credentials for SDNCAdapter",
+ "BPMN", ErrorCode.UnknownError.getValue(), ex)
+ }
+ }
+
+ // Set the timeout value, e.g. PT5M. It may be specified in the request as the
+ // bpTimeout value. If it's not in the request, use the URN mapping value.
+
+ String timeout = jsonUtil.getJsonValue(request, requestType + ".bpTimeout")
+
+ // in addition to null/empty, also need to verify that the timer value is a valid duration "P[n]T[n]H|M|S"
+ String timerRegex = "PT[0-9]+[HMS]"
+ if (timeout == null || timeout.isEmpty() || !timeout.matches(timerRegex)) {
+ logger.debug(getProcessKey(execution) + ': preProcessRequest(): null/empty/invalid bpTimeout value. Using "mso.adapters.sdnc.timeout"')
+ timeout = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
+ }
+
+ // the timeout could still be null at this point if the config parm is missing/undefined
+ // forced to log (so OPs can fix the config) and temporarily use a hard coded value of 10 seconds
+ if (timeout == null) {
+ msoLogger.warnSimple('preProcessRequest()', 'property "mso.adapters.sdnc.timeout" is missing/undefined. Using "PT10S"')
+ timeout = "PT10S"
+ }
+
+ execution.setVariable(prefix + 'timeout', timeout)
+
+ Boolean failOnCallbackError = execution.getVariable("failOnCallbackError")
+ if(failOnCallbackError == null) {
+ execution.setVariable("failOnCallbackError", true)
+ }
+
+ logger.debug(getProcessKey(execution) + ': ' + prefix + 'timeout = ' + timeout)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception e) {
+ String msg = 'Caught exception in ' + method + ": " + e
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+ }
+
+ /**
+ * Sends the request to the SDNC adapter.
+ */
+ public void sendRequestToSDNCAdapter(DelegateExecution execution) {
+ def method = getClass().getSimpleName() + '.sendRequestToSDNCAdapter(' +
+ 'execution=' + execution.getId() +
+ ')'
+ logger.trace('Entered ' + method)
+
+ String prefix = execution.getVariable('prefix')
+
+ try {
+ String sdncAdapterMethod = execution.getVariable(prefix + 'sdncAdapterMethod')
+ logger.debug("SDNC Method is: " + sdncAdapterMethod)
+ String sdncAdapterUrl = execution.getVariable(prefix + 'sdncAdapterUrl')
+ logger.debug("SDNC Url is: " + sdncAdapterUrl)
+ String sdncAdapterRequest = execution.getVariable(prefix + 'sdncAdapterRequest')
+ logger.debug("SDNC Rest Request is: " + sdncAdapterRequest)
+
+ URL url = new URL(sdncAdapterUrl)
+
+ HttpClient httpClient = new HttpClientFactory().newJsonClient(url, ONAPComponents.SDNC_ADAPTER)
+ httpClient.addAdditionalHeader("mso-request-id", execution.getVariable("mso-request-id"))
+ httpClient.addAdditionalHeader("mso-service-instance-id", execution.getVariable("mso-service-instance-id"))
+ httpClient.addAdditionalHeader("Authorization", execution.getVariable(prefix + "basicAuthHeaderValue"))
+
+ Response response
+
+ if ("GET".equals(sdncAdapterMethod)) {
+ response = httpClient.get()
+ } else if ("PUT".equals(sdncAdapterMethod)) {
+ response = httpClient.put(sdncAdapterRequest)
+ } else if ("POST".equals(sdncAdapterMethod)) {
+ response = httpClient.post(sdncAdapterRequest)
+ } else if ("DELETE".equals(sdncAdapterMethod)) {
+ response = httpClient.delete(sdncAdapterRequest)
+ } else {
+ String msg = 'Unsupported HTTP method "' + sdncAdapterMethod + '" in ' + method + ": " + e
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+
+ execution.setVariable(prefix + "sdncAdapterStatusCode", response.getStatus())
+ if(response.hasEntity()){
+ execution.setVariable(prefix + "sdncAdapterResponse", response.readEntity(String.class))
+ }
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception e) {
+ String msg = 'Caught exception in ' + method + ": " + e
+ logger.debug(msg, e)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+ }
+
+ /**
+ * Processes a callback.
+ */
+ public void processCallback(DelegateExecution execution){
+ def method = getClass().getSimpleName() + '.processCallback(' +
+ 'execution=' + execution.getId() +
+ ')'
+ logger.trace('Entered ' + method)
+
+ String prefix = execution.getVariable('prefix')
+ String callback = execution.getVariable('SDNCAResponse_MESSAGE')
+ logger.debug("Incoming SDNC Rest Callback is: " + callback)
+
+ try {
+ int callbackNumber = 1
+ while (execution.getVariable(prefix + 'callback' + callbackNumber) != null) {
+ ++callbackNumber
+ }
+
+ execution.setVariable(prefix + 'callback' + callbackNumber, callback)
+ execution.removeVariable('SDNCAResponse_MESSAGE')
+
+ String responseType = jsonUtil.getJsonRootProperty(callback)
+
+ // Get the ackFinalIndicator and make sure it's either Y or N. Default to Y.
+ String ackFinalIndicator = jsonUtil.getJsonValue(callback, responseType + ".ackFinalIndicator")
+
+ if (!'N'.equals(ackFinalIndicator)) {
+ ackFinalIndicator = 'Y'
+ }
+
+ execution.setVariable(prefix + "ackFinalIndicator", ackFinalIndicator)
+
+ if (responseType.endsWith('Error')) {
+ Boolean failOnCallbackError = execution.getVariable("failOnCallbackError")
+ if(failOnCallbackError) {
+ sdncAdapterBuildWorkflowException(execution, callback)
+ }
+ }
+
+ } catch (Exception e) {
+ callback = callback == null || String.valueOf(callback).isEmpty() ? "NONE" : callback
+ String msg = "Received error from SDNCAdapter: " + callback
+ logger.debug(getProcessKey(execution) + ': ' + msg)
+ exceptionUtil.buildWorkflowException(execution, 5300, msg)
+ }
+ }
+
+ /**
+ * Tries to parse the response as XML to extract the information to create
+ * a WorkflowException. If the response cannot be parsed, a more generic
+ * WorkflowException is created.
+ */
+ public void sdncAdapterBuildWorkflowException(DelegateExecution execution, String response) {
+ try {
+ String responseType = jsonUtil.getJsonRootProperty(response)
+ String responseCode = jsonUtil.getJsonValue(response, responseType + ".responseCode")
+ String responseMessage = jsonUtil.getJsonValue(response, responseType + ".responseMessage")
+
+ String info = ""
+
+ if (responseCode != null && !responseCode.isEmpty()) {
+ info += " responseCode='" + responseCode + "'"
+ }
+
+ if (responseMessage != null && !responseMessage.isEmpty()) {
+ info += " responseMessage='" + responseMessage + "'"
+ }
+
+ // Note: the mapping function handles a null or empty responseCode
+ int mappedResponseCode = Integer.parseInt(exceptionUtil.MapSDNCResponseCodeToErrorCode(responseCode))
+ exceptionUtil.buildWorkflowException(execution, mappedResponseCode, "Received " + responseType +
+ " from SDNCAdapter:" + info)
+ } catch (Exception e) {
+ response = response == null || String.valueOf(response).isEmpty() ? "NONE" : response
+ exceptionUtil.buildWorkflowException(execution, 5300, "Received error from SDNCAdapter: " + response)
+ }
+ }
+
+ /**
+ * Gets the last callback request from the execution, or null if there was no callback.
+ */
+ public String getLastCallback(DelegateExecution execution) {
+ def method = getClass().getSimpleName() + '.getLastCallback(' +
+ 'execution=' + execution.getId() +
+ ')'
+ logger.trace('Entered ' + method)
+
+ String prefix = execution.getVariable('prefix')
+
+ try {
+ int callbackNumber = 1
+ String callback = null
+
+ while (true) {
+ String thisCallback = (String) execution.getVariable(prefix + 'callback' + callbackNumber)
+
+ if (thisCallback == null) {
+ break
+ }
+
+ callback = thisCallback
+ ++callbackNumber
+ }
+
+ return callback
+ } catch (Exception e) {
+ String msg = 'Caught exception in ' + method + ": " + e
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+ }
+
+ /**
+ * Sets the timeout value to wait for the next notification.
+ */
+ public void setTimeoutValue(DelegateExecution execution) {
+ def method = getClass().getSimpleName() + '.setTimeoutValue(' +
+ 'execution=' + execution.getId() +
+ ')'
+ logger.trace('Entered ' + method)
+
+ String prefix = execution.getVariable('prefix')
+
+ try {
+ def timeoutValue = UrnPropertiesReader.getVariable("mso.adapters.sdnc.timeout", execution)
+
+ if (execution.getVariable(prefix + 'callback1') != null) {
+ // Waiting for subsequent notifications
+ }
+ } catch (Exception e) {
+ String msg = 'Caught exception in ' + method + ": " + e
+ logger.debug(msg)
+ logger.error(LoggingAnchor.FOUR, MessageEnum.BPMN_GENERAL_EXCEPTION_ARG.toString(), msg, "BPMN",
+ ErrorCode.UnknownError.getValue())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 2000, msg)
+ }
+ }
+
+ public Logger getLogger() {
+ return logger
+ }
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
index 567725246e..646861a6a0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSI.groovy
@@ -246,11 +246,61 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
void getNSSIAssociatedProfiles(DelegateExecution execution) {
LOGGER.trace("${getPrefix()} Start getNSSIAssociatedProfiles")
+ List<SliceProfile> associatedProfiles = new ArrayList<>()
+
+ AAIResourcesClient client = getAAIClient()
+
def currentNSSI = execution.getVariable("currentNSSI")
ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ String nssiId = currentNSSI['nssiId']
+
+ // NSSI
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResultWrapper nssiWrapper = client.get(nssiUri)
+ Optional<Relationships> nssiRelationships = nssiWrapper.getRelationships()
+
+ if (nssiRelationships.isPresent()) {
+ // Allotted Resource
+ for (AAIResourceUri allottedResourceUri : nssiRelationships.get().getRelatedUris(Types.ALLOTTED_RESOURCE)) {
+ AAIResultWrapper arWrapper = client.get(allottedResourceUri)
+ Optional<Relationships> arRelationships = arWrapper.getRelationships()
+
+ boolean isFound = false
+ if(arRelationships.isPresent()) {
+ // Slice Profile Instance
+ for (AAIResourceUri sliceProfileInstanceUri : arRelationships.get().getRelatedUris(Types.SERVICE_INSTANCE)) {
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+ if(sliceProfileInstance.getServiceRole().equals("slice-profile-instance")) { // Service instance as a Slice Profile Instance
+ associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ currentNSSI['sliceProfileInstanceUri'] = sliceProfileInstanceUri
+
+ isFound = true
+ break // Should be only one
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No Slice Profile Instance found")
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for Allotted Resource")
+ }
+
+ if(isFound) {
+ break
+ }
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No relationships found for nssi id = " + nssiId)
+ }
if(associatedProfiles.isEmpty()) {
String msg = String.format("No associated profiles found for NSSI %s in AAI", nssi.getServiceInstanceId())
@@ -587,13 +637,13 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param constituteVnf
* @return List<VfModules>
*/
- List<VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
+ List<org.onap.so.serviceinstancebeans.VfModules> prepareVfModules(DelegateExecution execution, GenericVnf constituteVnf) {
AAIResourcesClient client = getAAIClient()
- List<VfModules> vfModuless = new ArrayList<>()
+ List<org.onap.so.serviceinstancebeans.VfModules> vfModuless = new ArrayList<>()
for (VfModule vfModule : constituteVnf.getVfModules().getVfModule()) {
- VfModules vfmodules = new VfModules()
+ org.onap.so.serviceinstancebeans.VfModules vfmodules = new org.onap.so.serviceinstancebeans.VfModules()
ModelInfo vfModuleModelInfo = new ModelInfo()
vfModuleModelInfo.setModelInvariantUuid(vfModule.getModelInvariantId())
@@ -703,7 +753,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
Vnfs vnf = new Vnfs()
// Line of Business
- LineOfBusiness lob = new LineOfBusiness()
+ org.onap.so.serviceinstancebeans.LineOfBusiness lob = new org.onap.so.serviceinstancebeans.LineOfBusiness()
lob.setLineOfBusinessName("VNF")
vnf.setLineOfBusiness(lob)
@@ -739,8 +789,8 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* Prepare Service
* @return Service
*/
- Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
- Service service = new Service()
+ org.onap.so.serviceinstancebeans.Service prepareService(DelegateExecution execution, ServiceInstance networkServiceInstance, ModelInfo modelInfo) {
+ org.onap.so.serviceinstancebeans.Service service = new org.onap.so.serviceinstancebeans.Service()
// Model Info
service.setModelInfo(prepareServiceModelInfo(networkServiceInstance, modelInfo))
@@ -793,21 +843,21 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return OwningEntity
*/
- OwningEntity prepareOwningEntity(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.OwningEntity prepareOwningEntity(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
AAIResourceUri networkServiceInstanceUri = (AAIResourceUri)currentNSSI['networkServiceInstanceUri']
- OwningEntity owningEntity = new OwningEntity()
+ org.onap.so.serviceinstancebeans.OwningEntity owningEntity = new org.onap.so.serviceinstancebeans.OwningEntity()
AAIResultWrapper wrapper = client.get(networkServiceInstanceUri)
Optional<Relationships> owningEntityRelationshipsOps = wrapper.getRelationships()
if (owningEntityRelationshipsOps.isPresent()) {
List<AAIResourceUri> owningEntityRelatedAAIUris = owningEntityRelationshipsOps.get().getRelatedUris(Types.OWNING_ENTITY)
if (!(owningEntityRelatedAAIUris == null || owningEntityRelatedAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
+ Optional<org.onap.aai.domain.yang.OwningEntity> owningEntityOpt = client.get(org.onap.aai.domain.yang.v19.OwningEntity.class, owningEntityRelatedAAIUris.get(0)) // Many-To-One relation
if (owningEntityOpt.isPresent()) {
owningEntity.setOwningEntityId(owningEntityOpt.get().getOwningEntityId())
owningEntity.setOwningEntityName(owningEntityOpt.get().getOwningEntityName())
@@ -825,12 +875,12 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
* @param execution
* @return Project
*/
- Project prepareProject(DelegateExecution execution) {
+ org.onap.so.serviceinstancebeans.Project prepareProject(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
AAIResourcesClient client = getAAIClient()
- Project project = new Project()
+ org.onap.so.serviceinstancebeans.Project project = new org.onap.so.serviceinstancebeans.Project()
AAIResourceUri cloudRegionRelatedAAIUri = (AAIResourceUri)currentNSSI['cloudRegionRelatedAAIUri']
@@ -840,7 +890,7 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
if (cloudRegionOps.isPresent()) {
List<AAIResourceUri> projectAAIUris = cloudRegionOps.get().getRelatedUris(Types.PROJECT)
if (!(projectAAIUris == null || projectAAIUris.isEmpty())) {
- Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.Project.class, projectAAIUris.get(0))
+ Optional<org.onap.aai.domain.yang.Project> projectOpt = client.get(org.onap.aai.domain.yang.v19.Project.class, projectAAIUris.get(0))
if (projectOpt.isPresent()) {
project.setProjectName(projectOpt.get().getProjectName())
}
@@ -950,23 +1000,49 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
-
String nssiId = currentNSSI['nssiId']
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
+ AAIResourceUri sliceProfileInstanceUri = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
- String currentSNSSAI = currentNSSI['S-NSSAI']
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ List<SliceProfile> associatedProfiles = sliceProfileInstance.getSliceProfiles()?.getSliceProfile()
+
+ String currentSNSSAI = currentNSSI['S-NSSAI']
+
+ if(!(associatedProfiles == null || associatedProfiles.isEmpty())) {
+ // Removes slice profile which contains given S-NSSAI and updates Slice Profile Instance
+ associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+
+ try {
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ currentNSSI['sliceProfileInstance'] = sliceProfileInstance
+ } catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ }
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profiles found")
+ }
- associatedProfiles.removeIf({ associatedProfile -> (associatedProfile.getSNssai().equals(currentSNSSAI)) })
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found")
+ }
+ // Removes SLice Profile Instance association with NSSI
try {
- getAAIClient().update(nssiUri, nssi)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI update call: " + e.getMessage())
+ client.disconnect(nssiUri, sliceProfileInstanceUri)
+ }
+ catch (Exception e) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance association with NSSI dosconnect call: " + e.getMessage())
}
+
LOGGER.trace("${getPrefix()} Exit removeSPAssociationWithNSSI")
}
@@ -982,17 +1058,10 @@ class DoCommonCoreNSSI extends AbstractServiceTaskProcessor {
def currentNSSI = execution.getVariable("currentNSSI")
- SliceProfile sliceProfileContainsSNSSAI = (SliceProfile)currentNSSI['sliceProfileS-NSSAI']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
- // global-customer-id, service-type, service-instance-id, profile-id
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileContainsSNSSAI.getProfileId()))
+ AAIResourceUri sliceProfileInstanceURI = (AAIResourceUri)currentNSSI['sliceProfileInstanceUri']
try {
- client.delete(sliceProfileUri)
+ client.delete(sliceProfileInstanceURI)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance delete call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
index 055cbfc9cc..fe881eb888 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSI.groovy
@@ -22,10 +22,14 @@ package org.onap.so.bpmn.infrastructure.scripts
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aaiclient.client.aai.AAIResourcesClient
+import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
+import org.onap.aaiclient.client.aai.entities.Relationships
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.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.common.scripts.ExceptionUtil
@@ -299,12 +303,38 @@ class DoDeallocateCoreNSSI extends DoCommonCoreNSSI {
String nssiId = currentNSSI['nssiId']
String nsiId = currentNSSI['nsiId']
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ // NSSI
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ ServiceInstance nssi = currentNSSI['nssi']
+
+ String allottedResourceId = null
+
+ // Removes Allotted resource
+ List<AllottedResource> allottedResources = nssi.getAllottedResources()?.getAllottedResource()
+ if(allottedResources != null && allottedResources.size() == 1) { // Shouldn contain one allotted resource
+ allottedResourceId = allottedResources.get(0).getId()
+ allottedResources.remove(0)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No allotted resource found for NSSI id = " + nssiId)
+ }
+
+ try {
+ client.update(nssiUri, nssi)
+ }catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
+ }
+
+
+ // Remove association between NSI and Allotted Resource
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResourceId))
try {
- client.disconnect(nssiUri, nsiUri)
+ client.disconnect(nsiUri, allottedResourceUri)
}catch(Exception e){
exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI association with NSI disconnect call: " + e.getMessage())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
index 4ccea61ed4..ff16184f02 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSI.groovy
@@ -22,8 +22,11 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.camunda.bpm.engine.delegate.DelegateExecution
+import org.onap.aai.domain.yang.v19.AllottedResource
+import org.onap.aai.domain.yang.v19.AllottedResources
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
+import org.onap.aai.domain.yang.v19.SliceProfiles
import org.onap.aaiclient.client.aai.AAIResourcesClient
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri
@@ -37,6 +40,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.slf4j.Logger
import org.slf4j.LoggerFactory
+import static org.apache.commons.lang3.StringUtils.isAllLowerCase
import static org.apache.commons.lang3.StringUtils.isBlank
class DoModifyCoreNSSI extends DoCommonCoreNSSI {
@@ -51,22 +55,18 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
private static final Logger LOGGER = LoggerFactory.getLogger( DoModifyCoreNSSI.class)
+
/**
- * Creates Slice Profile Instance
+ * Prepares Slice Profile
* @param execution
+ * @return SLice Profile
*/
- void createSliceProfileInstance(DelegateExecution execution) {
- LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
-
+ SliceProfile prepareSliceProfile(DelegateExecution execution) {
def currentNSSI = execution.getVariable("currentNSSI")
String sliceProfileID = currentNSSI['sliceProfileId']
Map<String,Object> sliceProfileMap = new ObjectMapper().readValue(currentNSSI['sliceProfile'], Map.class)
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
- String nssiId = currentNSSI['nssiId']
-
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setServiceAreaDimension("")
sliceProfile.setPayloadSize(0)
@@ -112,14 +112,80 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
sliceProfile.setProfileId(sliceProfileID)
sliceProfile.setE2ELatency(0)
+ return sliceProfile
+ }
+
+
+ /**
+ * Prepares Slice Profile Instance
+ * @param execution
+ * @return Slice Profile Instance
+ */
+ ServiceInstance prepareSliceProfileInstance(DelegateExecution execution) {
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ String sliceProfileInstanceId = UUID.randomUUID().toString()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+
+
+ String sliceInstanceName = "sliceprofile_" + sliceProfileInstanceId
+ sliceProfileInstance.setServiceInstanceName(sliceInstanceName)
+
+ String serviceType = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "sST")
+ sliceProfileInstance.setServiceType(serviceType)
+
+ String serviceStatus = "deactivated"
+ sliceProfileInstance.setOrchestrationStatus(serviceStatus)
+
+ String serviceInstanceLocationid = jsonUtil.getJsonValue(currentNSSI['sliceProfile'], "plmnIdList")
+ sliceProfileInstance.setServiceInstanceLocationId(serviceInstanceLocationid)
+
+ String serviceRole = "slice-profile-instance"
+ sliceProfileInstance.setServiceRole(serviceRole)
+ List<String> snssaiList = (List<String>)currentNSSI['S-NSSAIs']
+ String snssai = snssaiList.get(0)
+
+ sliceProfileInstance.setEnvironmentContext(snssai)
+ sliceProfileInstance.setWorkloadContext("CN-NF")
+
+ // TO DO: Model info
+
+ return sliceProfileInstance
+ }
+
+
+
+ /**
+ * Creates Slice Profile Instance
+ * @param execution
+ */
+ void createSliceProfileInstance(DelegateExecution execution) {
+ LOGGER.trace("${PREFIX} Start createSliceProfileInstance")
+
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+
+ SliceProfile sliceProfile = prepareSliceProfile(execution)
+
+ ServiceInstance sliceProfileInstance = prepareSliceProfileInstance(execution)
+
+ SliceProfiles sliceProfiles = new SliceProfiles()
+ sliceProfiles.getSliceProfile().add(sliceProfile)
+ sliceProfileInstance.setSliceProfiles(sliceProfiles)
+
try {
AAIResourcesClient client = getAAIClient()
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
- client.create(uri, sliceProfile)
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
+ client.create(uri, sliceProfileInstance)
- currentNSSI['createdSliceProfile'] = sliceProfile
+ currentNSSI['createdSliceProfileInstanceId'] = sliceProfileInstance.getServiceInstanceId()
} catch (Exception ex) {
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile create call:" + ex.getMessage())
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Slice Profile create call:" + ex.getMessage())
}
LOGGER.trace("${PREFIX} Exit createSliceProfileInstance")
@@ -127,6 +193,42 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
/**
+ * Creates Allotted Resource
+ * @param execution
+ * @return AllottedResource
+ */
+ AllottedResource createAllottedResource(DelegateExecution execution) {
+ def currentNSSI = execution.getVariable("currentNSSI")
+
+ String globalSubscriberId = execution.getVariable("globalSubscriberId")
+ String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ // TO DO: No other info
+
+ try {
+ AAIResourcesClient client = getAAIClient()
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+
+ client.create(allottedResourceUri, allottedResource)
+
+ currentNSSI['allottedResourceUri'] = allottedResourceUri
+ } catch (Exception ex) {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occurred while Allotted Resource create call:" + ex.getMessage())
+ }
+
+ return allottedResource
+ }
+
+
+
+ /**
* Creates Slice Profile association with NSSI
* @param execution
*/
@@ -135,26 +237,48 @@ class DoModifyCoreNSSI extends DoCommonCoreNSSI {
def currentNSSI = execution.getVariable("currentNSSI")
- String sliceProfileID = currentNSSI['sliceProfileId']
-
- String globalSubscriberId = execution.getVariable("globalSubscriberId")
- String subscriptionServiceType = execution.getVariable("subscriptionServiceType")
String nssiId = currentNSSI['nssiId']
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileID))
+ String sliceProfileInstanceId = currentNSSI['createdSliceProfileInstanceId']
+ AAIResourcesClient client = getAAIClient()
+
+ // Creates Allotted Resource
+ AllottedResource allottedResource = createAllottedResource(execution)
+ AAIResourceUri allottedResourceUri = (AAIResourceUri)currentNSSI['allottedResourceUri']
+
+ // Updates Slice Profile Instance with Allotted Resource
try {
- SliceProfile createdSliceProfile = (SliceProfile)currentNSSI['createdSliceProfile']
- ServiceInstance nssi = (ServiceInstance)currentNSSI['nssi']
- List<SliceProfile> associatedProfiles = nssi.getSliceProfiles().getSliceProfile()
- associatedProfiles.add(createdSliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+ Optional<ServiceInstance> sliceProfileInstanceOpt = client.get(ServiceInstance.class, sliceProfileInstanceUri)
+ if (sliceProfileInstanceOpt.isPresent()) {
+ ServiceInstance sliceProfileInstance = sliceProfileInstanceOpt.get()
+
+ AllottedResources allottedResources = sliceProfileInstance.getAllottedResources()
+ if(allottedResources == null) {
+ allottedResources = new AllottedResources()
+ }
+
+ allottedResources.getAllottedResource().add(allottedResource)
+ sliceProfileInstance.setAllottedResources(allottedResources)
+
+ client.update(sliceProfileInstanceUri, sliceProfileInstance)
+ }
+ else {
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "No slice profile instance found with id = " + sliceProfileInstanceId)
+ }
+
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile Instance update call: " + e.getMessage())
+ }
- getAAIClient().update(nssiUri, nssi)
- getAAIClient().connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
- }catch(Exception e){
- exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while Slice Profile association with NSSI disconnect call: " + e.getMessage())
+ // Associates NSSI with Allotted Resource
+ try {
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ client.connect(nssiUri, allottedResourceUri, AAIEdgeLabel.USES)
+ } catch(Exception e){
+ exceptionUtil.buildAndThrowWorkflowException(execution, 25000, "Exception occured while NSSI with Allotted Resource connect call: " + e.getMessage())
}
LOGGER.trace("${PREFIX} Exit associateSliceProfileInstanceWithNSSI")
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
index 6ca3937d68..9707dd2242 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCommonCoreNSSITest.groovy
@@ -36,6 +36,7 @@ import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.T
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
import org.onap.so.bpmn.common.scripts.MsoGroovyTest
+import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.serviceinstancebeans.RequestDetails
import javax.ws.rs.core.Response
@@ -185,8 +186,10 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
+ String nssiId = "5G-999"
ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
+ nssi.setServiceInstanceId(nssiId)
+ currentNSSI.put("nssiId", nssiId)
SliceProfiles sliceProfiles = new SliceProfiles()
@@ -194,13 +197,49 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
slProfiles.add(new SliceProfile())
slProfiles.add(new SliceProfile())
- nssi.setSliceProfiles(sliceProfiles)
+ //nssi.setSliceProfiles(sliceProfiles)
currentNSSI.put("nssi", nssi)
- DoCommonCoreNSSI obj = new DoCommonCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
+ DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
+ when(spy.getAAIClient()).thenReturn(client)
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ AAIResultWrapper wrapperMock = mock(AAIResultWrapper.class) //new AAIResultWrapper(json)
+ Relationships rsMock = mock(Relationships.class)
+ Optional<Relationships> orsMock = Optional.of(rsMock)
+ List<AAIResourceUri> allottedUris = new ArrayList<>()
+ AAIResourceUri allottedUri = AAIUriFactory.createResourceUri(Types.ALLOTTED_RESOURCE.getFragment("allotted-id"))
+ allottedUris.add(allottedUri)
+
+ when(client.get(nssiUri)).thenReturn(wrapperMock)
+ when(wrapperMock.getRelationships()).thenReturn(orsMock)
+ when(rsMock.getRelatedUris(Types.ALLOTTED_RESOURCE)).thenReturn(allottedUris)
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ List<AAIResourceUri> sliceProfileInstanceUris = new ArrayList<>()
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstance.getServiceInstanceId()))
+ sliceProfileInstanceUris.add(sliceProfileInstanceUri)
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(allottedUri)).thenReturn(wrapperMock)
+ when(rsMock.getRelatedUris(Types.SERVICE_INSTANCE)).thenReturn(sliceProfileInstanceUris)
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(slProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
+ spy.getNSSIAssociatedProfiles(mockExecution)
List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
+ assertTrue("sliceProfileInstanceUri not found in contect Map", currentNSSI.get("sliceProfileInstanceUri") != null)
assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
}
@@ -262,6 +301,20 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
+
+ String sliceProfileInstanceId = "slice-profile-instance-id"
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ sliceProfileInstance.setServiceRole("slice-profile-instance")
+
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+
+ currentNSSI.put("sliceProfileInstanceUri", sliceProfileInstanceUri)
+
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -284,13 +337,19 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
associatedProfiles.add(sliceProfile2)
associatedProfiles.add(sliceProfile3)
+ SliceProfiles sps = new SliceProfiles()
+ sps.getSliceProfile().addAll(associatedProfiles)
+ sliceProfileInstance.setSliceProfiles(sps)
+
int sizeBefore = associatedProfiles.size()
- doNothing().when(client).update(nssiUri, nssi)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
+ doNothing().when(client). disconnect(nssiUri, sliceProfileInstanceUri)
spy.removeSPAssociationWithNSSI(mockExecution)
- assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
+ assertTrue("Association between slice profile and NSSI wasn't removed", ((ServiceInstance)currentNSSI.get("sliceProfileInstance")).getSliceProfiles().getSliceProfile().size() == (sizeBefore - 1))
}
@@ -300,30 +359,16 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
- String globalSubscriberId = "global-id"
- String subscriptionServiceType = "subscription-service-type"
- String nssiId = "5G-999"
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer("global-subscriber-id").serviceSubscription("subscription-service-type").
+ serviceInstance("slice-profile-instance-id"))
- when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
- when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
-
- currentNSSI.put("nssiId", nssiId)
-
- String theSNSSAI = "theS-NSSAI"
-
- SliceProfile sliceProfile = new SliceProfile()
- sliceProfile.setSNssai(theSNSSAI)
- sliceProfile.setProfileId("prof-id")
-
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
-
- currentNSSI.put("sliceProfileS-NSSAI", sliceProfile)
+ currentNSSI.put("sliceProfileInstanceUri", uri)
DoCommonCoreNSSI spy = spy(DoCommonCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
- doNothing().when(client).delete(nssiUri)
+ doNothing().when(client).delete(uri)
spy.deleteSliceProfileInstance(mockExecution)
@@ -426,8 +471,13 @@ class DoCommonCoreNSSITest extends MsoGroovyTest {
prepareProject(cloudRegionAAIUri)
- String requestDetails = spy.prepareRequestDetails(mockExecution)
+ String prepareRequestDetailsResponse = spy.prepareRequestDetails(mockExecution)
+
+ JsonUtils jsonUtil = new JsonUtils()
+ String errorCode = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorCode")
+ String errMsg = jsonUtil.getJsonValue(prepareRequestDetailsResponse, "errorMessage")
+ assertTrue(errMsg, errorCode == null || errorCode.isEmpty())
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
index c6e874591f..26b96a0a4a 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoDeallocateCoreNSSITest.groovy
@@ -26,6 +26,7 @@ import org.mockito.Mockito
import org.onap.aai.domain.yang.v19.*
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.generated.fluentbuilders.AAIFluentTypeBuilder.Types
import org.onap.so.bpmn.common.scripts.ExternalAPIUtil
import org.onap.so.bpmn.common.scripts.ExternalAPIUtilFactory
@@ -153,31 +154,6 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoDeallocateCoreNSSI obj = new DoDeallocateCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAI() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -232,9 +208,30 @@ class DoDeallocateCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nsiId", nsiId)
AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance nssi = new ServiceInstance()
+ nssi.setServiceInstanceId(nssiId)
+
+ AllottedResources allottedResources = new AllottedResources()
+ AllottedResource allottedResource = new AllottedResource()
+ allottedResource.setId(UUID.randomUUID().toString())
+ allottedResources.getAllottedResource().add(allottedResource)
+ nssi.setAllottedResources(allottedResources)
+
+ currentNSSI.put("nssi", nssi)
+
AAIResourceUri nsiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nsiId))
- doNothing().when(client).disconnect(nssiUri, nsiUri)
+ doNothing().when(client).update(nssiUri, nssi)
+
+ String globalSubscriberId = "globalSubscriberId"
+ String subscriptionServiceType = "subscription-service-type"
+ when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
+ when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).allottedResource(allottedResource.getId()))
+
+ doNothing().when(client).disconnect(nsiUri, allottedResourceUri)
spy.removeNSSIAssociationWithNSI(mockExecution)
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
index 32c4c1aa57..ac6f897dfa 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoModifyCoreNSSITest.groovy
@@ -23,6 +23,8 @@ package org.onap.so.bpmn.infrastructure.scripts
import com.fasterxml.jackson.databind.ObjectMapper
import org.junit.Before
import org.junit.Test
+import org.mockito.Mockito
+import org.onap.aai.domain.yang.v19.AllottedResource
import org.onap.aai.domain.yang.v19.ServiceInstance
import org.onap.aai.domain.yang.v19.SliceProfile
import org.onap.aai.domain.yang.v19.SliceProfiles
@@ -46,31 +48,6 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
@Test
- void testGetNSSIAssociatedProfiles() {
- def currentNSSI = [:]
- when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
-
- ServiceInstance nssi = new ServiceInstance()
- nssi.setServiceInstanceId("5G-999")
-
- SliceProfiles sliceProfiles = new SliceProfiles()
-
- List<SliceProfile> slProfiles = sliceProfiles.getSliceProfile()
- slProfiles.add(new SliceProfile())
- slProfiles.add(new SliceProfile())
-
- nssi.setSliceProfiles(sliceProfiles)
- currentNSSI.put("nssi", nssi)
-
- DoModifyCoreNSSI obj = new DoModifyCoreNSSI()
- obj.getNSSIAssociatedProfiles(mockExecution)
-
- List<SliceProfile> associatedProfiles = (List<SliceProfile>)currentNSSI.get("associatedProfiles")
- assertTrue("Either associatedProfiles doesn't exist or size is incorrect", (associatedProfiles != null && associatedProfiles.size() == 2))
- }
-
-
- @Test
void testCalculateSNSSAISliceProfileInstanceHasToBeDeleted() {
def currentNSSI = [:]
when(mockExecution.getVariable("currentNSSI")).thenReturn(currentNSSI)
@@ -154,9 +131,15 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String sliceProfileId = "sliceProfileId"
- currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\"}")
+ currentNSSI.put("sliceProfile", "{\"sliceProfileId\":\"slice-profile-id\",\"snssaiList\":[\"S-NSSAI\"],\"expDataRateUL\":\"12\",\"expDataRateDL\":\"5\"," +
+ "\"activityFactor\":\"2\",\"resourceSharingLevel\":\"resource-sharing-level\",\"uEMobilityLevel\":\"ue-mobility-level\",\"coverageAreaTAList\":\"coverage-area-ta-list\"," +
+ "\"maxNumberofUEs\":\"10000\",\"latency\":\"7\"}")
currentNSSI.put("sliceProfileId", sliceProfileId)
+ List<String> snssais = new ArrayList<>()
+ snssais.add("s-nssai")
+ currentNSSI.put("S-NSSAIs", snssais)
+
DoModifyCoreNSSI spy = spy(DoModifyCoreNSSI.class)
when(spy.getAAIClient()).thenReturn(client)
@@ -169,17 +152,21 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
currentNSSI.put("nssiId", nssiId)
- AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(UUID.randomUUID().toString())
+
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).
+ serviceInstance(sliceProfileInstance.getServiceInstanceId()))
SliceProfile sliceProfile = new SliceProfile()
sliceProfile.setProfileId(sliceProfileId)
- doNothing().when(client).create(uri, sliceProfile)
+ doNothing().when(client).create(uri, sliceProfileInstance)
spy.createSliceProfileInstance(mockExecution)
- assertNotNull("Slice Profile doesn't exist", currentNSSI.get("createdSliceProfile"))
- assertTrue("Unexpected Slice Profile Id", ((SliceProfile)currentNSSI.get("createdSliceProfile")).getProfileId().equals(sliceProfile.getProfileId()))
+ assertTrue("Slice Profile Instance Id doesn't exist", (currentNSSI.get("createdSliceProfileInstanceId")) != null)
+
}
@@ -202,8 +189,19 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
String globalSubscriberId = "globalSubscriberId"
String subscriptionServiceType = "subscriptionServiceType"
- AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
- AAIResourceUri sliceProfileUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(nssiId).sliceProfile(sliceProfileId))
+ String sliceProfileInstanceId = "slice-rpofile-instance-id"
+ currentNSSI.put("createdSliceProfileInstanceId", sliceProfileInstanceId)
+
+ AllottedResource allottedResource = new AllottedResource()
+
+ String allottedResourceId = UUID.randomUUID().toString()
+
+ allottedResource.setId(allottedResourceId)
+
+ AAIResourceUri allottedResourceUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.business().customer(globalSubscriberId).serviceSubscription(subscriptionServiceType).serviceInstance(sliceProfileInstanceId).allottedResource(allottedResourceId))
+ doNothing().when(client).create(allottedResourceUri, allottedResource)
+
+ currentNSSI.put("allottedResourceUri", allottedResourceUri)
when(mockExecution.getVariable("globalSubscriberId")).thenReturn(globalSubscriberId)
when(mockExecution.getVariable("subscriptionServiceType")).thenReturn(subscriptionServiceType)
@@ -213,19 +211,26 @@ class DoModifyCoreNSSITest extends MsoGroovyTest {
SliceProfile sliceProfile = new SliceProfile()
currentNSSI.put("createdSliceProfile", sliceProfile)
+ AAIResourceUri sliceProfileInstanceUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(sliceProfileInstanceId))
+
+ AAIResourceUri nssiUri = AAIUriFactory.createResourceUri(Types.SERVICE_INSTANCE.getFragment(nssiId))
+
+ ServiceInstance sliceProfileInstance = new ServiceInstance()
+ sliceProfileInstance.setServiceInstanceId(sliceProfileInstanceId)
+ Optional<ServiceInstance> sliceProfileInstanceOpt = Optional.of(sliceProfileInstance)
+
+ when(client.get(ServiceInstance.class, sliceProfileInstanceUri)).thenReturn(sliceProfileInstanceOpt)
+ doNothing().when(client).update(sliceProfileInstanceUri, sliceProfileInstance)
+
ServiceInstance nssi = new ServiceInstance()
nssi.setServiceInstanceId(nssiId)
nssi.setSliceProfiles(new SliceProfiles())
currentNSSI.put("nssi", nssi)
- int sizeBelore = nssi.getSliceProfiles().getSliceProfile().size()
-
- doNothing().when(client).update(nssiUri, nssi)
- doNothing().when(client).connect(sliceProfileUri, nssiUri, AAIEdgeLabel.BELONGS_TO)
+ doNothing().when(client).connect(nssiUri, sliceProfileInstanceUri, AAIEdgeLabel.USES)
spy.associateSliceProfileInstanceWithNSSI(mockExecution)
- assertTrue("Wrong number of associated slice profiles", ((ServiceInstance)currentNSSI.get("nssi")).getSliceProfiles().getSliceProfile().size() == (sizeBelore + 1))
}
}