From c7d74b01b59da07704be4069acece1a91d451a7e Mon Sep 17 00:00:00 2001 From: "Lott, Christopher (cl778h)" Date: Fri, 28 Feb 2020 15:00:18 -0500 Subject: [PATCH] Drop A1 mediator and AC xApp Drop AC xApp control/config screen from front-end. Drop A1 Mediator controller and tests from back-end. Change AC metrics tab to Machine Learning (ML). Issue-ID: OAM-56 Change-Id: I0e9958212c230d417131519f5f69023dc2a0720e Signed-off-by: Lott, Christopher (cl778h) --- .gitmodules | 3 - dashboard/a1-med-client/.gitignore | 23 --- dashboard/a1-med-client/README.md | 31 ---- dashboard/a1-med-client/pom.xml | 193 --------------------- dashboard/a1-med-client/ric-plt-a1 | 1 - .../a1med/client/test/A1MediatorClientTest.java | 58 ------- dashboard/pom.xml | 1 - dashboard/webapp-backend/pom.xml | 5 - .../ric/portal/dashboard/DashboardConstants.java | 2 +- .../dashboard/config/A1MediatorApiBuilder.java | 65 ------- .../dashboard/config/A1MediatorConfiguration.java | 61 ------- .../dashboard/config/WebSecurityConfiguration.java | 2 - .../dashboard/controller/A1MediatorController.java | 138 --------------- .../dashboard/controller/AdminController.java | 12 +- .../src/main/resources/application.yaml | 2 +- .../config/A1MediatorMockConfiguration.java | 152 ---------------- .../config/AppManagerMockConfiguration.java | 2 +- .../config/test/A1MediatorConfigTest.java | 37 ---- .../controller/A1MediatorControllerTest.java | 109 ------------ .../dashboard/controller/AdminControllerTest.java | 4 +- .../resources/rate-control-policy-instance.json | 7 - .../test/resources/rate-control-policy-type.json | 44 ----- .../src/app/ac-xapp/ac-xapp.component.html | 60 ------- .../src/app/ac-xapp/ac-xapp.component.scss | 38 ---- .../src/app/ac-xapp/ac-xapp.component.spec.ts | 45 ----- .../src/app/ac-xapp/ac-xapp.component.ts | 121 ------------- .../src/app/app-control/app-control.component.ts | 8 +- .../src/app/interfaces/ac-xapp.types.ts | 34 ---- .../webapp-frontend/src/app/rd-routing.module.ts | 2 - dashboard/webapp-frontend/src/app/rd.module.ts | 2 - .../app/services/ac-xapp/ac-xapp.service.spec.ts | 31 ---- .../src/app/services/ac-xapp/ac-xapp.service.ts | 81 --------- .../src/app/stats/stats.component.html | 8 +- .../src/app/stats/stats.component.ts | 9 +- .../ui/catalog-card/catalog-card.component.html | 3 - docs/release-notes.rst | 4 +- 36 files changed, 23 insertions(+), 1375 deletions(-) delete mode 100644 dashboard/a1-med-client/.gitignore delete mode 100644 dashboard/a1-med-client/README.md delete mode 100644 dashboard/a1-med-client/pom.xml delete mode 160000 dashboard/a1-med-client/ric-plt-a1 delete mode 100644 dashboard/a1-med-client/src/test/java/org/oransc/ric/portal/dashboard/a1med/client/test/A1MediatorClientTest.java delete mode 100644 dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorApiBuilder.java delete mode 100644 dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfiguration.java delete mode 100644 dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1MediatorController.java delete mode 100644 dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java delete mode 100644 dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/test/A1MediatorConfigTest.java delete mode 100644 dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/A1MediatorControllerTest.java delete mode 100644 dashboard/webapp-backend/src/test/resources/rate-control-policy-instance.json delete mode 100644 dashboard/webapp-backend/src/test/resources/rate-control-policy-type.json delete mode 100644 dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.html delete mode 100644 dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.scss delete mode 100644 dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.spec.ts delete mode 100644 dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.ts delete mode 100644 dashboard/webapp-frontend/src/app/interfaces/ac-xapp.types.ts delete mode 100644 dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.spec.ts delete mode 100644 dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.ts diff --git a/.gitmodules b/.gitmodules index e4d0c777..3f35354f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,3 @@ -[submodule "dashboard/a1-med-client/ric-plt-a1"] - path = dashboard/a1-med-client/ric-plt-a1 - url = ../../ric-plt/a1 [submodule "dashboard/app-mgr-client/ric-plt-appmgr"] path = dashboard/app-mgr-client/ric-plt-appmgr url = ../../ric-plt/appmgr diff --git a/dashboard/a1-med-client/.gitignore b/dashboard/a1-med-client/.gitignore deleted file mode 100644 index 27fd4617..00000000 --- a/dashboard/a1-med-client/.gitignore +++ /dev/null @@ -1,23 +0,0 @@ -*.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/dashboard/a1-med-client/README.md b/dashboard/a1-med-client/README.md deleted file mode 100644 index beaff1b5..00000000 --- a/dashboard/a1-med-client/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# A1 Mediator Client Generator - -This projects generates a REST client library from the OpenAPI specification -file obtained from the ric-plt/a1 project, available here as a git submodule -with a pinned version, and packages it in a jar. - -## Eclipse and STS Users - -The source folder should be generated automatically by the Swagger Codegen maven -plugin and should also appear on the build path in Eclipse/STS, but if not, -follow these steps: - -1. Generate the code using maven: - mvn install -2. Add this folder to the project build path: - target/generated-sources/swagger/src/main/java - -## License - -Copyright (C) 2019-2020 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/dashboard/a1-med-client/pom.xml b/dashboard/a1-med-client/pom.xml deleted file mode 100644 index 34ee440b..00000000 --- a/dashboard/a1-med-client/pom.xml +++ /dev/null @@ -1,193 +0,0 @@ - - - - 4.0.0 - - org.o-ran-sc.portal.ric-dashboard - ric-dash-parent - 2.0.1-SNAPSHOT - - - org.o-ran-sc.ric-plt.a1.client - a1-med-client - RIC A1 Mediator Client - - 2.1.0-SNAPSHOT - - UTF-8 - UTF-8 - - 0 - - org.oransc.ricplt.a1.client - - - - - - javax.annotation - javax.annotation-api - - - io.swagger.core.v3 - swagger-annotations - 2.0.8 - - - 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.codegen.v3 - swagger-codegen-maven-plugin - 3.0.8 - - - - generate - - - ${project.basedir}/ric-plt-a1/a1/openapi.yaml - java - ${client.base.package.name} - ${client.base.package.name}.model - ${client.base.package.name}.api - ${client.base.package.name}.invoker - - ${project.groupId} - ${project.artifactId} - ${project.version} - resttemplate - true - java8 - Apache 2.0 - https://www.apache.org/licenses/LICENSE-2.0 - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - true - - - ${project.version}-b${build.number} - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - - generate-sources - - add-source - - - - target/generated-sources/swagger/src/main/java - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - io.swagger.codegen.v3 - swagger-codegen-maven-plugin - [1.0,) - - generate - - - - - - - - - - - - - - diff --git a/dashboard/a1-med-client/ric-plt-a1 b/dashboard/a1-med-client/ric-plt-a1 deleted file mode 160000 index ccb4a69e..00000000 --- a/dashboard/a1-med-client/ric-plt-a1 +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ccb4a69e473cab6db7e8d52a04f9b4922528e24f diff --git a/dashboard/a1-med-client/src/test/java/org/oransc/ric/portal/dashboard/a1med/client/test/A1MediatorClientTest.java b/dashboard/a1-med-client/src/test/java/org/oransc/ric/portal/dashboard/a1med/client/test/A1MediatorClientTest.java deleted file mode 100644 index 8e5cef4e..00000000 --- a/dashboard/a1-med-client/src/test/java/org/oransc/ric/portal/dashboard/a1med/client/test/A1MediatorClientTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.a1med.client.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.oransc.ricplt.a1.client.api.A1MediatorApi; -import org.oransc.ricplt.a1.client.invoker.ApiClient; -import org.springframework.web.client.RestClientException; - -/** - * Demonstrates use of the generated A1 mediator client. - * - * The tests fail because no server is available. - */ -public class A1MediatorClientTest { - - @Test - public void demo() { - ApiClient apiClient = new ApiClient(); - apiClient.setBasePath("http://localhost:30099/"); - A1MediatorApi a1Api = new A1MediatorApi(apiClient); - try { - Object o = a1Api.a1ControllerGetPolicyInstance(1, "policyInstanceId"); - System.out.println("a1ControllerGetPolicyInstance answered code {} " + apiClient.getStatusCode().toString() - + ", content " + o.toString()); - Assertions.assertTrue(apiClient.getStatusCode().is2xxSuccessful()); - } catch (RestClientException e) { - System.err.println("a1ControllerGetPolicyInstance failed: " + e.toString()); - } - try { - String policy = "{}"; - a1Api.a1ControllerCreateOrReplacePolicyInstance(1, "policyInstanceId", policy); - System.out.println( - "a1ControllerCreateOrReplacePolicyInstance answered: " + apiClient.getStatusCode().toString()); - Assertions.assertTrue(apiClient.getStatusCode().is2xxSuccessful()); - } catch (RestClientException e) { - System.err.println("a1ControllerCreateOrReplacePolicyInstance failed: " + e.toString()); - } - } -} diff --git a/dashboard/pom.xml b/dashboard/pom.xml index b61a4b02..75b587b0 100644 --- a/dashboard/pom.xml +++ b/dashboard/pom.xml @@ -44,7 +44,6 @@ limitations under the License. ========================LICENSE_END=================================== - a1-med-client app-mgr-client e2-mgr-client webapp-frontend diff --git a/dashboard/webapp-backend/pom.xml b/dashboard/webapp-backend/pom.xml index 5e944213..ed1da945 100644 --- a/dashboard/webapp-backend/pom.xml +++ b/dashboard/webapp-backend/pom.xml @@ -44,11 +44,6 @@ limitations under the License. - - org.o-ran-sc.ric-plt.a1.client - a1-med-client - 2.1.0-SNAPSHOT - org.o-ran-sc.ric-plt.appmgr.client app-mgr-client diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java index 6f02a223..6f124ed8 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/DashboardConstants.java @@ -31,8 +31,8 @@ public abstract class DashboardConstants { // Factor out method names used in multiple controllers public static final String VERSION_METHOD = "version"; // Apps with metric panels - public static final String APP_NAME_AC = "AC"; public static final String APP_NAME_MC = "MC"; + public static final String APP_NAME_ML = "ML"; // The role names are defined by ONAP Portal. // The prefix "ROLE_" is required by Spring. // These are used in Java code annotations that require constants. diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorApiBuilder.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorApiBuilder.java deleted file mode 100644 index 4604e3c9..00000000 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorApiBuilder.java +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.config; - -import java.lang.invoke.MethodHandles; - -import org.oransc.ric.portal.dashboard.model.RicInstance; -import org.oransc.ric.portal.dashboard.model.RicRegionList; -import org.oransc.ricplt.a1.client.api.A1MediatorApi; -import org.oransc.ricplt.a1.client.invoker.ApiClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.DefaultUriBuilderFactory; - -/** - * The OpenAPI generated API client code using Spring RestTemplate is not thread - * safe according to https://github.com/swagger-api/swagger-codegen/issues/9222 - * - * As a workaround this builder creates a new client at every request. If this - * proves to be too slow then clients could be cached for each thread. - */ -public class A1MediatorApiBuilder { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final String urlSuffix; - private final RicRegionList instanceConfig; - - public A1MediatorApiBuilder(final RicRegionList instanceConfig, final String urlSuffix) { - logger.debug("ctor: suffix {}", urlSuffix); - this.instanceConfig = instanceConfig; - this.urlSuffix = urlSuffix; - } - - private ApiClient apiClient(String instanceKey) { - RicInstance instance = instanceConfig.getInstance(instanceKey); - String url = new DefaultUriBuilderFactory(instance.getPltUrlPrefix().trim()).builder() - .path(this.urlSuffix.trim()).build().normalize().toString(); - logger.debug("apiClient URL {}", url); - return new ApiClient(new RestTemplate()).setBasePath(url); - } - - public A1MediatorApi getA1MediatorApi(String instanceKey) { - return new A1MediatorApi(apiClient(instanceKey)); - } - -} diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfiguration.java deleted file mode 100644 index 2e8efb2b..00000000 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/A1MediatorConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.config; - -import java.lang.invoke.MethodHandles; - -import org.oransc.ric.portal.dashboard.model.RicRegionList; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; - -/** - * Creates an A1 mediator client builder as a bean to be managed by the Spring - * container. - */ -@Configuration -@Profile("!test") -public class A1MediatorConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - // Populated by the autowired constructor - private final String urlSuffix; - private final RicRegionList instanceConfig; - - @Autowired - public A1MediatorConfiguration(@Value("${a1med.url.suffix}") final String urlSuffix, - final RicRegionList instanceConfig) { - logger.info("ctor: URL suffix {}", urlSuffix); - this.urlSuffix = urlSuffix; - this.instanceConfig = instanceConfig; - } - - @Bean - // The bean (method) name must be globally unique - public A1MediatorApiBuilder a1MediatorApiBuilder() { - return new A1MediatorApiBuilder(instanceConfig, urlSuffix); - } - -} diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java index f1438d7e..471002ad 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/config/WebSecurityConfiguration.java @@ -25,7 +25,6 @@ import java.lang.reflect.InvocationTargetException; import org.onap.portalsdk.core.onboarding.util.PortalApiConstants; import org.oransc.ric.portal.dashboard.DashboardConstants; import org.oransc.ric.portal.dashboard.DashboardUserManager; -import org.oransc.ric.portal.dashboard.controller.A1MediatorController; import org.oransc.ric.portal.dashboard.controller.AdminController; import org.oransc.ric.portal.dashboard.controller.AppManagerController; import org.oransc.ric.portal.dashboard.controller.E2ManagerController; @@ -93,7 +92,6 @@ public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { "/swagger-ui.html", // "/webjars/**", // PortalApiConstants.API_PREFIX + "/**", // - A1MediatorController.CONTROLLER_PATH + "/" + DashboardConstants.VERSION_METHOD, // AdminController.CONTROLLER_PATH + "/" + AdminController.HEALTH_METHOD, // AdminController.CONTROLLER_PATH + "/" + AdminController.VERSION_METHOD, // AppManagerController.CONTROLLER_PATH + "/" + DashboardConstants.RIC_INSTANCE_KEY + "/*/" diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1MediatorController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1MediatorController.java deleted file mode 100644 index c31fc0be..00000000 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/A1MediatorController.java +++ /dev/null @@ -1,138 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.controller; - -import java.lang.invoke.MethodHandles; -import java.util.List; - -import org.oransc.ric.portal.dashboard.DashboardApplication; -import org.oransc.ric.portal.dashboard.DashboardConstants; -import org.oransc.ric.portal.dashboard.config.A1MediatorApiBuilder; -import org.oransc.ric.portal.dashboard.model.SuccessTransport; -import org.oransc.ricplt.a1.client.api.A1MediatorApi; -import org.oransc.ricplt.a1.client.model.PolicyTypeSchema; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.security.access.annotation.Secured; -import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; - -/** - * Proxies calls from the front end to the A1 Mediator API to get and put - * policies. All methods are deliberately kept ignorant of the data format. - * - * If a method throws RestClientResponseException, it is handled by - * {@link CustomResponseEntityExceptionHandler#handleProxyMethodException(Exception, org.springframework.web.context.request.WebRequest)} - * which returns status 502. All other exceptions are handled by Spring which - * returns status 500. - */ -@RestController -@RequestMapping(value = A1MediatorController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE) -public class A1MediatorController { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - // Publish paths in constants so tests are easy to write - public static final String CONTROLLER_PATH = DashboardConstants.ENDPOINT_PREFIX + "/a1-p"; - public static final String PP_TYPE_ID = "poltype"; - public static final String PP_INST_ID = "polinst"; - // The get- and put-instance methods use the same path - private static final String POLICY_INSTANCE_METHOD_PATH = /* controller path + */ DashboardConstants.RIC_INSTANCE_KEY - + "/{" + DashboardConstants.RIC_INSTANCE_KEY + "}/" + PP_TYPE_ID + "/{" + PP_TYPE_ID + "}/" + PP_INST_ID - + "/{" + PP_INST_ID + "}"; - - // Populated by the autowired constructor - private final A1MediatorApiBuilder a1MediatorClientBuilder; - - @Autowired - public A1MediatorController(final A1MediatorApiBuilder a1MediatorApiBuilder) { - Assert.notNull(a1MediatorApiBuilder, "builder must not be null"); - this.a1MediatorClientBuilder = a1MediatorApiBuilder; - if (logger.isDebugEnabled()) - logger.debug("ctor: configured with builder type {}", a1MediatorApiBuilder.getClass().getName()); - } - - @ApiOperation(value = "Gets the A1 client library MANIFEST.MF property Implementation-Version.", response = SuccessTransport.class) - @GetMapping(DashboardConstants.VERSION_METHOD) - // No role required - public SuccessTransport getA1MediatorClientVersion() { - return new SuccessTransport(200, DashboardApplication.getImplementationVersion(A1MediatorApi.class)); - } - - @ApiOperation(value = "Gets the registered policy type IDs from the A1 Mediator", response = Integer.class, responseContainer = "List") - @GetMapping(DashboardConstants.RIC_INSTANCE_KEY + "/{" + DashboardConstants.RIC_INSTANCE_KEY + "}/" + PP_TYPE_ID) - @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD }) - public List getAllPolicyTypes(@PathVariable(DashboardConstants.RIC_INSTANCE_KEY) String instanceKey) { - logger.debug("getAllPolicyTypes: instance {}", instanceKey); - Object result = a1MediatorClientBuilder.getA1MediatorApi(instanceKey).a1ControllerGetAllPolicyTypes(); - @SuppressWarnings("unchecked") - List result2 = (List) result; - return result2; - } - - @ApiOperation(value = "Gets the specified policy type from the A1 Mediator", response = PolicyTypeSchema.class) - @GetMapping(DashboardConstants.RIC_INSTANCE_KEY + "/{" + DashboardConstants.RIC_INSTANCE_KEY + "}/" + PP_TYPE_ID - + "/{" + PP_TYPE_ID + "}") - @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD }) - public PolicyTypeSchema getPolicyType(@PathVariable(DashboardConstants.RIC_INSTANCE_KEY) String instanceKey, - @PathVariable(PP_TYPE_ID) Integer policyTypeId) { - logger.debug("getPolicyType: instance {} typeId {}", instanceKey, policyTypeId); - return a1MediatorClientBuilder.getA1MediatorApi(instanceKey).a1ControllerGetPolicyType(policyTypeId); - } - - @ApiOperation(value = "Gets the specified policy instance from the A1 Mediator") - @GetMapping(POLICY_INSTANCE_METHOD_PATH) - @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD }) - public Object getPolicyInstance(@PathVariable(DashboardConstants.RIC_INSTANCE_KEY) String instanceKey, - @PathVariable(PP_TYPE_ID) Integer policyTypeId, // - @PathVariable(PP_INST_ID) String policyInstanceId) { - logger.debug("getPolicyInstance: instance {} typeId {} instanceId {}", instanceKey, policyTypeId, - policyInstanceId); - return a1MediatorClientBuilder.getA1MediatorApi(instanceKey).a1ControllerGetPolicyInstance(policyTypeId, - policyInstanceId); - } - - @ApiOperation(value = "Creates or replaces the specified policy instance at the A1 Mediator") - @PutMapping(POLICY_INSTANCE_METHOD_PATH) - @Secured({ DashboardConstants.ROLE_ADMIN }) - public ResponseEntity createPolicyInstance( - @PathVariable(DashboardConstants.RIC_INSTANCE_KEY) String instanceKey, - @PathVariable(PP_TYPE_ID) Integer policyTypeId, // - @PathVariable(PP_INST_ID) String policyInstanceId, - @ApiParam(value = "Policy body") @RequestBody String policyBody) { - logger.debug("createPolicyInstance: instance {} typeId {} instanceId {}", instanceKey, policyTypeId, - policyInstanceId); - A1MediatorApi api = a1MediatorClientBuilder.getA1MediatorApi(instanceKey); - api.a1ControllerCreateOrReplacePolicyInstance(policyTypeId, policyInstanceId, policyBody); - return ResponseEntity.status(api.getApiClient().getStatusCode().value()).body(null); - } - -} diff --git a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java index 58e94810..1285a0b6 100644 --- a/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java +++ b/dashboard/webapp-backend/src/main/java/org/oransc/ric/portal/dashboard/controller/AdminController.java @@ -62,12 +62,12 @@ public class AdminController { public static final String VERSION_METHOD = DashboardConstants.VERSION_METHOD; public static final String XAPPMETRICS_METHOD = "metrics"; - @Value("${metrics.url.ac}") - private String acAppMetricsUrl; - @Value("${metrics.url.mc}") private String mcAppMetricsUrl; + @Value("${metrics.url.ml}") + private String mlAppMetricsUrl; + @Autowired private DashboardUserManager dashboardUserManager; @@ -114,10 +114,10 @@ public class AdminController { @Secured({ DashboardConstants.ROLE_ADMIN, DashboardConstants.ROLE_STANDARD }) public ResponseEntity getAppMetricsUrl(@RequestParam String app) { String metricsUrl = null; - if (DashboardConstants.APP_NAME_AC.equals(app)) - metricsUrl = acAppMetricsUrl; - else if (DashboardConstants.APP_NAME_MC.equals(app)) + if (DashboardConstants.APP_NAME_MC.equals(app)) metricsUrl = mcAppMetricsUrl; + else if (DashboardConstants.APP_NAME_ML.equals(app)) + metricsUrl = mlAppMetricsUrl; logger.debug("getAppMetricsUrl: app {} metricsurl {}", app, metricsUrl); if (metricsUrl != null) return new ResponseEntity<>(new SuccessTransport(HttpStatus.OK.ordinal(), metricsUrl), HttpStatus.OK); diff --git a/dashboard/webapp-backend/src/main/resources/application.yaml b/dashboard/webapp-backend/src/main/resources/application.yaml index da8fe99f..9a327eb4 100644 --- a/dashboard/webapp-backend/src/main/resources/application.yaml +++ b/dashboard/webapp-backend/src/main/resources/application.yaml @@ -82,8 +82,8 @@ mock: # Kibana report on metrics metrics: url: - ac: http://jar-app-props-kibana-url-ac mc: http://jar-app-props-kibana-url-mc + ml: http://jar-app-props-kibana-url-ml # Regions and instances # The regions are a just convenience for users, diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java deleted file mode 100644 index b1ff3f9c..00000000 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/A1MediatorMockConfiguration.java +++ /dev/null @@ -1,152 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.config; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.oransc.ric.portal.dashboard.TestUtils; -import org.oransc.ricplt.a1.client.api.A1MediatorApi; -import org.oransc.ricplt.a1.client.invoker.ApiClient; -import org.oransc.ricplt.a1.client.model.PolicyTypeSchema; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Profile; -import org.springframework.http.HttpStatus; - -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; -import com.fasterxml.jackson.databind.ObjectMapper; - -/** - * Creates a mock implementation of the A1 mediator client builder with mock - * methods that answer Admission Control mock data. - */ -@Configuration -@Profile("test") -public class A1MediatorMockConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - // A "control" is an element in the XApp descriptor - public static final String AC_CONTROL_NAME = "admission_control_policy"; - public static final Integer ADMISSION_CONTROL_POLICY_ID = 21000; - - // Simulate remote method delay for UI testing - private final int delayMs; - - // Mock values - private final List policyTypeIds; - private final PolicyTypeSchema rateControlPolicyType; - private final Map appPolicyMap; - - public A1MediatorMockConfiguration(@Value("${mock.config.delay:0}") int delayMs) - throws IOException, JsonParseException, JsonMappingException { - logger.debug("ctor: configured with delay {}", delayMs); - this.delayMs = delayMs; - policyTypeIds = new ArrayList<>(); - policyTypeIds.add(ADMISSION_CONTROL_POLICY_ID); - ObjectMapper mapper = new ObjectMapper(); - final String policyType = TestUtils.readDataFromPath("rate-control-policy-type.json"); - rateControlPolicyType = mapper.readValue(policyType, PolicyTypeSchema.class); - final String policyInstance = TestUtils.readDataFromPath("rate-control-policy-instance.json"); - appPolicyMap = new HashMap<>(); - appPolicyMap.put(AC_CONTROL_NAME, policyInstance); - } - - private void delay() throws InterruptedException { - if (delayMs > 0) { - logger.debug("delay: sleeping {}", delayMs); - Thread.sleep(delayMs); - } - } - - private ApiClient apiClient() { - ApiClient mockClient = mock(ApiClient.class); - when(mockClient.getStatusCode()).thenReturn(HttpStatus.OK); - return mockClient; - } - - private A1MediatorApi a1MediatorApi(String instanceKey) { - logger.debug("a1MediatorApi: instance {}", instanceKey); - ApiClient apiClient = apiClient(); - A1MediatorApi mockApi = mock(A1MediatorApi.class); - when(mockApi.getApiClient()).thenReturn(apiClient); - doAnswer(inv -> { - delay(); - return policyTypeIds; - }).when(mockApi).a1ControllerGetAllPolicyTypes(); - doAnswer(inv -> { - delay(); - Integer policyTypeId = inv.getArgument(0); - if (policyTypeId.compareTo(ADMISSION_CONTROL_POLICY_ID) != 0) - throw new IllegalArgumentException("Unexpected policy type: " + policyTypeId); - return rateControlPolicyType; - }).when(mockApi).a1ControllerGetPolicyType(any(Integer.class)); - doAnswer(inv -> { - delay(); - Integer policyTypeId = inv.getArgument(0); - if (policyTypeId.compareTo(ADMISSION_CONTROL_POLICY_ID) != 0) - throw new IllegalArgumentException("Unexpected policy type: " + policyTypeId); - String policyInstId = inv.getArgument(1); - if (!AC_CONTROL_NAME.equals(policyInstId)) - throw new IllegalArgumentException("Unexpected policy instance: " + policyInstId); - return appPolicyMap.get(policyInstId); - }).when(mockApi).a1ControllerGetPolicyInstance(any(Integer.class), any(String.class)); - doAnswer(inv -> { - delay(); - Integer policyTypeId = inv.getArgument(0); - if (policyTypeId.compareTo(ADMISSION_CONTROL_POLICY_ID) != 0) - throw new IllegalArgumentException("Unexpected policy type: " + policyTypeId); - String policyInstId = inv.getArgument(1); - if (!AC_CONTROL_NAME.equals(policyInstId)) - throw new IllegalArgumentException("Unexpected policy instance: " + policyInstId); - String policy = inv.getArgument(2); - appPolicyMap.put(policyInstId, policy); - return null; - }).when(mockApi).a1ControllerCreateOrReplacePolicyInstance(any(Integer.class), any(String.class), - any(Object.class)); - return mockApi; - } - - @Bean - // Must use the same name as the non-mock configuration - public A1MediatorApiBuilder a1MediatorApiBuilder() { - final A1MediatorApiBuilder mockBuilder = mock(A1MediatorApiBuilder.class); - for (final String key : RICInstanceMockConfiguration.INSTANCE_KEYS) { - final A1MediatorApi mockApi = a1MediatorApi(key); - when(mockBuilder.getA1MediatorApi(key)).thenReturn(mockApi); - } - return mockBuilder; - } - -} diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java index 32a775fa..341df538 100644 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java +++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/AppManagerMockConfiguration.java @@ -97,7 +97,7 @@ public class AppManagerMockConfiguration { private XappApi xappApi(String instanceKey) { logger.debug("Creating XappApi for instance {}", instanceKey); // Create instance-specific objects - String[] appNames = { "AdmissionControl " + instanceKey, "UE Event Collector " + instanceKey }; + String[] appNames = { "Measurement Campaign " + instanceKey, "UE Event Collector " + instanceKey }; final String configJson = " { \"config\" : \"example-" + instanceKey + "\"}"; final ConfigValidationErrors configValErrs = new ConfigValidationErrors(); configValErrs.add(new ConfigValidationError().field("mock error")); diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/test/A1MediatorConfigTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/test/A1MediatorConfigTest.java deleted file mode 100644 index cdea6d4b..00000000 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/config/test/A1MediatorConfigTest.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.config.test; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.oransc.ric.portal.dashboard.config.A1MediatorApiBuilder; -import org.oransc.ric.portal.dashboard.config.RICInstanceMockConfiguration; -import org.oransc.ricplt.a1.client.api.A1MediatorApi; - -public class A1MediatorConfigTest extends AbstractConfigTest { - - @Test - public void builderTest() { - A1MediatorApiBuilder builder = new A1MediatorApiBuilder(instanceConfig, "suffix"); - A1MediatorApi a1Api = builder.getA1MediatorApi(RICInstanceMockConfiguration.INSTANCE_KEY_1); - Assertions.assertNotNull(a1Api); - } - -} diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/A1MediatorControllerTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/A1MediatorControllerTest.java deleted file mode 100644 index 2a9b8202..00000000 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/A1MediatorControllerTest.java +++ /dev/null @@ -1,109 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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.oransc.ric.portal.dashboard.controller; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.net.URI; -import java.util.List; - -import org.junit.Assert; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.oransc.ric.portal.dashboard.DashboardConstants; -import org.oransc.ric.portal.dashboard.config.A1MediatorMockConfiguration; -import org.oransc.ric.portal.dashboard.config.RICInstanceMockConfiguration; -import org.oransc.ric.portal.dashboard.model.SuccessTransport; -import org.oransc.ricplt.a1.client.model.PolicyTypeSchema; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; - -public class A1MediatorControllerTest extends AbstractControllerTest { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Test - public void versionTest() { - URI uri = buildUri(null, A1MediatorController.CONTROLLER_PATH, DashboardConstants.VERSION_METHOD); - logger.info("Invoking {}", uri); - SuccessTransport st = restTemplate.getForObject(uri, SuccessTransport.class); - Assertions.assertFalse(st.getData().toString().isEmpty()); - } - - @Test - public void getTypeIdsTest() throws IOException { - URI uri = buildUri(null, A1MediatorController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY, - RICInstanceMockConfiguration.INSTANCE_KEY_1, A1MediatorController.PP_TYPE_ID); - logger.info("Invoking {}", uri); - ResponseEntity> response = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET, null, - new ParameterizedTypeReference>() { - }); - Assertions.assertTrue(response.getStatusCode().is2xxSuccessful()); - Assert.assertFalse(response.getBody().isEmpty()); - } - - @Test - public void getPolicyTypeTest() throws IOException { - URI uri = buildUri(null, A1MediatorController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY, - RICInstanceMockConfiguration.INSTANCE_KEY_1, A1MediatorController.PP_TYPE_ID, - Integer.toString(A1MediatorMockConfiguration.ADMISSION_CONTROL_POLICY_ID)); - logger.info("Invoking {}", uri); - ResponseEntity response = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET, null, - PolicyTypeSchema.class); - Assertions.assertTrue(response.getStatusCode().is2xxSuccessful()); - Assert.assertFalse(response.getBody().getName().isEmpty()); - } - - @Test - public void getInstanceTest() throws IOException { - URI uri = buildUri(null, A1MediatorController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY, - RICInstanceMockConfiguration.INSTANCE_KEY_1, A1MediatorController.PP_TYPE_ID, - Integer.toString(A1MediatorMockConfiguration.ADMISSION_CONTROL_POLICY_ID), - A1MediatorController.PP_INST_ID, A1MediatorMockConfiguration.AC_CONTROL_NAME); - logger.info("Invoking {}", uri); - ResponseEntity response = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET, null, - String.class); - Assertions.assertTrue(response.getStatusCode().is2xxSuccessful()); - Assert.assertFalse(response.getBody().isEmpty()); - } - - @Test - public void putInstanceTest() throws IOException { - URI uri = buildUri(null, A1MediatorController.CONTROLLER_PATH, DashboardConstants.RIC_INSTANCE_KEY, - RICInstanceMockConfiguration.INSTANCE_KEY_1, A1MediatorController.PP_TYPE_ID, - Integer.toString(A1MediatorMockConfiguration.ADMISSION_CONTROL_POLICY_ID), - A1MediatorController.PP_INST_ID, A1MediatorMockConfiguration.AC_CONTROL_NAME); - ObjectMapper mapper = new ObjectMapper(); - JsonNode body = mapper.readTree("{ \"policy\" : true }"); - HttpEntity entity = new HttpEntity<>(body); - logger.info("Invoking {} with body {}", uri, body); - ResponseEntity voidResponse = testRestTemplateAdminRole().exchange(uri, HttpMethod.PUT, entity, - Void.class); - Assertions.assertTrue(voidResponse.getStatusCode().is2xxSuccessful()); - } - -} diff --git a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java index fa1a832d..152d14b2 100644 --- a/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java +++ b/dashboard/webapp-backend/src/test/java/org/oransc/ric/portal/dashboard/controller/AdminControllerTest.java @@ -92,7 +92,7 @@ public class AdminControllerTest extends AbstractControllerTest { URI uri; metricsQueryParms.clear(); - metricsQueryParms.put("app", DashboardConstants.APP_NAME_AC); + metricsQueryParms.put("app", DashboardConstants.APP_NAME_MC); uri = buildUri(metricsQueryParms, AdminController.CONTROLLER_PATH, AdminController.XAPPMETRICS_METHOD); logger.debug("Invoking {}", uri); ResponseEntity successResponse = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET, @@ -101,7 +101,7 @@ public class AdminControllerTest extends AbstractControllerTest { Assertions.assertTrue(successResponse.getStatusCode().is2xxSuccessful()); metricsQueryParms.clear(); - metricsQueryParms.put("app", DashboardConstants.APP_NAME_MC); + metricsQueryParms.put("app", DashboardConstants.APP_NAME_ML); logger.debug("Invoking {}", uri); successResponse = testRestTemplateStandardRole().exchange(uri, HttpMethod.GET, null, SuccessTransport.class); Assertions.assertFalse(successResponse.getBody().getData().toString().isEmpty()); diff --git a/dashboard/webapp-backend/src/test/resources/rate-control-policy-instance.json b/dashboard/webapp-backend/src/test/resources/rate-control-policy-instance.json deleted file mode 100644 index d8742ff6..00000000 --- a/dashboard/webapp-backend/src/test/resources/rate-control-policy-instance.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "class": 12, - "enforce": true, - "window_length": 20, - "blocking_rate": 20, - "trigger_threshold": 10 -} diff --git a/dashboard/webapp-backend/src/test/resources/rate-control-policy-type.json b/dashboard/webapp-backend/src/test/resources/rate-control-policy-type.json deleted file mode 100644 index 7abf9322..00000000 --- a/dashboard/webapp-backend/src/test/resources/rate-control-policy-type.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "Policy for Rate Control", - "policy_type_id": 21000, - "description": "This policy is associated with rate control. An instance of the policy specifies the traffic class to which it applies and parameters to use to control how much it must be throttled in case of an overload. Each instance of the policy that is created MUST be associated with a unique class ID (identifyed by the key 'class', which is used by the xAPP to differentiate traffic. If an agent tries to create a policy with the SAME class id, it will be rejected by the xAPP, even if it has a unique policy instance id. ", - "create_schema": { - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "object", - "additionalProperties": false, - "properties": { - "class": { - "type": "integer", - "minimum": 1, - "maximum": 256, - "description": "integer id representing class to which we are applying policy" - }, - "enforce": { - "type": "boolean", - "description": "Whether to enable or disable enforcement of policy on this class" - }, - "window_length": { - "type": "integer", - "minimum": 15, - "maximum": 300, - "description": "Sliding window length in seconds" - }, - "trigger_threshold": { - "type": "integer", - "minimum": 1 - }, - "blocking_rate": { - "type": "number", - "minimum": 0, - "maximum": 100 - } - }, - "required": [ - "class", - "enforce", - "blocking_rate", - "trigger_threshold", - "window_length" - ] - } -} \ No newline at end of file diff --git a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.html b/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.html deleted file mode 100644 index 5b557532..00000000 --- a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.html +++ /dev/null @@ -1,60 +0,0 @@ - -
-

