aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml4
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java2
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java5
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java15
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java45
-rw-r--r--so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml6
6 files changed, 54 insertions, 23 deletions
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml
index 6dfe635098..7f0fd93c8d 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-application/src/main/resources/application.yaml
@@ -65,5 +65,5 @@ so:
etsi-catalog-manager:
base:
endpoint: http://modeling-etsicatalog.onap:8806/api
-etsi-so-ns-lcm-manager:
- endpoint: http://so-etsi-nfvo-ns-lcm:9095 \ No newline at end of file
+so-etsi-nfvo-ns-lcm:
+ endpoint: http://so-etsi-nfvo-ns-lcm.onap:9095 \ No newline at end of file
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java
index baf11193cf..da1649de57 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/EtsiSoNsLcmManagerUrlProvider.java
@@ -36,7 +36,7 @@ public class EtsiSoNsLcmManagerUrlProvider {
@Autowired
public EtsiSoNsLcmManagerUrlProvider(
- @Value("${etsi-so-ns-lcm-manager.endpoint}") final String etsiNsLcmManagerEndpoint) {
+ @Value("${so-etsi-nfvo-ns-lcm.endpoint:http://so-etsi-nfvo-ns-lcm.onap:9095}") final String etsiNsLcmManagerEndpoint) {
this.etsiNsLcmManagerEndpoint = etsiNsLcmManagerEndpoint;
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
index fb0a2503a2..87ec8420c6 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementController.java
@@ -125,7 +125,10 @@ public class NsLifecycleManagementController {
public ResponseEntity<?> instantiateNs(@PathVariable("nsInstanceId") final String nsInstanceId,
@RequestBody final InstantiateNsRequest instantiateNsRequest) {
logger.debug("Received instantiate NS request: {}\n with nsInstanceId: {}", instantiateNsRequest, nsInstanceId);
- return ResponseEntity.status(HttpStatus.NOT_IMPLEMENTED).body("Operation is not supported yet");
+ final URI resourceUri = nsLifeCycleManager.instantiateNs(nsInstanceId, instantiateNsRequest);
+ logger.info("{} Ns Instantiation started successfully. Resource Operation Occurrence uri: {}", nsInstanceId,
+ resourceUri);
+ return ResponseEntity.accepted().location(resourceUri).build();
}
/**
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java
index 8d9fdbe339..3db04fcfe8 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/main/java/org/onap/so/etsi/nfvo/ns/lcm/rest/exceptions/NsLcmControllerExceptionHandler.java
@@ -41,21 +41,18 @@ public class NsLcmControllerExceptionHandler {
.body(getInlineResponse400(nsRequestProcessingException));
}
- private InlineResponse400 getInlineResponse400(final NsRequestProcessingException nsRequestProcessingException) {
+ @ExceptionHandler(Exception.class)
+ public ResponseEntity<InlineResponse400> handleNsRequestProcessingException(final Exception exception) {
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new InlineResponse400()
+ .status(HttpStatus.INTERNAL_SERVER_ERROR.value()).detail(exception.getMessage()));
+ }
+ private InlineResponse400 getInlineResponse400(final NsRequestProcessingException nsRequestProcessingException) {
if (nsRequestProcessingException.getProblemDetails() != null) {
return nsRequestProcessingException.getProblemDetails();
}
-
return new InlineResponse400().status(HttpStatus.INTERNAL_SERVER_ERROR.value())
.detail(nsRequestProcessingException.getMessage());
-
- }
-
- @ExceptionHandler(Exception.class)
- public ResponseEntity<InlineResponse400> handleNsRequestProcessingException(final Exception exception) {
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(new InlineResponse400()
- .status(HttpStatus.INTERNAL_SERVER_ERROR.value()).detail(exception.getMessage()));
}
}
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
index 4ff74eaaa1..81c4e8fd68 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/java/org/onap/so/etsi/nfvo/ns/lcm/rest/NsLifecycleManagementControllerTest.java
@@ -69,11 +69,16 @@ import com.google.gson.Gson;
@SpringBootTest(classes = TestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
public class NsLifecycleManagementControllerTest {
+ private static final String EXPECTED_BASE_URL =
+ "http://so-etsi-nfvo-ns-lcm.onap:9095/so/so-etsi-nfvo-ns-lcm/v1/api/nslcm/v1";
+ private static final String RANDOM_NS_LCM_OP_OCC_ID = UUID.randomUUID().toString();
private static final String RANDOM_NS_INST_ID = UUID.randomUUID().toString();
private static final String SERVICE_TYPE = "NetworkService";
private static final String GLOBAL_CUSTOMER_ID = UUID.randomUUID().toString();
- private static final String EXPECTED_LOCATION_URL = "http://etsi-so-ns-lcm-manager-service:9095"
- + "/so/so-etsi-nfvo-ns-lcm/v1/" + "api/nslcm/v1/ns_instances/" + RANDOM_NS_INST_ID;
+ private static final String EXPECTED_CREATE_REQ_LOCATION_URL =
+ EXPECTED_BASE_URL + "/ns_instances/" + RANDOM_NS_INST_ID;
+ private static final String EXPECTED_INSTANTIATE_REQ_LOCATION_URL =
+ EXPECTED_BASE_URL + "/ns_lcm_op_occs/" + RANDOM_NS_LCM_OP_OCC_ID;
@LocalServerPort
private int port;
@@ -115,7 +120,7 @@ public class NsLifecycleManagementControllerTest {
assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION));
final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION);
assertEquals(1, actual.size());
- assertEquals(EXPECTED_LOCATION_URL, actual.get(0));
+ assertEquals(EXPECTED_CREATE_REQ_LOCATION_URL, actual.get(0));
}
@Test
@@ -177,11 +182,39 @@ public class NsLifecycleManagementControllerTest {
@Test
public void testInstantiateNs_ValidInstantiateNsRequest() {
- final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + UUID.randomUUID().toString() + "/instantiate";
- final HttpEntity<?> request = new HttpEntity<>(getInstantiateNsRequest());
+
+ final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest();
+ when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest)))
+ .thenReturn(RANDOM_NS_LCM_OP_OCC_ID);
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate";
+ final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest);
final ResponseEntity<Void> responseEntity =
testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, Void.class);
- assertEquals(HttpStatus.NOT_IMPLEMENTED, responseEntity.getStatusCode());
+ assertEquals(HttpStatus.ACCEPTED, responseEntity.getStatusCode());
+
+ final HttpHeaders httpHeaders = responseEntity.getHeaders();
+ assertTrue(httpHeaders.containsKey(HttpHeaders.LOCATION));
+ final List<String> actual = httpHeaders.get(HttpHeaders.LOCATION);
+ assertEquals(1, actual.size());
+ assertEquals(EXPECTED_INSTANTIATE_REQ_LOCATION_URL, actual.get(0));
+ }
+
+ @Test
+ public void testInstantiateNs_instantiateNsRequest_nsRequestProcessingExceptionThrown_returnInlineResponse400() {
+ final String message = "Unable to process request";
+ final InstantiateNsRequest instantiateNsRequest = getInstantiateNsRequest();
+ when(mockedJobExecutorService.runInstantiateNsJob(eq(RANDOM_NS_INST_ID), eq(instantiateNsRequest)))
+ .thenThrow(new NsRequestProcessingException(message, new InlineResponse400().detail(message)));
+
+ final String baseUrl = getNsLcmBaseUrl() + "/ns_instances/" + RANDOM_NS_INST_ID + "/instantiate";
+ final HttpEntity<?> request = new HttpEntity<>(instantiateNsRequest);
+ final ResponseEntity<InlineResponse400> responseEntity =
+ testRestTemplate.exchange(baseUrl, HttpMethod.POST, request, InlineResponse400.class);
+
+ assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, responseEntity.getStatusCode());
+ assertTrue(responseEntity.hasBody());
+ assertNotNull(responseEntity.getBody());
}
@Test
diff --git a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml
index 6c8a7997af..44acda20a4 100644
--- a/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml
+++ b/so-etsi-nfvo/so-etsi-nfvo-ns-lcm/so-etsi-nfvo-ns-lcm-service/src/test/resources/application.yaml
@@ -26,7 +26,7 @@ spring:
nfvo:
jdbcUrl: jdbc:h2:mem:NFVO;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;INIT=CREATE SCHEMA IF NOT EXISTS NFVO;
driver-class-name: org.h2.Driver
- pool-name: ns-lcm-bpmn-pool
+ pool-name: ns-lcm-nfvo-pool
registerMbeans: true
jpa:
hibernate:
@@ -36,6 +36,4 @@ logging:
org.reflections.Reflections: ERROR
etsi-catalog-manager:
base:
- endpoint: http://modeling-etsicatalog.onap:8806/api
-etsi-so-ns-lcm-manager:
- endpoint: http://etsi-so-ns-lcm-manager-service:9095 \ No newline at end of file
+ endpoint: http://modeling-etsicatalog.onap:8806/api \ No newline at end of file