summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java27
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java87
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java16
-rw-r--r--adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java10
4 files changed, 116 insertions, 24 deletions
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
index eb4b9f538d..6817be8c49 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java
@@ -39,6 +39,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.onap.aai.domain.yang.Flavor;
import org.onap.aai.domain.yang.Image;
import org.onap.aai.domain.yang.PInterface;
@@ -77,9 +78,11 @@ public class AaiHelper {
List<Relationship> relationships = relationshipList.getRelationship();
// vserver to pserver relationship
- Relationship pserverRelationship = buildRelationship(
- AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname()));
- relationships.add(pserverRelationship);
+ if (!StringUtils.isEmpty(server.getHypervisorHostname())) {
+ Relationship pserverRelationship = buildRelationship(
+ AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname()));
+ relationships.add(pserverRelationship);
+ }
// vserver to generic-vnf relationship
Relationship genericVnfRelationship =
@@ -87,10 +90,11 @@ public class AaiHelper {
relationships.add(genericVnfRelationship);
// vserver to vnfc relationship
- Relationship vnfcRelationship =
- buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName()));
- relationships.add(vnfcRelationship);
-
+ if (!StringUtils.isEmpty(server.getName())) {
+ Relationship vnfcRelationship =
+ buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName()));
+ relationships.add(vnfcRelationship);
+ }
// vserver to vf-module relationship
Relationship vfModuleRelationship =
@@ -105,9 +109,12 @@ public class AaiHelper {
}
// vserver to flavor relationship
- Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner,
- cloudRegionId, server.getFlavor().getId()));
- relationships.add(flavorRel);
+ if (server.getFlavor() != null) {
+ Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner,
+ cloudRegionId, server.getFlavor().getId()));
+ relationships.add(flavorRel);
+ }
+
return relationshipList;
}
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
index 8ce537bb97..464a17d2a5 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java
@@ -72,6 +72,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed;
import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.heatbridge.constants.HeatBridgeConstants;
+import org.onap.so.heatbridge.helpers.AaiHelper;
import org.onap.so.heatbridge.openstack.api.OpenstackClient;
import org.onap.so.heatbridge.openstack.api.OpenstackClientException;
import org.openstack4j.model.compute.Flavor;
@@ -228,7 +229,7 @@ public class HeatBridgeImplTest {
Server server2 = mock(Server.class);
when(server2.getId()).thenReturn("test-server2-id");
- when(server2.getHypervisorHostname()).thenReturn("test-hypervisor");
+ when(server2.getHypervisorHostname()).thenReturn("");
when(server2.getName()).thenReturn("test-server2-name");
when(server2.getStatus()).thenReturn(Status.ACTIVE);
when(server2.getLinks()).thenReturn(new ArrayList<>());
@@ -262,6 +263,90 @@ public class HeatBridgeImplTest {
}
@Test
+ public void testUpdateVserversToAaiNoHypervisorName() throws HeatBridgeException {
+ // Arrange
+ Server server1 = mock(Server.class);
+
+ when(server1.getId()).thenReturn("test-server1-id");
+ when(server1.getHypervisorHostname()).thenReturn("");
+ when(server1.getName()).thenReturn("test-server1-name");
+ when(server1.getStatus()).thenReturn(Status.ACTIVE);
+ when(server1.getLinks()).thenReturn(new ArrayList<>());
+
+ Server server2 = mock(Server.class);
+ when(server2.getId()).thenReturn("test-server2-id");
+ when(server2.getName()).thenReturn("test-server2-name");
+ when(server2.getStatus()).thenReturn(Status.ACTIVE);
+ when(server2.getLinks()).thenReturn(new ArrayList<>());
+
+ List<Server> servers = Arrays.asList(server1, server2);
+
+ Image image = mock(Image.class);
+ when(server1.getImage()).thenReturn(image);
+ when(server2.getImage()).thenReturn(image);
+ when(image.getId()).thenReturn("test-image-id");
+
+ Flavor flavor = mock(Flavor.class);
+ when(server1.getFlavor()).thenReturn(flavor);
+ when(server2.getFlavor()).thenReturn(flavor);
+ when(flavor.getId()).thenReturn("test-flavor-id");
+
+ // Act
+ heatbridge.buildAddVserversToAaiAction("test-genericVnf-id", "test-vfModule-id", servers);
+
+ // Assert
+ ArgumentCaptor<AAIResourceUri> captor = ArgumentCaptor.forClass(AAIResourceUri.class);
+ verify(transaction, times(2)).create(captor.capture(), any(Vserver.class));
+
+ List<AAIResourceUri> uris = captor.getAllValues();
+ assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID,
+ server1.getId()), uris.get(0));
+ assertEquals(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, CLOUD_OWNER, REGION_ID, TENANT_ID,
+ server2.getId()), uris.get(1));
+ }
+
+ @Test
+ public void testCreateRelationships() throws HeatBridgeException {
+ AaiHelper aaiHelper = new AaiHelper();
+ // Arrange
+ Server server1 = mock(Server.class);
+
+ when(server1.getId()).thenReturn("test-server1-id");
+ when(server1.getHypervisorHostname()).thenReturn("test-hypervisor");
+ when(server1.getName()).thenReturn("test-server1-name");
+ when(server1.getStatus()).thenReturn(Status.ACTIVE);
+ when(server1.getLinks()).thenReturn(new ArrayList<>());
+
+ // HypervisorHostname is not set
+ Server server2 = mock(Server.class);
+ when(server2.getId()).thenReturn("test-server1-id");
+ when(server2.getName()).thenReturn("test-server1-name");
+ when(server2.getStatus()).thenReturn(Status.ACTIVE);
+ when(server2.getLinks()).thenReturn(new ArrayList<>());
+
+ // HypervisorHostname is empty string
+ Server server3 = mock(Server.class);
+ when(server3.getId()).thenReturn("test-server1-id");
+ when(server3.getHypervisorHostname()).thenReturn("");
+ when(server3.getName()).thenReturn("test-server1-name");
+ when(server3.getStatus()).thenReturn(Status.ACTIVE);
+ when(server3.getLinks()).thenReturn(new ArrayList<>());
+
+ org.onap.aai.domain.yang.RelationshipList relList = aaiHelper.getVserverRelationshipList(CLOUD_OWNER, REGION_ID,
+ "test-genericVnf-id", "test-vfModule-id", server1);
+ assertEquals(4, relList.getRelationship().size());
+
+ org.onap.aai.domain.yang.RelationshipList relList2 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER,
+ REGION_ID, "test-genericVnf-id", "test-vfModule-id", server2);
+ assertEquals(3, relList2.getRelationship().size());
+
+ org.onap.aai.domain.yang.RelationshipList relList3 = aaiHelper.getVserverRelationshipList(CLOUD_OWNER,
+ REGION_ID, "test-genericVnf-id", "test-vfModule-id", server3);
+ assertEquals(3, relList3.getRelationship().size());
+ }
+
+
+ @Test
public void testUpdateImagesToAai() throws HeatBridgeException {
// Arrange
Image image1 = mock(Image.class);
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
index 28e931a3e1..2adba81f9e 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/InfraActiveRequestsRepositoryCustomController.java
@@ -29,6 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@@ -39,27 +41,25 @@ public class InfraActiveRequestsRepositoryCustomController {
@Autowired
InfraActiveRequestsRepository infraActiveRequestsRepository;
- @RequestMapping(method = RequestMethod.POST,
- value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
+ @PostMapping(value = "/infraActiveRequests/getCloudOrchestrationFiltersFromInfraActive")
public List<InfraActiveRequests> getCloudOrchestrationFiltersFromInfraActive(
@RequestBody Map<String, String> orchestrationMap) {
return infraActiveRequestsRepository.getCloudOrchestrationFiltersFromInfraActive(orchestrationMap);
}
- @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive")
+ @PostMapping(value = "/infraActiveRequests/getOrchestrationFiltersFromInfraActive")
public List<InfraActiveRequests> getOrchestrationFiltersFromInfraActive(
@RequestBody Map<String, List<String>> orchestrationMap) {
return infraActiveRequestsRepository.getOrchestrationFiltersFromInfraActive(orchestrationMap);
}
- @RequestMapping(method = RequestMethod.GET,
- value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
+ @GetMapping(value = "/infraActiveRequests/checkVnfIdStatus/{operationalEnvironmentId}")
public InfraActiveRequests checkVnfIdStatus(
@PathVariable("operationalEnvironmentId") String operationalEnvironmentId) {
return infraActiveRequestsRepository.checkVnfIdStatus(operationalEnvironmentId);
}
- @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/checkInstanceNameDuplicate")
+ @PostMapping(value = "/infraActiveRequests/checkInstanceNameDuplicate")
public InfraActiveRequests checkInstanceNameDuplicate(
@RequestBody InstanceNameDuplicateCheckRequest instanceNameDuplicateCheckRequest) {
return infraActiveRequestsRepository.checkInstanceNameDuplicate(
@@ -68,14 +68,14 @@ public class InfraActiveRequestsRepositoryCustomController {
instanceNameDuplicateCheckRequest.getRequestScope());
}
- @RequestMapping(method = RequestMethod.POST, value = "/infraActiveRequests/v1/getInfraActiveRequests")
+ @PostMapping(value = "/infraActiveRequests/v1/getInfraActiveRequests")
public List<InfraActiveRequests> getInfraActiveRequests(@RequestBody Map<String, String[]> filters,
@RequestParam("from") long startTime, @RequestParam("to") long endTime,
@RequestParam(value = "maxResult", required = false) Integer maxResult) {
return infraActiveRequestsRepository.getInfraActiveRequests(filters, startTime, endTime, maxResult);
}
- @RequestMapping(method = RequestMethod.GET, value = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules")
+ @GetMapping(value = "/infraActiveRequests/getInProgressVolumeGroupsAndVfModules")
public List<InfraActiveRequests> getInProgressVolumeGroupsAndVfModules() {
return infraActiveRequestsRepository.getInProgressVolumeGroupsAndVfModules();
}
diff --git a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java
index e32d90b137..29585b94eb 100644
--- a/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java
+++ b/adapters/mso-requests-db-adapter/src/main/java/org/onap/so/adapters/requestsdb/OrchestrationTaskRepositoryCustomController.java
@@ -33,29 +33,29 @@ public class OrchestrationTaskRepositoryCustomController {
@Autowired
private OrchestrationTaskRepository orchestrationTaskRepository;
- @RequestMapping(method = RequestMethod.GET, value = "/orchestrationTask")
+ @GetMapping(value = "/orchestrationTask")
public List<OrchestrationTask> getAllOrchestrationTask() {
return orchestrationTaskRepository.findAll();
}
- @RequestMapping(method = RequestMethod.GET, value = "/orchestrationTask/{taskId}")
+ @GetMapping(value = "/orchestrationTask/{taskId}")
public OrchestrationTask getOrchestrationTask(@PathVariable("taskId") String taskId) throws MsoRequestsDbException {
return orchestrationTaskRepository.findById(taskId)
.orElseThrow(() -> new MsoRequestsDbException("orchestration task not found: " + taskId));
}
- @RequestMapping(method = RequestMethod.POST, value = "/orchestrationTask/")
+ @PostMapping(value = "/orchestrationTask/")
public OrchestrationTask createOrchestrationTask(@RequestBody OrchestrationTask orchestrationTask) {
return orchestrationTaskRepository.save(orchestrationTask);
}
- @RequestMapping(method = RequestMethod.PUT, value = "/orchestrationTask/{taskId}")
+ @PutMapping(value = "/orchestrationTask/{taskId}")
public OrchestrationTask updateOrchestrationTask(@PathVariable("taskId") String taskId,
@RequestBody OrchestrationTask orchestrationTask) throws MsoRequestsDbException {
return orchestrationTaskRepository.save(orchestrationTask);
}
- @RequestMapping(method = RequestMethod.DELETE, value = "/orchestrationTask/{taskId}")
+ @DeleteMapping(value = "/orchestrationTask/{taskId}")
public void deleteOrchestrationTask(@PathVariable("taskId") String taskId) {
orchestrationTaskRepository.deleteById(taskId);
}