Admission Control xApp Policy

- -
-
- Enforce -
- - - Traffic class ID (1-256) - Number is required - - Valid number is required - - - - Sliding window length in minutes (15-300) - Number is required - - Valid number is required - - - - Connections to block when triggered (1-100) - Number is required - - Valid number is required - - - - Number of events in window to trigger blocking (min 1) - Number is - required - Valid number is required - -
- -
-
- -
diff --git a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.scss b/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.scss deleted file mode 100644 index 185a48f4..00000000 --- a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.scss +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - - .ac__section { -} - - /* used to place form fields on separate lines/rows */ -.input-display-block { - display: block; - width: 400px; -} - -.version__text { - color: gray; - font-size: 10px; -} - -.update-button { - margin-top: 10px; - float: right; -} diff --git a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.spec.ts b/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.spec.ts deleted file mode 100644 index a8329a52..00000000 --- a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.spec.ts +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AcXappComponent } from './ac-xapp.component'; - -describe('AcXappComponent', () => { - let component: AcXappComponent; - let fixture: ComponentFixture; - - beforeEach(async(() => { - TestBed.configureTestingModule({ - declarations: [ AcXappComponent ] - }) - .compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(AcXappComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.ts b/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.ts deleted file mode 100644 index 12caad72..00000000 --- a/dashboard/webapp-frontend/src/app/ac-xapp/ac-xapp.component.ts +++ /dev/null @@ -1,121 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - -import { HttpErrorResponse } from '@angular/common/http'; -import { Component, OnDestroy, OnInit } from '@angular/core'; -import { FormControl, FormGroup, Validators } from '@angular/forms'; -import { Subscription } from 'rxjs'; -import { ACAdmissionIntervalControl } from '../interfaces/ac-xapp.types'; -import { RicInstance } from '../interfaces/dashboard.types'; -import { ACXappService } from '../services/ac-xapp/ac-xapp.service'; -import { InstanceSelectorService } from '../services/instance-selector/instance-selector.service'; -import { ErrorDialogService } from '../services/ui/error-dialog.service'; -import { NotificationService } from '../services/ui/notification.service'; - -@Component({ - selector: 'rd-ac-xapp', - templateUrl: './ac-xapp.component.html', - styleUrls: ['./ac-xapp.component.scss'] -}) -export class AcXappComponent implements OnInit, OnDestroy { - - //declare acForm as Public variable. Private variables should not be used in template HTML - acForm: FormGroup; - private instanceChange: Subscription; - private instanceKey: string; - - constructor( - private acXappService: ACXappService, - private errorDialogService: ErrorDialogService, - private notificationService: NotificationService, - public instanceSelectorService: InstanceSelectorService, ) { } - - ngOnInit() { - this.acForm = new FormGroup({ - // Names must match the ACAdmissionIntervalControl interface - enforce: new FormControl(true, [Validators.required]), - class: new FormControl('', [Validators.required, Validators.min(1), Validators.max(256)]), - window_length: new FormControl('', [Validators.required, Validators.min(15), Validators.max(300)]), - blocking_rate: new FormControl('', [Validators.required, Validators.min(0), Validators.max(100)]), - trigger_threshold: new FormControl('', [Validators.required, Validators.min(1)]) - }); - - this.instanceChange = this.instanceSelectorService.getSelectedInstance().subscribe((instance: RicInstance) => { - if (instance.key) { - // TODO: show pending action indicator - this.instanceKey = instance.key; - this.acXappService.getPolicy(instance.key).subscribe((res: ACAdmissionIntervalControl) => { - this.acForm.controls['class'].setValue(res.class); - this.acForm.controls['enforce'].setValue(res.enforce); - this.acForm.controls['window_length'].setValue(res.window_length); - this.acForm.controls['blocking_rate'].setValue(res.blocking_rate); - this.acForm.controls['trigger_threshold'].setValue(res.trigger_threshold); - // TODO: clear pending action indicator - }, - (error: HttpErrorResponse) => { - // TODO: clear pending action indicator - this.errorDialogService.displayError(error.message); - }); - } - }); - } - - ngOnDestroy() { - this.instanceChange.unsubscribe(); - } - - updateAc = (acFormValue: ACAdmissionIntervalControl) => { - if (this.acForm.valid) { - // convert strings to numbers using the plus operator - const acFormValueConverted = { - class: +acFormValue.class, - enforce: acFormValue.enforce, - window_length: +acFormValue.window_length, - blocking_rate: +acFormValue.blocking_rate, - trigger_threshold: +acFormValue.trigger_threshold - }; - this.acXappService.putPolicy(this.instanceKey, acFormValueConverted).subscribe( - response => { - if (response.status === 200) { - this.notificationService.success('AC update policy succeeded!'); - } - }, - (error => { - this.errorDialogService.displayError('AC update policy failed: ' + error.message); - }) - ); - } - } - - hasError(controlName: string, errorName: string) { - if (this.acForm.controls[controlName].hasError(errorName)) { - return true; - } - return false; - } - - validateControl(controlName: string) { - if (this.acForm.controls[controlName].invalid && this.acForm.controls[controlName].touched) { - return true; - } - return false; - } - -} diff --git a/dashboard/webapp-frontend/src/app/app-control/app-control.component.ts b/dashboard/webapp-frontend/src/app/app-control/app-control.component.ts index fd2b26c0..75044a31 100644 --- a/dashboard/webapp-frontend/src/app/app-control/app-control.component.ts +++ b/dashboard/webapp-frontend/src/app/app-control/app-control.component.ts @@ -74,13 +74,7 @@ export class AppControlComponent implements OnInit, OnDestroy { controlApp(app: XappControlRow): void { // TODO: identify apps without hardcoding to names - const acAppPattern0 = /[Aa][Dd][Mm][Ii][Nn]/; - const acAppPattern1 = /[Aa][Dd][Mm][Ii][Ss]{2}[Ii][Oo][Nn]/; - if (acAppPattern0.test(app.xapp) || acAppPattern1.test(app.xapp)) { - this.router.navigate(['/ac']); - } else { - this.errorDialogService.displayError('No control available for ' + app.xapp + ' (yet)'); - } + this.errorDialogService.displayError('No control available for ' + app.xapp + ' (yet)'); } onUndeployApp(app: XappControlRow): void { diff --git a/dashboard/webapp-frontend/src/app/interfaces/ac-xapp.types.ts b/dashboard/webapp-frontend/src/app/interfaces/ac-xapp.types.ts deleted file mode 100644 index 66093569..00000000 --- a/dashboard/webapp-frontend/src/app/interfaces/ac-xapp.types.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - -// Models of data used by the AC xApp - -export interface ACAdmissionIntervalControl { - class: number; - enforce: boolean; - window_length: number; - blocking_rate: number; - trigger_threshold: number; -} - -export interface ACAdmissionIntervalControlAck { - status: string; - message: string; -} diff --git a/dashboard/webapp-frontend/src/app/rd-routing.module.ts b/dashboard/webapp-frontend/src/app/rd-routing.module.ts index af8ec2e4..3cc2d975 100644 --- a/dashboard/webapp-frontend/src/app/rd-routing.module.ts +++ b/dashboard/webapp-frontend/src/app/rd-routing.module.ts @@ -21,7 +21,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { Routes, RouterModule } from '@angular/router'; -import { AcXappComponent } from './ac-xapp/ac-xapp.component'; import { CatalogComponent } from './catalog/catalog.component'; import { ControlComponent } from './control/control.component'; import { MainComponent } from './main/main.component'; @@ -33,7 +32,6 @@ const routes: Routes = [ {path: '', component: MainComponent}, {path: 'catalog', component: CatalogComponent}, {path: 'control', component: ControlComponent}, - {path: 'ac', component: AcXappComponent}, {path: 'stats', component: StatsComponent}, {path: 'platform', component: PlatformComponent}, {path: 'user', component: UserComponent}, diff --git a/dashboard/webapp-frontend/src/app/rd.module.ts b/dashboard/webapp-frontend/src/app/rd.module.ts index 0a1e2bfd..67fc9717 100644 --- a/dashboard/webapp-frontend/src/app/rd.module.ts +++ b/dashboard/webapp-frontend/src/app/rd.module.ts @@ -54,7 +54,6 @@ import { NgModule } from '@angular/core'; import { ToastrModule } from 'ngx-toastr'; // RD components -import { AcXappComponent } from './ac-xapp/ac-xapp.component'; import { AddDashboardUserDialogComponent } from './user/add-dashboard-user-dialog/add-dashboard-user-dialog.component'; import { AppConfigurationComponent } from './app-configuration/app-configuration.component'; import { AppControlComponent } from './app-control/app-control.component'; @@ -92,7 +91,6 @@ import { UiService } from './services/ui/ui.service'; @NgModule({ declarations: [ - AcXappComponent, AddDashboardUserDialogComponent, AppConfigurationComponent, AppControlComponent, diff --git a/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.spec.ts b/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.spec.ts deleted file mode 100644 index b3bf4d41..00000000 --- a/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ -import { TestBed } from '@angular/core/testing'; - -import { ACXappService } from './ac-xapp.service'; - -describe('ACXappService', () => { - beforeEach(() => TestBed.configureTestingModule({})); - - it('should be created', () => { - const service: ACXappService = TestBed.get(ACXappService); - expect(service).toBeTruthy(); - }); -}); diff --git a/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.ts b/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.ts deleted file mode 100644 index dbe4cd6e..00000000 --- a/dashboard/webapp-frontend/src/app/services/ac-xapp/ac-xapp.service.ts +++ /dev/null @@ -1,81 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * %% - * 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=================================== - */ - -import { HttpClient } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { map } from 'rxjs/operators'; -import { ACAdmissionIntervalControl, ACAdmissionIntervalControlAck } from '../../interfaces/ac-xapp.types'; -import { DashboardSuccessTransport } from '../../interfaces/dashboard.types'; -import { DashboardService } from '../dashboard/dashboard.service'; - -/** - * Services for calling the Dashboard's A1 endpoints to get/put AC policies. - */ -@Injectable({ - providedIn: 'root' -}) -export class ACXappService { - - private component = 'a1-p'; - private policyTypePath = 'poltype'; - private policyInstPath = 'polinst'; - private acPolicyType = '21000'; - private acPolicyInst = 'admission_control_policy'; - - constructor( - private dashboardSvc: DashboardService, - private httpClient: HttpClient) { - } - - /** - * Gets AC client version details - * @returns Observable that yields a String - */ - getVersion(instanceKey: string): Observable { - const path = this.dashboardSvc.buildPath(this.component, null, 'version'); - return this.httpClient.get(path).pipe( - // Extract the string here - map(res => res['data']) - ); - } - - /** - * Gets admission control policy. - * @returns Observable that yields an ACAdmissionIntervalControl - */ - getPolicy(instanceKey: string): Observable { - const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.policyTypePath, this.acPolicyType, - this.policyInstPath, this.acPolicyInst); - return this.httpClient.get(path); - } - - /** - * Puts admission control policy. - * @param policy an instance of ACAdmissionIntervalControl - * @returns Observable that yields a response code, no data - */ - putPolicy(instanceKey: string, policy: ACAdmissionIntervalControl): Observable { - const path = this.dashboardSvc.buildPath(this.component, instanceKey, this.policyTypePath, this.acPolicyType, - this.policyInstPath, this.acPolicyInst); - return this.httpClient.put(path, policy, { observe: 'response' }); - } - -} diff --git a/dashboard/webapp-frontend/src/app/stats/stats.component.html b/dashboard/webapp-frontend/src/app/stats/stats.component.html index 16d07def..798d557a 100644 --- a/dashboard/webapp-frontend/src/app/stats/stats.component.html +++ b/dashboard/webapp-frontend/src/app/stats/stats.component.html @@ -22,20 +22,20 @@

Platform stats

- + - + - + - + diff --git a/dashboard/webapp-frontend/src/app/stats/stats.component.ts b/dashboard/webapp-frontend/src/app/stats/stats.component.ts index 558b1766..29930566 100644 --- a/dashboard/webapp-frontend/src/app/stats/stats.component.ts +++ b/dashboard/webapp-frontend/src/app/stats/stats.component.ts @@ -21,7 +21,6 @@ import { Component, OnInit, ViewChildren, QueryList } from '@angular/core'; import { BaseChartDirective } from 'ng2-charts/ng2-charts'; import { StatsService } from '../services/stats/stats.service'; import { HttpClient } from '@angular/common/http'; -import { map } from 'rxjs/operators'; import { DashboardSuccessTransport } from '../interfaces/dashboard.types'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; @@ -34,8 +33,8 @@ export class StatsComponent implements OnInit { @ViewChildren(BaseChartDirective) charts: QueryList; checked = false; - metricsUrlAc: SafeResourceUrl; metricsUrlMc: SafeResourceUrl; + metricsUrlMl: SafeResourceUrl; constructor(private service: StatsService, private httpClient: HttpClient, @@ -43,12 +42,12 @@ export class StatsComponent implements OnInit { } ngOnInit() { - this.service.getAppMetricsUrl('AC').subscribe((res: DashboardSuccessTransport) => { - this.metricsUrlAc = this.sanitize.bypassSecurityTrustResourceUrl(res.data); - }); this.service.getAppMetricsUrl('MC').subscribe((res: DashboardSuccessTransport) => { this.metricsUrlMc = this.sanitize.bypassSecurityTrustResourceUrl(res.data); }); + this.service.getAppMetricsUrl('ML').subscribe((res: DashboardSuccessTransport) => { + this.metricsUrlMl = this.sanitize.bypassSecurityTrustResourceUrl(res.data); + }); } } diff --git a/dashboard/webapp-frontend/src/app/ui/catalog-card/catalog-card.component.html b/dashboard/webapp-frontend/src/app/ui/catalog-card/catalog-card.component.html index 2587df19..6d02d665 100644 --- a/dashboard/webapp-frontend/src/app/ui/catalog-card/catalog-card.component.html +++ b/dashboard/webapp-frontend/src/app/ui/catalog-card/catalog-card.component.html @@ -23,9 +23,6 @@
wifi UE Event Collector
-
- check_box Admission Control -
open_in_new Deploy
diff --git a/docs/release-notes.rst b/docs/release-notes.rst index 03c6eb7a..1a304496 100644 --- a/docs/release-notes.rst +++ b/docs/release-notes.rst @@ -5,9 +5,11 @@ RIC Dashboard Release Notes =========================== -Version 2.0.1, 26 Feb 2020 +Version 2.0.1, 28 Feb 2020 -------------------------- * Revise controllers to use ResponseEntity +* Drop AC xApp control/config screen from front-end +* Drop A1 Mediator controller and tests from back-end * Upgrade to Spring-Boot 2.2.4.RELEASE Version 2.0.0, 5 Feb 2020 -- 2.16.6