From: Lott, Christopher (cl778h) Date: Wed, 24 Apr 2019 16:48:44 +0000 (-0400) Subject: Add E2 manager client and controller X-Git-Tag: R2~124 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=056a49df629daf4189a34c37ee30b1f5ad88a59d;p=portal%2Fric-dashboard.git Add E2 manager client and controller Change-Id: I025007db900524ec1247fbea471f27fa82ebc76b Signed-off-by: Lott, Christopher (cl778h) --- diff --git a/e2-mgr-client/.gitignore b/e2-mgr-client/.gitignore new file mode 100644 index 00000000..27fd4617 --- /dev/null +++ b/e2-mgr-client/.gitignore @@ -0,0 +1,23 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# exclude jar for gradle wrapper +!gradle/wrapper/*.jar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build + +logs/ diff --git a/e2-mgr-client/README.md b/e2-mgr-client/README.md new file mode 100644 index 00000000..50cab55f --- /dev/null +++ b/e2-mgr-client/README.md @@ -0,0 +1,19 @@ +# E2 Manager Client Generator + +This projects generates a REST client library from the Swagger specification +file stored here and packages it in a jar. + +## License + +Copyright (C) 2019 AT&T Intellectual Property & Nokia. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/e2-mgr-client/pom.xml b/e2-mgr-client/pom.xml new file mode 100644 index 00000000..57d94050 --- /dev/null +++ b/e2-mgr-client/pom.xml @@ -0,0 +1,172 @@ + + + + 4.0.0 + + org.oranosc.ric.portal.dashboard + ric-dash-parent + 1.0.0-SNAPSHOT + + org.oranosc.ric.e2mgr.client + e2-mgr-client + RIC E2 Manager client + 0.0.1-SNAPSHOT + + UTF-8 + UTF-8 + 1.5.15 + org.oranosc.ric.e2mgr.client + + + + + io.swagger + swagger-annotations + ${swagger-annotations-version} + + + org.springframework + spring-context + + + + org.springframework + spring-web + + + + + com.fasterxml.jackson.core + jackson-core + + + + com.fasterxml.jackson.core + jackson-annotations + + + + com.fasterxml.jackson.core + jackson-databind + + + + com.fasterxml.jackson.jaxrs + jackson-jaxrs-json-provider + + + + com.fasterxml.jackson.datatype + jackson-datatype-jsr310 + + + + + org.junit.jupiter + junit-jupiter-api + + test + + + + + + io.swagger + swagger-codegen-maven-plugin + 2.3.1 + + + + generate + + + ${project.basedir}/src/main/resources/e2_mgr_rest_api_v0_0_1.yaml + java + + ${project.groupId} + ${project.artifactId} + ${project.version} + www.oran-osc.org + E2 manager client library + resttemplate + true + java8 + Apache 2.0 + https://www.apache.org/licenses/LICENSE-2.0 + + + http://gerrit.oran-osc.org + RIC Team + + AT&T and Nokia + + + ${client.base.package.name} + ${client.base.package.name}.model + ${client.base.package.name}.api + ${client.base.package.name}.invoker + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + 1.8 + 1.8 + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + attach-javadocs + + jar + + + + + + + org.apache.maven.plugins + maven-source-plugin + + + + attach-sources + + jar + + + + + + + diff --git a/e2-mgr-client/src/main/resources/e2_mgr_rest_api_v0_0_1.yaml b/e2-mgr-client/src/main/resources/e2_mgr_rest_api_v0_0_1.yaml new file mode 100644 index 00000000..2ab547ef --- /dev/null +++ b/e2-mgr-client/src/main/resources/e2_mgr_rest_api_v0_0_1.yaml @@ -0,0 +1,76 @@ +### +# ========================LICENSE_START================================= +# ORAN-OSC +# %% +# Copyright (C) 2019 AT&T Intellectual Property and Nokia +# %% +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ========================LICENSE_END=================================== +### +--- +swagger: "2.0" +info: + description: "Draft API for RIC e2-manager" + version: "0.0.1" + title: "RIC e2-manager" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +host: "localhost" +basePath: "/e2/v1" +schemes: + - "http" +paths: + /e2/v1/health: + get: + summary: "Health check of E2 Manager" + operationId: "getHealth" + responses: + 200: + description: "Health is good" + 500: + description: "Health is poor" + /e2/v1/setup: + post: + summary: "Set up connection to a RAN element" + operationId: "setupRan" + consumes: + - "application/json" + produces: + - "application/json" + parameters: + - in: "body" + name: "ranSetupRequest" + description: "Setup request with host and port" + required: true + schema: + $ref: "#/definitions/ranSetupRequest" + responses: + 200: + description: "Setup successful" + 400: + description: "Invalid input" +definitions: + ranSetupRequest: + type: "object" + properties: + ranIp: + type: "string" + description: "IPv4/IPv6 address" + ranPort: + type: "integer" + format: "int32" + example: 80 + ranName: + type: "string" + description: "eNodeB/gNodeB name" diff --git a/e2-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/e2mgr/demo/E2ManagerClientTest.java b/e2-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/e2mgr/demo/E2ManagerClientTest.java new file mode 100644 index 00000000..065a76c3 --- /dev/null +++ b/e2-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/e2mgr/demo/E2ManagerClientTest.java @@ -0,0 +1,46 @@ +/*- + * ========================LICENSE_START================================= + * ORAN-OSC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ +package org.oranosc.ric.portal.dashboard.e2mgr.demo; + +import org.junit.jupiter.api.Test; +import org.oranosc.ric.e2mgr.client.api.DefaultApi; +import org.oranosc.ric.e2mgr.client.invoker.ApiClient; +import org.springframework.web.client.RestClientException; + +/** + * Demonstrates use of the generated E2 manager client. + * + * The test fails because no server is available. + */ +public class E2ManagerClientTest { + + @Test + public void demo() { + ApiClient apiClient = new ApiClient(); + apiClient.setBasePath("http://localhost:30099/"); + DefaultApi e2Mgr = new DefaultApi(apiClient); + try { + e2Mgr.getHealth(); + System.out.println("getHealth answered: " + apiClient.getStatusCode().toString()); + } catch (RestClientException e) { + System.err.println("getHealth failed: " + e.toString()); + } + } +} diff --git a/pom.xml b/pom.xml index a6d0af73..9928ca06 100644 --- a/pom.xml +++ b/pom.xml @@ -46,6 +46,7 @@ limitations under the License. webapp-frontend webapp-backend xapp-mgr-client + e2-mgr-client diff --git a/webapp-backend/pom.xml b/webapp-backend/pom.xml index b8657ca7..b604eeda 100644 --- a/webapp-backend/pom.xml +++ b/webapp-backend/pom.xml @@ -36,7 +36,12 @@ limitations under the License. - ${project.groupId} + org.oranosc.ric.e2mgr.client + e2-mgr-client + 0.0.1-SNAPSHOT + + + org.oranosc.ric.xappmgr.client xapp-mgr-client 0.0.10-SNAPSHOT @@ -74,6 +79,12 @@ limitations under the License. springfox-swagger-ui ${springfox.version} + + org.junit.jupiter + junit-jupiter-api + + test + diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/DashboardApplication.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/DashboardApplication.java index 6f413922..e3ab0042 100644 --- a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/DashboardApplication.java +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/DashboardApplication.java @@ -25,8 +25,12 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; @SpringBootApplication +// Limit the annotation scan to the dashboard classes; +// exclude the generated client classes! +@ComponentScan("org.oranosc.ric.portal.dashboard") public class DashboardApplication { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/E2ManagerConfiguration.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/E2ManagerConfiguration.java new file mode 100644 index 00000000..cf750da6 --- /dev/null +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/E2ManagerConfiguration.java @@ -0,0 +1,47 @@ +/*- + * ========================LICENSE_START================================= + * ORAN-OSC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ +package org.oranosc.ric.portal.dash; + +import org.oranosc.ric.e2mgr.client.api.DefaultApi; +import org.oranosc.ric.e2mgr.client.invoker.ApiClient; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +public class E2ManagerConfiguration { + + @Value("${e2.manager.base.url}") + private String e2ManagerBaseUrl; + + /** + * Required by autowired constructor {@link DefaultApi#DefaultApi(ApiClient)} + * + * @return Instance of E2 Manager client configured from properties + */ + @Bean + public ApiClient e2ManagerClient() { + ApiClient apiClient = new ApiClient(new RestTemplate()); + apiClient.setBasePath(e2ManagerBaseUrl); + return apiClient; + } + +} diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/XappManagerConfiguration.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/XappManagerConfiguration.java index b0f04a77..bdee12cc 100644 --- a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/XappManagerConfiguration.java +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/XappManagerConfiguration.java @@ -19,16 +19,14 @@ */ package org.oranosc.ric.portal.dash; -import org.oranosc.ric.portal.dashboard.xmc.api.DefaultApi; -import org.oranosc.ric.portal.dashboard.xmc.invoker.ApiClient; +import org.oranosc.ric.xappmgr.client.api.DefaultApi; +import org.oranosc.ric.xappmgr.client.invoker.ApiClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; @Configuration -@ComponentScan("org.oranosc.ric.portal") public class XappManagerConfiguration { @Value("${xapp.manager.base.url}") @@ -40,20 +38,10 @@ public class XappManagerConfiguration { * @return Instance of ApiClient configured from properties */ @Bean - public ApiClient apiClient() { - ApiClient apiClient = new ApiClient(); + public ApiClient xappApiClient() { + ApiClient apiClient = new ApiClient(new RestTemplate()); apiClient.setBasePath(xappManagerBaseUrl); return apiClient; } - /** - * Required by autowired constructor {@link ApiClient#ApiClient(RestTemplate)} - * - * @return Instance of RestTemplate - */ - @Bean - public RestTemplate restTemplate() { - return new RestTemplate(); - } - } diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/E2ManagerController.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/E2ManagerController.java new file mode 100644 index 00000000..c76d4aab --- /dev/null +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/E2ManagerController.java @@ -0,0 +1,111 @@ +/*- + * ========================LICENSE_START================================= + * ORAN-OSC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ +package org.oranosc.ric.portal.dash.controller; + +import java.lang.invoke.MethodHandles; +import java.util.HashSet; +import java.util.Set; + +import javax.servlet.http.HttpServletResponse; + +import org.oranosc.ric.e2mgr.client.api.DefaultApi; +import org.oranosc.ric.e2mgr.client.model.RanSetupRequest; +import org.oranosc.ric.portal.dash.DashboardConstants; +import org.oranosc.ric.portal.dash.model.SuccessTransport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import io.swagger.annotations.ApiOperation; + +/** + * Provides methods to contact the E2 Manager. + * + * As of this writing the E2 interface only supports setup connection and check + * health actions; it does not support query or close operations on existing + * connections. So this class mocks up some of that needed functionality. + */ +@Configuration +@RestController +@RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/e2mgr", produces = MediaType.APPLICATION_JSON_VALUE) +public class E2ManagerController { + + private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); + + @Autowired + private DefaultApi e2ManagerClient; + + // Tracks the requests previously submitted. + // TODO remove when the E2 manager is extended. + private Set requests = new HashSet<>(); + + private void assertNotNull(Object o) { + if (o == null) + throw new IllegalArgumentException("Null not permitted"); + } + + private void assertNotEmpty(String s) { + assertNotNull(s); + if (s.isEmpty()) + throw new IllegalArgumentException("Empty not permitted"); + } + + @ApiOperation(value = "Gets the health from the E2 manager, expressed as the response code.", response = String.class) + @RequestMapping(value = "/health", method = RequestMethod.GET) + public SuccessTransport getHealth() { + logger.debug("getHealth"); + return new SuccessTransport(); + } + + @ApiOperation(value = "Gets the unique requests submitted to the E2 manager.", response = RanSetupRequest.class, responseContainer = "List") + @RequestMapping(value = "/setup", method = RequestMethod.GET) + public Iterable getRequests() { + logger.debug("getRequests"); + return requests; + } + + @ApiOperation(value = "Sets up a RAN connection via the E2 manager.") + @RequestMapping(value = "/setup", method = RequestMethod.POST) + public void setup(@RequestBody RanSetupRequest rsr, HttpServletResponse response) { + logger.debug("setup {}", rsr); + try { + assertNotEmpty(rsr.getRanIp()); + assertNotEmpty(rsr.getRanName()); + assertNotNull(rsr.getRanPort()); + } catch (Exception ex) { + logger.error("Bad request", ex); + response.setStatus(HttpServletResponse.SC_BAD_REQUEST); + } + try { + requests.add(rsr); + e2ManagerClient.setupRan(rsr); + } catch (Exception ex) { + logger.error("Failed", ex); + response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); + } + } + +} diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/SimpleErrorController.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/SimpleErrorController.java new file mode 100644 index 00000000..f7180d3a --- /dev/null +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/SimpleErrorController.java @@ -0,0 +1,100 @@ +/*- + * ========================LICENSE_START================================= + * ORAN-OSC + * %% + * Copyright (C) 2019 AT&T Intellectual Property and Nokia + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ========================LICENSE_END=================================== + */ +package org.oranosc.ric.portal.dash.controller; + +import java.util.Map; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.web.servlet.error.ErrorAttributes; +import org.springframework.boot.web.servlet.error.ErrorController; +import org.springframework.util.Assert; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.context.request.ServletWebRequest; +import org.springframework.web.context.request.WebRequest; + +import springfox.documentation.annotations.ApiIgnore; + +/** + * Returns JSON on error within the Spring-managed context. Does not fire for + * anything else; e.g., resource not found outside the context. If trace is + * requested via request parameter ("?trace=true") and available, adds stack + * trace information to the standard JSON error response. + * + * Excluded from Swagger API documentation. + * + * https://stackoverflow.com/questions/25356781/spring-boot-remove-whitelabel-error-page + * https://www.baeldung.com/spring-boot-custom-error-page + */ +@ApiIgnore +@RestController +public class SimpleErrorController implements ErrorController { + + private static final String ERROR_PATH = "/error"; + private static final String TRACE = "trace"; + private final ErrorAttributes errorAttributes; + + /** + * Constructor + * + * @param errorAttributes + * error attributes must not be null + */ + @Autowired + public SimpleErrorController(ErrorAttributes errorAttributes) { + Assert.notNull(errorAttributes, "ErrorAttributes must not be null"); + this.errorAttributes = errorAttributes; + } + + @Override + public String getErrorPath() { + return ERROR_PATH; + } + + /** + * Builds a map with error details + * + * @param aRequest + * HttpServletRequest + * @return Map of String to Object + */ + @RequestMapping(ERROR_PATH) + public Map error(HttpServletRequest aRequest) { + Map body = getErrorAttributes(aRequest, getTraceParameter(aRequest)); + body.put("decorated-by", SimpleErrorController.class.getName()); + body.computeIfPresent(TRACE, (key, value) -> body.put(TRACE, ((String) value).split("\n\t"))); + return body; + } + + private boolean getTraceParameter(HttpServletRequest request) { + String parameter = request.getParameter(TRACE); + if (parameter == null) + return false; + return !"false".equalsIgnoreCase(parameter); + } + + private Map getErrorAttributes(HttpServletRequest aRequest, boolean includeStackTrace) { + WebRequest webRequest = new ServletWebRequest(aRequest); + return errorAttributes.getErrorAttributes(webRequest, includeStackTrace); + } + +} diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/CatalogController.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappCatalogController.java similarity index 91% rename from webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/CatalogController.java rename to webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappCatalogController.java index 3b8d998b..b36740a6 100644 --- a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/CatalogController.java +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappCatalogController.java @@ -22,9 +22,9 @@ package org.oranosc.ric.portal.dash.controller; import java.lang.invoke.MethodHandles; import org.oranosc.ric.portal.dash.DashboardConstants; -import org.oranosc.ric.portal.dashboard.xmc.model.AllXapps; -import org.oranosc.ric.portal.dashboard.xmc.model.Xapp; -import org.oranosc.ric.portal.dashboard.xmc.model.Xapp.StatusEnum; +import org.oranosc.ric.xappmgr.client.model.AllXapps; +import org.oranosc.ric.xappmgr.client.model.Xapp; +import org.oranosc.ric.xappmgr.client.model.Xapp.StatusEnum; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.MediaType; @@ -34,7 +34,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping(value = DashboardConstants.ENDPOINT_PREFIX + "/catalog", produces = MediaType.APPLICATION_JSON_VALUE) -public class CatalogController { +public class XappCatalogController { private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); diff --git a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappManagerController.java b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappManagerController.java index 1e4e5224..c70958c1 100644 --- a/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappManagerController.java +++ b/webapp-backend/src/main/java/org/oranosc/ric/portal/dash/controller/XappManagerController.java @@ -22,8 +22,8 @@ package org.oranosc.ric.portal.dash.controller; import java.lang.invoke.MethodHandles; import org.oranosc.ric.portal.dash.DashboardConstants; -import org.oranosc.ric.portal.dashboard.xmc.api.DefaultApi; -import org.oranosc.ric.portal.dashboard.xmc.model.AllXapps; +import org.oranosc.ric.xappmgr.client.api.DefaultApi; +import org.oranosc.ric.xappmgr.client.model.AllXapps; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; diff --git a/webapp-backend/src/main/resources/application.properties b/webapp-backend/src/main/resources/application.properties index 1c2f09b2..5e8ba9d1 100644 --- a/webapp-backend/src/main/resources/application.properties +++ b/webapp-backend/src/main/resources/application.properties @@ -19,10 +19,18 @@ ### # Default properties for the RIC Dashboard backend REST server +# This lacks any spring prefix +# The server port number is chosen RANDOMLY when running a test +server.port = 8080 + # A1 mediation URL is editable a1.mediation.url = http://localhost:12345 a1.mediation.delay.path = /a1ric/delay a1.mediation.load.path = /a1ric/load a1.mediation.metrics.path = /a1ric/metrics -xapp.manager.base.url = http://localhost:30099 \ No newline at end of file +# E2 +e2.manager.base.url = http://localhost:30098 + +# Xapp Manager (not A1 mediator) +xapp.manager.base.url = http://localhost:30099 diff --git a/xapp-mgr-client/pom.xml b/xapp-mgr-client/pom.xml index cc549400..2659dbf1 100644 --- a/xapp-mgr-client/pom.xml +++ b/xapp-mgr-client/pom.xml @@ -27,6 +27,7 @@ limitations under the License. ric-dash-parent 1.0.0-SNAPSHOT + org.oranosc.ric.xappmgr.client xapp-mgr-client RIC xApp Manager client 0.0.10-SNAPSHOT @@ -34,7 +35,7 @@ limitations under the License. UTF-8 UTF-8 1.5.15 - ${project.groupId}.xmc + org.oranosc.ric.xappmgr.client @@ -81,9 +82,9 @@ limitations under the License. - junit - junit - + org.junit.jupiter + junit-jupiter-api + test @@ -99,7 +100,7 @@ limitations under the License. generate - ${project.basedir}/xapp_manager_rest_api_v0_0_10.json + ${project.basedir}/src/main/resources/xapp_manager_rest_api_v0_0_10.json java ${project.groupId} diff --git a/xapp-mgr-client/xapp_manager_rest_api_v0_0_10.json b/xapp-mgr-client/src/main/resources/xapp_manager_rest_api_v0_0_10.json similarity index 100% rename from xapp-mgr-client/xapp_manager_rest_api_v0_0_10.json rename to xapp-mgr-client/src/main/resources/xapp_manager_rest_api_v0_0_10.json diff --git a/xapp-mgr-client/XappManagerClientDemo.java b/xapp-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/xmc/demo/XappManagerClientTest.java similarity index 65% rename from xapp-mgr-client/XappManagerClientDemo.java rename to xapp-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/xmc/demo/XappManagerClientTest.java index bb5a58ad..eaf316d5 100644 --- a/xapp-mgr-client/XappManagerClientDemo.java +++ b/xapp-mgr-client/src/test/java/org/oranosc/ric/portal/dashboard/xmc/demo/XappManagerClientTest.java @@ -19,32 +19,39 @@ */ package org.oranosc.ric.portal.dashboard.xmc.demo; -import org.oranosc.ric.portal.dashboard.api.DefaultApi; -import org.oranosc.ric.portal.dashboard.model.AllXapps; -import org.oranosc.ric.portal.dashboard.invoker.ApiClient; -import org.oranosc.ric.portal.dashboard.model.Xapp; +import org.junit.jupiter.api.Test; +import org.oranosc.ric.xappmgr.client.api.DefaultApi; +import org.oranosc.ric.xappmgr.client.invoker.ApiClient; +import org.oranosc.ric.xappmgr.client.model.AllXapps; +import org.oranosc.ric.xappmgr.client.model.Xapp; import org.springframework.web.client.RestClientException; -public class XappManagerClientDemo { +/** + * Demonstrates use of the generated xApp manager client. + * + * The test fails because no server is available. + */ +public class XappManagerClientTest { - public static void main(String[] args) { + @Test + public void demo() { ApiClient apiClient = new ApiClient(); apiClient.setBasePath("http://localhost:30099/"); DefaultApi apiInstance = new DefaultApi(apiClient); try { apiInstance.getHealth(); - System.out.println("Healthcheck answered " + apiClient.getStatusCode().toString()); + System.out.println("getHealth answered: " + apiClient.getStatusCode().toString()); } catch (RestClientException e) { - System.err.println("Failed on DefaultApi#getHealth: " + e.toString()); + System.err.println("getHealth failed: " + e.toString()); } try { AllXapps allXapps = apiInstance.getAllXapps(); - System.out.println("getAllXapps answered " + apiClient.getStatusCode().toString()); + System.out.println("getAllXapps answered: " + apiClient.getStatusCode().toString()); System.out.println("xApp count: " + allXapps.size()); for (Xapp x : allXapps) System.out.println("xApp: " + x.toString()); } catch (RestClientException e) { - System.err.println("Failed on DefaultApi#getAllXapps: " + e.toString()); + System.err.println("getAllXapps failed: " + e.toString()); } }