summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java20
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java4
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java57
-rw-r--r--common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java22
4 files changed, 91 insertions, 12 deletions
diff --git a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
index ef979a660f..bc7a3d0bb7 100644
--- a/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
+++ b/adapters/mso-nssmf-adapter/src/main/java/org/onap/so/adapters/nssmf/manager/impl/external/ExternalAnNssmfManager.java
@@ -33,12 +33,15 @@ import org.onap.so.beans.nsmf.NssmfAdapterNBIRequest;
import org.onap.so.db.request.beans.ResourceOperationStatus;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.marshal;
import static org.onap.so.adapters.nssmf.util.NssmfAdapterUtil.unMarshal;
public class ExternalAnNssmfManager extends ExternalNssmfManager {
+ private Map<String, String> bodyParams = new HashMap<>(); // request body params
+
@Override
protected String doWrapExtAllocateReqBody(NssmfAdapterNBIRequest nbiRequest) throws ApplicationException {
Map<String, Object> request = new HashMap<>();
@@ -49,13 +52,17 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager {
@Override
protected void doAfterRequest() throws ApplicationException {
if (ActionType.ALLOCATE.equals(actionType) || ActionType.DEALLOCATE.equals(actionType)) {
- @SuppressWarnings("unchecked")
- Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class);
-
- String nssiId = response.get("nSSId");
+ String nssiId;
+ if (ActionType.ALLOCATE.equals(actionType)) {
+ @SuppressWarnings("unchecked")
+ Map<String, String> response = unMarshal(restResponse.getResponseContent(), Map.class);
+ nssiId = response.get("href");
+ } else {
+ nssiId = this.bodyParams.get("nssiId");
+ }
NssiResponse resp = new NssiResponse();
- resp.setJobId(nssiId);
+ resp.setJobId(UUID.randomUUID().toString());
resp.setNssiId(nssiId);
RestResponse returnRsp = new RestResponse();
@@ -82,6 +89,9 @@ public class ExternalAnNssmfManager extends ExternalNssmfManager {
@Override
protected String doWrapDeAllocateReqBody(DeAllocateNssi deAllocateNssi) throws ApplicationException {
+ this.bodyParams.clear();
+ this.bodyParams.put("nssiId", deAllocateNssi.getNssiId());
+
Map<String, String> request = new HashMap<>();
request.put("nSSId", deAllocateNssi.getNssiId());
return marshal(request);
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 10f39f717f..7e25ed600f 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
@@ -508,13 +508,14 @@ public class HeatBridgeImpl implements HeatBridgeApi {
}
}
- private void updateLInterfaceIps(final Port port, final LInterface lIf) {
+ protected void updateLInterfaceIps(final Port port, final LInterface lIf) {
for (IP ip : port.getFixedIps()) {
String ipAddress = ip.getIpAddress();
if (InetAddressValidator.getInstance().isValidInet4Address(ipAddress)) {
Subnet subnet = osClient.getSubnetById(ip.getSubnetId());
IPAddressString cidr = new IPAddressString(subnet.getCidr());
L3InterfaceIpv4AddressList lInterfaceIp = new L3InterfaceIpv4AddressList();
+ lInterfaceIp.setIsFloating(false);
lInterfaceIp.setL3InterfaceIpv4Address(ipAddress);
lInterfaceIp.setNeutronNetworkId(port.getNetworkId());
lInterfaceIp.setNeutronSubnetId(ip.getSubnetId());
@@ -529,6 +530,7 @@ public class HeatBridgeImpl implements HeatBridgeApi {
Subnet subnet = osClient.getSubnetById(ip.getSubnetId());
IPAddressString cidr = new IPAddressString(subnet.getCidr());
L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList();
+ ipv6.setIsFloating(false);
ipv6.setL3InterfaceIpv6Address(ipAddress);
ipv6.setNeutronNetworkId(port.getNetworkId());
ipv6.setNeutronSubnetId(ip.getSubnetId());
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 03f6c737f3..18348f19d7 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
@@ -32,9 +32,12 @@
*/
package org.onap.so.heatbridge;
+import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
@@ -65,6 +68,7 @@ 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;
import org.onap.aai.domain.yang.PInterface;
import org.onap.aai.domain.yang.SriovPf;
@@ -73,6 +77,8 @@ import org.onap.aaiclient.client.aai.AAIResourcesClient;
import org.onap.aaiclient.client.aai.AAISingleTransactionClient;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
+import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
+import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
@@ -93,8 +99,11 @@ import org.openstack4j.model.network.Subnet;
import org.openstack4j.openstack.heat.domain.HeatResource;
import org.openstack4j.openstack.heat.domain.HeatResource.Resources;
import org.springframework.core.env.Environment;
+import com.fasterxml.jackson.core.JsonParseException;
+import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
+import inet.ipaddr.IPAddressString;
@RunWith(MockitoJUnitRunner.class)
@@ -529,6 +538,54 @@ public class HeatBridgeImplTest {
}
@Test
+ public void testUpdateLInterfaceIps()
+ throws HeatBridgeException, JsonParseException, JsonMappingException, IOException {
+
+ Port port = mock(Port.class);
+ when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a");
+ when(port.getDeviceId()).thenReturn("test-device-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);
+
+ LInterface lIf = new LInterface();
+ lIf.setInterfaceName("test-port-name");
+
+ // Act
+ heatbridge.updateLInterfaceIps(port, lIf);
+
+ L3InterfaceIpv6AddressList ipv6 = new L3InterfaceIpv6AddressList();
+ ipv6.setIsFloating(false);
+ ipv6.setL3InterfaceIpv6Address("2606:ae00:2e60:100::226");
+ ipv6.setNeutronNetworkId(port.getNetworkId());
+ ipv6.setNeutronSubnetId(ip.getSubnetId());
+ ipv6.setL3InterfaceIpv6PrefixLength(Long.parseLong("24"));
+
+ ArgumentCaptor<Optional> argument = ArgumentCaptor.forClass(Optional.class);
+
+ // Assert
+ verify(transaction).createIfNotExists(
+ eq(AAIUriFactory.createResourceUri(
+ AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion("CloudOwner", "RegionOne")
+ .tenant("7320ec4a5b9d4589ba7c4412ccfd290f").vserver("test-device-id")
+ .lInterface("test-port-name").l3InterfaceIpv6AddressList("2606:ae00:2e60:100::226"))),
+ argument.capture());
+
+ assertTrue(argument.getValue().isPresent());
+
+ assertThat((L3InterfaceIpv6AddressList) argument.getValue().get(), sameBeanAs(ipv6));
+ }
+
+ @Test
public void testUpdateVserverLInterfacesToAai_skipVlans() throws HeatBridgeException {
// Arrange
List<Resource> stackResources = (List<Resource>) extractTestStackResources();
diff --git a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
index 26c3c0012a..83675da5f0 100644
--- a/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
+++ b/common/src/main/java/org/onap/so/beans/nsmf/AnSliceProfile.java
@@ -21,6 +21,7 @@
package org.onap.so.beans.nsmf;
import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@@ -28,24 +29,33 @@ import java.util.List;
@Data
public class AnSliceProfile {
- private List<String> sNSSAIList;
-
+ @JsonProperty(value = "sliceProfileId", required = true)
private String sliceProfileId;
- private List<Integer> coverageAreaTAList;
-
- @JsonInclude(JsonInclude.Include.NON_DEFAULT)
- private int latency;
+ @JsonProperty(value = "sNSSAIList", required = true)
+ private List<String> sNSSAIList;
+ @JsonProperty(value = "pLMNIdList", required = true)
private List<String> pLMNIdList;
+ @JsonProperty(value = "perfReq", required = true)
private AnPerfReq perfReq;
@JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "maxNumberofUEs")
private long maxNumberofUEs;
+ @JsonProperty(value = "coverageAreaTAList")
+ private List<Integer> coverageAreaTAList;
+
+ @JsonInclude(JsonInclude.Include.NON_DEFAULT)
+ @JsonProperty(value = "latency")
+ private int latency;
+
+ @JsonProperty(value = "uEMobilityLevel")
private UeMobilityLevel uEMobilityLevel;
+ @JsonProperty(value = "resourceSharingLevel")
private ResourceSharingLevel resourceSharingLevel;
}