summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java70
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java39
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy70
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy7
4 files changed, 152 insertions, 34 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 cfc4919572..eb0529c85f 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
@@ -48,6 +48,7 @@ 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.lang3.StringUtils;
import org.apache.commons.validator.routines.InetAddressValidator;
import org.onap.aai.domain.yang.Flavor;
import org.onap.aai.domain.yang.Image;
@@ -376,44 +377,47 @@ public class HeatBridgeImpl implements HeatBridgeApi {
boolean isL2Multicast = false;
Port port = osClient.getPortById(portId);
Network network = osClient.getNetworkById(port.getNetworkId());
- LInterface lIf = new LInterface();
- lIf.setInterfaceId(port.getId());
- lIf.setInterfaceName(port.getName());
- lIf.setMacaddr(port.getMacAddress());
- lIf.setNetworkName(network.getName());
- lIf.setIsPortMirrored(false);
- lIf.setIsIpUnnumbered(false);
- lIf.setInMaint(false);
-
- if (port.getProfile() != null && port.getProfile().get("trusted") != null) {
- String trusted = port.getProfile().get("trusted").toString();
- if (Boolean.parseBoolean(trusted)) {
- isL2Multicast = true;
+ if (!StringUtils.isEmpty(port.getDeviceId())) {
+ LInterface lIf = new LInterface();
+ lIf.setInterfaceId(port.getId());
+ lIf.setInterfaceName(port.getName());
+ lIf.setMacaddr(port.getMacAddress());
+ lIf.setNetworkName(network.getName());
+ lIf.setIsPortMirrored(false);
+ lIf.setIsIpUnnumbered(false);
+ lIf.setInMaint(false);
+
+ if (port.getProfile() != null && port.getProfile().get("trusted") != null) {
+ String trusted = port.getProfile().get("trusted").toString();
+ if (Boolean.parseBoolean(trusted)) {
+ isL2Multicast = true;
+ }
}
- }
- lIf.setL2Multicasting(isL2Multicast);
- lIf.setInterfaceType(getInterfaceType(nodeType, port.getvNicType()));
- lIf.setRelationshipList(new RelationshipList());
+ lIf.setL2Multicasting(isL2Multicast);
+ lIf.setInterfaceType(getInterfaceType(nodeType, port.getvNicType()));
+ lIf.setRelationshipList(new RelationshipList());
- if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) {
- lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER);
- } else {
- lIf.setInterfaceRole(port.getvNicType());
- }
+ if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) {
+ lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER);
+ } else {
+ lIf.setInterfaceRole(port.getvNicType());
+ }
- // Update l-interface to the vserver
- transaction.createIfNotExists(
- AAIUriFactory.createResourceUri(
- AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId)
- .tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())),
- Optional.of(lIf));
+ // Update l-interface to the vserver
+ transaction
+ .createIfNotExists(
+ AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure()
+ .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId)
+ .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())),
+ Optional.of(lIf));
- updateLInterfaceIps(port, lIf);
+ updateLInterfaceIps(port, lIf);
- if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) {
- Server server = getOpenstackServerById(port.getDeviceId());
- createVlanAndSriovVF(port, lIf, server.getHypervisorHostname());
- updateSriovPfToSriovVF(port, lIf);
+ if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) {
+ Server server = getOpenstackServerById(port.getDeviceId());
+ createVlanAndSriovVF(port, lIf, server.getHypervisorHostname());
+ updateSriovPfToSriovVF(port, lIf);
+ }
}
}
}
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 f06df8f22e..a18904f8f4 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
@@ -752,6 +752,45 @@ public class HeatBridgeImplTest {
}
@Test
+ public void testBuildAddVserverLInterfacesToAaiAction_DeviceIdNull()
+ 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.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(null);
+ String pfPciId = "0000:08:00.0";
+
+ Network network = mock(Network.class);
+ when(network.getId()).thenReturn("test-network-id");
+ when(network.getNetworkType()).thenReturn(NetworkType.VLAN);
+ when(network.getProviderSegID()).thenReturn("2345");
+
+ when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port);
+ when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port);
+ when(osClient.getPortById("70a09dfd-f1c5-4bc8-bd8f-dc539b8d662a")).thenReturn(port);
+ when(osClient.getPortById("12f88b4d-c8a4-4fbd-bcb4-7e36af02430b")).thenReturn(port);
+ when(osClient.getPortById("c54b9f45-b413-4937-bbe4-3c8a5689cfc9")).thenReturn(port);
+ when(osClient.getNetworkById(anyString())).thenReturn(network);
+
+ PInterface pIf = mock(PInterface.class);
+ when(pIf.getInterfaceName()).thenReturn("test-port-id");
+ doNothing().when(heatbridge).updateSriovPfToSriovVF(any(), any());
+
+ // Act
+ heatbridge.buildAddVserverLInterfacesToAaiAction(stackResources, Arrays.asList("1", "2"), "CloudOwner");
+
+ // Assert
+ verify(transaction, times(0)).createIfNotExists(any(AAIResourceUri.class), any(Optional.class));
+ verify(osClient, times(5)).getPortById(anyString());
+ verify(osClient, times(5)).getNetworkById(anyString());
+ }
+
+ @Test
public void testExtractOpenstackImagesFromServers() throws HeatBridgeException {
// Arrange
List<Server> serverList = new ArrayList<>();
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
index b5e1e6b82a..c5a928aaf9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSlice.groovy
@@ -49,7 +49,9 @@ import org.onap.so.client.HttpClient
import org.onap.so.client.HttpClientFactory
import org.onap.logging.filter.base.ONAPComponents
import org.onap.so.bpmn.core.UrnPropertiesReader
+import org.onap.aai.domain.yang.NetworkRoute
import org.onap.aai.domain.yang.v19.ServiceInstance
+import org.onap.aai.domain.yang.v20.Relationship
import org.onap.aaiclient.client.aai.AAIObjectType
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper
import org.onap.aaiclient.client.aai.entities.AAIEdgeLabel
@@ -86,6 +88,15 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
//networkServiceModelUuid
String networkServiceModelUuid = jsonUtil.getJsonValue(execution.getVariable("networkServiceModelInfo"), "modelUuid") ?: ""
execution.setVariable("networkServiceModelUuid", networkServiceModelUuid)
+ String sliceParams = execution.getVariable("sliceParams")
+ logger.debug("sliceParams "+sliceParams)
+ List<String> bhEndPoints = jsonUtil.StringArrayToList(jsonUtil.getJsonValue(sliceParams, "endPoints"))
+ if(bhEndPoints.empty) {
+ logger.debug("End point info is empty")
+ exceptionUtil.buildAndThrowWorkflowException(execution, 500, "End point info is empty")
+ }else {
+ execution.setVariable("bh_endpoint", bhEndPoints.get(0))
+ }
logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice::: preProcessRequest ****")
}
@@ -376,6 +387,8 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
if(response.getStatus()!=200 || response.getStatus()!=201 || response.getStatus()!=202) {
exceptionUtil.buildAndThrowWorkflowException(execution, response.getStatus(), "Set association of NSSI and Network service instance has failed in AAI")
} else {
+ //end point update
+ createEndPointsInAai(execution)
execution.setVariable("progress", 100)
execution.setVariable("status", "finished")
execution.setVariable("statusDescription", "DoAllocateCoreNonSharedNSSI success")
@@ -389,6 +402,63 @@ class DoAllocateCoreNonSharedSlice extends AbstractServiceTaskProcessor {
logger.debug(Prefix+ " **** Exit DoAllocateCoreNonSharedSlice ::: updateRelationship ****")
}
+ private void createEndPointsInAai(DelegateExecution execution) {
+ String type = "endpoint"
+ String function = "core_EP"
+ int prefixLength = 24
+ String addressFamily = "ipv4"
+ //BH RAN end point update
+ String bh_endpoint = execution.getVariable("bhEndPoints")
+ String bh_routeId = UUID.randomUUID().toString()
+ execution.setVariable("coreEp_ID_bh", bh_routeId)
+ String role = "CN"
+ String cnIpAddress = jsonUtil.getJsonValue(bh_endpoint, "IpAddress")
+ String LogicalLinkId = jsonUtil.getJsonValue(bh_endpoint, "LogicalLinkId")
+ String nextHopInfo = jsonUtil.getJsonValue(bh_endpoint, "nextHopInfo")
+ NetworkRoute bh_ep = new NetworkRoute()
+ bh_ep.setRouteId(bh_routeId)
+ bh_ep.setFunction(function)
+ bh_ep.setRole(role)
+ bh_ep.setType(type)
+ bh_ep.setIpAddress(cnIpAddress)
+ bh_ep.setLogicalInterfaceId(LogicalLinkId)
+ bh_ep.setNextHop(nextHopInfo)
+ bh_ep.setPrefixLength(prefixLength)
+ bh_ep.setAddressFamily(addressFamily)
+ try {
+ AAIResourcesClient client = new AAIResourcesClient()
+ logger.debug("creating bh endpoint . ID : "+bh_routeId+" node details : "+bh_ep.toString())
+ AAIResourceUri networkRouteUri = AAIUriFactory.createResourceUri( new AAIObjectType(AAINamespaceConstants.NETWORK, NetworkRoute.class), bh_routeId)
+ client.create(networkRouteUri, bh_ep)
+ //relationship b/w bh_ep and Core NSSI
+ def coreNssi = execution.getVariable("NSSIserviceInstanceId")
+ Relationship relationship = new Relationship()
+ String relatedLink = "aai/v21/network/network-routes/network-route/${bh_routeId}"
+ relationship.setRelatedLink(relatedLink)
+ relationship.setRelatedTo("network-route")
+ relationship.setRelationshipLabel("org.onap.relationships.inventory.ComposedOf")
+ try {
+ AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.SERVICE_INSTANCE,
+ execution.getVariable("globalSubscriberId"),
+ execution.getVariable("subscriptionServiceType"),
+ coreNssi).relationshipAPI()
+ client.create(uri, relationship)
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in CreateCommunicationService.createRelationShipInAAI. " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ } catch (BpmnError e) {
+ throw e
+ } catch (Exception ex) {
+ String msg = "Exception in createEndPointsInAai " + ex.getMessage()
+ logger.info(msg)
+ exceptionUtil.buildAndThrowWorkflowException(execution, 7000, msg)
+ }
+ }
+
/**
* prepare ResourceOperation status
* @param execution
diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
index 1eddf66b86..6b15407dd0 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/test/groovy/org/onap/so/bpmn/infrastructure/scripts/DoAllocateCoreNonSharedSliceTest.groovy
@@ -58,9 +58,13 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
"modelInstanceName" : "5gcembb_proxy 0"
}"""
+ String sliceParams= """{\r\n\t\"sliceProfile\": {\r\n\t\t\"snssaiList\": [\r\n\t\t\t\"001-100001\"\r\n\t\t],\r\n\t\t\"sliceProfileId\": \"ab9af40f13f721b5f13539d87484098\",\r\n\t\t\"plmnIdList\": [\r\n\t\t\t\"460-00\",\r\n\t\t\t\"460-01\"\r\n\t\t],\r\n\t\t\"perfReq\": {\r\n\t\t\t\"perfReqEmbbList \": [{\r\n\t\t\t\t\"activityFactor\": 50\r\n\t\t\t}]\r\n\t\t},\r\n\t\t\"maxNumberofUEs\": 200,\r\n\t\t\"coverageAreaTAList\": [\r\n\t\t\t\"1\",\r\n\t\t\t\"2\",\r\n\t\t\t\"3\",\r\n\t\t\t\"4\"\r\n\t\t],\r\n\t\t\"latency\": 2,\r\n\t\t\"resourceSharingLevel\": \"non-shared\"\r\n\t},\r\n\t\"endPoints\": [{\r\n\t\t\"IpAdress\": \"\",\r\n\t\t\"LogicalLinkId\": \"\",\r\n\t\t\"nextHopInfo\": \"\"\r\n\t}],\r\n\t\"nsiInfo\": {\r\n\t\t\"nsiId\": \"NSI-M-001-HDBNJ-NSMF-01-A-ZX\",\r\n\t\t\"nsiName\": \"eMBB-001\"\r\n\t},\r\n\t\"scriptName\": \"AN1\"\r\n}"""
+
when(mockExecution.getVariable("serviceInstanceId")).thenReturn("123456")
when(mockExecution.getVariable("networkServiceModelInfo")).thenReturn(networkServiceModelInfo)
+ when(mockExecution.getVariable("sliceParams")).thenReturn(sliceParams)
+
DoAllocateCoreNonSharedSlice allocateNssi = new DoAllocateCoreNonSharedSlice()
allocateNssi.preProcessRequest(mockExecution)
@@ -73,7 +77,8 @@ class DoAllocateCoreNonSharedSliceTest extends MsoGroovyTest {
Mockito.verify(mockExecution, times(1)).setVariable(eq("orchestrationStatus"), captor.capture())
assertEquals("created", captor.getValue())
- Mockito.verify(mockExecution, times(4)).setVariable(captor.capture() as String, captor.capture())
+
+ Mockito.verify(mockExecution, times(5)).setVariable(captor.capture() as String, captor.capture())
}
@Test