From: Lathish Date: Tue, 9 Feb 2021 10:41:21 +0000 (+0000) Subject: Fixed bugs in Gateway X-Git-Tag: 2.2.0~91 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=85132f5ec832e4d28a334a21a036e4b3a9ef7eca;p=portal%2Fnonrtric-controlpanel.git Fixed bugs in Gateway Updated the Proxy configuration in Frontend Updated the nginx conf Deleted the Web-backend project Issue-ID: NONRTRIC-434 Change-Id: Ie56759a35385b615fc7c5af18b154432f45c0d26 Signed-off-by: Lathish --- diff --git a/docs/developer-guide.rst b/docs/developer-guide.rst index 51752b8..afe1a24 100644 --- a/docs/developer-guide.rst +++ b/docs/developer-guide.rst @@ -21,24 +21,23 @@ To run the Control Panel locally for development with simulated services, follow .. _gerrit: https://gerrit.o-ran-sc.org/r/admin/repos/portal/nonrtric-controlpanel -- Start the backend: - - cd webapp-backend - - mvn clean install - - mvn -Dorg.oransc.portal.nonrtric.controlpanel=mock -Dtest=MockControlPanelBackEnd -DfailIfNoTests=false test - - -- Now you can open URL: `localhost:8080`_ in a browser to access the backend directly. - -.. _localhost:8080: http://localhost:8080 - Start the frontend: cd webapp-frontend - - ./ng serve --proxy-config proxy.conf.json + + To start the frontend with Mock data: + + npm run start:mock + + To start the UI: + + You need to start the ControlPanel API Gateway, Policy Management Service & EI Service for the UI to list policy & EI information + + ./ng serve --proxy-config proxy.conf.json + + OR + + npm start - Now you can open URL: `localhost:4200`_ in a browser to access the Control Panel. diff --git a/nonrtric-gateway/Dockerfile b/nonrtric-gateway/Dockerfile index 9f2a545..f803a9c 100644 --- a/nonrtric-gateway/Dockerfile +++ b/nonrtric-gateway/Dockerfile @@ -24,7 +24,7 @@ ARG JAR WORKDIR /opt/app/nonrtric-gateway RUN mkdir -p /var/log/nonrtric-gateway -EXPOSE 8081 8433 +EXPOSE 9090 ADD /config/application.yaml /opt/app/nonrtric-gateway/config/application.yaml ADD target/${JAR} /opt/app/nonrtric-gateway/nonrtric-gateway.jar diff --git a/nonrtric-gateway/config/application.yaml b/nonrtric-gateway/config/application.yaml index cf3c358..98fd7d5 100644 --- a/nonrtric-gateway/config/application.yaml +++ b/nonrtric-gateway/config/application.yaml @@ -26,14 +26,14 @@ spring: httpserver: wiretap: true routes: - - id: policytypes + - id: A1-Policy uri: https://localhost:8433 predicates: - - Path=/a1-policy/v2/policy-types/** - - id: policies + - Path=/a1-policy/** + - id: A1-EI uri: https://localhost:8433 predicates: - - Path=/a1-policy/v2/policies/** + - Path=/ei-producer/** management: endpoint: gateway: diff --git a/pom.xml b/pom.xml deleted file mode 100644 index dccfe22..0000000 --- a/pom.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - 4.0.0 - - - org.springframework.boot - spring-boot-starter-parent - 2.3.4.RELEASE - - - org.o-ran-sc.portal.nonrtric.controlpanel - nonrtric-controlpanel-parent - Non-RT RIC Control Panel project - pom - 2.2.0-SNAPSHOT - - 11 - 3.7.0.1746 - - - webapp-backend - - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - - - - - org.apache.maven.plugins - maven-source-plugin - - - attach-sources - - jar - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - - org.sonarsource.scanner.maven - sonar-maven-plugin - ${sonar-maven-plugin.version} - - - - diff --git a/webapp-backend/.gitignore b/webapp-backend/.gitignore deleted file mode 100644 index f4a6f7b..0000000 --- a/webapp-backend/.gitignore +++ /dev/null @@ -1,34 +0,0 @@ -/.classpath -/.project -/.settings -/target/ -/logs/ -/.mvn/wrapper/maven-wrapper.jar -bin/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -/build/ - -/application-tlab2.properties -/application.properties -/controlpanel-users.json diff --git a/webapp-backend/README.md b/webapp-backend/README.md deleted file mode 100644 index acec8ac..0000000 --- a/webapp-backend/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Non-RT RIC Control Panel Web Application Backend - -The Non-RT RIC Control Panel back-end provides REST services to the Control Panel -front-end Typescript features running in the user's browser. For -production use, it also serves the Angular application files. - -Please see the documentation in the docs/ folder. - -The backend server publishes live API documentation at the -URL `http://your-host-name-here:8080/swagger-ui.html` - -## License - -Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. -Modifications Copyright (C) 2019 Nordix Foundation -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/webapp-backend/eclipse-formatter.xml b/webapp-backend/eclipse-formatter.xml deleted file mode 100644 index 7339434..0000000 --- a/webapp-backend/eclipse-formatter.xml +++ /dev/null @@ -1,315 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/webapp-backend/pom.xml b/webapp-backend/pom.xml deleted file mode 100644 index d49b53b..0000000 --- a/webapp-backend/pom.xml +++ /dev/null @@ -1,308 +0,0 @@ - - - - 4.0.0 - - org.o-ran-sc.portal.nonrtric.controlpanel - nonrtric-controlpanel-parent - 2.2.0-SNAPSHOT - - nonrtric-controlpanel-be - Non-RT RIC Control Panel Webapp backend - - 2.6.0 - 2.9.2 - 2.7.1 - 1.7.9 - 2.8.1 - 1.18.0 - 0.8.5 - 0.33.0 - 20190722 - - 0 - - - - onap-releases - ONAP - Release Repository - https://nexus.onap.org/content/repositories/releases - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-webflux - - - org.slf4j - slf4j-api - - - org.apache.axis2 - axis2-kernel - ${apache-axis2.version} - - - org.projectlombok - lombok - provided - - - - org.slf4j - jcl-over-slf4j - - - ch.qos.logback - logback-classic - - - ch.qos.logback - logback-core - - - io.springfox - springfox-swagger2 - ${springfox.version} - - - io.springfox - springfox-swagger-ui - ${springfox.version} - - - org.immutables - value - ${immutable.version} - provided - - - org.immutables - gson - ${immutable.version} - - - org.json - json - ${json.version} - - - - - org.mockito - mockito-core - test - - - org.springframework.boot - spring-boot-starter-test - test - - - org.junit.jupiter - junit-jupiter-api - test - - - org.junit.jupiter - junit-jupiter-engine - test - - - org.junit.platform - junit-platform-launcher - test - - - io.projectreactor - reactor-test - test - - - com.squareup.okhttp3 - mockwebserver - test - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - add-source - generate-sources - - add-source - - - - ${project.build.directory}/generated-sources/annotations/ - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - net.revelc.code.formatter - formatter-maven-plugin - ${formatter-maven-plugin.version} - - ${project.basedir}/eclipse-formatter.xml - - - - - com.diffplug.spotless - spotless-maven-plugin - ${spotless-maven-plugin.version} - - - - - com,java,javax,org - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - true - - - ${project.version}-b${build.number} - - - - - - - org.apache.maven.plugins - maven-deploy-plugin - - true - - - - org.jacoco - jacoco-maven-plugin - ${jacoco-maven-plugin.version} - - - default-prepare-agent - - prepare-agent - - - - default-report - prepare-package - - report - - - - - - - io.fabric8 - docker-maven-plugin - ${docker-maven-plugin.version} - - true - - ${env.CONTAINER_PULL_REGISTRY} - ${env.CONTAINER_PUSH_REGISTRY} - - - - - o-ran-sc/nonrtric-controlpanel-backend:${project.version} - - openjdk:11-jre-slim - - - ${project.version} - - - artifact - - - - mkdir /logs - chmod -R 777 /logs - - - - - java - -Xms128m - -Xmx256m - -cp - maven:maven/${project.artifactId}-${project.version}.${project.packaging} - -Dloader.main=org.oransc.portal.nonrtric.controlpanel.ControlPanelApplication - -Djava.security.egd=file:/dev/./urandom - org.springframework.boot.loader.PropertiesLauncher - - - - - - - - - - - build - push - - - - - - - diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelApplication.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelApplication.java deleted file mode 100644 index 8f5befe..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelApplication.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel; - -import java.lang.invoke.MethodHandles; - -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 scan to controlpanel classes; exclude generated API classes -@ComponentScan("org.oransc.portal.nonrtric.controlpanel") -public class ControlPanelApplication { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - public static void main(String[] args) { - SpringApplication.run(ControlPanelApplication.class); - // Ensure this appears on the console by using level WARN - logger.warn("main: version '{}' successful start", - getImplementationVersion(MethodHandles.lookup().lookupClass())); - } - - /** - * Gets version details for the specified class. - * - * @param clazz Class to get the version - * - * @return the value of the MANIFEST.MF property Implementation-Version as - * written by maven when packaged in a jar; 'unknown' otherwise. - */ - public static String getImplementationVersion(Class clazz) { - String classPath = clazz.getResource(clazz.getSimpleName() + ".class").toString(); - return classPath.startsWith("jar") ? clazz.getPackage().getImplementationVersion() : "unknown-not-jar"; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelConstants.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelConstants.java deleted file mode 100644 index b3766e8..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/ControlPanelConstants.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel; - -public abstract class ControlPanelConstants { - - private ControlPanelConstants() { - // Sonar insists on hiding the constructor - } - - public static final String ENDPOINT_PREFIX = "/api"; -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SpringContextCache.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SpringContextCache.java deleted file mode 100644 index 5ceab55..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SpringContextCache.java +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.config; - -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -/** - * Allows non-Spring-managed classes to obtain the Spring application context. - */ -@Component -public class SpringContextCache implements ApplicationContextAware { - - private ApplicationContext applicationContext = null; - - @Override - public void setApplicationContext(final ApplicationContext appContext) { - applicationContext = appContext; - } - - public ApplicationContext getApplicationContext() { - return applicationContext; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SwaggerConfiguration.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SwaggerConfiguration.java deleted file mode 100644 index fa00b2f..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/SwaggerConfiguration.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.config; - -import org.oransc.portal.nonrtric.controlpanel.ControlPanelApplication; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * http://www.baeldung.com/swagger-2-documentation-for-spring-rest-api - */ -@Configuration -@EnableSwagger2 -public class SwaggerConfiguration { - - /** - * @return new Docket - */ - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2).select() // - .apis(RequestHandlerSelectors.basePackage(ControlPanelApplication.class.getPackage().getName())) // - .paths(PathSelectors.any()) // - .build() // - .apiInfo(apiInfo()); - } - - private ApiInfo apiInfo() { - final String version = ControlPanelApplication.class.getPackage().getImplementationVersion(); - return new ApiInfoBuilder() // - .title("Non-RT RIC Control Panel backend") // - .description("Proxies access to Near-RT RIC.")// - .termsOfServiceUrl("Terms of service") // - .contact(new Contact("Non-RT RIC Control Panel Dev Team", // - "http://no-docs-yet.org/", // - "noreply@O-RAN-SC.org")) // - .license("Apache 2.0 License").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0") // - .version(version == null ? "version not available" : version) // - .build(); - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/TomcatWebServerConfiguration.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/TomcatWebServerConfiguration.java deleted file mode 100644 index 150dc6b..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/config/TomcatWebServerConfiguration.java +++ /dev/null @@ -1,59 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.config; - -import java.lang.invoke.MethodHandles; - -import org.apache.catalina.connector.Connector; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; -import org.springframework.boot.web.servlet.server.ServletWebServerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class TomcatWebServerConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Value("${server.http.port}") - private int httpPort; - - @Bean - public ServletWebServerFactory servletContainer() { - logger.debug("Http Port: {}", httpPort); - TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); - if (httpPort > 0) { - tomcat.addAdditionalTomcatConnectors(getHttpConnector(httpPort)); - } - return tomcat; - } - - private static Connector getHttpConnector(int port) { - Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); - connector.setScheme("http"); - connector.setPort(port); - connector.setSecure(false); - return connector; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/CustomResponseEntityExceptionHandler.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/CustomResponseEntityExceptionHandler.java deleted file mode 100644 index 02ccae2..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/CustomResponseEntityExceptionHandler.java +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import java.lang.invoke.MethodHandles; - -import org.oransc.portal.nonrtric.controlpanel.model.ErrorTransport; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.client.HttpStatusCodeException; -import org.springframework.web.client.RestClientResponseException; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -/** - * Catches certain exceptions. This controller advice factors out try-catch - * blocks in many controller methods. - * - * Also see:
- * https://www.baeldung.com/exception-handling-for-rest-with-spring - * https://www.springboottutorial.com/spring-boot-exception-handling-for-rest-services - */ -@ControllerAdvice -public class CustomResponseEntityExceptionHandler extends ResponseEntityExceptionHandler { - - // Superclass has "logger" that is exposed here, so use a different name - private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - /** - * Logs the error and generates a JSON response when a REST controller method - * takes a RestClientResponseException. This is thrown by the Http client when a - * remote method returns a non-2xx code. All the controller methods are proxies - * in that they just forward the request along to a remote system, so if that - * remote system fails, return 502 plus some details about the failure, rather - * than the generic 500 that Spring-Boot will return on an uncaught exception. - * - * Why 502? I quote:
HTTP server received an invalid response from a - * server it consulted when acting as a proxy or gateway.
- * - * @param ex - * The exception - * - * @param request - * The original request - * - * @return A response entity with status code 502 plus some details in the body. - */ - @ExceptionHandler({RestClientResponseException.class}) - public final ResponseEntity handleProxyMethodException(Exception ex, WebRequest request) { - // Capture the full stack trace in the log. - log.error("handleProxyMethodException: request {}, exception {}", request.getDescription(false), - ex.getMessage()); - if (ex instanceof HttpStatusCodeException) { - HttpStatusCodeException hsce = (HttpStatusCodeException) ex; - return new ResponseEntity<>(new ErrorTransport(hsce.getRawStatusCode(), hsce.getResponseBodyAsString(), - ex.toString(), request.getDescription(false)), HttpStatus.BAD_GATEWAY); - } else { - return new ResponseEntity<>(new ErrorTransport(500, ex), HttpStatus.BAD_GATEWAY); - } - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java deleted file mode 100644 index 297f5bc..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/EnrichmentController.java +++ /dev/null @@ -1,139 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import io.swagger.annotations.ApiOperation; - -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.List; - -import org.oransc.portal.nonrtric.controlpanel.ControlPanelConstants; -import org.oransc.portal.nonrtric.controlpanel.eiproducerapi.EiProducerApi; -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.Assert; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * Proxies calls from the front end to the EI Producer API. - * - * 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 = EnrichmentController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE) -public class EnrichmentController { - - 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 = ControlPanelConstants.ENDPOINT_PREFIX + "/enrichment"; - // Endpoints - public static final String EI_TYPES = "eitypes"; - public static final String EI_PRODUCERS = "eiproducers"; - public static final String EI_JOBS = "eijobs"; - public static final String EI_TYPE_ID = "ei_type_id"; - public static final String EI_PRODUCER_ID = "ei_producer_id"; - public static final String STATUS = "status"; - - // Populated by the autowired constructor - private final EiProducerApi eiProducerApi; - public static com.google.gson.Gson gson = new GsonBuilder().create(); - - @Autowired - public EnrichmentController(final EiProducerApi eiProducerApi) { - Assert.notNull(eiProducerApi, "API must not be null"); - this.eiProducerApi = eiProducerApi; - logger.debug("enrichment: configured with client type {}", eiProducerApi.getClass().getName()); - } - - @ApiOperation(value = "Get the EI job definitions for one EI producer") - @GetMapping(EI_JOBS) - public ResponseEntity getEiJobs() { - logger.debug("getEiJobs"); - ResponseEntity response = this.eiProducerApi.getAllEiProducerIds(); - JsonArray bodyJson = JsonParser.parseString(response.getBody()).getAsJsonArray(); - List allJobs = new ArrayList<>(); - for (JsonElement producerId : bodyJson) { - allJobs.addAll(getJobs(producerId)); - } - return new ResponseEntity<>(gson.toJson(allJobs), HttpStatus.OK); - } - - private List getJobs(JsonElement producerId) { - ResponseEntity> jobsResponse = - this.eiProducerApi.getEiJobsForOneEiProducer(producerId.getAsString()); - return jobsResponse.getBody(); - } - - @ApiOperation(value = "Get EI producers") - @GetMapping(EI_PRODUCERS) - public ResponseEntity getEiProducers() { - logger.debug("getEiProducers"); - ResponseEntity response = this.eiProducerApi.getAllEiProducerIds(); - JsonArray bodyJson = JsonParser.parseString(response.getBody()).getAsJsonArray(); - List producers = new ArrayList<>(); - for (JsonElement producerId : bodyJson) { - ProducerInfo producerInfo = ProducerInfo.builder() // - .id(producerId.getAsString()) // - .types(getSupportedTypes(producerId)) // - .status(getProducerStatus(producerId)) // - .build(); - producers.add(producerInfo); - } - - return new ResponseEntity<>(gson.toJson(producers), HttpStatus.OK); - } - - private String[] getSupportedTypes(JsonElement producerId) { - ResponseEntity producerResponse = - this.eiProducerApi.getEiProducer(producerId.getAsString()); - List supportedTypes = new ArrayList<>(); - for (ProducerEiTypeRegistrationInfo type : producerResponse.getBody().types) { - supportedTypes.add(type.eiTypeId); - } - return supportedTypes.toArray(new String[0]); - } - - private String getProducerStatus(JsonElement producerId) { - ResponseEntity statusResponse = - this.eiProducerApi.getEiProducerStatus(producerId.getAsString()); - return statusResponse.getBody().opState.toString(); - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/Html5PathsController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/Html5PathsController.java deleted file mode 100644 index 1ed6d0a..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/Html5PathsController.java +++ /dev/null @@ -1,67 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.net.URL; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; - -/** - * Listens for requests to known Angular routes. - */ -@Controller -public class Html5PathsController { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - /** - * Forwards the browser to the index (main) page upon request of a known route. - * This unfortunately requires duplication of the Angular route strings in the - * path mappings on this method. Could switch to a regex pattern instead someday - * if the routes change too often. - * - * https://stackoverflow.com/questions/44692781/configure-spring-boot-to-redirect-404-to-a-single-page-app - * - * @param request - * HttpServletRequest - * @param response - * HttpServletResponse - * @throws IOException - * On error - */ - @GetMapping("/policy") - public void forwardAngularRoutes(HttpServletRequest request, HttpServletResponse response) throws IOException { - URL url = new URL(request.getScheme(), request.getServerName(), request.getServerPort(), "/index.html"); - if (logger.isDebugEnabled()) - logger.debug("forwardAngularRoutes: {} redirected to {}", request.getRequestURI(), url); - response.sendRedirect(url.toString()); - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java deleted file mode 100644 index ccc2ac7..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/PolicyController.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import io.swagger.annotations.ApiOperation; - -import java.lang.invoke.MethodHandles; - -import javax.servlet.http.HttpServletResponse; - -import org.oransc.portal.nonrtric.controlpanel.ControlPanelConstants; -import org.oransc.portal.nonrtric.controlpanel.policyagentapi.PolicyAgentApi; -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.util.Assert; -import org.springframework.web.bind.annotation.DeleteMapping; -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.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -/** - * Proxies calls from the front end to the Policy Agent API. - * - * 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 = PolicyController.CONTROLLER_PATH, produces = MediaType.APPLICATION_JSON_VALUE) -public class PolicyController { - - 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 = ControlPanelConstants.ENDPOINT_PREFIX + "/policy"; - // Endpoints - public static final String POLICY_TYPES_METHOD = "policytypes"; - public static final String POLICY_TYPE_PARAM = "type"; - public static final String POLICIES_NAME = "policies"; - public static final String POLICY_INSTANCE_ID_NAME = "policy_instance_id"; - - // Populated by the autowired constructor - private final PolicyAgentApi policyAgentApi; - - @Autowired - public PolicyController(final PolicyAgentApi policyAgentApi) { - Assert.notNull(policyAgentApi, "API must not be null"); - this.policyAgentApi = policyAgentApi; - logger.debug("ctor: configured with client type {}", policyAgentApi.getClass().getName()); - } - - /* - * The fields are defined in the Policy Control Typescript interface. - */ - @ApiOperation(value = "Gets the policy types from Near-RT RIC") - @GetMapping(POLICY_TYPES_METHOD) - public ResponseEntity getAllPolicyTypes(HttpServletResponse response) { - logger.debug("getAllPolicyTypes"); - return this.policyAgentApi.getAllPolicyTypes(); - } - - @ApiOperation(value = "Returns the policy instances for the given policy type.") - @GetMapping(POLICIES_NAME) - public ResponseEntity getPolicyInstances( - @RequestParam(name = "type", required = true) String policyTypeIdString) { - logger.debug("getPolicyInstances {}", policyTypeIdString); - return this.policyAgentApi.getPolicyInstancesForType(policyTypeIdString); - } - - @ApiOperation(value = "Returns a policy instance") - @GetMapping(POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME + "}") - public ResponseEntity getPolicyInstance(@PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) { - logger.debug("getPolicyInstance {}", policyInstanceId); - return this.policyAgentApi.getPolicyInstance(policyInstanceId); - } - - @ApiOperation(value = "Creates the policy instances for the given policy type.") - @PutMapping(POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME + "}") - public ResponseEntity putPolicyInstance( // - @RequestParam(POLICY_TYPE_PARAM) String policyTypeIdString, // - @RequestParam(name = "ric", required = true) String ric, // - @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId, // - @RequestBody String instance) { - logger.debug("putPolicyInstance ric: {}, typeId: {}, instanceId: {}, instance: {}", ric, policyTypeIdString, - policyInstanceId, instance); - return this.policyAgentApi.putPolicy(policyTypeIdString, policyInstanceId, instance, ric); - } - - @ApiOperation(value = "Deletes the policy instances for the given policy type.") - @DeleteMapping(POLICIES_NAME + "/{" + POLICY_INSTANCE_ID_NAME + "}") - public ResponseEntity deletePolicyInstance( // - @RequestParam(POLICY_TYPE_PARAM) String policyTypeIdString, - @PathVariable(POLICY_INSTANCE_ID_NAME) String policyInstanceId) { - logger.debug("deletePolicyInstance typeId: {}, instanceId: {}", policyTypeIdString, policyInstanceId); - return this.policyAgentApi.deletePolicy(policyInstanceId); - } - - @ApiOperation(value = "Returns the rics supporting the given policy type.") - @GetMapping("/rics") - public ResponseEntity getRicsSupportingType( - @RequestParam(name = "policyType", required = true) String supportingPolicyType) { - logger.debug("getRicsSupportingType {}", supportingPolicyType); - - return this.policyAgentApi.getRicsSupportingType(supportingPolicyType); - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/SimpleErrorController.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/SimpleErrorController.java deleted file mode 100644 index 156acf4..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/controller/SimpleErrorController.java +++ /dev/null @@ -1,92 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import java.lang.invoke.MethodHandles; -import java.util.Map; - -import javax.servlet.http.HttpServletRequest; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -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.http.MediaType; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.context.request.ServletWebRequest; -import springfox.documentation.annotations.ApiIgnore; - -/** - * Provides a controller which is invoked on any error within the Spring-managed - * context, including page not found, and redirects the caller to a custom error - * page. The caller is also redirected to this page if a REST controller takes - * an uncaught exception. - * - * 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 -@Controller -@RequestMapping(value = SimpleErrorController.ERROR_PATH, produces = MediaType.APPLICATION_JSON_VALUE) -public class SimpleErrorController implements ErrorController { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @SuppressWarnings("squid:S1075") // URIs should not be hardcoded - public static final String ERROR_PATH = "/error"; - - private final ErrorAttributes errorAttributes; - - @Autowired - public SimpleErrorController(ErrorAttributes errorAttributes) { - this.errorAttributes = errorAttributes; - } - - @Override - public String getErrorPath() { - logger.warn("getErrorPath"); - return ERROR_PATH; - } - - @GetMapping - public String handleError(HttpServletRequest request) { - ServletWebRequest servletWebRequest = new ServletWebRequest(request); - Throwable t = errorAttributes.getError(servletWebRequest); - if (t != null) - logger.warn("handleError", t); - Map attributes = errorAttributes.getErrorAttributes(servletWebRequest, true); - attributes.forEach((attribute, value) -> logger.warn("handleError: {} -> {}", attribute, value)); - // Return the name of the page INCLUDING suffix, which I guess is a "view" name. - // Just "error" is not enough, but don't seem to need a ModelAndView object. - return "error.html"; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java deleted file mode 100644 index 60a3300..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApi.java +++ /dev/null @@ -1,39 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.eiproducerapi; - -import java.util.List; - -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; -import org.springframework.http.ResponseEntity; - -public interface EiProducerApi { - - public ResponseEntity getAllEiProducerIds(); - - public ResponseEntity getEiProducer(String eiProducerId); - - public ResponseEntity> getEiJobsForOneEiProducer(String eiProducerId); - - public ResponseEntity getEiProducerStatus(String eiProducerId); - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java deleted file mode 100644 index 921d586..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImpl.java +++ /dev/null @@ -1,114 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.eiproducerapi; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; - -import java.lang.invoke.MethodHandles; -import java.util.List; - -import org.json.JSONArray; -import org.json.JSONObject; -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.oransc.portal.nonrtric.controlpanel.util.ErrorResponseHandler; -import org.oransc.portal.nonrtric.controlpanel.util.JsonArrayHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; - -@Component("EiProducerApi") -public class EiProducerApiImpl implements EiProducerApi { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private static final String EI_PRODUCERS = "/eiproducers"; - private static final String EI_JOBS = "/eijobs"; - private static final String STATUS = "/status"; - - private final AsyncRestClient webClient; - private static com.google.gson.Gson gson = new GsonBuilder().create(); - - @Autowired - public EiProducerApiImpl( - @org.springframework.beans.factory.annotation.Value("${enrichmentcontroller.url.prefix}") final String urlPrefix) { - this(new AsyncRestClient(urlPrefix)); - logger.debug("enrichment controller url prefix '{}'", urlPrefix); - } - - public EiProducerApiImpl(AsyncRestClient webClient) { - this.webClient = webClient; - } - - @Override - public ResponseEntity getAllEiProducerIds() { - return getResponseArray(EI_PRODUCERS); - } - - @Override - public ResponseEntity getEiProducer(String eiProducerId) throws JsonSyntaxException { - ResponseEntity resp = getResponseObject(EI_PRODUCERS + "/" + eiProducerId); - ProducerRegistrationInfo info = gson.fromJson(resp.getBody(), ProducerRegistrationInfo.class); - return new ResponseEntity<>(info, resp.getStatusCode()); - } - - @Override - public ResponseEntity> getEiJobsForOneEiProducer(String eiProducerId) - throws JsonSyntaxException, IllegalStateException { - ResponseEntity resp = getResponseArray(EI_PRODUCERS + "/" + eiProducerId + EI_JOBS); - List jobs = JsonArrayHandler.parseJsonArray(resp.getBody(), JobInfo.class); - return new ResponseEntity<>(jobs, resp.getStatusCode()); - } - - @Override - public ResponseEntity getEiProducerStatus(String eiProducerId) throws JsonSyntaxException { - ResponseEntity resp = getResponseObject(EI_PRODUCERS + "/" + eiProducerId + STATUS); - ProducerStatusInfo status = gson.fromJson(resp.getBody(), ProducerStatusInfo.class); - return new ResponseEntity<>(status, resp.getStatusCode()); - } - - private ResponseEntity getResponseArray(String url) { - try { - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return rsp; - } - return new ResponseEntity<>(new JSONArray(rsp.getBody()).toString(), rsp.getStatusCode()); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } - - private ResponseEntity getResponseObject(String url) { - try { - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return rsp; - } - return new ResponseEntity<>(new JSONObject(rsp.getBody()).toString(), rsp.getStatusCode()); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/k8sapi/SimpleKubernetesClient.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/k8sapi/SimpleKubernetesClient.java deleted file mode 100644 index a95265c..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/k8sapi/SimpleKubernetesClient.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.k8sapi; - -import java.lang.invoke.MethodHandles; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.DefaultUriBuilderFactory; - -/** - * Provides a method to get a list of pods using RestTemplate. As currently - * configured this uses the default JVM HTTPS support which can be configured to - * ignore errors as a workaround for self-signed SSL certificates. - */ -public class SimpleKubernetesClient { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final String k8sUrl; - - public SimpleKubernetesClient(String baseUrl) { - logger.debug("ctor: baseUrl {}", baseUrl); - k8sUrl = baseUrl; - } - - public String listPods(String namespace) { - logger.debug("listPods for namespace {}", namespace); - String podsUrl = new DefaultUriBuilderFactory(k8sUrl.trim()).builder().pathSegment("v1") - .pathSegment("namespaces").pathSegment(namespace.trim()).pathSegment("pods").build().normalize().toString(); - RestTemplate rt = new RestTemplate(); - ResponseEntity podsResponse = rt.getForEntity(podsUrl, String.class); - return podsResponse.getBody(); - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ErrorTransport.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ErrorTransport.java deleted file mode 100644 index 9646b1d..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ErrorTransport.java +++ /dev/null @@ -1,134 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import java.time.Instant; - -/** - * This mimics the model Spring-Boot uses for a message returned on failure, to - * be serialized as JSON. - */ -public class ErrorTransport implements IControlPanelResponse { - - private Instant timestamp; - private Integer status; - private String error; - private String message; - private String path; - - /** - * Builds an empty object. - */ - public ErrorTransport() { - // no-arg constructor - } - - /** - * Convenience constructor for minimal value set. - * - * @param status - * Integer value like 400 - * @param error - * Error message - */ - public ErrorTransport(int status, String error) { - this(status, error, null, null); - } - - /** - * Convenience constructor for populating an error from an exception - * - * @param status - * Integer value like 400 - * @param throwable - * The caught exception/throwable to convert to String with - * an upper bound on characters - */ - public ErrorTransport(int status, Throwable throwable) { - this.timestamp = Instant.now(); - this.status = status; - final int enough = 256; - String exString = throwable.toString(); - this.error = exString.length() > enough ? exString.substring(0, enough) : exString; - } - - /** - * Builds an object with all fields - * - * @param status - * Integer value like 500 - * @param error - * Explanation - * @param message - * Additional explanation - * @param path - * Requested path - */ - public ErrorTransport(int status, String error, String message, String path) { - this.timestamp = Instant.now(); - this.status = status; - this.error = error; - this.message = message; - this.path = path; - } - - public Integer getStatus() { - return status; - } - - public void setStatus(Integer status) { - this.status = status; - } - - public String getMessage() { - return message; - } - - public void setMessage(String error) { - this.message = error; - } - - public Instant getTimestamp() { - return timestamp; - } - - public void setTimestamp(Instant timestamp) { - this.timestamp = timestamp; - } - - public String getError() { - return error; - } - - public void setError(String error) { - this.error = error; - } - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/IControlPanelResponse.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/IControlPanelResponse.java deleted file mode 100644 index 377e097..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/IControlPanelResponse.java +++ /dev/null @@ -1,28 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -/** - * Marker interface used by all transport models. - */ -public interface IControlPanelResponse { - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/JobInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/JobInfo.java deleted file mode 100644 index 9f64153..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/JobInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@ApiModel(value = "ei_job_request", description = "The EI job") -@Builder -public class JobInfo { - - @ApiModelProperty(value = "Identity of the EI job", required = true) - @SerializedName("ei_job_identity") - public String id; - - @ApiModelProperty(value = "Type identity for the job") - @SerializedName("ei_type_identity") - public String typeId; - - @ApiModelProperty(value = "Json for the job data") - @SerializedName("ei_job_data") - public Object jobData; - - @ApiModelProperty(value = "URI for the target of the EI") - @SerializedName("target_uri") - public String targetUri; - - @ApiModelProperty(value = "The owner of the job") - @SerializedName("owner") - public String owner; - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java deleted file mode 100644 index 9ea4d93..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@Builder -public class PolicyInfo { - @SerializedName(value = "id", alternate = "policy_id") - public String policyId; - - @SerializedName(value = "type", alternate = "policytype_id") - public String policyTypeId; - - @SerializedName(value = "ric", alternate = "ric_id") - public String ricId; - - @SerializedName(value = "json", alternate = "policy_data") - public Object policyData; - - @SerializedName(value = "service", alternate = "service_id") - public String serviceId; - - @SerializedName("transient") - public boolean isTransient = false; - - @SerializedName(value = "statusNotificationUri", alternate = "status_notification_uri") - public String statusNotificationUri = ""; - - @SerializedName("lastModified") - public String lastModified = ""; - - public boolean validate() { - return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java deleted file mode 100644 index 993538c..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstance.java +++ /dev/null @@ -1,62 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@Builder -public class PolicyInstance { - - @SerializedName(value = "policy_id") - public String policyId; - - @SerializedName(value = "policytype_id") - public String policyTypeId; - - @SerializedName(value = "ric_id") - public String ricId; - - @SerializedName(value = "policy_data") - public Object policyData; - - @SerializedName(value = "service_id") - public String serviceId; - - @SerializedName(value = "transient") - public boolean isTransient = false; - - @SerializedName(value = "status_notification_uri") - public String statusNotificationUri = ""; - - @SerializedName(value = "lastModified") - public String lastModified = ""; - - public boolean validate() { - return policyId != null && policyTypeId != null && ricId != null && policyData != null && serviceId != null; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstances.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstances.java deleted file mode 100644 index 6bb7161..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyInstances.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import java.util.ArrayList; - -public class PolicyInstances extends ArrayList { - - private static final long serialVersionUID = -928428052502491021L; - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyType.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyType.java deleted file mode 100644 index ac114b3..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyType.java +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -public class PolicyType { - - String name; - - Object schema; - - public PolicyType(String name, Object schema) { - this.name = name; - this.schema = schema; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Object getSchema() { - return schema; - } - - public void setSchema(Object schema) { - this.schema = schema; - } - - @Override - public String toString() { - return "[name:" + name + ", schema:" + schema.toString() + "]"; - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyTypes.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyTypes.java deleted file mode 100644 index c998245..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/PolicyTypes.java +++ /dev/null @@ -1,29 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import java.util.ArrayList; - -public class PolicyTypes extends ArrayList { - - private static final long serialVersionUID = -928428052502491021L; - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerInfo.java deleted file mode 100644 index 08aeee9..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * Copyright (C) 2020 Nordix Foundation. 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. - * ========================LICENSE_END=================================== - */ - -package org.oransc.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@ApiModel(value = "ei_producer", description = "The EI producer") -@Builder -public class ProducerInfo { - - @ApiModelProperty(value = "Idenitity of the EI producer", required = true) - @SerializedName("ei_producer_id") - public String id; - - @ApiModelProperty(value = "Types provided by the EI producer", required = true) - @SerializedName("ei_producer_types") - public String[] types; - - @ApiModelProperty(value = "Status of the EI producer", required = true) - @SerializedName("status") - public String status; - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerRegistrationInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerRegistrationInfo.java deleted file mode 100644 index 670beb3..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerRegistrationInfo.java +++ /dev/null @@ -1,68 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -import java.util.Collection; - -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@ApiModel(value = "producer_registration_info", description = "Information for an EI producer") -@Builder -public class ProducerRegistrationInfo { - - @Gson.TypeAdapters - @ApiModel(value = "producer_ei_type_registration_info", description = "Information for an EI type") - @Builder - public static class ProducerEiTypeRegistrationInfo { - - @ApiModelProperty(value = "EI type identity", required = true) - @SerializedName("ei_type_identity") - public String eiTypeId; - - @ApiModelProperty(value = "Json schema for the job data") - @SerializedName("ei_job_data_schema") - public Object jobDataSchema; - } - - @ApiModelProperty(value = "Supported EI types", required = true) - @SerializedName("supported_ei_types") - public Collection types; - - @ApiModelProperty(value = "callback for EI job", required = true) - @SerializedName("ei_job_callback_url") - public String jobCallbackUrl; - - @ApiModelProperty(value = "callback for producer supervision", required = true) - @SerializedName("ei_producer_supervision_callback_url") - public String producerSupervisionCallbackUrl; - - @ApiModelProperty(value = "status", required = true) - @SerializedName("status") - public ProducerStatusInfo status; -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerStatusInfo.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerStatusInfo.java deleted file mode 100644 index 53daebb..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/ProducerStatusInfo.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -import com.google.gson.annotations.SerializedName; - -import lombok.Builder; - -import org.immutables.gson.Gson; - -@Gson.TypeAdapters -@Builder -public class ProducerStatusInfo { - - @Gson.TypeAdapters - public enum OperationalState { - ENABLED, DISABLED - } - - @SerializedName("operational_state") - public final OperationalState opState; - - public ProducerStatusInfo(OperationalState state) { - this.opState = state; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/SuccessTransport.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/SuccessTransport.java deleted file mode 100644 index 3e2fd7b..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/model/SuccessTransport.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.model; - -public class SuccessTransport implements IControlPanelResponse { - - private int status; - private Object data; - - /** - * Builds an empty object - */ - public SuccessTransport() { - // no-arg constructor - } - - /** - * Builds an object with the specified values. - * - * @param status - * Status code - * @param data - * Data to transport - */ - public SuccessTransport(int status, Object data) { - this.status = status; - this.data = data; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApi.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApi.java deleted file mode 100644 index ce34d86..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApi.java +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.policyagentapi; - -import org.springframework.http.ResponseEntity; - -public interface PolicyAgentApi { - - public ResponseEntity getAllPolicyTypes(); - - public ResponseEntity getPolicyInstancesForType(String type); - - public ResponseEntity getPolicyInstance(String id); - - public ResponseEntity putPolicy(String policyTypeIdString, String policyInstanceId, Object json, - String ric); - - public ResponseEntity deletePolicy(String policyInstanceId); - - public ResponseEntity getRicsSupportingType(String typeName); - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java deleted file mode 100644 index ee961ab..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImpl.java +++ /dev/null @@ -1,252 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.policyagentapi; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import com.google.gson.reflect.TypeToken; - -import java.lang.invoke.MethodHandles; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.immutables.gson.Gson; -import org.immutables.value.Value; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstance; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyType; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyTypes; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.oransc.portal.nonrtric.controlpanel.util.ErrorResponseHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Component; - -@Component("PolicyAgentApi") -public class PolicyAgentApiImpl implements PolicyAgentApi { - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private final AsyncRestClient webClient; - - private static com.google.gson.Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // - - @Autowired - public PolicyAgentApiImpl( - @org.springframework.beans.factory.annotation.Value("${policycontroller.url.prefix}") final String urlPrefix) { - this(new AsyncRestClient(urlPrefix)); - logger.debug("ctor prefix '{}'", urlPrefix); - } - - public PolicyAgentApiImpl(AsyncRestClient webClient) { - this.webClient = webClient; - } - - @Override - public ResponseEntity getAllPolicyTypes() { - try { - final String url = "/a1-policy/v2/policy-types"; - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return rsp; - } - - PolicyTypes result = new PolicyTypes(); - JsonArray policyTypeIds = JsonParser.parseString(rsp.getBody()).getAsJsonObject() // - .get("policytype_ids") // - .getAsJsonArray(); // - - for (JsonElement policyTypeId : policyTypeIds) { - - String typeId = policyTypeId.getAsString(); - - JsonObject schemaObj = getIndividualPolicySchema(typeId); - PolicyType pt = new PolicyType(typeId, schemaObj.toString()); - result.add(pt); - } - return new ResponseEntity<>(gson.toJson(result), rsp.getStatusCode()); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } - - public JsonObject getIndividualPolicySchema(String id) { - try { - final String url = "/a1-policy/v2/policy-types/" + id; - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return null; - } - - JsonObject policy_schema = JsonParser.parseString(rsp.getBody()).getAsJsonObject() // - .get("policy_schema") // - .getAsJsonObject(); // - - return policy_schema; - } catch (Exception e) { - return null; - } - } - - @Override - public ResponseEntity getPolicyInstancesForType(String type) { - try { - String url = "/a1-policy/v2/policies?policytype_id=" + type; - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return rsp; - } - JsonArray policyInstances = JsonParser.parseString(rsp.getBody()).getAsJsonObject() // - .get("policy_ids") // - .getAsJsonArray(); // - - List res = new ArrayList<>(); - for (JsonElement p : policyInstances) { - ResponseEntity policyInstance = getIndividualPolicyInstance(p.getAsString()); - res.add(policyInstance.getBody()); - } - - return new ResponseEntity<>(gson.toJson(res), rsp.getStatusCode()); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } - - public ResponseEntity getIndividualPolicyInstance(String id) { - try { - String url = "/a1-policy/v2/policies/" + id; - ResponseEntity rsp = webClient.getForEntity(url).block(); - JsonObject obj = JsonParser.parseString(rsp.getBody()).getAsJsonObject(); - - // lastModified timestamp is fetched from PolicyStatus instead - ResponseEntity status = getPolicyStatus(id); - String lastModified = JsonParser.parseString(status.getBody()).getAsJsonObject() // - .get("last_modified") // - .getAsString(); // - obj.addProperty("lastModified", lastModified); - - PolicyInfo i = gson.fromJson(obj, PolicyInfo.class); - return new ResponseEntity<>(i, rsp.getStatusCode()); - } catch (Exception e) { - ResponseEntity rsp = ErrorResponseHandler.handleException(e); - return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode()); - } - } - - public ResponseEntity getPolicyStatus(String id) { - try { - String url = "/a1-policy/v2/policies/" + id + "/status"; - ResponseEntity rsp = webClient.getForEntity(url).block(); - return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode()); - } catch (Exception e) { - ResponseEntity rsp = ErrorResponseHandler.handleException(e); - return new ResponseEntity<>(rsp.getBody(), rsp.getStatusCode()); - } - } - - @Override - public ResponseEntity getPolicyInstance(String id) { - ResponseEntity rsp = getIndividualPolicyInstance(id); - PolicyInfo i = (PolicyInfo) rsp.getBody(); - return new ResponseEntity<>(i.policyData, rsp.getStatusCode()); - } - - @Override - public ResponseEntity putPolicy(String policyTypeIdString, String policyInstanceId, Object json, - String ric) { - String url = "/a1-policy/v2/policies/"; - - JsonElement data = JsonParser.parseString(json.toString()).getAsJsonObject(); - - PolicyInstance i = PolicyInstance.builder() // - .policyId(policyInstanceId) // - .policyTypeId(policyTypeIdString) // - .ricId(ric) // - .policyData(data) // - .serviceId("controlpanel") // - .build(); // - - try { - String jsonStr = gson.toJson(i, PolicyInstance.class); - logger.debug("PolicyInstance: " + jsonStr); - webClient.putForEntity(url, jsonStr).block(); - return new ResponseEntity<>(HttpStatus.OK); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } - - @Override - public ResponseEntity deletePolicy(String policyInstanceId) { - String url = "/a1-policy/v2/policies/" + policyInstanceId; - try { - webClient.deleteForEntity(url).block(); - return new ResponseEntity<>(HttpStatus.OK); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } - - @Value.Immutable - @Gson.TypeAdapters - interface RicInfo { - public String ric_id(); - - public Collection managed_element_ids(); - - public Collection policytype_ids(); - } - - @Override - public ResponseEntity getRicsSupportingType(String typeName) { - try { - String url = "/a1-policy/v2/rics?policytype_id=" + typeName; - ResponseEntity rsp = webClient.getForEntity(url).block(); - if (!rsp.getStatusCode().is2xxSuccessful()) { - return rsp; - } - - JsonArray rics = JsonParser.parseString(rsp.getBody()).getAsJsonObject() // - .get("rics") // - .getAsJsonArray(); // - - Type listType = new TypeToken>() {}.getType(); - List rspParsed = gson.fromJson(rics, listType); - Collection result = new ArrayList<>(rspParsed.size()); - for (RicInfo ric : rspParsed) { - result.add(ric.ric_id()); - } - String json = gson.toJson(result); - return new ResponseEntity<>(json, HttpStatus.OK); - } catch (Exception e) { - return ErrorResponseHandler.handleException(e); - } - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClient.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClient.java deleted file mode 100644 index ac99c58..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClient.java +++ /dev/null @@ -1,278 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.util; - -import io.netty.channel.ChannelOption; -import io.netty.handler.ssl.SslContext; -import io.netty.handler.ssl.SslContextBuilder; -import io.netty.handler.ssl.util.InsecureTrustManagerFactory; -import io.netty.handler.timeout.ReadTimeoutHandler; -import io.netty.handler.timeout.WriteTimeoutHandler; - -import java.io.FileInputStream; -import java.io.IOException; -import java.lang.invoke.MethodHandles; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.NoSuchAlgorithmException; -import java.security.cert.Certificate; -import java.security.cert.CertificateException; -import java.security.cert.X509Certificate; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.stream.Collectors; - -import org.immutables.value.Value; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.http.client.reactive.ReactorClientHttpConnector; -import org.springframework.util.ResourceUtils; -import org.springframework.web.reactive.function.client.ExchangeStrategies; -import org.springframework.web.reactive.function.client.WebClient; -import org.springframework.web.reactive.function.client.WebClient.RequestHeadersSpec; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import reactor.core.publisher.Mono; -import reactor.netty.http.client.HttpClient; -import reactor.netty.resources.ConnectionProvider; -import reactor.netty.tcp.TcpClient; - -/** - * Generic reactive REST client. - */ -public class AsyncRestClient { - - @Value.Immutable - @Value.Style(redactedMask = "####") - public interface WebClientConfig { - public boolean isTrustStoreUsed(); - - @Value.Redacted - public String trustStorePassword(); - - public String trustStore(); - } - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private WebClient webClient = null; - private final String baseUrl; - private static final AtomicInteger sequenceNumber = new AtomicInteger(); - private final WebClientConfig clientConfig; - static KeyStore clientTrustStore = null; - - public AsyncRestClient(String baseUrl) { - this(baseUrl, - ImmutableWebClientConfig.builder().isTrustStoreUsed(false).trustStore("").trustStorePassword("").build()); - } - - public AsyncRestClient(String baseUrl, WebClientConfig config) { - this.baseUrl = baseUrl; - this.clientConfig = config; - } - - public Mono> putForEntity(String uri, String body) { - Object traceTag = createTraceTag(); - logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri); - logger.trace("{} PUT body: {}", traceTag, body); - return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec request = client.put() // - .uri(uri) // - .contentType(MediaType.APPLICATION_JSON) // - .bodyValue(body); - return retrieve(traceTag, request); - }); - } - - public Mono> putForEntity(String uri) { - Object traceTag = createTraceTag(); - logger.debug("{} PUT uri = '{}{}''", traceTag, baseUrl, uri); - logger.trace("{} PUT body: ", traceTag); - return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec request = client.put() // - .uri(uri); - return retrieve(traceTag, request); - }); - } - - public Mono put(String uri, String body) { - return putForEntity(uri, body) // - .flatMap(this::toBody); - } - - public Mono> getForEntity(String uri) { - Object traceTag = createTraceTag(); - logger.debug("{} GET uri = '{}{}''", traceTag, baseUrl, uri); - return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec request = client.get().uri(uri); - return retrieve(traceTag, request); - }); - } - - public Mono get(String uri) { - return getForEntity(uri) // - .flatMap(this::toBody); - } - - public Mono> deleteForEntity(String uri) { - Object traceTag = createTraceTag(); - logger.debug("{} DELETE uri = '{}{}''", traceTag, baseUrl, uri); - return getWebClient() // - .flatMap(client -> { - RequestHeadersSpec request = client.delete().uri(uri); - return retrieve(traceTag, request); - }); - } - - public Mono delete(String uri) { - return deleteForEntity(uri) // - .flatMap(this::toBody); - } - - private Mono> retrieve(Object traceTag, RequestHeadersSpec request) { - final Class clazz = String.class; - return request.retrieve() // - .toEntity(clazz) // - .doOnNext(entity -> logger.trace("{} Received: {}", traceTag, entity.getBody())) // - .doOnError(throwable -> onHttpError(traceTag, throwable)); - } - - private static Object createTraceTag() { - return sequenceNumber.incrementAndGet(); - } - - private void onHttpError(Object traceTag, Throwable t) { - if (t instanceof WebClientResponseException) { - WebClientResponseException exception = (WebClientResponseException) t; - logger.debug("{} HTTP error status = '{}', body '{}'", traceTag, exception.getStatusCode(), - exception.getResponseBodyAsString()); - } else { - logger.debug("{} HTTP error: {}", traceTag, t.getMessage()); - } - } - - private Mono toBody(ResponseEntity entity) { - if (entity.getBody() == null) { - return Mono.just(""); - } else { - return Mono.just(entity.getBody()); - } - } - - private boolean isCertificateEntry(KeyStore trustStore, String alias) { - try { - return trustStore.isCertificateEntry(alias); - } catch (KeyStoreException e) { - logger.error("Error reading truststore {}", e.getMessage()); - return false; - } - } - - private Certificate getCertificate(KeyStore trustStore, String alias) { - try { - return trustStore.getCertificate(alias); - } catch (KeyStoreException e) { - logger.error("Error reading truststore {}", e.getMessage()); - return null; - } - } - - private static synchronized KeyStore getTrustStore(String trustStorePath, String trustStorePass) - throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { - if (clientTrustStore == null) { - KeyStore store = KeyStore.getInstance(KeyStore.getDefaultType()); - store.load(new FileInputStream(ResourceUtils.getFile(trustStorePath)), trustStorePass.toCharArray()); - clientTrustStore = store; - } - return clientTrustStore; - } - - private SslContext createSslContextRejectingUntrustedPeers(String trustStorePath, String trustStorePass) - throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException { - - final KeyStore trustStore = getTrustStore(trustStorePath, trustStorePass); - List certificateList = Collections.list(trustStore.aliases()).stream() // - .filter(alias -> isCertificateEntry(trustStore, alias)) // - .map(alias -> getCertificate(trustStore, alias)) // - .collect(Collectors.toList()); - final X509Certificate[] certificates = certificateList.toArray(new X509Certificate[certificateList.size()]); - - return SslContextBuilder.forClient() // - .trustManager(certificates) // - .build(); - } - - private SslContext createSslContext() - throws NoSuchAlgorithmException, CertificateException, KeyStoreException, IOException { - if (this.clientConfig.isTrustStoreUsed()) { - return createSslContextRejectingUntrustedPeers(this.clientConfig.trustStore(), - this.clientConfig.trustStorePassword()); - } else { - // Trust anyone - return SslContextBuilder.forClient() // - .trustManager(InsecureTrustManagerFactory.INSTANCE) // - .build(); - } - } - - private WebClient createWebClient(String baseUrl, SslContext sslContext) { - ConnectionProvider connectionProvider = ConnectionProvider.newConnection(); - TcpClient tcpClient = TcpClient.create(connectionProvider) // - .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000) // - .secure(c -> c.sslContext(sslContext)) // - - .doOnConnected(connection -> { - connection.addHandlerLast(new ReadTimeoutHandler(30)); - connection.addHandlerLast(new WriteTimeoutHandler(30)); - }); - HttpClient httpClient = HttpClient.from(tcpClient); - ReactorClientHttpConnector connector = new ReactorClientHttpConnector(httpClient); - - ExchangeStrategies exchangeStrategies = ExchangeStrategies.builder() // - .codecs(configurer -> configurer.defaultCodecs().maxInMemorySize(-1)) // - .build(); - - return WebClient.builder() // - .clientConnector(connector) // - .baseUrl(baseUrl) // - .exchangeStrategies(exchangeStrategies) // - .build(); - } - - private Mono getWebClient() { - if (this.webClient == null) { - try { - SslContext sslContext = createSslContext(); - this.webClient = createWebClient(this.baseUrl, sslContext); - } catch (Exception e) { - logger.error("Could not create WebClient {}", e.getMessage()); - return Mono.error(e); - } - } - return Mono.just(this.webClient); - } - -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/ErrorResponseHandler.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/ErrorResponseHandler.java deleted file mode 100644 index 09d4684..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/ErrorResponseHandler.java +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.util; - -import javax.net.ssl.SSLException; - -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.HttpClientErrorException; -import org.springframework.web.client.HttpServerErrorException; - -public class ErrorResponseHandler { - - private ErrorResponseHandler() { - throw new IllegalStateException("ErrorResponseHandler is a utility class and not meant to be instantiated"); - } - - public static ResponseEntity handleException(Exception throwable) { - if (throwable instanceof HttpClientErrorException) { - HttpClientErrorException e = (HttpClientErrorException) throwable; - return new ResponseEntity<>(e.getMessage(), e.getStatusCode()); - } else if (throwable instanceof HttpServerErrorException) { - HttpServerErrorException e = (HttpServerErrorException) throwable; - return new ResponseEntity<>(e.getResponseBodyAsString(), e.getStatusCode()); - } else if (throwable instanceof SSLException) { - SSLException e = (SSLException) throwable; - return new ResponseEntity<>("Could not create WebClient " + e.getMessage(), - HttpStatus.INTERNAL_SERVER_ERROR); - } - return new ResponseEntity<>(throwable.getClass().getName() + ": " + throwable.getMessage(), - HttpStatus.INTERNAL_SERVER_ERROR); - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/HttpsURLConnectionUtils.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/HttpsURLConnectionUtils.java deleted file mode 100644 index 5b1dcb4..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/HttpsURLConnectionUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.util; - -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; - -import javax.net.ssl.HostnameVerifier; -import javax.net.ssl.HttpsURLConnection; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManager; - -import org.apache.axis2.java.security.TrustAllTrustManager; - -/** - * Disables and enables certificate and host-name checking in - * HttpsURLConnection, the default JVM implementation of the HTTPS/TLS protocol. - * Has no effect on implementations such as Apache Http Client, Ok Http. - * - * https://stackoverflow.com/questions/23504819/how-to-disable-ssl-certificate-checking-with-spring-resttemplate/58291331#58291331 - */ -public final class HttpsURLConnectionUtils { - - private static final HostnameVerifier jvmHostnameVerifier = HttpsURLConnection.getDefaultHostnameVerifier(); - - private static final HostnameVerifier trivialHostnameVerifier = - (hostname, sslSession) -> hostname.equalsIgnoreCase(sslSession.getPeerHost()); - - private static final TrustManager[] UNQUESTIONING_TRUST_MANAGER = new TrustManager[] {new TrustAllTrustManager()}; - - public static void turnOffSslChecking() throws NoSuchAlgorithmException, KeyManagementException { - HttpsURLConnection.setDefaultHostnameVerifier(trivialHostnameVerifier); - // Install the all-trusting trust manager - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, UNQUESTIONING_TRUST_MANAGER, null); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - } - - public static void turnOnSslChecking() throws KeyManagementException, NoSuchAlgorithmException { - HttpsURLConnection.setDefaultHostnameVerifier(jvmHostnameVerifier); - // Return it to the initial state (discovered by reflection, now hardcoded) - SSLContext sc = SSLContext.getInstance("TLS"); - sc.init(null, null, null); - HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory()); - } - - private HttpsURLConnectionUtils() { - throw new UnsupportedOperationException("Do not instantiate libraries."); - } -} diff --git a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/JsonArrayHandler.java b/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/JsonArrayHandler.java deleted file mode 100644 index 7af2429..0000000 --- a/webapp-backend/src/main/java/org/oransc/portal/nonrtric/controlpanel/util/JsonArrayHandler.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.oransc.portal.nonrtric.controlpanel.util; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.util.ArrayList; -import java.util.List; - -public class JsonArrayHandler { - - public static com.google.gson.Gson gson = new GsonBuilder().create(); - - public static List parseJsonArray(String jsonString, Class clazz) { - List result = new ArrayList<>(); - JsonArray jsonArr = JsonParser.parseString(jsonString).getAsJsonArray(); - for (JsonElement jsonElement : jsonArr) { - T json = gson.fromJson(jsonElement.toString(), clazz); - result.add(json); - } - return result; - } -} diff --git a/webapp-backend/src/main/resources/application.properties b/webapp-backend/src/main/resources/application.properties deleted file mode 100644 index f21d8d5..0000000 --- a/webapp-backend/src/main/resources/application.properties +++ /dev/null @@ -1,44 +0,0 @@ -# ========================LICENSE_START================================= -# O-RAN-SC -# %% -# Copyright (C) 2019 AT&T Intellectual Property -# Modifications Copyright (C) 2019 Nordix Foundation -# %% -# 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=================================== - -# Defines Non-RT RIC Control Panel property keys and default values. -# Create a copy in the launch directory to override values; or -# copy to "application-abc.properties" as mentioned in the README. - -# A spring property but without a "spring" prefix; -# the port number is chosen RANDOMLY when running tests -server.port = 8082 -server.ssl.key-store-type = PKCS12 -server.ssl.key-store-password = ericsson_kwdjfhw -server.ssl.key-store = classpath:keystore.jks -server.ssl.key-password = ericsson_kwdjfhw -server.http.port = 8080 - -# endpoint URLs must be supplied at deployment time -# NOTE: change policycontroller.url.prefix to http://localhost:8081 when running -# controlpanel locally (i.e., not inside the docker container) -# policycontroller.url.prefix = https://policy-agent-container:8433 -policycontroller.url.prefix = http://policy-agent-container:8081 - -# URL for enrichment coordinator service -# enrichmentcontroller.url.prefix = https://enrichment-service-container:8434 -enrichmentcontroller.url.prefix = http://enrichment-service-container:8083/ei-producer/v1 - -# Mimic slow endpoints by defining sleep period, in milliseconds -mock.config.delay = 0 diff --git a/webapp-backend/src/main/resources/key.properties b/webapp-backend/src/main/resources/key.properties deleted file mode 100644 index c2cab7d..0000000 --- a/webapp-backend/src/main/resources/key.properties +++ /dev/null @@ -1,22 +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=================================== - -# Test properties for the EPSDK-FW library. -# This file must be present on the Java classpath. - -cipher.enc.key = bogus diff --git a/webapp-backend/src/main/resources/keystore.jks b/webapp-backend/src/main/resources/keystore.jks deleted file mode 100644 index 6de24a9..0000000 Binary files a/webapp-backend/src/main/resources/keystore.jks and /dev/null differ diff --git a/webapp-backend/src/main/resources/logback.xml b/webapp-backend/src/main/resources/logback.xml deleted file mode 100644 index e966bc6..0000000 --- a/webapp-backend/src/main/resources/logback.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - ${pattern} - - - - - ${logDirectory}/${componentName}.log - true - - ${logDirectory}/${componentName}.%i.log.zip - 1 - 9 - - - 10MB - - - - ${pattern} - - - - - - - - - - > - - - - - - - - - - - diff --git a/webapp-backend/src/main/resources/static/error.html b/webapp-backend/src/main/resources/static/error.html deleted file mode 100644 index c09d1aa..0000000 --- a/webapp-backend/src/main/resources/static/error.html +++ /dev/null @@ -1,36 +0,0 @@ - - - - - -Static error page - - - -

Non-RT RIC Control Panel Error

-

The previous request could not be processed.

-Click here to reload the application - - diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/MockControlPanelBackEnd.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/MockControlPanelBackEnd.java deleted file mode 100644 index 2f69ee2..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/MockControlPanelBackEnd.java +++ /dev/null @@ -1,70 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel; - -import java.lang.invoke.MethodHandles; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -/** - * This class supports front-end web development. Placing this class in the test - * area allows excluding the mock configuration classes and the Mockito - * dependencies from the packaged version of the app. - * - * To launch a development server set the environment variable as listed below. - * This runs a Spring-Boot server with mock back-end beans, and keeps the server - * alive for manual testing. Supply this JVM argument: - */ -@SuppressWarnings("java:S3577") // Class name should start or end with Test. This is not a test class per se, but a mock - // of the server. -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.DEFINED_PORT) -class MockControlPanelBackEnd { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @LocalServerPort - private int port; - - /* - * Keeps the test server alive forever. Use a guard so this test is never run by - * Jenkins. - */ - @SuppressWarnings("squid:S2699") // To avoid warning about missing assertion. - @Test - void keepServerAlive() { - logger.warn("Keeping server alive! Port: " + this.port); - try { - synchronized (this) { - this.wait(); - } - } catch (Exception ex) { - logger.warn(ex.toString()); - } - } -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java deleted file mode 100644 index 5309d98..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/RestApiTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel; - -import static org.assertj.core.api.Assertions.assertThat; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; - -import java.io.BufferedReader; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.PrintStream; -import java.lang.invoke.MethodHandles; -import java.util.stream.Collectors; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerInfo; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.context.ApplicationContext; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -class RestApiTest { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private static Gson gson = new GsonBuilder().setPrettyPrinting().create(); - - @Autowired - ApplicationContext context; - - @LocalServerPort - private int port; - - @Test - void createApiDoc() throws FileNotFoundException { - String url = "/v2/api-docs"; - ResponseEntity resp = restClient().getForEntity(url).block(); - assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - JsonObject jsonElement = JsonParser.parseString(resp.getBody()).getAsJsonObject(); - jsonElement.remove("host"); - String indented = gson.toJson(jsonElement); - try (PrintStream out = new PrintStream(new FileOutputStream("../docs/api.json"))) { - out.println(indented); - } - } - - @Test - void getJobs() throws FileNotFoundException { - String url = "/api/enrichment/eijobs"; - ResponseEntity resp = restClient().getForEntity(url).block(); - assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - - JsonArray jobs = JsonParser.parseString(resp.getBody()).getAsJsonArray(); - JobInfo wantedJobInfo = JobInfo.builder() // - .id("job1") // - .typeId("type1") // - .jobData(getStringFromFile("job-1.json")) // - .targetUri("http://example.com/") // - .owner("owner") // - .build(); - JobInfo wantedJobInfo2 = JobInfo.builder() // - .id("job2") // - .typeId("type2") // - .jobData(getStringFromFile("job-2.json")) // - .targetUri("http://example.com/") // - .owner("owner") // - .build(); - assertThat(jobs).hasSize(6) // - .contains(gson.toJsonTree(wantedJobInfo), // - gson.toJsonTree(wantedJobInfo2)); - } - - @Test - void getProducers() { - String url = "/api/enrichment/eiproducers"; - ResponseEntity resp = restClient().getForEntity(url).block(); - assertThat(resp.getStatusCode()).isEqualTo(HttpStatus.OK); - - JsonArray producers = JsonParser.parseString(resp.getBody()).getAsJsonArray(); - - ProducerInfo wantedProducerInfo = ProducerInfo.builder() // - .id("prod-1") // - .types(new String[] {"type1", "type2"}) // - .status("ENABLED") // - .build(); - ProducerInfo wantedProducerInfo2 = ProducerInfo.builder() // - .id("prod-2") // - .types(new String[] {"type1"}) // - .status("DISABLED") // - .build(); - ProducerInfo wantedProducerInfo3 = ProducerInfo.builder() // - .id("3-prod") // - .types(new String[] {"type1", "type2"}) // - .status("ENABLED") // - .build(); - assertThat(producers).hasSize(3) // - .contains(gson.toJsonTree(wantedProducerInfo), // - gson.toJsonTree(wantedProducerInfo2), // - gson.toJsonTree(wantedProducerInfo3)); - } - - private AsyncRestClient restClient() { - return new AsyncRestClient(baseUrl()); - } - - private String baseUrl() { - return "https://localhost:" + this.port; - } - - private String getStringFromFile(String path) { - try { - InputStream inputStream = MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path); - return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n")); - } catch (Exception e) { - logger.error("Cannot read file :" + path, e); - return ""; - } - } -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/AbstractControllerTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/AbstractControllerTest.java deleted file mode 100644 index 504223b..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/AbstractControllerTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import java.lang.invoke.MethodHandles; -import java.net.URI; -import java.util.Map; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; -import org.springframework.boot.web.server.LocalServerPort; -import org.springframework.test.context.junit.jupiter.SpringExtension; -import org.springframework.web.util.UriComponentsBuilder; - -@ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) -// Need the fake answers from the backend -class AbstractControllerTest { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - // Created by Spring black magic - // https://spring.io/guides/gs/testing-web/ - @LocalServerPort - private int localServerPort; - - protected final AsyncRestClient webClient = new AsyncRestClient(""); - - /** - * Flexible URI builder. - * - * @param queryParams Map of string-string query parameters - * @param path Array of path components. If a component has an embedded - * slash, the string is split and each subcomponent is added - * individually. - * @return URI - */ - protected URI buildUri(final Map queryParams, final String... path) { - UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("https://localhost:" + localServerPort + "/"); - for (int p = 0; p < path.length; ++p) { - if (path[p] == null || path[p].isEmpty()) { - throw new IllegalArgumentException("Unexpected null or empty at path index " + Integer.toString(p)); - } else if (path[p].contains("/")) { - String[] subpaths = path[p].split("/"); - for (String s : subpaths) - if (!s.isEmpty()) - builder.pathSegment(s); - } else { - builder.pathSegment(path[p]); - } - } - if (queryParams != null && queryParams.size() > 0) { - for (Map.Entry entry : queryParams.entrySet()) { - if (entry.getKey() == null || entry.getValue() == null) - throw new IllegalArgumentException("Unexpected null key or value"); - else - builder.queryParam(entry.getKey(), entry.getValue()); - } - } - return builder.build().encode().toUri(); - } - - // Because I put the annotations on this parent class, - // must define at least one test here. - @Test - void contextLoads() { - // Silence Sonar warning about missing assertion. - Assertions.assertTrue(logger.isWarnEnabled()); - logger.info("Context loads on mock profile"); - } - -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/DefaultContextTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/DefaultContextTest.java deleted file mode 100644 index 8f7e793..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/controller/DefaultContextTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 AT&T Intellectual Property - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.controller; - -import java.lang.invoke.MethodHandles; - -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit.jupiter.SpringExtension; - -/** - * Tests whether the default (not mock) configuration classes run to completion. - */ -@ExtendWith(SpringExtension.class) -@SpringBootTest -class DefaultContextTest { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - @Test - void contextLoads() { - // Silence Sonar warning about missing assertion. - Assertions.assertTrue(logger.isWarnEnabled()); - logger.info("Context loads on default profile"); - } - -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java deleted file mode 100644 index 1f4c21b..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/eiproducerapi/EiProducerApiImplTest.java +++ /dev/null @@ -1,162 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.eiproducerapi; - -import static org.junit.Assert.assertThrows; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonSyntaxException; - -import java.util.Arrays; -import java.util.List; - -import org.junit.jupiter.api.Test; -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.HttpServerErrorException; -import reactor.core.publisher.Mono; - -class EiProducerApiImplTest { - private static final String URL_EI_PRODUCERS = "/eiproducers"; - private static final String EI_PRODUCER_1 = "eiprod1"; - private static final String EI_PRODUCER_2 = "eiprod2"; - private static final String EI_PRODUCER_1_INFO_VALID = - "{\"supported_ei_types\":[{\"ei_type_identity\":\"eitype1\",\"ei_job_data_schema\":{\"title\":\"eijob1\"}}]}"; - private static final String EI_PRODUCER_1_INFO_INVALID = - "{\"supported_ei_types\":[{\"ei_type_identity\":\"eitype1\",\"ei_job_data_schema\":\"title\":\"eijob1\"}}]}"; - private static final String URL_STATUS = "/status"; - private static final String EI_PRODUCER_1_STATUS_VALID = "{\"operational_state\":\"ENABLED\"}"; - private static final String EI_PRODUCER_1_STATUS_INVALID = "\"operational_state\":\"ENABLED\"}"; - private static final String URL_EI_JOBS = "/eijobs"; - private static final String EI_JOB_1_INFO = - "{\"ei_job_identity\":\"eijob1\",\"ei_job_data\":{},\"ei_type_identity\":\"eitype1\"}"; - private static final String EI_JOB_2_INFO = - "{\"ei_job_identity\":\"eijob2\",\"ei_job_data\":{},\"ei_type_identity\":\"eitype2\"}"; - - AsyncRestClient restClientMock = mock(AsyncRestClient.class); - EiProducerApiImpl apiUnderTest = new EiProducerApiImpl(restClientMock); - private static com.google.gson.Gson gson = new GsonBuilder().create(); - - private void whenGetReturnOK(String url, HttpStatus status, String body) { - ResponseEntity ret = new ResponseEntity<>(body, status); - when(restClientMock.getForEntity(eq(url))).thenReturn(Mono.just(ret)); - } - - private void whenGetReturnFailure(String url, HttpStatus status, String body) { - HttpServerErrorException e = new HttpServerErrorException(status, body); - when(restClientMock.getForEntity(eq(url))).thenReturn(Mono.error(e)); - } - - @Test - void testGetAllEiProducerIdsFailure() { - whenGetReturnFailure(URL_EI_PRODUCERS, HttpStatus.NOT_FOUND, ""); - ResponseEntity returnedResp = apiUnderTest.getAllEiProducerIds(); - assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode()); - } - - @Test - void testGetAllEiProducerIdsSuccess() { - String eiProducerIds = Arrays.asList(EI_PRODUCER_1, EI_PRODUCER_2).toString(); - - whenGetReturnOK(URL_EI_PRODUCERS, HttpStatus.OK, eiProducerIds); - - ResponseEntity returnedResp = apiUnderTest.getAllEiProducerIds(); - assertEquals("[\"" + EI_PRODUCER_1 + "\",\"" + EI_PRODUCER_2 + "\"]", returnedResp.getBody()); - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - } - - @Test - void testGetEiProducerValidJson() { - whenGetReturnOK(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1, HttpStatus.OK, EI_PRODUCER_1_INFO_VALID); - - ResponseEntity returnedResp = apiUnderTest.getEiProducer(EI_PRODUCER_1); - - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - assertEquals(EI_PRODUCER_1_INFO_VALID, gson.toJson(returnedResp.getBody())); - } - - @Test - public void whenGetEiProducerExceptionThrown_thenAssertionSucceeds() { - whenGetReturnOK(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1, HttpStatus.OK, EI_PRODUCER_1_INFO_INVALID); - Exception exception = assertThrows(JsonSyntaxException.class, () -> { - apiUnderTest.getEiProducer(EI_PRODUCER_1); - }); - - String expectedMessage = "Expected BEGIN_OBJECT but was STRING"; - String actualMessage = exception.getMessage(); - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - void whenGetEiJobsForOneEiProducerExceptionThrown_thenAssertionSucceeds() { - whenGetReturnFailure(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1 + URL_EI_JOBS, HttpStatus.NOT_FOUND, ""); - Exception exception = assertThrows(IllegalStateException.class, () -> { - apiUnderTest.getEiJobsForOneEiProducer(EI_PRODUCER_1); - }); - - String expectedMessage = "Not a JSON Array: null"; - String actualMessage = exception.getMessage(); - assertTrue(actualMessage.contains(expectedMessage)); - } - - @Test - void testGetEiJobsForOneEiProducerSuccess() { - String eiJobs = Arrays.asList(EI_JOB_1_INFO, EI_JOB_2_INFO).toString(); - - whenGetReturnOK(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1 + URL_EI_JOBS, HttpStatus.OK, eiJobs); - - ResponseEntity> returnedResp = apiUnderTest.getEiJobsForOneEiProducer(EI_PRODUCER_1); - assertTrue(gson.toJson(returnedResp.getBody()).contains("\"ei_job_identity\":\"eijob1\"")); - assertTrue(gson.toJson(returnedResp.getBody()).contains("\"ei_job_identity\":\"eijob2\"")); - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - } - - @Test - void testGetEiProducerStatusValidJson() { - whenGetReturnOK(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1 + URL_STATUS, HttpStatus.OK, EI_PRODUCER_1_STATUS_VALID); - - ResponseEntity returnedResp = apiUnderTest.getEiProducerStatus(EI_PRODUCER_1); - - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - assertEquals(EI_PRODUCER_1_STATUS_VALID, gson.toJson(returnedResp.getBody())); - } - - @Test - public void whenGetEiProducerStatusExceptionThrown_thenAssertionSucceeds() { - whenGetReturnOK(URL_EI_PRODUCERS + "/" + EI_PRODUCER_1 + URL_STATUS, HttpStatus.OK, - EI_PRODUCER_1_STATUS_INVALID); - Exception exception = assertThrows(JsonSyntaxException.class, () -> { - apiUnderTest.getEiProducerStatus(EI_PRODUCER_1); - }); - - String expectedMessage = "Expected BEGIN_OBJECT but was STRING"; - String actualMessage = exception.getMessage(); - assertTrue(actualMessage.contains(expectedMessage)); - } -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java deleted file mode 100644 index b8d75c3..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/EnrichmentControllerMockConfiguration.java +++ /dev/null @@ -1,215 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.mock; - -import com.google.gson.GsonBuilder; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.stream.Collectors; - -import org.oransc.portal.nonrtric.controlpanel.eiproducerapi.EiProducerApi; -import org.oransc.portal.nonrtric.controlpanel.model.JobInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerRegistrationInfo.ProducerEiTypeRegistrationInfo; -import org.oransc.portal.nonrtric.controlpanel.model.ProducerStatusInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestClientException; - -/** - * Creates a mock implementation of the policy controller client API. - */ -@TestConfiguration -public class EnrichmentControllerMockConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private static com.google.gson.Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // - - @Bean - public EiProducerApi eiProducerApi() { - MockEiProducerApi apiClient = new MockEiProducerApi(); - return apiClient; - } - - class MockEiProducerApi implements EiProducerApi { - private final Database database = new Database(); - - @Override - public ResponseEntity getAllEiProducerIds() { - List result = new ArrayList<>(); - result.addAll(database.getAllEiProducerIds()); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); - } - - public ResponseEntity getAllEiProducers() { - List result = new ArrayList<>(); - result.addAll(database.getAllEiProducers()); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); - } - - @Override - public ResponseEntity getEiProducer(String eiProducerId) { - ProducerRegistrationInfo result = database.getEiProducerInstance(eiProducerId); - return new ResponseEntity<>(result, HttpStatus.OK); - } - - @Override - public ResponseEntity> getEiJobsForOneEiProducer(String eiProducerId) { - List result = new ArrayList<>(); - - result.addAll(database.getAllEiJobs()); - return new ResponseEntity<>(result, HttpStatus.OK); - } - - @Override - public ResponseEntity getEiProducerStatus(String eiProducerId) { - ProducerRegistrationInfo result = database.getEiProducerInstance(eiProducerId); - return new ResponseEntity<>(result.status, HttpStatus.OK); - } - } - - class Database { - - Database() { - - List supported_types = new ArrayList(); - - // Create ProducerEiTypeRegistrationInfo instance - String schema = getStringFromFile("ei-type-1.json"); - ProducerEiTypeRegistrationInfo eiType1 = getEiTypeInstance("type1", schema, Arrays.asList("prod-1")); - supported_types.add(eiType1); - - // Create ProducerEiTypeRegistrationInfo instance - schema = getStringFromFile("ei-type-2.json"); - ProducerEiTypeRegistrationInfo eiType2 = getEiTypeInstance("type2", schema, Arrays.asList("prod-1")); - supported_types.add(eiType2); - - // Create ProducerRegistrationInfo instance - putEiProducerInstance("prod-1", "http://example.com/", "http://example.com/", "http://example.com/", - supported_types, new ProducerStatusInfo(ProducerStatusInfo.OperationalState.ENABLED)); - - putEiProducerInstance("prod-2", "http://example.com/", "http://example.com/", "http://example.com/", - Arrays.asList(supported_types.get(0)), new ProducerStatusInfo(ProducerStatusInfo.OperationalState.DISABLED)); - - putEiProducerInstance("3-prod", "http://example.com/", "http://example.com/", "http://example.com/", - supported_types, new ProducerStatusInfo(ProducerStatusInfo.OperationalState.ENABLED)); - - // Create EiJob instance - schema = getStringFromFile("job-1.json"); - putEiJobInstance("type1", "job1", schema, "owner", "http://example.com/"); - - schema = getStringFromFile("job-1.json"); - putEiJobInstance("type2", "job2", schema, "owner", "http://example.com/"); - } - - private String getStringFromFile(String path) { - try { - InputStream inputStream = - MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path); - return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n")); - } catch (Exception e) { - logger.error("Cannot read file :" + path, e); - return ""; - } - } - - String normalize(String str) { - return str.replace('\n', ' '); - } - - void putEiJobInstance(String typeId, String instanceId, Object instanceData, String owner, String targetUrl) { - JobInfo i = JobInfo.builder() // - .jobData(instanceData) // - .id(instanceId) // - .owner(owner) // - .typeId(typeId) // - .targetUri(targetUrl) // - .build(); // - eiJobs.put(instanceId, i); - } - - void putEiProducerInstance(String id, String creation_url, String deletion_url, String callback_url, - List supported_types, ProducerStatusInfo status) { - ProducerRegistrationInfo eiProducer = ProducerRegistrationInfo.builder() // - .jobCallbackUrl(creation_url) // - .producerSupervisionCallbackUrl(callback_url) // - .types(supported_types) // - .status(status) // - .build(); // - eiProducers.put(id, eiProducer); - } - - ProducerEiTypeRegistrationInfo getEiTypeInstance(String id, Object data, List producer_ids) { - return ProducerEiTypeRegistrationInfo.builder() // - .eiTypeId(id) // - .jobDataSchema(data) // - .build(); // - } - - public void deleteEiProducerInstance(String id) { - eiProducers.remove(id); - } - - public void deleteEiJobInstance(String id) { - eiJobs.remove(id); - } - - ProducerRegistrationInfo getEiProducerInstance(String id) throws RestClientException { - ProducerRegistrationInfo i = eiProducers.get(id); - if (i == null) { - throw new RestClientException("Producer not found: " + id); - } - return i; - } - - public Collection getAllEiProducerIds() { - return Collections.unmodifiableCollection(eiProducers.keySet()); - } - - public Collection getAllEiProducers() { - return eiProducers.values(); - } - - public List getAllEiJobs() { - return new ArrayList<>(eiJobs.values()); - } - - private Map eiProducers = new HashMap<>(); - private Map eiJobs = new HashMap<>(); - } -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java deleted file mode 100644 index d6476db..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/mock/PolicyControllerMockConfiguration.java +++ /dev/null @@ -1,203 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2019 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.mock; - -import com.google.gson.GsonBuilder; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.lang.invoke.MethodHandles; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.Vector; -import java.util.stream.Collectors; - -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstances; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyType; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyTypes; -import org.oransc.portal.nonrtric.controlpanel.policyagentapi.PolicyAgentApi; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.boot.test.context.TestConfiguration; -import org.springframework.context.annotation.Bean; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.RestClientException; - -/** - * Creates a mock implementation of the policy controller client API. - */ -@TestConfiguration -public class PolicyControllerMockConfiguration { - - private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - - private static com.google.gson.Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // - - @Bean - public PolicyAgentApi policyAgentApi() { - MockPolicyAgentApi apiClient = new MockPolicyAgentApi(); - return apiClient; - } - - class MockPolicyAgentApi implements PolicyAgentApi { - private final Database database = new Database(); - - @Override - public ResponseEntity getPolicyInstance(String id) { - return new ResponseEntity<>(database.getInstance(id), HttpStatus.OK); - } - - @Override - public ResponseEntity putPolicy(String policyTypeIdString, String policyInstanceId, Object json, - String ric) { - database.putInstance(policyTypeIdString, policyInstanceId, json, ric); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Override - public ResponseEntity deletePolicy(String policyInstanceId) { - database.deleteInstance(policyInstanceId); - return new ResponseEntity<>(HttpStatus.OK); - } - - @Override - public ResponseEntity getAllPolicyTypes() { - PolicyTypes result = new PolicyTypes(); - result.addAll(database.getTypes()); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); - } - - @Override - public ResponseEntity getPolicyInstancesForType(String type) { - PolicyInstances result = new PolicyInstances(); - List inst = database.getInstances(Optional.of(type)); - result.addAll(inst); - return new ResponseEntity<>(gson.toJson(result), HttpStatus.OK); - } - - @Override - public ResponseEntity getRicsSupportingType(String typeName) { - Vector res = new Vector<>(); - res.add("ric_1"); - res.add("ric_2"); - res.add("ric_3"); - return new ResponseEntity<>(gson.toJson(res), HttpStatus.OK); - } - } - - class Database { - - Database() { - PolicyType policyType = new PolicyType("", "{}"); - types.put("", policyType); - - String schema = getStringFromFile("demo-policy-schema-1.json"); - policyType = new PolicyType("type2", schema); - types.put("type2", policyType); - - schema = getStringFromFile("demo-policy-schema-2.json"); - policyType = new PolicyType("type3", schema); - types.put("type3", policyType); - - schema = getStringFromFile("demo-policy-schema-3.json"); - policyType = new PolicyType("type4", schema); - types.put("type4", policyType); - - putInstance("", "123", "{\"data\":\"data\"}", "ric_1"); - } - - private String getStringFromFile(String path) { - try { - InputStream inputStream = - MethodHandles.lookup().lookupClass().getClassLoader().getResourceAsStream(path); - return new BufferedReader(new InputStreamReader(inputStream)).lines().collect(Collectors.joining("\n")); - } catch (Exception e) { - logger.error("Cannot read file :" + path, e); - return ""; - } - } - - String normalize(String str) { - return str.replace('\n', ' '); - } - - private String getTimeStampUTC() { - return java.time.Instant.now().toString(); - } - - void putInstance(String typeId, String instanceId, Object instanceData, String ric) { - PolicyInfo i = PolicyInfo.builder() // - .policyData(instanceData) // - .lastModified(getTimeStampUTC()) // - .policyId(instanceId) // - .ricId(ric) // - .serviceId("service") // - .policyTypeId(typeId) // - .build(); // - instances.put(instanceId, i); - } - - public void deleteInstance(String instanceId) { - instances.remove(instanceId); - } - - Object getInstance(String id) throws RestClientException { - PolicyInfo i = instances.get(id); - if (i == null) { - throw new RestClientException("Type not found: " + id); - } - return i.policyData; - } - - public Collection getTypes() { - return types.values(); - } - - public List getInstances(Optional typeId) { - ArrayList result = new ArrayList<>(); - for (PolicyInfo i : instances.values()) { - if (typeId.isPresent()) { - if (i.policyTypeId.equals(typeId.get())) { - result.add(i); - } - - } else { - result.add(i); - } - } - return result; - } - - private Map types = new HashMap<>(); - private Map instances = new HashMap<>(); - - } - -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java deleted file mode 100644 index 1d84de4..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/policyagentapi/PolicyAgentApiImplTest.java +++ /dev/null @@ -1,317 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * Modifications Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.policyagentapi; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; - -import com.google.gson.GsonBuilder; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonParser; - -import java.nio.charset.StandardCharsets; -import java.util.Arrays; - -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInfo; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstance; -import org.oransc.portal.nonrtric.controlpanel.model.PolicyInstances; -import org.oransc.portal.nonrtric.controlpanel.util.AsyncRestClient; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.web.client.HttpServerErrorException; -import reactor.core.publisher.Mono; - -class PolicyAgentApiImplTest { - private static final String URL_POLICY_SCHEMAS = "/a1-policy/v2/policy-types"; - private static final String POLICY_TYPE_1_ID = "type1"; - private static final String POLICY_TYPE_1_VALID = "{\"title\":\"type1\"}"; - private static final String POLICY_TYPE_1_INVALID = "\"title\":\"type1\"}"; - private static final String POLICY_TYPE_2_VALID = "{\"title\":\"type2\"}"; - private static final String POLICY_1_ID = "policy1"; - private static final String POLICY_DATA = - "{\"qosObjectives\":{\"priorityLevel\":22.0},\"scope\":{\"qosId\":\"22\",\"ueId\":\"22\"}}"; - private static final String POLICY_1_VALID = - "{\"policy_id\":\"policy1\",\"policytype_id\":\"type1\",\"ric_id\":\"ric1\",\"policy_data\":" + POLICY_DATA - + ",\"service_id\":\"controlpanel\"}"; - private static final String POLICY_1_INVALID = "\"policy_id\":\"policy1\"}"; - private static final String RIC_1_ID = "ric1"; - private static final String RIC_1_INFO_VALID = "{\"ric_id\":\"ric1\",\"policytype_ids\":[\"type1\"]}"; - private static final String RIC_1_INFO_INVALID = "{\"ric_id\":\"ric1\",\"policytype_ids\":\"type1\"]}"; - private static final String CLIENT_ERROR_MESSAGE = "XXXXXXX"; - private static final String SERVICE_ID = "controlpanel"; - private static final String TIMESTAMP = "2021-01-12T09:59:33.392470Z"; - private static final String STATUS = - "{\"last_modified\": \"" + TIMESTAMP + "\",\"status\":{\"enforceStatus\": \"\",\"enforceReason\": \"\"}}"; - private static com.google.gson.Gson gson = new GsonBuilder() // - .serializeNulls() // - .create(); // - - PolicyAgentApiImpl apiUnderTest; - - AsyncRestClient restClient; - - @BeforeEach - void init() { - restClient = mock(AsyncRestClient.class); - apiUnderTest = new PolicyAgentApiImpl(restClient); - } - - private void whenGetReturnOK(String url, HttpStatus status, String body) { - ResponseEntity ret = new ResponseEntity<>(body, status); - when(restClient.getForEntity(eq(url))).thenReturn(Mono.just(ret)); - } - - private void whenGetReturnFailure(String url, HttpStatus status, String body) { - HttpServerErrorException e = new HttpServerErrorException(status, body); - when(restClient.getForEntity(eq(url))).thenReturn(Mono.error(e)); - } - - @Test - void testGetAllPolicyTypesFailure() { - whenGetReturnFailure(URL_POLICY_SCHEMAS, HttpStatus.NOT_FOUND, ""); - ResponseEntity returnedResp = apiUnderTest.getAllPolicyTypes(); - assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode()); - } - - @Test - void testGetAllPolicyTypesSuccessValidJson() { - String returnValue = "{\"policytype_ids\": [\"type1\",\"type2\"]}"; - whenGetReturnOK(URL_POLICY_SCHEMAS, HttpStatus.OK, returnValue); - whenGetReturnOK(URL_POLICY_SCHEMAS + "/type1", HttpStatus.OK, "{\"policy_schema\":{}}"); - whenGetReturnOK(URL_POLICY_SCHEMAS + "/type2", HttpStatus.OK, "{\"policy_schema\":{}}"); - - ResponseEntity resp = apiUnderTest.getAllPolicyTypes(); - assertTrue(resp.getBody().contains("\"name\":\"type1\"")); - assertEquals(HttpStatus.OK, resp.getStatusCode()); - } - - @Test - void testGetAllPolicyTypesSuccessInvalidJson() { - String policyTypes = Arrays.asList(POLICY_TYPE_1_INVALID, POLICY_TYPE_2_VALID).toString(); - whenGetReturnOK(URL_POLICY_SCHEMAS, HttpStatus.OK, policyTypes); - - ResponseEntity returnedResp = apiUnderTest.getAllPolicyTypes(); - - assertTrue(returnedResp.getBody().contains("Exception")); - assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, returnedResp.getStatusCode()); - } - - private String urlPolicyInstances(String type) { - return "/a1-policy/v2/policies?policytype_id=" + type; - } - - @Test - void testGetPolicyInstancesForTypeFailure() { - whenGetReturnFailure(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.NOT_FOUND, ""); - - ResponseEntity returnedResp = apiUnderTest.getPolicyInstancesForType(POLICY_TYPE_1_ID); - - assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode()); - } - - @Test - void testGetPolicyInstancesForTypeSuccessValidJson() { - String policyInstances = "{\"policy_ids\":[\"policy1\"]}"; - String policyInstancesJson = parsePolicyInstancesJson("[\"policy1\"]"); - - whenGetReturnOK(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.OK, policyInstances); - whenGetReturnOK(urlPolicyInstance(POLICY_1_ID), HttpStatus.OK, POLICY_1_VALID); - whenGetReturnOK(urlPolicyStatus(POLICY_1_ID), HttpStatus.OK, STATUS); - - ResponseEntity returnedResp = apiUnderTest.getPolicyInstancesForType(POLICY_TYPE_1_ID); - assertEquals(returnedResp.getBody(), policyInstancesJson); - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - } - - @Test - void testGetPolicyInstancesForTypeSuccessInvalidJson() { - String policyInstances = Arrays.asList(POLICY_1_INVALID).toString(); - - whenGetReturnOK(urlPolicyInstances(POLICY_TYPE_1_ID), HttpStatus.OK, policyInstances); - - ResponseEntity returnedResp = apiUnderTest.getPolicyInstancesForType(POLICY_TYPE_1_ID); - - assertTrue(returnedResp.getBody().contains("Exception")); - assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, returnedResp.getStatusCode()); - } - - private String urlPolicyInstance(String id) { - return "/a1-policy/v2/policies/" + id; - } - - private String urlPolicyStatus(String id) { - return "/a1-policy/v2/policies/" + id + "/status"; - } - - @Test - void testGetPolicyInstance() { - whenGetReturnOK(urlPolicyInstance(POLICY_1_ID), HttpStatus.OK, POLICY_1_VALID); - whenGetReturnOK(urlPolicyStatus(POLICY_1_ID), HttpStatus.OK, STATUS); - - ResponseEntity returnedResp = apiUnderTest.getPolicyInstance(POLICY_1_ID); - - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - assertEquals(POLICY_DATA, gson.toJson(returnedResp.getBody())); - } - - private String urlPutPolicy() { - return "/a1-policy/v2/policies/"; - } - - private void whenPutReturnOK(String url, String putBody, HttpStatus status, String body) { - ResponseEntity ret = new ResponseEntity<>(body, status); - when(restClient.putForEntity(eq(url), eq(putBody))).thenReturn(Mono.just(ret)); - } - - private void whenPutReturnFailure(String url, String putBody, HttpStatus status, String body) { - HttpServerErrorException e = - new HttpServerErrorException(status, body, body.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - when(restClient.putForEntity(eq(url), eq(putBody))).thenReturn(Mono.error(e)); - } - - @Test - void testPutPolicyFailure() { - String url = urlPutPolicy(); - JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject(); - PolicyInstance i = PolicyInstance.builder() // - .policyId(POLICY_1_ID) // - .policyTypeId(POLICY_TYPE_1_ID) // - .ricId(RIC_1_ID) // - .policyData(data) // - .serviceId(SERVICE_ID) // - .build(); // - - String jsonStr = gson.toJson(i); - whenPutReturnFailure(url, jsonStr, HttpStatus.NOT_FOUND, CLIENT_ERROR_MESSAGE); - - ResponseEntity returnedResp = - apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_DATA, RIC_1_ID); - - assertTrue(returnedResp.getBody().contains(CLIENT_ERROR_MESSAGE)); - assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode()); - } - - @Test - void testPutPolicySuccess() { - String url = urlPutPolicy(); - JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject(); - PolicyInstance i = PolicyInstance.builder() // - .policyId(POLICY_1_ID) // - .policyTypeId(POLICY_TYPE_1_ID) // - .ricId(RIC_1_ID) // - .policyData(data) // - .serviceId(SERVICE_ID) // - .build(); // - String jsonStr = gson.toJson(i); - whenPutReturnOK(url, jsonStr, HttpStatus.OK, POLICY_1_VALID); - - ResponseEntity returnedResp = - apiUnderTest.putPolicy(POLICY_TYPE_1_ID, POLICY_1_ID, POLICY_DATA, RIC_1_ID); - assertNull(returnedResp.getBody()); - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - } - - private void whenDeleteReturnOK(String url, HttpStatus status) { - ResponseEntity ret = new ResponseEntity<>(status); - when(restClient.deleteForEntity(eq(url))).thenReturn(Mono.just(ret)); - } - - private void whenDeleteReturnFailure(String url, HttpStatus status, String body) { - HttpServerErrorException e = - new HttpServerErrorException(status, body, body.getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8); - when(restClient.deleteForEntity(eq(url))).thenReturn(Mono.error(e)); - } - - private String deletePolicyUrl(String id) { - return "/a1-policy/v2/policies/" + id; - } - - @Test - void testDeletePolicyFailure() { - whenDeleteReturnFailure(deletePolicyUrl(POLICY_1_ID), HttpStatus.NOT_FOUND, CLIENT_ERROR_MESSAGE); - - ResponseEntity returnedResp = apiUnderTest.deletePolicy(POLICY_1_ID); - - assertTrue(returnedResp.getBody().contains(CLIENT_ERROR_MESSAGE)); - assertEquals(HttpStatus.NOT_FOUND, returnedResp.getStatusCode()); - } - - @Test - void testDeletePolicySuccess() { - whenDeleteReturnOK(deletePolicyUrl(POLICY_1_ID), HttpStatus.OK); - ResponseEntity returnedResp = apiUnderTest.deletePolicy(POLICY_1_ID); - - assertEquals(HttpStatus.OK, returnedResp.getStatusCode()); - } - - private String urlRicInfo(String typeName) { - return "/a1-policy/v2/rics?policytype_id=" + typeName; - } - - @Test - void testGetRicsSupportingTypeValidJson() { - String rics = Arrays.asList(RIC_1_INFO_VALID).toString(); - String returnVal = "{\"rics\":" + rics + "}"; - this.whenGetReturnOK(urlRicInfo(POLICY_TYPE_1_ID), HttpStatus.OK, returnVal); - - ResponseEntity resp = apiUnderTest.getRicsSupportingType(POLICY_TYPE_1_ID); - - assertEquals(HttpStatus.OK, resp.getStatusCode()); - assertEquals("[\"ric1\"]", resp.getBody()); - } - - @Test - void testGetRicsSupportingTypeInvalidJson() { - String rics = Arrays.asList(RIC_1_INFO_INVALID).toString(); - - this.whenGetReturnOK(urlRicInfo(POLICY_TYPE_1_ID), HttpStatus.OK, rics); - - ResponseEntity returnedResp = apiUnderTest.getRicsSupportingType(POLICY_TYPE_1_ID); - - assertTrue(returnedResp.getBody().contains("Exception")); - assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, returnedResp.getStatusCode()); - } - - private String parsePolicyInstancesJson(String inputString) { - JsonArray arr = JsonParser.parseString(inputString).getAsJsonArray(); - PolicyInstances res = new PolicyInstances(); - JsonElement data = JsonParser.parseString(POLICY_DATA).getAsJsonObject(); - for (JsonElement id : arr) { - PolicyInfo i = PolicyInfo.builder() // - .policyId(id.getAsString()) // - .policyTypeId(POLICY_TYPE_1_ID) // - .ricId(RIC_1_ID) // - .policyData(data) // - .serviceId(SERVICE_ID) // - .lastModified(TIMESTAMP) // - .build(); // - res.add(i); - } - return gson.toJson(res); - } -} diff --git a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClientTest.java b/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClientTest.java deleted file mode 100644 index f668803..0000000 --- a/webapp-backend/src/test/java/org/oransc/portal/nonrtric/controlpanel/util/AsyncRestClientTest.java +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * ========================LICENSE_START================================= - * O-RAN-SC - * %% - * Copyright (C) 2020 Nordix Foundation - * %% - * 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.portal.nonrtric.controlpanel.util; - -import io.netty.util.internal.logging.InternalLoggerFactory; -import io.netty.util.internal.logging.JdkLoggerFactory; - -import java.io.IOException; - -import okhttp3.mockwebserver.MockResponse; -import okhttp3.mockwebserver.MockWebServer; - -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.web.reactive.function.client.WebClientResponseException; - -import reactor.core.publisher.Mono; -import reactor.test.StepVerifier; -import reactor.util.Loggers; - -class AsyncRestClientTest { - private static final String BASE_URL = "BaseUrl"; - private static final String REQUEST_URL = "/test"; - private static final String TEST_JSON = "{\"type\":\"type1\"}"; - private static final int SUCCESS_CODE = 200; - private static final int ERROR_CODE = 500; - - private static MockWebServer mockWebServer; - - private static AsyncRestClient clientUnderTest; - - @BeforeAll - public static void init() { - // skip a lot of unnecessary logs from MockWebServer - InternalLoggerFactory.setDefaultFactory(JdkLoggerFactory.INSTANCE); - Loggers.useJdkLoggers(); - mockWebServer = new MockWebServer(); - clientUnderTest = new AsyncRestClient(mockWebServer.url(BASE_URL).toString()); - } - - @AfterAll - public static void tearDown() throws IOException { - mockWebServer.shutdown(); - } - - @Test - void testGetNoError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); - - Mono returnedMono = clientUnderTest.get(REQUEST_URL); - StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); - } - - @Test - void testGetError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE)); - - Mono returnedMono = clientUnderTest.get(REQUEST_URL); - StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); - } - - @Test - void testPutNoError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE) // - .setBody(TEST_JSON)); - - Mono returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); - StepVerifier.create(returnedMono).expectNext(TEST_JSON).expectComplete().verify(); - } - - @Test - void testPutWithoutBodyNoError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE) // - .setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE)); - - Mono> returnedMono = clientUnderTest.putForEntity(REQUEST_URL); - StepVerifier.create(returnedMono).expectNextCount(1).expectComplete().verify(); - } - - @Test - void testPutError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE)); - - Mono returnedMono = clientUnderTest.put(REQUEST_URL, TEST_JSON); - StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); - } - - @Test - void testDeleteNoError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(SUCCESS_CODE)); - - Mono returnedMono = clientUnderTest.delete(REQUEST_URL); - StepVerifier.create(returnedMono).expectNext("").expectComplete().verify(); - } - - @Test - void testDeleteError() { - mockWebServer.enqueue(new MockResponse().setResponseCode(ERROR_CODE)); - - Mono returnedMono = clientUnderTest.delete(REQUEST_URL); - StepVerifier.create(returnedMono) - .expectErrorMatches(throwable -> throwable instanceof WebClientResponseException).verify(); - } - -} diff --git a/webapp-backend/src/test/resources/caas-ingress-ricaux-pods.json b/webapp-backend/src/test/resources/caas-ingress-ricaux-pods.json deleted file mode 100644 index 216b7db..0000000 --- a/webapp-backend/src/test/resources/caas-ingress-ricaux-pods.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "kind": "PodList", - "apiVersion": "v1", - "metadata": { - "selfLink": "/api/v1/namespaces/ricaux/pods", - "resourceVersion": "1594484" - }, - "items": [] -} diff --git a/webapp-backend/src/test/resources/caas-ingress-ricplt-pods.json b/webapp-backend/src/test/resources/caas-ingress-ricplt-pods.json deleted file mode 100644 index cf9c1a0..0000000 --- a/webapp-backend/src/test/resources/caas-ingress-ricplt-pods.json +++ /dev/null @@ -1,1847 +0,0 @@ -{ - "kind": "PodList", - "apiVersion": "v1", - "metadata": { - "selfLink": "/api/v1/namespaces/ricplt/pods", - "resourceVersion": "3189380" - }, - "items": [ - { - "metadata": { - "name": "deployment-ricplt-a1mediator-74d9fc4c8c-77vtp", - "generateName": "deployment-ricplt-a1mediator-74d9fc4c8c-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-a1mediator-74d9fc4c8c-77vtp", - "uid": "487c582d-36d6-406a-92a3-bfbce04b83de", - "resourceVersion": "2945631", - "creationTimestamp": "2019-10-18T16:15:04Z", - "labels": { - "app": "ricplt-a1mediator", - "group": "nagios", - "pod-template-hash": "74d9fc4c8c", - "release": "r1-a1mediator" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-a1mediator-74d9fc4c8c", - "uid": "84ef8695-3eb2-4dcd-b214-9d00ab5fb6b3", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "a1conf", - "configMap": { - "name": "configmap-ricplt-a1mediator-a1conf", - "defaultMode": 420 - } - }, - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-a1mediator", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-a1:0.10.3", - "ports": [ - { - "name": "http", - "containerPort": 10000, - "protocol": "TCP" - }, - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 4562, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-a1mediator-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "a1conf", - "mountPath": "/opt/ricmanifest.json", - "subPath": "ricmanifest.json" - }, - { - "name": "a1conf", - "mountPath": "/opt/rmr_string_int_mapping.txt", - "subPath": "rmr_string_int_mapping.txt" - }, - { - "name": "a1conf", - "mountPath": "/opt/route/local.rt", - "subPath": "local.rt" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "livenessProbe": { - "httpGet": { - "path": "/a1-p/healthcheck", - "port": "http", - "scheme": "HTTP" - }, - "timeoutSeconds": 1, - "periodSeconds": 10, - "successThreshold": 1, - "failureThreshold": 3 - }, - "readinessProbe": { - "httpGet": { - "path": "/a1-p/healthcheck", - "port": "http", - "scheme": "HTTP" - }, - "timeoutSeconds": 1, - "periodSeconds": 10, - "successThreshold": 1, - "failureThreshold": 3 - }, - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.202", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "a1mediator", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:04Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:09Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:09Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:04Z" - } - ], - "hostIP": "172.29.16.202", - "podIP": "10.244.4.71", - "podIPs": [ - { - "ip": "10.244.4.71" - } - ], - "startTime": "2019-10-18T16:15:04Z", - "containerStatuses": [ - { - "name": "container-ricplt-a1mediator", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:05Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-a1:0.10.3", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-a1@sha256:64a61ed84d4d05dfa1690bb45949da333d7b088e2e12dbba0ce60c06445f52cb", - "containerID": "docker://07ceed10ee2a4413c167951e458b59a505a073cce82ac543146e58b698489d59", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-appmgr-6ccf55b98b-kbkt4", - "generateName": "deployment-ricplt-appmgr-6ccf55b98b-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-appmgr-6ccf55b98b-kbkt4", - "uid": "4e084e8a-eb0a-4ea2-9cc1-7f812cd6bb28", - "resourceVersion": "2945633", - "creationTimestamp": "2019-10-18T16:15:01Z", - "labels": { - "app": "ricplt-appmgr", - "group": "nagios", - "pod-template-hash": "6ccf55b98b", - "release": "r1-appmgr" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-appmgr-6ccf55b98b", - "uid": "a169ebc4-9b7c-4b8d-81ed-6364e07df24e", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "config-volume", - "configMap": { - "name": "configmap-ricplt-appmgr-appconfig", - "defaultMode": 420 - } - }, - { - "name": "cert-volume", - "configMap": { - "name": "xapp-mgr-certs", - "defaultMode": 420 - } - }, - { - "name": "secret-volume", - "secret": { - "secretName": "xapp-mgr-creds", - "defaultMode": 420 - } - }, - { - "name": "helm-secret-volume", - "emptyDir": { - - } - }, - { - "name": "appmgr-bin-volume", - "configMap": { - "name": "configmap-ricplt-appmgr-bin", - "defaultMode": 493 - } - }, - { - "name": "svcacct-ricplt-appmgr-token-kclzw", - "secret": { - "secretName": "svcacct-ricplt-appmgr-token-kclzw", - "defaultMode": 420 - } - } - ], - "initContainers": [ - { - "name": "container-ricplt-appmgr-copy-tiller-secret", - "image": "registry.kube-system.svc.rec.io:5555/ric/it-dep-init:0.0.1", - "command": [ - "/appmgr-tiller-secret-copier.sh" - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-appmgr-env" - } - } - ], - "env": [ - { - "name": "SVCACCT_NAME", - "value": "svcacct-ricplt-appmgr" - }, - { - "name": "CLUSTER_NAME", - "value": "kubernetes" - }, - { - "name": "KUBECONFIG", - "value": "/tmp/kubeconfig" - }, - { - "name": "K8S_API_HOST", - "value": "https://10.254.0.1:443" - }, - { - "name": "SECRET_NAMESPACE", - "value": "ricinfra" - }, - { - "name": "SECRET_NAME", - "value": "secret-helm-client-ricxapp" - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "helm-secret-volume", - "mountPath": "/opt/ric/secret" - }, - { - "name": "appmgr-bin-volume", - "mountPath": "/svcacct-to-kubeconfig.sh", - "subPath": "svcacct-to-kubeconfig.sh" - }, - { - "name": "appmgr-bin-volume", - "mountPath": "/appmgr-tiller-secret-copier.sh", - "subPath": "appmgr-tiller-secret-copier.sh" - }, - { - "name": "svcacct-ricplt-appmgr-token-kclzw", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "IfNotPresent" - } - ], - "containers": [ - { - "name": "container-ricplt-appmgr", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-appmgr:0.1.9", - "ports": [ - { - "name": "http", - "containerPort": 8080, - "protocol": "TCP" - }, - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 4560, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-appmgr-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "config-volume", - "mountPath": "/opt/ric/config/appmgr.yaml", - "subPath": "appmgr.yaml" - }, - { - "name": "cert-volume", - "mountPath": "/opt/ric/certificates" - }, - { - "name": "helm-secret-volume", - "mountPath": "/opt/ric/secret" - }, - { - "name": "secret-volume", - "mountPath": "/opt/ric/secret/helm_repo_username", - "subPath": "helm_repo_username" - }, - { - "name": "secret-volume", - "mountPath": "/opt/ric/secret/helm_repo_password", - "subPath": "helm_repo_password" - }, - { - "name": "svcacct-ricplt-appmgr-token-kclzw", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "svcacct-ricplt-appmgr", - "serviceAccount": "svcacct-ricplt-appmgr", - "nodeName": "172.29.16.203", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "appmgr", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:03Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:04Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:04Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:01Z" - } - ], - "hostIP": "172.29.16.203", - "podIP": "10.244.3.252", - "podIPs": [ - { - "ip": "10.244.3.252" - } - ], - "startTime": "2019-10-18T16:15:01Z", - "initContainerStatuses": [ - { - "name": "container-ricplt-appmgr-copy-tiller-secret", - "state": { - "terminated": { - "exitCode": 0, - "reason": "Completed", - "startedAt": "2019-10-18T16:15:02Z", - "finishedAt": "2019-10-18T16:15:02Z", - "containerID": "docker://130db0adfad526204726bf11fe24741d94f11f39f97f0d826b066ec852e5a452" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/it-dep-init:0.0.1", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/it-dep-init@sha256:d3a2c02660a0b5da5a7e38626c49018ca7f5e3bc39106b0728ff72245cd20be5", - "containerID": "docker://130db0adfad526204726bf11fe24741d94f11f39f97f0d826b066ec852e5a452" - } - ], - "containerStatuses": [ - { - "name": "container-ricplt-appmgr", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:03Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-appmgr:0.1.9", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-appmgr@sha256:5c076f702d570b385d10200cda8d504475ce44eb1bcbb131b1d50e00eabae4d7", - "containerID": "docker://791f455c1974a100aaa09ab0a290e438d75aa1c3aadcb717c42d53e02cdedb83", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-dbaas-d4c9f7b88-7wgb9", - "generateName": "deployment-ricplt-dbaas-d4c9f7b88-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-dbaas-d4c9f7b88-7wgb9", - "uid": "e54e51fc-c4bd-4308-805e-16c2d588dacd", - "resourceVersion": "2945634", - "creationTimestamp": "2019-10-18T16:15:01Z", - "labels": { - "app": "ricplt-dbaas", - "group": "nagios", - "pod-template-hash": "d4c9f7b88", - "release": "r1-dbaas" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-dbaas-d4c9f7b88", - "uid": "7e8d5d34-efa9-41fe-b92f-d9b71bc40360", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-dbaas", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-dbaas:0.1.0", - "ports": [ - { - "name": "sql", - "containerPort": 6379, - "protocol": "TCP" - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 0, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.202", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:01Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:03Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:03Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:01Z" - } - ], - "hostIP": "172.29.16.202", - "podIP": "10.244.4.70", - "podIPs": [ - { - "ip": "10.244.4.70" - } - ], - "startTime": "2019-10-18T16:15:01Z", - "containerStatuses": [ - { - "name": "container-ricplt-dbaas", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:02Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-dbaas:0.1.0", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-dbaas@sha256:f63cfa353f355155ec6455a68d18c631900a2602bf7cc2ba35d6210971736b76", - "containerID": "docker://8972d8b61d5c3ff56b50814575647d70fb3307602506cda3e34b6734c28a3f36", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-e2mgr-86c76477c5-mf5t5", - "generateName": "deployment-ricplt-e2mgr-86c76477c5-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-e2mgr-86c76477c5-mf5t5", - "uid": "5f2231ea-bec0-46fc-a8f8-09b0b80e982f", - "resourceVersion": "2945636", - "creationTimestamp": "2019-10-18T16:15:02Z", - "labels": { - "app": "ricplt-e2mgr", - "group": "nagios", - "pod-template-hash": "86c76477c5", - "release": "r1-e2mgr" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-e2mgr-86c76477c5", - "uid": "f7dfd4a3-4eb3-4c46-a6c8-adc4ae37ef57", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "local-router-file", - "configMap": { - "name": "configmap-ricplt-e2mgr-router-configmap", - "defaultMode": 420 - } - }, - { - "name": "local-configuration-file", - "configMap": { - "name": "configmap-ricplt-e2mgr-configuration-configmap", - "defaultMode": 420 - } - }, - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-e2mgr", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-e2mgr:2.0.7", - "ports": [ - { - "name": "http", - "containerPort": 3800, - "protocol": "TCP" - }, - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 3801, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-e2mgr-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "local-router-file", - "mountPath": "/opt/E2Manager/router.txt", - "subPath": "router.txt" - }, - { - "name": "local-configuration-file", - "mountPath": "/opt/E2Manager/resources/configuration.yaml", - "subPath": "configuration.yaml" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always", - "securityContext": { - "privileged": false - }, - "stdin": true, - "tty": true - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.204", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "e2mgr", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:02Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:05Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:05Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:02Z" - } - ], - "hostIP": "172.29.16.204", - "podIP": "10.244.2.100", - "podIPs": [ - { - "ip": "10.244.2.100" - } - ], - "startTime": "2019-10-18T16:15:02Z", - "containerStatuses": [ - { - "name": "container-ricplt-e2mgr", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:04Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-e2mgr:2.0.7", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-e2mgr@sha256:87fa19a934215bdec71a355ef08eec9e273c992bab80af727f4f1b7a74ebacfa", - "containerID": "docker://ff3a2fcfc72b00e3c317899f2b620da2f65e3de260623daed7825f6a74dbcb5c", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-e2term-5dcf8b54b-5mkxl", - "generateName": "deployment-ricplt-e2term-5dcf8b54b-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-e2term-5dcf8b54b-5mkxl", - "uid": "8fae1dcd-5e42-4a66-be6f-e893d5563689", - "resourceVersion": "2945639", - "creationTimestamp": "2019-10-18T16:15:03Z", - "labels": { - "app": "ricplt-e2term", - "group": "nagios", - "pod-template-hash": "5dcf8b54b", - "release": "r1-e2term" - }, - "annotations": { - "danm.k8s.io/interfaces": "[\n {\"clusterNetwork\":\"default\", \"ip\":\"dynamic\"},\n {\"clusterNetwork\":\"ran\", \"ip\":\"dynamic\", \"ip6\":\"dynamic\"}\n]\n", - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-e2term-5dcf8b54b", - "uid": "cc20b8a0-6d74-4fb9-b384-bdce9c9ae184", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "local-router-file", - "configMap": { - "name": "configmap-ricplt-e2term-router-configmap", - "defaultMode": 420 - } - }, - { - "name": "localtime", - "hostPath": { - "path": "/etc/localtime", - "type": "" - } - }, - { - "name": "pizpub-config", - "configMap": { - "name": "configmap-ricplt-e2term-pizpub", - "defaultMode": 420 - } - }, - { - "name": "vol-shared", - "persistentVolumeClaim": { - "claimName": "pvc-ricplt-e2term" - } - }, - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-e2term", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-e2:2.0.7.5", - "ports": [ - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 38000, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-e2term-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "local-router-file", - "mountPath": "/opt/e2/router.txt", - "subPath": "router.txt" - }, - { - "name": "local-router-file", - "mountPath": "/tmp/rmr_verbose", - "subPath": "rmr_verbose" - }, - { - "name": "vol-shared", - "mountPath": "/data/outgoing/", - "subPath": "outgoing" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always", - "securityContext": { - "privileged": false - }, - "stdin": true, - "tty": true - }, - { - "name": "container-ricplt-e2term-pizpub", - "image": "registry.kube-system.svc.rec.io:5555/ric/pizpub:0.0.5155", - "resources": { - - }, - "volumeMounts": [ - { - "name": "localtime", - "readOnly": true, - "mountPath": "/etc/localtime" - }, - { - "name": "vol-shared", - "mountPath": "/data" - }, - { - "name": "pizpub-config", - "mountPath": "/opt/app/config/conf/" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "lifecycle": { - "postStart": { - "exec": { - "command": [ - "/bin/sh", - "/opt/app/config/conf/cleaner.sh", - "/data/sent", - "3" - ] - } - } - }, - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirstWithHostNet", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.201", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "e2term", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:22Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:33Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:33Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:22Z" - } - ], - "hostIP": "172.29.16.201", - "podIP": "10.244.1.90", - "podIPs": [ - { - "ip": "10.244.1.90" - } - ], - "startTime": "2019-10-18T16:15:22Z", - "containerStatuses": [ - { - "name": "container-ricplt-e2term", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:31Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "ranco-dev-tools.eastus.cloudapp.azure.com:10001/ric-plt-e2:2.0.7.5", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-e2@sha256:0ea1a356d018495a93e124ddd793e09626bf6e4d9b96355e731673ef7fab5a1f", - "containerID": "docker://bf9ca87dbad9436b0ed99ffe38036fb49033a9bc2cf2eb548397fbc9c48f1c3d", - "started": true - }, - { - "name": "container-ricplt-e2term-pizpub", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:32Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "ranco-dev-tools.eastus.cloudapp.azure.com:10001/pizpub:0.0.5155", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/pizpub@sha256:138c2d2d25e6528c4a5a8a402c277722d1c1fd4d6792b644967acd538affb1ed", - "containerID": "docker://93e39661623b7afc8156008bb6fbc206458964a6eb0633f80164e4c7ef59fe76", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-jaegeradapter-6ff8676c7-m4qkf", - "generateName": "deployment-ricplt-jaegeradapter-6ff8676c7-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-jaegeradapter-6ff8676c7-m4qkf", - "uid": "d6a5e9e9-87d0-4d1e-b1b7-cc1a4f20dc2e", - "resourceVersion": "2945640", - "creationTimestamp": "2019-10-18T16:15:08Z", - "labels": { - "app": "ricplt-jaegeradapter", - "group": "nagios", - "pod-template-hash": "6ff8676c7", - "release": "r1-jaegeradapter" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-jaegeradapter-6ff8676c7", - "uid": "98bc03d7-a082-4ac1-9b89-064022a37dff", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-jaegeradapter", - "image": "registry.kube-system.svc.rec.io:5555/ric/all-in-one:1.12", - "ports": [ - { - "name": "zipkincompact", - "containerPort": 5775, - "protocol": "UDP" - }, - { - "name": "jaegercompact", - "containerPort": 6831, - "protocol": "UDP" - }, - { - "name": "jaegerbinary", - "containerPort": 6832, - "protocol": "UDP" - }, - { - "name": "httpquery", - "containerPort": 16686, - "protocol": "TCP" - }, - { - "name": "httpconfig", - "containerPort": 5778, - "protocol": "TCP" - }, - { - "name": "zipkinhttp", - "containerPort": 9411, - "protocol": "TCP" - }, - { - "name": "jaegerhttp", - "containerPort": 14268, - "protocol": "TCP" - }, - { - "name": "jaegerhttpt", - "containerPort": 14267, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-jaegeradapter" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "livenessProbe": { - "httpGet": { - "path": "/", - "port": 16686, - "scheme": "HTTP" - }, - "timeoutSeconds": 1, - "periodSeconds": 10, - "successThreshold": 1, - "failureThreshold": 3 - }, - "readinessProbe": { - "httpGet": { - "path": "/", - "port": 16686, - "scheme": "HTTP" - }, - "timeoutSeconds": 1, - "periodSeconds": 10, - "successThreshold": 1, - "failureThreshold": 3 - }, - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.203", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "jaegeradapter", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:08Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:15Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:15Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:08Z" - } - ], - "hostIP": "172.29.16.203", - "podIP": "10.244.3.254", - "podIPs": [ - { - "ip": "10.244.3.254" - } - ], - "startTime": "2019-10-18T16:15:08Z", - "containerStatuses": [ - { - "name": "container-ricplt-jaegeradapter", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:09Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/all-in-one:1.12", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/all-in-one@sha256:51b901b653f4a4ca5dd50be9133c08dacf2d3eb092e507c213e7955a0e132297", - "containerID": "docker://95013a49a1705a503f5f7dde7a38fa7277523a73cdef96d264fcefe170e8a921", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-rsm-88477585f-qkkj7", - "generateName": "deployment-ricplt-rsm-88477585f-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-rsm-88477585f-qkkj7", - "uid": "d4c58ff4-743e-4ed6-bd36-aeb02daa1ca6", - "resourceVersion": "2945642", - "creationTimestamp": "2019-10-18T16:15:07Z", - "labels": { - "app": "ricplt-rsm", - "group": "nagios", - "pod-template-hash": "88477585f", - "release": "r1-rsm" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-rsm-88477585f", - "uid": "1fe7de57-90d9-4898-9b71-1ae9c4a6f014", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "local-router-file", - "configMap": { - "name": "configmap-ricplt-rsm-router-configmap", - "defaultMode": 420 - } - }, - { - "name": "local-configuration-file", - "configMap": { - "name": "configmap-ricplt-rsm", - "defaultMode": 420 - } - }, - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-rsm", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-rsm:2.0.7", - "ports": [ - { - "name": "http", - "containerPort": 4800, - "protocol": "TCP" - }, - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 4801, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-rsm-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "local-router-file", - "mountPath": "/opt/RSM/router.txt", - "subPath": "router.txt" - }, - { - "name": "local-configuration-file", - "mountPath": "/opt/RSM/resources/configuration.yaml", - "subPath": "configuration.yaml" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always", - "securityContext": { - "privileged": false - }, - "stdin": true, - "tty": true - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.203", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "rsm", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:07Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:09Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:09Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:07Z" - } - ], - "hostIP": "172.29.16.203", - "podIP": "10.244.3.253", - "podIPs": [ - { - "ip": "10.244.3.253" - } - ], - "startTime": "2019-10-18T16:15:07Z", - "containerStatuses": [ - { - "name": "container-ricplt-rsm", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:08Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-rsm:2.0.7", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-rsm@sha256:e6fb3bc17fcd5a2fbc7d34eeb744fbfed4eaaaf6c669e084b379ee05368820d3", - "containerID": "docker://5e90673a6b2c292f2ce7c731bf8747c8a63f429eca08d08a993130001c7d6f5e", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-submgr-7549b87fb8-4t6mx", - "generateName": "deployment-ricplt-submgr-7549b87fb8-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-submgr-7549b87fb8-4t6mx", - "uid": "c6fbd48b-2757-421c-a534-f1931b04312b", - "resourceVersion": "2945646", - "creationTimestamp": "2019-10-18T16:15:05Z", - "labels": { - "app": "ricplt-submgr", - "group": "nagios", - "pod-template-hash": "7549b87fb8", - "release": "r1-submgr" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-submgr-7549b87fb8", - "uid": "e2b9dd9f-cca4-4f64-9e11-b6ee174c4f6f", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "config-volume", - "configMap": { - "name": "submgrcfg", - "items": [ - { - "key": "submgrcfg", - "path": "submgr-config.yaml", - "mode": 420 - } - ], - "defaultMode": 420 - } - }, - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-submgr", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-submgr:0.10.5", - "command": [ - "/run_submgr.sh" - ], - "ports": [ - { - "name": "http", - "containerPort": 3800, - "protocol": "TCP" - }, - { - "name": "rmrroute", - "containerPort": 4561, - "protocol": "TCP" - }, - { - "name": "rmrdata", - "containerPort": 4560, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-submgr-env" - } - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "config-volume", - "mountPath": "/cfg" - }, - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.205", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "submgr", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:05Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:07Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:07Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:05Z" - } - ], - "hostIP": "172.29.16.205", - "podIP": "10.244.0.168", - "podIPs": [ - { - "ip": "10.244.0.168" - } - ], - "startTime": "2019-10-18T16:15:05Z", - "containerStatuses": [ - { - "name": "container-ricplt-submgr", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:07Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-submgr:0.10.5", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-submgr@sha256:aa8ada253d0800a849b6124fc54793815caaf93ad46b8d47cdd1f590ef69f813", - "containerID": "docker://724ba7834ef80d1f3c85ae7990ead480ed5226f0275816bae358edc9ddf54da6", - "started": true - } - ], - "qosClass": "BestEffort" - } - }, - { - "metadata": { - "name": "deployment-ricplt-vespamgr-55f6484b7-g5zfw", - "generateName": "deployment-ricplt-vespamgr-55f6484b7-", - "namespace": "ricplt", - "selfLink": "/api/v1/namespaces/ricplt/pods/deployment-ricplt-vespamgr-55f6484b7-g5zfw", - "uid": "a7ae0f4a-adfa-48c6-8c41-725ba1c84b11", - "resourceVersion": "2945649", - "creationTimestamp": "2019-10-18T16:15:06Z", - "labels": { - "app": "ricplt-vespamgr", - "group": "nagios", - "pod-template-hash": "55f6484b7", - "release": "r1-vespamgr" - }, - "annotations": { - "kubernetes.io/psp": "caas-default" - }, - "ownerReferences": [ - { - "apiVersion": "apps/v1", - "kind": "ReplicaSet", - "name": "deployment-ricplt-vespamgr-55f6484b7", - "uid": "dc5e0e81-23da-4fed-99da-14cb7a8fe06c", - "controller": true, - "blockOwnerDeletion": true - } - ] - }, - "spec": { - "volumes": [ - { - "name": "default-token-5j24g", - "secret": { - "secretName": "default-token-5j24g", - "defaultMode": 420 - } - } - ], - "containers": [ - { - "name": "container-ricplt-vespamgr", - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-vespamgr:0.0.5", - "ports": [ - { - "name": "http", - "containerPort": 8080, - "protocol": "TCP" - } - ], - "envFrom": [ - { - "configMapRef": { - "name": "configmap-ricplt-vespamgr" - } - }, - { - "secretRef": { - "name": "vespa-secrets" - } - } - ], - "env": [ - { - "name": "VESMGR_APPMGRDOMAIN", - "value": "appmgr-service" - } - ], - "resources": { - - }, - "volumeMounts": [ - { - "name": "default-token-5j24g", - "readOnly": true, - "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount" - } - ], - "livenessProbe": { - "httpGet": { - "path": "/supervision", - "port": 8080, - "scheme": "HTTP" - }, - "initialDelaySeconds": 30, - "timeoutSeconds": 20, - "periodSeconds": 60, - "successThreshold": 1, - "failureThreshold": 3 - }, - "terminationMessagePath": "/dev/termination-log", - "terminationMessagePolicy": "File", - "imagePullPolicy": "Always" - } - ], - "restartPolicy": "Always", - "terminationGracePeriodSeconds": 30, - "dnsPolicy": "ClusterFirst", - "serviceAccountName": "default", - "serviceAccount": "default", - "nodeName": "172.29.16.204", - "securityContext": { - - }, - "imagePullSecrets": [ - { - "name": "docker-reg-cred" - } - ], - "hostname": "vespamgr", - "schedulerName": "default-scheduler", - "enableServiceLinks": true - }, - "status": { - "phase": "Running", - "conditions": [ - { - "type": "Initialized", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:06Z" - }, - { - "type": "Ready", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:08Z" - }, - { - "type": "ContainersReady", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:08Z" - }, - { - "type": "PodScheduled", - "status": "True", - "lastProbeTime": null, - "lastTransitionTime": "2019-10-18T16:15:06Z" - } - ], - "hostIP": "172.29.16.204", - "podIP": "10.244.2.101", - "podIPs": [ - { - "ip": "10.244.2.101" - } - ], - "startTime": "2019-10-18T16:15:06Z", - "containerStatuses": [ - { - "name": "container-ricplt-vespamgr", - "state": { - "running": { - "startedAt": "2019-10-18T16:15:08Z" - } - }, - "lastState": { - - }, - "ready": true, - "restartCount": 0, - "image": "registry.kube-system.svc.rec.io:5555/ric/ric-plt-vespamgr:0.0.5", - "imageID": "docker-pullable://registry.kube-system.svc.rec.io:5555/ric/ric-plt-vespamgr@sha256:97753ef72471a5fddd59ff35a2fe763b041848f6e83214acb78ad73c7316b371", - "containerID": "docker://80884c969cbf802945c075afc47d747b5e747e4645c691d376820c9d61094e7c", - "started": true - } - ], - "qosClass": "BestEffort" - } - } - ] -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/demo-policy-schema-1.json b/webapp-backend/src/test/resources/demo-policy-schema-1.json deleted file mode 100644 index fa7410f..0000000 --- a/webapp-backend/src/test/resources/demo-policy-schema-1.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Example_QoSTarget_1.0.0", - "description": "Example QoS Target policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "qosId": { - "type": "string" - }, - "cellId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "qosId" - ] - }, - "statement": { - "type": "object", - "properties": { - "gfbr": { - "type": "number" - }, - "mfbr": { - "type": "number" - }, - "priorityLevel": { - "type": "number" - }, - "pdb": { - "type": "number" - } - }, - "minProperties": 1, - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/demo-policy-schema-2.json b/webapp-backend/src/test/resources/demo-policy-schema-2.json deleted file mode 100644 index f3eb28f..0000000 --- a/webapp-backend/src/test/resources/demo-policy-schema-2.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Example_QoETarget_1.0.0", - "description": "Example QoE Target policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "sliceId": { - "type": "string" - }, - "qosId": { - "type": "string" - }, - "cellId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId", - "sliceId" - ] - }, - "statement": { - "type": "object", - "properties": { - "qoeScore": { - "type": "number" - }, - "initialBuffering": { - "type": "number" - }, - "reBuffFreq": { - "type": "number" - }, - "stallRatio": { - "type": "number" - } - }, - "minProperties": 1, - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/demo-policy-schema-3.json b/webapp-backend/src/test/resources/demo-policy-schema-3.json deleted file mode 100644 index 18bce36..0000000 --- a/webapp-backend/src/test/resources/demo-policy-schema-3.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "Example_TrafficSteeringPreference_1.0.0", - "description": "Example Traffic Steering Preference policy type", - "type": "object", - "properties": { - "scope": { - "type": "object", - "properties": { - "ueId": { - "type": "string" - }, - "sliceId": { - "type": "string" - }, - "qosId": { - "type": "string" - }, - "cellId": { - "type": "string" - } - }, - "additionalProperties": false, - "required": [ - "ueId" - ] - }, - "statement": { - "type": "object", - "properties": { - "cellIdList": { - "type": "array", - "minItems": 1, - "uniqueItems": true, - "items": { - "type": "string" - } - }, - "preference": { - "type": "string", - "enum": [ - "SHALL", - "PREFER", - "AVOID", - "FORBID" - ] - }, - "primary": { - "type": "boolean" - } - }, - "required": [ - "cellIdList", - "preference" - ], - "additionalProperties": false - } - } -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/ei-type-1.json b/webapp-backend/src/test/resources/ei-type-1.json deleted file mode 100644 index c74ba28..0000000 --- a/webapp-backend/src/test/resources/ei-type-1.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_Type1_1.0.0", - "description": "EI-Type 1", - "type": "object" -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/ei-type-2.json b/webapp-backend/src/test/resources/ei-type-2.json deleted file mode 100644 index 68a1137..0000000 --- a/webapp-backend/src/test/resources/ei-type-2.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "title": "STD_Type2_1.0.0", - "description": "EI-Type 2", - "type": "object" -} \ No newline at end of file diff --git a/webapp-backend/src/test/resources/job-1.json b/webapp-backend/src/test/resources/job-1.json deleted file mode 100644 index 3f9e757..0000000 --- a/webapp-backend/src/test/resources/job-1.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "jobparam1":"value1", - "jobparam2":"value2", - "jobparam3":"value3" -} diff --git a/webapp-backend/src/test/resources/job-2.json b/webapp-backend/src/test/resources/job-2.json deleted file mode 100644 index 3f9e757..0000000 --- a/webapp-backend/src/test/resources/job-2.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "jobparam1":"value1", - "jobparam2":"value2", - "jobparam3":"value3" -} diff --git a/webapp-frontend/README.md b/webapp-frontend/README.md index 68ff85f..7ac722a 100644 --- a/webapp-frontend/README.md +++ b/webapp-frontend/README.md @@ -3,6 +3,7 @@ ## Development server Run `./ng serve --proxy-config proxy.conf.json` or `npm start` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. +You may also need to Start the Control Panel Gateway,Policy Management Service & EI Coordinator if you want to view the data in UI. ## Development server with Mock Data Run `npm run start:mock` for a dev server with mock data. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. This enables the developer to test the UI without the need of backend. diff --git a/webapp-frontend/nginx.conf b/webapp-frontend/nginx.conf index 164875c..3da6003 100644 --- a/webapp-frontend/nginx.conf +++ b/webapp-frontend/nginx.conf @@ -4,11 +4,11 @@ http { include /etc/nginx/mime.types; upstream backend { - server nonrtricgateway:9090; + server nonrtric-gateway:9090; } server { - listen 7070; + listen 8080; server_name localhost; root /usr/share/nginx/html; index index.html; diff --git a/webapp-frontend/proxy.conf.json b/webapp-frontend/proxy.conf.json index b82271d..d704341 100644 --- a/webapp-frontend/proxy.conf.json +++ b/webapp-frontend/proxy.conf.json @@ -1,6 +1,10 @@ { - "/api": { - "target": "http://localhost:8080", + "/a1-policy": { + "target": "http://localhost:9090", "secure": false - } -} + }, + "/ei-producer": { + "target": "http://localhost:9090", + "secure": false + } +} \ No newline at end of file